Added Paranoia check for VM execution
This commit is contained in:
@ -173,10 +173,13 @@ func (t *Trie) Update(key string, value string) {
|
||||
k := CompactHexDecode(key)
|
||||
|
||||
root := t.UpdateState(t.Root, k, value)
|
||||
if _, ok := root.([]byte); !ok {
|
||||
t.Root = t.cache.PutValue(root, true)
|
||||
} else {
|
||||
switch root.(type) {
|
||||
case string:
|
||||
t.Root = root
|
||||
case []byte:
|
||||
t.Root = root
|
||||
default:
|
||||
t.Root = t.cache.PutValue(root, true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,10 +200,13 @@ func (t *Trie) Delete(key string) {
|
||||
k := CompactHexDecode(key)
|
||||
|
||||
root := t.DeleteState(t.Root, k)
|
||||
if _, ok := root.([]byte); !ok {
|
||||
t.Root = t.cache.PutValue(root, true)
|
||||
} else {
|
||||
switch root.(type) {
|
||||
case string:
|
||||
t.Root = root
|
||||
case []byte:
|
||||
t.Root = root
|
||||
default:
|
||||
t.Root = t.cache.PutValue(root, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,6 @@ func TestRemote(t *testing.T) {
|
||||
for key, value := range test.In {
|
||||
trie.Update(get(key), get(value))
|
||||
}
|
||||
fmt.Printf("%-15s: %x\n", test.Name, trie.Root)
|
||||
|
||||
a := NewValue(h(test.Root)).Bytes()
|
||||
b := NewValue(trie.Root).Bytes()
|
||||
@ -271,3 +270,23 @@ func TestTrieReplay(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestIt(t *testing.T) {
|
||||
_, trie := New()
|
||||
|
||||
test := map[string]string{
|
||||
"0x000000000000000000000000ec4f34c97e43fbb2816cfd95e388353c7181dab1": "0x4e616d6552656700000000000000000000000000000000000000000000000000",
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000045": "0x22b224a1420a802ab51d326e29fa98e34c4f24ea",
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000046": "0x67706c2076330000000000000000000000000000000000000000000000000000",
|
||||
"0x000000000000000000000000697c7b8c961b56f675d570498424ac8de1a918f6": "0x6f6f6f6820736f2067726561742c207265616c6c6c793f000000000000000000",
|
||||
"0x0000000000000000000000007ef9e639e2733cb34e4dfc576d4b23f72db776b2": "0x4655474156000000000000000000000000000000000000000000000000000000",
|
||||
"0x6f6f6f6820736f2067726561742c207265616c6c6c793f000000000000000000": "0x697c7b8c961b56f675d570498424ac8de1a918f6",
|
||||
"0x4655474156000000000000000000000000000000000000000000000000000000": "0x7ef9e639e2733cb34e4dfc576d4b23f72db776b2",
|
||||
"0x4e616d6552656700000000000000000000000000000000000000000000000000": "0xec4f34c97e43fbb2816cfd95e388353c7181dab1",
|
||||
}
|
||||
|
||||
for k, v := range test {
|
||||
trie.Update(k, v)
|
||||
}
|
||||
fmt.Printf("root : %x\n", trie.Root)
|
||||
}
|
||||
|
Reference in New Issue
Block a user