statesynctest

package
v1.21.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2025 License: GPL-3.0, LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertTrieConsistency

func AssertTrieConsistency(t testing.TB, root common.Hash, a, b *triedb.Database, onLeaf func(key, val []byte) error)

AssertTrieConsistency ensures given trieDB [a] and [b] both have the same non-empty trie at [root]. (all key/value pairs must be equal)

func CorruptTrie

func CorruptTrie(t *testing.T, diskdb ethdb.Batcher, tr *trie.Trie, n int)

CorruptTrie deletes every [n]th trie node from the trie given by [tr] from the underlying [db]. Assumes [tr] can be iterated without issue.

func FillAccounts

func FillAccounts(
	t *testing.T, trieDB *triedb.Database, root common.Hash, numAccounts int,
	onAccount func(*testing.T, int, types.StateAccount) types.StateAccount,
) (common.Hash, map[*utilstest.Key]*types.StateAccount)

FillAccounts adds [numAccounts] randomly generated accounts to the secure trie at [root] and commits it to [trieDB]. [onAccount] is called if non-nil (so the caller can modify the account before it is stored in the secure trie). returns the new trie root and a map of funded keys to StateAccount structs.

func FillAccountsWithOverlappingStorage

func FillAccountsWithOverlappingStorage(
	t *testing.T, trieDB *triedb.Database, root common.Hash, numAccounts int, numOverlappingStorageRoots int,
) (common.Hash, map[*utilstest.Key]*types.StateAccount)

FillAccountsWithOverlappingStorage adds [numAccounts] randomly generated accounts to the secure trie at [root] and commits it to [trieDB]. For each 3 accounts created: - One does not have a storage trie, - One has a storage trie shared with other accounts (total number of shared storage tries [numOverlappingStorageRoots]), - One has a uniquely generated storage trie, returns the new trie root and a map of funded keys to StateAccount structs.

func FillTrie

func FillTrie(t *testing.T, start, numKeys int, keySize int, trieDB *triedb.Database, root common.Hash) (common.Hash, [][]byte, [][]byte)

FillTrie fills a given trie with [numKeys] number of keys, each of size [keySize] returns inserted keys and values FillTrie reads from rand and the caller should call rand.Seed(n) for deterministic results

func GenerateTrie

func GenerateTrie(t *testing.T, trieDB *triedb.Database, numKeys int, keySize int) (common.Hash, [][]byte, [][]byte)

GenerateTrie creates a trie with [numKeys] key-value pairs inside of [trieDB]. Returns the root of the generated trie, the slice of keys inserted into the trie in lexicographical order, and the slice of corresponding values. GenerateTrie reads from rand and the caller should call rand.Seed(n) for deterministic results

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL