aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-11-13 19:47:27 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-01-03 20:45:35 +0800
commit6f69cdd109b1dd692b8dfb15e7c53d2051fbc946 (patch)
treec92974f8b82209073ad1ee3faec6e149f834bf69 /tests
parentb8caba97099ee5eed33c3b80dd4ea540722e7d8f (diff)
downloadgo-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.gz
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.bz2
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.lz
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.xz
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.zst
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.zip
all: switch gas limits from big.Int to uint64
Diffstat (limited to 'tests')
-rw-r--r--tests/block_test_util.go20
-rw-r--r--tests/gen_btheader.go16
-rw-r--r--tests/gen_stenv.go8
-rw-r--r--tests/gen_tttransaction.go8
-rw-r--r--tests/state_test_util.go8
-rw-r--r--tests/transaction_test_util.go8
6 files changed, 34 insertions, 34 deletions
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index a789e6d88..e2d1a0b43 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -77,8 +77,8 @@ type btHeader struct {
UncleHash common.Hash
ExtraData []byte
Difficulty *big.Int
- GasLimit *big.Int
- GasUsed *big.Int
+ GasLimit uint64
+ GasUsed uint64
Timestamp *big.Int
}
@@ -86,8 +86,8 @@ type btHeaderMarshaling struct {
ExtraData hexutil.Bytes
Number *math.HexOrDecimal256
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
- GasUsed *math.HexOrDecimal256
+ GasLimit *math.HexOrDecimal64
+ GasUsed *math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
@@ -141,8 +141,8 @@ func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis {
Timestamp: t.json.Genesis.Timestamp.Uint64(),
ParentHash: t.json.Genesis.ParentHash,
ExtraData: t.json.Genesis.ExtraData,
- GasLimit: t.json.Genesis.GasLimit.Uint64(),
- GasUsed: t.json.Genesis.GasUsed.Uint64(),
+ GasLimit: t.json.Genesis.GasLimit,
+ GasUsed: t.json.Genesis.GasUsed,
Difficulty: t.json.Genesis.Difficulty,
Mixhash: t.json.Genesis.MixHash,
Coinbase: t.json.Genesis.Coinbase,
@@ -234,11 +234,11 @@ func validateHeader(h *btHeader, h2 *types.Header) error {
if h.Difficulty.Cmp(h2.Difficulty) != 0 {
return fmt.Errorf("Difficulty: want: %v have: %v", h.Difficulty, h2.Difficulty)
}
- if h.GasLimit.Cmp(h2.GasLimit) != 0 {
- return fmt.Errorf("GasLimit: want: %v have: %v", h.GasLimit, h2.GasLimit)
+ if h.GasLimit != h2.GasLimit {
+ return fmt.Errorf("GasLimit: want: %d have: %d", h.GasLimit, h2.GasLimit)
}
- if h.GasUsed.Cmp(h2.GasUsed) != 0 {
- return fmt.Errorf("GasUsed: want: %v have: %v", h.GasUsed, h2.GasUsed)
+ if h.GasUsed != h2.GasUsed {
+ return fmt.Errorf("GasUsed: want: %d have: %d", h.GasUsed, h2.GasUsed)
}
if h.Timestamp.Cmp(h2.Time) != 0 {
return fmt.Errorf("Timestamp: want: %v have: %v", h.Timestamp, h2.Time)
diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go
index 5d65e0dbc..1be659ecb 100644
--- a/tests/gen_btheader.go
+++ b/tests/gen_btheader.go
@@ -29,8 +29,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
UncleHash common.Hash
ExtraData hexutil.Bytes
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
- GasUsed *math.HexOrDecimal256
+ GasLimit math.HexOrDecimal64
+ GasUsed math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
var enc btHeader
@@ -47,8 +47,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
enc.UncleHash = b.UncleHash
enc.ExtraData = b.ExtraData
enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
- enc.GasLimit = (*math.HexOrDecimal256)(b.GasLimit)
- enc.GasUsed = (*math.HexOrDecimal256)(b.GasUsed)
+ enc.GasLimit = (math.HexOrDecimal64)(b.GasLimit)
+ enc.GasUsed = (math.HexOrDecimal64)(b.GasUsed)
enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
return json.Marshal(&enc)
}
@@ -68,8 +68,8 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
UncleHash *common.Hash
ExtraData hexutil.Bytes
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
- GasUsed *math.HexOrDecimal256
+ GasLimit *math.HexOrDecimal64
+ GasUsed *math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
var dec btHeader
@@ -116,10 +116,10 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
b.Difficulty = (*big.Int)(dec.Difficulty)
}
if dec.GasLimit != nil {
- b.GasLimit = (*big.Int)(dec.GasLimit)
+ b.GasLimit = uint64(*dec.GasLimit)
}
if dec.GasUsed != nil {
- b.GasUsed = (*big.Int)(dec.GasUsed)
+ b.GasUsed = uint64(*dec.GasUsed)
}
if dec.Timestamp != nil {
b.Timestamp = (*big.Int)(dec.Timestamp)
diff --git a/tests/gen_stenv.go b/tests/gen_stenv.go
index c780524bc..1d4baf2fd 100644
--- a/tests/gen_stenv.go
+++ b/tests/gen_stenv.go
@@ -17,14 +17,14 @@ func (s stEnv) MarshalJSON() ([]byte, error) {
type stEnv struct {
Coinbase common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"`
Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `json:"currentGasLimit" gencodec:"required"`
+ GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"`
Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"`
Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"`
}
var enc stEnv
enc.Coinbase = common.UnprefixedAddress(s.Coinbase)
enc.Difficulty = (*math.HexOrDecimal256)(s.Difficulty)
- enc.GasLimit = (*math.HexOrDecimal256)(s.GasLimit)
+ enc.GasLimit = math.HexOrDecimal64(s.GasLimit)
enc.Number = math.HexOrDecimal64(s.Number)
enc.Timestamp = math.HexOrDecimal64(s.Timestamp)
return json.Marshal(&enc)
@@ -34,7 +34,7 @@ func (s *stEnv) UnmarshalJSON(input []byte) error {
type stEnv struct {
Coinbase *common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"`
Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `json:"currentGasLimit" gencodec:"required"`
+ GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"`
Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"`
Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"`
}
@@ -53,7 +53,7 @@ func (s *stEnv) UnmarshalJSON(input []byte) error {
if dec.GasLimit == nil {
return errors.New("missing required field 'currentGasLimit' for stEnv")
}
- s.GasLimit = (*big.Int)(dec.GasLimit)
+ s.GasLimit = uint64(*dec.GasLimit)
if dec.Number == nil {
return errors.New("missing required field 'currentNumber' for stEnv")
}
diff --git a/tests/gen_tttransaction.go b/tests/gen_tttransaction.go
index b6759be91..840bdfdd8 100644
--- a/tests/gen_tttransaction.go
+++ b/tests/gen_tttransaction.go
@@ -17,7 +17,7 @@ var _ = (*ttTransactionMarshaling)(nil)
func (t ttTransaction) MarshalJSON() ([]byte, error) {
type ttTransaction struct {
Data hexutil.Bytes `gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `gencodec:"required"`
+ GasLimit math.HexOrDecimal64 `gencodec:"required"`
GasPrice *math.HexOrDecimal256 `gencodec:"required"`
Nonce math.HexOrDecimal64 `gencodec:"required"`
Value *math.HexOrDecimal256 `gencodec:"required"`
@@ -28,7 +28,7 @@ func (t ttTransaction) MarshalJSON() ([]byte, error) {
}
var enc ttTransaction
enc.Data = t.Data
- enc.GasLimit = (*math.HexOrDecimal256)(t.GasLimit)
+ enc.GasLimit = (math.HexOrDecimal64)(t.GasLimit)
enc.GasPrice = (*math.HexOrDecimal256)(t.GasPrice)
enc.Nonce = math.HexOrDecimal64(t.Nonce)
enc.Value = (*math.HexOrDecimal256)(t.Value)
@@ -42,7 +42,7 @@ func (t ttTransaction) MarshalJSON() ([]byte, error) {
func (t *ttTransaction) UnmarshalJSON(input []byte) error {
type ttTransaction struct {
Data hexutil.Bytes `gencodec:"required"`
- GasLimit *math.HexOrDecimal256 `gencodec:"required"`
+ GasLimit *math.HexOrDecimal64 `gencodec:"required"`
GasPrice *math.HexOrDecimal256 `gencodec:"required"`
Nonce *math.HexOrDecimal64 `gencodec:"required"`
Value *math.HexOrDecimal256 `gencodec:"required"`
@@ -62,7 +62,7 @@ func (t *ttTransaction) UnmarshalJSON(input []byte) error {
if dec.GasLimit == nil {
return errors.New("missing required field 'gasLimit' for ttTransaction")
}
- t.GasLimit = (*big.Int)(dec.GasLimit)
+ t.GasLimit = uint64(*dec.GasLimit)
if dec.GasPrice == nil {
return errors.New("missing required field 'gasPrice' for ttTransaction")
}
diff --git a/tests/state_test_util.go b/tests/state_test_util.go
index 1f4fb2bd5..78c05b024 100644
--- a/tests/state_test_util.go
+++ b/tests/state_test_util.go
@@ -76,7 +76,7 @@ type stPostState struct {
type stEnv struct {
Coinbase common.Address `json:"currentCoinbase" gencodec:"required"`
Difficulty *big.Int `json:"currentDifficulty" gencodec:"required"`
- GasLimit *big.Int `json:"currentGasLimit" gencodec:"required"`
+ GasLimit uint64 `json:"currentGasLimit" gencodec:"required"`
Number uint64 `json:"currentNumber" gencodec:"required"`
Timestamp uint64 `json:"currentTimestamp" gencodec:"required"`
}
@@ -84,7 +84,7 @@ type stEnv struct {
type stEnvMarshaling struct {
Coinbase common.UnprefixedAddress
Difficulty *math.HexOrDecimal256
- GasLimit *math.HexOrDecimal256
+ GasLimit math.HexOrDecimal64
Number math.HexOrDecimal64
Timestamp math.HexOrDecimal64
}
@@ -180,7 +180,7 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
Config: config,
Coinbase: t.json.Env.Coinbase,
Difficulty: t.json.Env.Difficulty,
- GasLimit: t.json.Env.GasLimit.Uint64(),
+ GasLimit: t.json.Env.GasLimit,
Number: t.json.Env.Number,
Timestamp: t.json.Env.Timestamp,
Alloc: t.json.Pre,
@@ -233,7 +233,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
return nil, fmt.Errorf("invalid tx data %q", dataHex)
}
- msg := types.NewMessage(from, to, tx.Nonce, value, new(big.Int).SetUint64(gasLimit), tx.GasPrice, data, true)
+ msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true)
return msg, nil
}
diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go
index 472b3d6f2..2028d2a27 100644
--- a/tests/transaction_test_util.go
+++ b/tests/transaction_test_util.go
@@ -46,7 +46,7 @@ type ttJSON struct {
type ttTransaction struct {
Data []byte `gencodec:"required"`
- GasLimit *big.Int `gencodec:"required"`
+ GasLimit uint64 `gencodec:"required"`
GasPrice *big.Int `gencodec:"required"`
Nonce uint64 `gencodec:"required"`
Value *big.Int `gencodec:"required"`
@@ -58,7 +58,7 @@ type ttTransaction struct {
type ttTransactionMarshaling struct {
Data hexutil.Bytes
- GasLimit *math.HexOrDecimal256
+ GasLimit math.HexOrDecimal64
GasPrice *math.HexOrDecimal256
Nonce math.HexOrDecimal64
Value *math.HexOrDecimal256
@@ -100,8 +100,8 @@ func (tt *ttTransaction) verify(signer types.Signer, tx *types.Transaction) erro
if !bytes.Equal(tx.Data(), tt.Data) {
return fmt.Errorf("Tx input data mismatch: got %x want %x", tx.Data(), tt.Data)
}
- if tx.Gas().Cmp(tt.GasLimit) != 0 {
- return fmt.Errorf("GasLimit mismatch: got %v, want %v", tx.Gas(), tt.GasLimit)
+ if tx.Gas() != tt.GasLimit {
+ return fmt.Errorf("GasLimit mismatch: got %d, want %d", tx.Gas(), tt.GasLimit)
}
if tx.GasPrice().Cmp(tt.GasPrice) != 0 {
return fmt.Errorf("GasPrice mismatch: got %v, want %v", tx.GasPrice(), tt.GasPrice)