aboutsummaryrefslogtreecommitdiffstats
path: root/trie/iterator_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-04-18 19:37:10 +0800
committerFelix Lange <fjl@twurst.com>2017-04-25 08:14:31 +0800
commita13e920af01692cb07a520cda688f1cc5b5469dd (patch)
tree2321214787947ca0b4f302225aa2950617dd5cdd /trie/iterator_test.go
parentf958d7d4822d257598ae36fc3b381040faa5bb30 (diff)
downloaddexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.gz
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.bz2
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.lz
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.xz
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.zst
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.zip
trie: clean up iterator constructors
Make it so each iterator has exactly one public constructor: - NodeIterators can be created through a method. - Iterators can be created through NewIterator on any NodeIterator.
Diffstat (limited to 'trie/iterator_test.go')
-rw-r--r--trie/iterator_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/trie/iterator_test.go b/trie/iterator_test.go
index c101bb7b0..04d51aaf5 100644
--- a/trie/iterator_test.go
+++ b/trie/iterator_test.go
@@ -42,7 +42,7 @@ func TestIterator(t *testing.T) {
trie.Commit()
found := make(map[string]string)
- it := NewIterator(trie)
+ it := NewIterator(trie.NodeIterator())
for it.Next() {
found[string(it.Key)] = string(it.Value)
}
@@ -72,7 +72,7 @@ func TestIteratorLargeData(t *testing.T) {
vals[string(value2.k)] = value2
}
- it := NewIterator(trie)
+ it := NewIterator(trie.NodeIterator())
for it.Next() {
vals[string(it.Key)].t = true
}
@@ -99,7 +99,7 @@ func TestNodeIteratorCoverage(t *testing.T) {
// Gather all the node hashes found by the iterator
hashes := make(map[common.Hash]struct{})
- for it := NewNodeIterator(trie); it.Next(true); {
+ for it := trie.NodeIterator(); it.Next(true); {
if it.Hash() != (common.Hash{}) {
hashes[it.Hash()] = struct{}{}
}
@@ -154,8 +154,8 @@ func TestDifferenceIterator(t *testing.T) {
trieb.Commit()
found := make(map[string]string)
- di, _ := NewDifferenceIterator(NewNodeIterator(triea), NewNodeIterator(trieb))
- it := NewIteratorFromNodeIterator(di)
+ di, _ := NewDifferenceIterator(triea.NodeIterator(), trieb.NodeIterator())
+ it := NewIterator(di)
for it.Next() {
found[string(it.Key)] = string(it.Value)
}
@@ -189,8 +189,8 @@ func TestUnionIterator(t *testing.T) {
}
trieb.Commit()
- di, _ := NewUnionIterator([]NodeIterator{NewNodeIterator(triea), NewNodeIterator(trieb)})
- it := NewIteratorFromNodeIterator(di)
+ di, _ := NewUnionIterator([]NodeIterator{triea.NodeIterator(), trieb.NodeIterator()})
+ it := NewIterator(di)
all := []struct{ k, v string }{
{"aardvark", "c"},