mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
add verkle to test
This commit is contained in:
parent
03c410d0bf
commit
36933e02e0
1 changed files with 30 additions and 16 deletions
|
|
@ -37,6 +37,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/ethdb/memorydb"
|
"github.com/ethereum/go-ethereum/ethdb/memorydb"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
"github.com/ethereum/go-ethereum/triedb"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
"golang.org/x/crypto/sha3"
|
"golang.org/x/crypto/sha3"
|
||||||
)
|
)
|
||||||
|
|
@ -535,13 +536,13 @@ func TestProcessVerkle(t *testing.T) {
|
||||||
func TestProcessParentBlockHash(t *testing.T) {
|
func TestProcessParentBlockHash(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
chainConfig = params.MergedTestChainConfig
|
chainConfig = params.MergedTestChainConfig
|
||||||
statedb, _ = state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewDatabase(memorydb.New())), nil)
|
|
||||||
hashA = common.Hash{0x01}
|
hashA = common.Hash{0x01}
|
||||||
hashB = common.Hash{0x02}
|
hashB = common.Hash{0x02}
|
||||||
header = &types.Header{ParentHash: hashA, Number: big.NewInt(2), Difficulty: big.NewInt(0)}
|
header = &types.Header{ParentHash: hashA, Number: big.NewInt(2), Difficulty: big.NewInt(0)}
|
||||||
parent = &types.Header{ParentHash: hashB, Number: big.NewInt(1), Difficulty: big.NewInt(0)}
|
parent = &types.Header{ParentHash: hashB, Number: big.NewInt(1), Difficulty: big.NewInt(0)}
|
||||||
coinbase = common.Address{}
|
coinbase = common.Address{}
|
||||||
)
|
)
|
||||||
|
test := func(statedb *state.StateDB) {
|
||||||
statedb.SetNonce(params.HistoryStorageAddress, 1)
|
statedb.SetNonce(params.HistoryStorageAddress, 1)
|
||||||
statedb.SetCode(params.HistoryStorageAddress, params.HistoryStorageCode)
|
statedb.SetCode(params.HistoryStorageAddress, params.HistoryStorageCode)
|
||||||
statedb.IntermediateRoot(true)
|
statedb.IntermediateRoot(true)
|
||||||
|
|
@ -561,6 +562,19 @@ func TestProcessParentBlockHash(t *testing.T) {
|
||||||
if have := getParentBlockHash(statedb, 0); have != hashB {
|
if have := getParentBlockHash(statedb, 0); have != hashB {
|
||||||
t.Errorf("expected parent hash %v, got %v", hashB, have)
|
t.Errorf("expected parent hash %v, got %v", hashB, have)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
t.Run("MPT", func(t *testing.T) {
|
||||||
|
statedb, _ := state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewDatabase(memorydb.New())), nil)
|
||||||
|
test(statedb)
|
||||||
|
})
|
||||||
|
t.Run("Verkle", func(t *testing.T) {
|
||||||
|
db := rawdb.NewMemoryDatabase()
|
||||||
|
cacheConfig := DefaultCacheConfigWithScheme(rawdb.PathScheme)
|
||||||
|
cacheConfig.SnapshotLimit = 0
|
||||||
|
triedb := triedb.NewDatabase(db, cacheConfig.triedbConfig(true))
|
||||||
|
statedb, _ := state.New(types.EmptyVerkleHash, state.NewDatabaseWithNodeDB(db, triedb), nil)
|
||||||
|
test(statedb)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getParentBlockHash(statedb *state.StateDB, number uint64) common.Hash {
|
func getParentBlockHash(statedb *state.StateDB, number uint64) common.Hash {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue