trie: fix error in node decoding (#19111)

pull/19029/head
Martin Holst Swende 6 years ago committed by Péter Szilágyi
parent fe5258b41e
commit a458153098
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
  1. 3
      trie/encoding.go
  2. 13
      trie/trie_test.go

@ -52,6 +52,9 @@ func hexToCompact(hex []byte) []byte {
}
func compactToHex(compact []byte) []byte {
if len(compact) == 0 {
return compact
}
base := keybytesToHex(compact)
// delete terminator flag
if base[0] < 2 {

@ -614,3 +614,16 @@ func updateString(trie *Trie, k, v string) {
func deleteString(trie *Trie, k string) {
trie.Delete([]byte(k))
}
func TestDecodeNode(t *testing.T) {
t.Parallel()
var (
hash = make([]byte, 20)
elems = make([]byte, 20)
)
for i := 0; i < 5000000; i++ {
rand.Read(hash)
rand.Read(elems)
decodeNode(hash, elems, 1)
}
}

Loading…
Cancel
Save