|
|
|
@ -95,7 +95,7 @@ func testMissingNode(t *testing.T, memonly bool, scheme string) { |
|
|
|
|
trie := NewEmpty(triedb) |
|
|
|
|
updateString(trie, "120000", "qwerqwerqwerqwerqwerqwerqwerqwer") |
|
|
|
|
updateString(trie, "123456", "asdfasdfasdfasdfasdfasdfasdfasdf") |
|
|
|
|
root, nodes, _ := trie.Commit(false) |
|
|
|
|
root, nodes := trie.Commit(false) |
|
|
|
|
triedb.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
|
|
|
|
|
if !memonly { |
|
|
|
@ -184,7 +184,7 @@ func TestInsert(t *testing.T) { |
|
|
|
|
updateString(trie, "A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") |
|
|
|
|
|
|
|
|
|
exp = common.HexToHash("d23786fb4a010da3ce639d66d5e904a11dbc02746d1ce25029e53290cabf28ab") |
|
|
|
|
root, _, _ = trie.Commit(false) |
|
|
|
|
root, _ = trie.Commit(false) |
|
|
|
|
if root != exp { |
|
|
|
|
t.Errorf("case 2: exp %x got %x", exp, root) |
|
|
|
|
} |
|
|
|
@ -209,7 +209,7 @@ func TestGet(t *testing.T) { |
|
|
|
|
if i == 1 { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
root, nodes, _ := trie.Commit(false) |
|
|
|
|
root, nodes := trie.Commit(false) |
|
|
|
|
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
trie, _ = New(TrieID(root), db) |
|
|
|
|
} |
|
|
|
@ -282,7 +282,7 @@ func TestReplication(t *testing.T) { |
|
|
|
|
for _, val := range vals { |
|
|
|
|
updateString(trie, val.k, val.v) |
|
|
|
|
} |
|
|
|
|
root, nodes, _ := trie.Commit(false) |
|
|
|
|
root, nodes := trie.Commit(false) |
|
|
|
|
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
|
|
|
|
|
// create a new trie on top of the database and check that lookups work.
|
|
|
|
@ -295,7 +295,7 @@ func TestReplication(t *testing.T) { |
|
|
|
|
t.Errorf("trie2 doesn't have %q => %q", kv.k, kv.v) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
hash, nodes, _ := trie2.Commit(false) |
|
|
|
|
hash, nodes := trie2.Commit(false) |
|
|
|
|
if hash != root { |
|
|
|
|
t.Errorf("root failure. expected %x got %x", root, hash) |
|
|
|
|
} |
|
|
|
@ -531,7 +531,7 @@ func runRandTest(rt randTest) error { |
|
|
|
|
case opHash: |
|
|
|
|
tr.Hash() |
|
|
|
|
case opCommit: |
|
|
|
|
root, nodes, _ := tr.Commit(true) |
|
|
|
|
root, nodes := tr.Commit(true) |
|
|
|
|
if nodes != nil { |
|
|
|
|
triedb.Update(root, origin, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
} |
|
|
|
@ -768,7 +768,7 @@ func TestCommitAfterHash(t *testing.T) { |
|
|
|
|
if exp != root { |
|
|
|
|
t.Errorf("got %x, exp %x", root, exp) |
|
|
|
|
} |
|
|
|
|
root, _, _ = trie.Commit(false) |
|
|
|
|
root, _ = trie.Commit(false) |
|
|
|
|
if exp != root { |
|
|
|
|
t.Errorf("got %x, exp %x", root, exp) |
|
|
|
|
} |
|
|
|
@ -894,7 +894,7 @@ func TestCommitSequence(t *testing.T) { |
|
|
|
|
trie.MustUpdate(crypto.Keccak256(addresses[i][:]), accounts[i]) |
|
|
|
|
} |
|
|
|
|
// Flush trie -> database
|
|
|
|
|
root, nodes, _ := trie.Commit(false) |
|
|
|
|
root, nodes := trie.Commit(false) |
|
|
|
|
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
// Flush memdb -> disk (sponge)
|
|
|
|
|
db.Commit(root) |
|
|
|
@ -935,7 +935,7 @@ func TestCommitSequenceRandomBlobs(t *testing.T) { |
|
|
|
|
trie.MustUpdate(key, val) |
|
|
|
|
} |
|
|
|
|
// Flush trie -> database
|
|
|
|
|
root, nodes, _ := trie.Commit(false) |
|
|
|
|
root, nodes := trie.Commit(false) |
|
|
|
|
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
// Flush memdb -> disk (sponge)
|
|
|
|
|
db.Commit(root) |
|
|
|
@ -984,7 +984,7 @@ func TestCommitSequenceStackTrie(t *testing.T) { |
|
|
|
|
stTrie.Update(key, val) |
|
|
|
|
} |
|
|
|
|
// Flush trie -> database
|
|
|
|
|
root, nodes, _ := trie.Commit(false) |
|
|
|
|
root, nodes := trie.Commit(false) |
|
|
|
|
// Flush memdb -> disk (sponge)
|
|
|
|
|
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
db.Commit(root) |
|
|
|
@ -1042,7 +1042,7 @@ func TestCommitSequenceSmallRoot(t *testing.T) { |
|
|
|
|
stTrie.Update(key, []byte{0x1}) |
|
|
|
|
|
|
|
|
|
// Flush trie -> database
|
|
|
|
|
root, nodes, _ := trie.Commit(false) |
|
|
|
|
root, nodes := trie.Commit(false) |
|
|
|
|
// Flush memdb -> disk (sponge)
|
|
|
|
|
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes)) |
|
|
|
|
db.Commit(root) |
|
|
|
|