adding some (failing) tests

This commit is contained in:
Guillaume Ballet 2023-10-19 15:45:58 +02:00 committed by Gary Rong
parent a02c50cd97
commit 40ebb2b828

View file

@ -283,21 +283,21 @@ func TestVerkleGenesisCommit(t *testing.T) {
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiTime: &verkleTime,
CancunTime: nil, CancunTime: &verkleTime,
PragueTime: nil, PragueTime: &verkleTime,
VerkleTime: &verkleTime, VerkleTime: &verkleTime,
TerminalTotalDifficulty: nil, TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
Ethash: nil, Ethash: nil,
Clique: nil, Clique: nil,
} }
genesis := &Genesis{ genesis := &Genesis{
BaseFee: big.NewInt(params.InitialBaseFee), BaseFee: big.NewInt(params.InitialBaseFee),
Config: verkleConfig, Config: verkleConfig,
Timestamp: verkleTime, Timestamp: verkleTime,
// difficulty is nil Difficulty: big.NewInt(0),
Alloc: GenesisAlloc{ Alloc: GenesisAlloc{
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}}, {1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
}, },
@ -308,4 +308,21 @@ func TestVerkleGenesisCommit(t *testing.T) {
if !bytes.Equal(got, expected) { if !bytes.Equal(got, expected) {
t.Fatalf("invalid genesis state root, expected %x, got %x", expected, got) t.Fatalf("invalid genesis state root, expected %x, got %x", expected, got)
} }
db := rawdb.NewMemoryDatabase()
triedb := trie.NewDatabase(db, &trie.Config{IsVerkle: true, PathDB: pathdb.Defaults})
block := genesis.MustCommit(db, triedb)
if !bytes.Equal(block.Root().Bytes(), expected) {
t.Fatalf("invalid genesis state root, expected %x, got %x", expected, got)
}
// Test that the trie is verkle
if !triedb.IsVerkle() {
t.Fatalf("expected trie to be verkle")
}
serialized := rawdb.ReadTrieNode(db, common.Hash{}, []byte{}, common.Hash{}, "path")
if len(serialized) == 0 {
t.Fatal("could not find node")
}
} }