aboutsummaryrefslogtreecommitdiffstats
path: root/core/gen_genesis_account.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-07-11 19:49:14 +0800
committerGitHub <noreply@github.com>2017-07-11 19:49:14 +0800
commit225de7ca0a9e861696a5a43b666090b574c4c769 (patch)
tree68aff6fb74fece37626ced330fa9c5da91b483a4 /core/gen_genesis_account.go
parentbd01cd7183e771984fb9c008e7a7ebf0a0c3f9ba (diff)
downloaddexon-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_account.go')
-rw-r--r--core/gen_genesis_account.go36
1 files changed, 26 insertions, 10 deletions
diff --git a/core/gen_genesis_account.go b/core/gen_genesis_account.go
index bc5fc936b..15c9565a2 100644
--- a/core/gen_genesis_account.go
+++ b/core/gen_genesis_account.go
@@ -12,27 +12,37 @@ import (
"github.com/ethereum/go-ethereum/common/math"
)
+var _ = (*genesisAccountMarshaling)(nil)
+
func (g GenesisAccount) MarshalJSON() ([]byte, error) {
type GenesisAccount struct {
- Code hexutil.Bytes `json:"code,omitempty"`
- Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
- Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
- Nonce math.HexOrDecimal64 `json:"nonce,omitempty"`
+ Code hexutil.Bytes `json:"code,omitempty"`
+ Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
+ Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
+ Nonce math.HexOrDecimal64 `json:"nonce,omitempty"`
+ PrivateKey hexutil.Bytes `json:"secretKey,omitempty"`
}
var enc GenesisAccount
enc.Code = g.Code
- enc.Storage = g.Storage
+ if g.Storage != nil {
+ enc.Storage = make(map[storageJSON]storageJSON, len(g.Storage))
+ for k, v := range g.Storage {
+ enc.Storage[storageJSON(k)] = storageJSON(v)
+ }
+ }
enc.Balance = (*math.HexOrDecimal256)(g.Balance)
enc.Nonce = math.HexOrDecimal64(g.Nonce)
+ enc.PrivateKey = g.PrivateKey
return json.Marshal(&enc)
}
func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
type GenesisAccount struct {
- Code hexutil.Bytes `json:"code,omitempty"`
- Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
- Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
- Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
+ Code hexutil.Bytes `json:"code,omitempty"`
+ Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
+ Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
+ Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
+ PrivateKey hexutil.Bytes `json:"secretKey,omitempty"`
}
var dec GenesisAccount
if err := json.Unmarshal(input, &dec); err != nil {
@@ -42,7 +52,10 @@ func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
g.Code = dec.Code
}
if dec.Storage != nil {
- g.Storage = dec.Storage
+ g.Storage = make(map[common.Hash]common.Hash, len(dec.Storage))
+ for k, v := range dec.Storage {
+ g.Storage[common.Hash(k)] = common.Hash(v)
+ }
}
if dec.Balance == nil {
return errors.New("missing required field 'balance' for GenesisAccount")
@@ -51,5 +64,8 @@ func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
if dec.Nonce != nil {
g.Nonce = uint64(*dec.Nonce)
}
+ if dec.PrivateKey != nil {
+ g.PrivateKey = dec.PrivateKey
+ }
return nil
}