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:
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user