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 /core/gen_genesis.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 'core/gen_genesis.go')
-rw-r--r-- | core/gen_genesis.go | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/core/gen_genesis.go b/core/gen_genesis.go index 3f83905c9..1f3b4a8aa 100644 --- a/core/gen_genesis.go +++ b/core/gen_genesis.go @@ -13,24 +13,27 @@ import ( "github.com/ethereum/go-ethereum/params" ) +var _ = (*genesisSpecMarshaling)(nil) + func (g Genesis) MarshalJSON() ([]byte, error) { type Genesis struct { Config *params.ChainConfig `json:"config"` Nonce math.HexOrDecimal64 `json:"nonce"` Timestamp math.HexOrDecimal64 `json:"timestamp"` - ParentHash common.Hash `json:"parentHash"` ExtraData hexutil.Bytes `json:"extraData"` GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash common.Hash `json:"mixHash"` Coinbase common.Address `json:"coinbase"` Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"` + Number uint64 `json:"number"` + GasUsed math.HexOrDecimal64 `json:"gasUsed"` + ParentHash common.Hash `json:"parentHash"` } var enc Genesis enc.Config = g.Config enc.Nonce = math.HexOrDecimal64(g.Nonce) enc.Timestamp = math.HexOrDecimal64(g.Timestamp) - enc.ParentHash = g.ParentHash enc.ExtraData = g.ExtraData enc.GasLimit = math.HexOrDecimal64(g.GasLimit) enc.Difficulty = (*math.HexOrDecimal256)(g.Difficulty) @@ -42,6 +45,9 @@ func (g Genesis) MarshalJSON() ([]byte, error) { enc.Alloc[common.UnprefixedAddress(k)] = v } } + enc.Number = g.Number + enc.GasUsed = math.HexOrDecimal64(g.GasUsed) + enc.ParentHash = g.ParentHash return json.Marshal(&enc) } @@ -50,13 +56,15 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { Config *params.ChainConfig `json:"config"` Nonce *math.HexOrDecimal64 `json:"nonce"` Timestamp *math.HexOrDecimal64 `json:"timestamp"` - ParentHash *common.Hash `json:"parentHash"` ExtraData hexutil.Bytes `json:"extraData"` GasLimit *math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash *common.Hash `json:"mixHash"` Coinbase *common.Address `json:"coinbase"` Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"` + Number *uint64 `json:"number"` + GasUsed *math.HexOrDecimal64 `json:"gasUsed"` + ParentHash *common.Hash `json:"parentHash"` } var dec Genesis if err := json.Unmarshal(input, &dec); err != nil { @@ -71,9 +79,6 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { if dec.Timestamp != nil { g.Timestamp = uint64(*dec.Timestamp) } - if dec.ParentHash != nil { - g.ParentHash = *dec.ParentHash - } if dec.ExtraData != nil { g.ExtraData = dec.ExtraData } @@ -98,5 +103,14 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { for k, v := range dec.Alloc { g.Alloc[common.Address(k)] = v } + if dec.Number != nil { + g.Number = *dec.Number + } + if dec.GasUsed != nil { + g.GasUsed = uint64(*dec.GasUsed) + } + if dec.ParentHash != nil { + g.ParentHash = *dec.ParentHash + } return nil } |