mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
trie: unset the edge valuenode as well
This commit is contained in:
parent
f63c68c245
commit
200f567e69
2 changed files with 14 additions and 4 deletions
|
|
@ -264,11 +264,13 @@ func unset(root node, rest []byte, removeLeft bool) {
|
||||||
unset(rn.Children[rest[0]], rest[1:], removeLeft)
|
unset(rn.Children[rest[0]], rest[1:], removeLeft)
|
||||||
case *shortNode:
|
case *shortNode:
|
||||||
rn.flags = nodeFlag{dirty: true}
|
rn.flags = nodeFlag{dirty: true}
|
||||||
|
if _, ok := rn.Val.(valueNode); ok {
|
||||||
|
rn.Val = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
unset(rn.Val, rest[len(rn.Key):], removeLeft)
|
unset(rn.Val, rest[len(rn.Key):], removeLeft)
|
||||||
case hashNode, nil:
|
case hashNode, nil, valueNode:
|
||||||
panic("it shouldn't happen")
|
panic("it shouldn't happen")
|
||||||
case valueNode:
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ func TestBadRangeProof(t *testing.T) {
|
||||||
keys = append(keys, entries[i].k)
|
keys = append(keys, entries[i].k)
|
||||||
vals = append(vals, entries[i].v)
|
vals = append(vals, entries[i].v)
|
||||||
}
|
}
|
||||||
testcase := mrand.Intn(4)
|
testcase := mrand.Intn(6)
|
||||||
var index int
|
var index int
|
||||||
switch testcase {
|
switch testcase {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -188,6 +188,14 @@ func TestBadRangeProof(t *testing.T) {
|
||||||
index = mrand.Intn(end - start)
|
index = mrand.Intn(end - start)
|
||||||
keys[index] = entries[len(entries)-1].k
|
keys[index] = entries[len(entries)-1].k
|
||||||
vals[index] = entries[len(entries)-1].v
|
vals[index] = entries[len(entries)-1].v
|
||||||
|
case 4:
|
||||||
|
// Set random key to nil
|
||||||
|
index = mrand.Intn(end - start)
|
||||||
|
keys[index] = nil
|
||||||
|
case 5:
|
||||||
|
// Set random value to nil
|
||||||
|
index = mrand.Intn(end - start)
|
||||||
|
vals[index] = nil
|
||||||
}
|
}
|
||||||
err := VerifyRangeProof(trie.Hash(), keys, vals, firstProof, lastProof)
|
err := VerifyRangeProof(trie.Hash(), keys, vals, firstProof, lastProof)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue