mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Add unit tests covering empty results
This commit is contained in:
parent
a32c95b156
commit
70de8fb0c1
1 changed files with 26 additions and 0 deletions
|
|
@ -102,6 +102,32 @@ func TestAccountRangeAt(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestEmptyAccountRangeAt(t *testing.T) {
|
||||
var (
|
||||
statedb = state.NewDatabase(rawdb.NewMemoryDatabase())
|
||||
state, _ = state.New(common.Hash{}, statedb)
|
||||
)
|
||||
|
||||
state.Commit(true)
|
||||
root := state.IntermediateRoot(true)
|
||||
|
||||
trie, err := statedb.OpenTrie(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
results, err := accountRange(trie, &common.Hash{0x0}, AccountRangeMaxResults)
|
||||
if err != nil {
|
||||
t.Fatalf("Empty results should not trigger an error: %v", err)
|
||||
}
|
||||
if results.Next != common.HexToHash("0") {
|
||||
t.Fatalf("Empty results should not return a second page")
|
||||
}
|
||||
if len(results.Addresses) != 0 {
|
||||
t.Fatalf("Empty state should not return addresses: %v", results.Addresses)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStorageRangeAt(t *testing.T) {
|
||||
// Create a state where account 0x010000... has a few storage entries.
|
||||
var (
|
||||
|
|
|
|||
Loading…
Reference in a new issue