Skip to content

Commit 3cfd0fe

Browse files
authored
core: add TestGenesisHashes and fix YoloV3 (#22559)
This adds simple unit test checking if the hard-coded genesis hash values in package params match the actual genesis block hashes.
1 parent 1e20734 commit 3cfd0fe

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎core/genesis_test.go‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,38 @@ func TestSetupGenesis(t *testing.T) {
162162
}
163163
}
164164
}
165+
166+
// TestGenesisHashes checks the congruity of default genesis data to corresponding hardcoded genesis hash values.
167+
func TestGenesisHashes(t *testing.T) {
168+
cases := []struct {
169+
genesis *Genesis
170+
hash common.Hash
171+
}{
172+
{
173+
genesis: DefaultGenesisBlock(),
174+
hash: params.MainnetGenesisHash,
175+
},
176+
{
177+
genesis: DefaultGoerliGenesisBlock(),
178+
hash: params.GoerliGenesisHash,
179+
},
180+
{
181+
genesis: DefaultRopstenGenesisBlock(),
182+
hash: params.RopstenGenesisHash,
183+
},
184+
{
185+
genesis: DefaultRinkebyGenesisBlock(),
186+
hash: params.RinkebyGenesisHash,
187+
},
188+
{
189+
genesis: DefaultYoloV3GenesisBlock(),
190+
hash: params.YoloV3GenesisHash,
191+
},
192+
}
193+
for i, c := range cases {
194+
b := c.genesis.MustCommit(rawdb.NewMemoryDatabase())
195+
if got := b.Hash(); got != c.hash {
196+
t.Errorf("case: %d, want: %s, got: %s", i, c.hash.Hex(), got.Hex())
197+
}
198+
}
199+
}

‎params/config.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var (
3131
RopstenGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
3232
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
3333
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
34-
YoloV3GenesisHash = common.HexToHash("0x374f07cc7fa7c251fc5f36849f574b43db43600526410349efdca2bcea14101a")
34+
YoloV3GenesisHash = common.HexToHash("0xf1f2876e8500c77afcc03228757b39477eceffccf645b734967fe3c7e16967b7")
3535
)
3636

3737
// TrustedCheckpoints associates each known checkpoint with the genesis hash of

0 commit comments

Comments
 (0)