Commit be3760dc authored by George Hotz's avatar George Hotz

see bugged trie in go

parent 5126ac1b
......@@ -63,7 +63,9 @@ func ParseNodeInternal(elems []byte, depth int, callback func(common.Hash) []byt
kind, val, lrest, err := rlp.Split(rest)
rest = lrest
check(err)
if len(val) > 0 {
fmt.Println(sprefix, i, kind, val, len(val))
}
if len(val) == 32 {
hh := common.BytesToHash(val)
//fmt.Println(sprefix, "node found with len", len(Preimages[hh]))
......
......@@ -4,6 +4,8 @@ import (
"fmt"
"io/ioutil"
"testing"
"github.com/ethereum/go-ethereum/common"
)
// go test -run TestTrie
......@@ -19,3 +21,24 @@ func TestTrie(t *testing.T) {
fmt.Println("serialized length is", len(dat))
ioutil.WriteFile("/tmp/eth/ramtrie", dat, 0644)
}
func TestBuggedTrie(t *testing.T) {
ram := make(map[uint32](uint32))
ram[0] = 1
ram[4] = 1
root := RamToTrie(ram)
fmt.Println("root(0,4) =", root)
ParseNode(root, 0, func(t common.Hash) []byte {
return Preimages[t]
})
ram[0x40] = 1
root = RamToTrie(ram)
fmt.Println("root(0,4,0x40) =", root)
ParseNode(root, 0, func(t common.Hash) []byte {
return Preimages[t]
})
}
......@@ -21,15 +21,15 @@ describe("MIPSMemory contract", function () {
await mm.AddTrieNode(new Uint8Array([0x80]))
let root = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
root = await write(mm, root, 0, 0)
root = await write(mm, root, 4, 0)
root = await write(mm, root, 0, 1)
root = await write(mm, root, 4, 1)
})
it("write three should work", async function() {
await mm.AddTrieNode(new Uint8Array([0x80]))
let root = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
root = await write(mm, root, 0, 0)
root = await write(mm, root, 4, 0)
root = await write(mm, root, 0x40, 0)
root = await write(mm, root, 0, 1)
root = await write(mm, root, 4, 1)
root = await write(mm, root, 0x40, 1)
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment