diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-07-11 19:49:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 19:49:14 +0800 |
commit | 225de7ca0a9e861696a5a43b666090b574c4c769 (patch) | |
tree | 68aff6fb74fece37626ced330fa9c5da91b483a4 /tests/gen_btheader.go | |
parent | bd01cd7183e771984fb9c008e7a7ebf0a0c3f9ba (diff) | |
download | dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.gz dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.bz2 dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.lz dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.xz dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.zst dexon-225de7ca0a9e861696a5a43b666090b574c4c769.zip |
tests: update tests and implement general state tests (#14734)
Tests are now included as a submodule. This should make updating easier
and removes ~60MB of JSON data from the working copy.
State tests are replaced by General State Tests, which run the same test
with multiple fork configurations.
With the new test runner, consensus tests are run as subtests by walking
json files. Many hex issues have been fixed upstream since the last
update and most custom parsing code is replaced by existing JSON hex
types. Tests can now be marked as 'expected failures', ensuring that
fixes for those tests will trigger an update to test configuration. The
new test runner also supports parallel execution and the -short flag.
Diffstat (limited to 'tests/gen_btheader.go')
-rw-r--r-- | tests/gen_btheader.go | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go new file mode 100644 index 000000000..5d65e0dbc --- /dev/null +++ b/tests/gen_btheader.go @@ -0,0 +1,128 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package tests + +import ( + "encoding/json" + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/core/types" +) + +var _ = (*btHeaderMarshaling)(nil) + +func (b btHeader) MarshalJSON() ([]byte, error) { + type btHeader struct { + Bloom types.Bloom + Coinbase common.Address + MixHash common.Hash + Nonce types.BlockNonce + Number *math.HexOrDecimal256 + Hash common.Hash + ParentHash common.Hash + ReceiptTrie common.Hash + StateRoot common.Hash + TransactionsTrie common.Hash + UncleHash common.Hash + ExtraData hexutil.Bytes + Difficulty *math.HexOrDecimal256 + GasLimit *math.HexOrDecimal256 + GasUsed *math.HexOrDecimal256 + Timestamp *math.HexOrDecimal256 + } + var enc btHeader + enc.Bloom = b.Bloom + enc.Coinbase = b.Coinbase + enc.MixHash = b.MixHash + enc.Nonce = b.Nonce + enc.Number = (*math.HexOrDecimal256)(b.Number) + enc.Hash = b.Hash + enc.ParentHash = b.ParentHash + enc.ReceiptTrie = b.ReceiptTrie + enc.StateRoot = b.StateRoot + enc.TransactionsTrie = b.TransactionsTrie + 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.Timestamp = (*math.HexOrDecimal256)(b.Timestamp) + return json.Marshal(&enc) +} + +func (b *btHeader) UnmarshalJSON(input []byte) error { + type btHeader struct { + Bloom *types.Bloom + Coinbase *common.Address + MixHash *common.Hash + Nonce *types.BlockNonce + Number *math.HexOrDecimal256 + Hash *common.Hash + ParentHash *common.Hash + ReceiptTrie *common.Hash + StateRoot *common.Hash + TransactionsTrie *common.Hash + UncleHash *common.Hash + ExtraData hexutil.Bytes + Difficulty *math.HexOrDecimal256 + GasLimit *math.HexOrDecimal256 + GasUsed *math.HexOrDecimal256 + Timestamp *math.HexOrDecimal256 + } + var dec btHeader + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.Bloom != nil { + b.Bloom = *dec.Bloom + } + if dec.Coinbase != nil { + b.Coinbase = *dec.Coinbase + } + if dec.MixHash != nil { + b.MixHash = *dec.MixHash + } + if dec.Nonce != nil { + b.Nonce = *dec.Nonce + } + if dec.Number != nil { + b.Number = (*big.Int)(dec.Number) + } + if dec.Hash != nil { + b.Hash = *dec.Hash + } + if dec.ParentHash != nil { + b.ParentHash = *dec.ParentHash + } + if dec.ReceiptTrie != nil { + b.ReceiptTrie = *dec.ReceiptTrie + } + if dec.StateRoot != nil { + b.StateRoot = *dec.StateRoot + } + if dec.TransactionsTrie != nil { + b.TransactionsTrie = *dec.TransactionsTrie + } + if dec.UncleHash != nil { + b.UncleHash = *dec.UncleHash + } + if dec.ExtraData != nil { + b.ExtraData = dec.ExtraData + } + if dec.Difficulty != nil { + b.Difficulty = (*big.Int)(dec.Difficulty) + } + if dec.GasLimit != nil { + b.GasLimit = (*big.Int)(dec.GasLimit) + } + if dec.GasUsed != nil { + b.GasUsed = (*big.Int)(dec.GasUsed) + } + if dec.Timestamp != nil { + b.Timestamp = (*big.Int)(dec.Timestamp) + } + return nil +} |