Commit 55270ac0 authored by George Hotz's avatar George Hotz

test running entirely on chain

parent 598fde4a
......@@ -49,8 +49,10 @@ func (s *StateDB) AddLog(log *types.Log) {
//fmt.Printf("R: %x -> %x\n", bytesTo32(log.Data[0:32]), bytesTo32(log.Data[32:]))
} else if log.Topics[0] == common.HexToHash("0x486ca368095cbbef9046ac7858bec943e866422cc388f49da1aa3aa77c10aa35") {
fmt.Printf("W: %x <- %x\n", bytesTo32(log.Data[0:32]), bytesTo32(log.Data[32:]))
} else if log.Topics[0] == common.HexToHash("0x86b89b5c9818dbbf520dd979a5f250d357508fe11b9511d4a43fd9bc6aa1be70") {
fmt.Println("state", common.BytesToHash(log.Data))
} else {
//fmt.Println("AddLog", log.Topics, log.Data)
fmt.Println("AddLog", log.Topics, log.Data)
}
}
}
......
package main
import (
"fmt"
"log"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func TestMipsChain(t *testing.T) {
// only need one ram
ram := LoadRam()
root := RamToTrie(ram)
interpreter, statedb := GetInterpreter(1, true)
DeployChain(interpreter, statedb)
// load chain trie node
for _, v := range Preimages {
//fmt.Println("AddTrieNode", k)
AddTrieNode(v, interpreter, statedb)
}
steps := 50
input := crypto.Keccak256Hash([]byte("Steps(bytes32,uint256)")).Bytes()[:4]
input = append(input, root.Bytes()...)
input = append(input, common.BigToHash(big.NewInt(int64(steps))).Bytes()...)
dat, gasUsed, err := RunWithInputAndGas(interpreter, statedb, input, uint64(steps*10000000))
if err != nil {
if len(dat) >= 0x24 {
fmt.Println(string(dat[0x24:]))
}
log.Fatal(err)
} else {
root = common.BytesToHash(dat)
fmt.Println("new state root", root, "gas used", gasUsed)
}
}
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