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.
This commit is contained in:
parent
1e207342b5
commit
3cfd0fe7a8
@ -162,3 +162,38 @@ func TestSetupGenesis(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestGenesisHashes checks the congruity of default genesis data to corresponding hardcoded genesis hash values.
|
||||||
|
func TestGenesisHashes(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
genesis *Genesis
|
||||||
|
hash common.Hash
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
genesis: DefaultGenesisBlock(),
|
||||||
|
hash: params.MainnetGenesisHash,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
genesis: DefaultGoerliGenesisBlock(),
|
||||||
|
hash: params.GoerliGenesisHash,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
genesis: DefaultRopstenGenesisBlock(),
|
||||||
|
hash: params.RopstenGenesisHash,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
genesis: DefaultRinkebyGenesisBlock(),
|
||||||
|
hash: params.RinkebyGenesisHash,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
genesis: DefaultYoloV3GenesisBlock(),
|
||||||
|
hash: params.YoloV3GenesisHash,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for i, c := range cases {
|
||||||
|
b := c.genesis.MustCommit(rawdb.NewMemoryDatabase())
|
||||||
|
if got := b.Hash(); got != c.hash {
|
||||||
|
t.Errorf("case: %d, want: %s, got: %s", i, c.hash.Hex(), got.Hex())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -31,7 +31,7 @@ var (
|
|||||||
RopstenGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
|
RopstenGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
|
||||||
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
|
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
|
||||||
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
|
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
|
||||||
YoloV3GenesisHash = common.HexToHash("0x374f07cc7fa7c251fc5f36849f574b43db43600526410349efdca2bcea14101a")
|
YoloV3GenesisHash = common.HexToHash("0xf1f2876e8500c77afcc03228757b39477eceffccf645b734967fe3c7e16967b7")
|
||||||
)
|
)
|
||||||
|
|
||||||
// TrustedCheckpoints associates each known checkpoint with the genesis hash of
|
// TrustedCheckpoints associates each known checkpoint with the genesis hash of
|
||||||
|
Loading…
Reference in New Issue
Block a user