Commit 808fc18a authored by George Hotz's avatar George Hotz

add unicorn minigeth test

parent fed882d2
......@@ -26,7 +26,7 @@ func LoadRam() map[uint32](uint32) {
// go test -run TestCompareUnicornChain
func TestCompareUnicornChain(t *testing.T) {
func TestCompareEvmChain(t *testing.T) {
totalSteps := 20
cchain := make(chan common.Hash, 1)
......
......@@ -49,7 +49,7 @@ func TestCompareUnicornEvm(t *testing.T) {
})
uniram := make(map[uint32](uint32))
go RunUnicorn(fn, uniram, steps, func(step int, mu uc.Unicorn, ram map[uint32](uint32)) {
go RunUnicorn(fn, uniram, steps, true, func(step int, mu uc.Unicorn, ram map[uint32](uint32)) {
SyncRegs(mu, ram)
cuni <- RegSerialize(ram)
done.Lock()
......
......@@ -66,7 +66,7 @@ func main() {
RunMinigeth(os.Args[1], steps, debug)
} else if os.Args[1] == "unicorn" {
uniram := make(map[uint32](uint32))
RunUnicorn(os.Args[2], uniram, steps, nil)
RunUnicorn(os.Args[2], uniram, steps, false, nil)
} else {
runTest(os.Args[1], 20, 2)
}
......
package main
import (
"testing"
)
func TestMinigethUnicorn(t *testing.T) {
uniram := make(map[uint32](uint32))
RunUnicorn("../mipigo/minigeth.bin", uniram, -1, false, nil)
}
......@@ -70,7 +70,7 @@ func SyncRegs(mu uc.Unicorn, ram map[uint32](uint32)) {
}
// reimplement simple.py in go
func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, callback func(int, uc.Unicorn, map[uint32](uint32))) {
func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode bool, callback func(int, uc.Unicorn, map[uint32](uint32))) {
mu, err := uc.NewUnicorn(uc.ARCH_MIPS, uc.MODE_32|uc.MODE_BIG_ENDIAN)
check(err)
......@@ -125,8 +125,6 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, callback fun
mu.RegWrite(uc.MIPS_REG_A3, 0)
}, 0, 0)
slowMode := true
if slowMode {
mu.HookAdd(uc.HOOK_MEM_WRITE, func(mu uc.Unicorn, access int, addr64 uint64, size int, value int64) {
rt := value
......
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