diff --git a/eth/api.go b/eth/api.go index f94795073d..98c2f5874f 100644 --- a/eth/api.go +++ b/eth/api.go @@ -344,6 +344,9 @@ type AccountRangeResult struct { } func accountRange(st state.Trie, start *common.Hash, maxResults int) (AccountRangeResult, error) { + if start == nil { + start = &common.Hash{0} + } it := trie.NewIterator(st.NodeIterator(start.Bytes())) result := AccountRangeResult{Accounts: make(map[common.Hash]*common.Address), Next: common.Hash{}} diff --git a/eth/api_test.go b/eth/api_test.go index 19fcd9649d..a4831a3008 100644 --- a/eth/api_test.go +++ b/eth/api_test.go @@ -88,6 +88,9 @@ func TestAccountRange(t *testing.T) { t.Logf("test getting number of results greater than max %d", AccountRangeMaxResults) accountRangeTest(t, &trie, state, &common.Hash{0x0}, AccountRangeMaxResults*2, AccountRangeMaxResults) + t.Logf("test with empty 'start' hash") + accountRangeTest(t, &trie, state, nil, AccountRangeMaxResults, AccountRangeMaxResults) + t.Logf("test pagination") // test pagination