From 225de7ca0a9e861696a5a43b666090b574c4c769 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 11 Jul 2017 13:49:14 +0200 Subject: 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. --- core/gen_genesis.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'core/gen_genesis.go') 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 } -- cgit v1.2.3