Commit 468e8d19 authored by George Hotz's avatar George Hotz

should fix tests

parent 544b641e
......@@ -27,7 +27,7 @@ func LoadRam() map[uint32](uint32) {
// go test -run TestCompareEvmChain
func TestCompareEvmChain(t *testing.T) {
totalSteps := 50
totalSteps := 20
cchain := make(chan common.Hash, 1)
cuni := make(chan common.Hash, 1)
......
......@@ -49,7 +49,7 @@ func TestCompareUnicornEvm(t *testing.T) {
})
uniram := make(map[uint32](uint32))
go RunUnicorn(fn, uniram, steps, true, func(step int, mu uc.Unicorn, ram map[uint32](uint32)) {
go RunUnicorn(fn, uniram, steps, true, false, 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, false, nil)
RunUnicorn(os.Args[2], uniram, steps, false, false, nil)
} else {
runTest(os.Args[1], 20, 2)
}
......
......@@ -10,7 +10,7 @@ import (
func TestMinigethUnicorn(t *testing.T) {
uniram := make(map[uint32](uint32))
RunUnicorn("../mipigo/minigeth.bin", uniram, -1, false, nil)
RunUnicorn("../mipigo/minigeth.bin", uniram, -1, false, true, nil)
}
func TestSimpleEVM(t *testing.T) {
......
......@@ -71,7 +71,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, slowMode bool, callback func(int, uc.Unicorn, map[uint32](uint32))) {
func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode bool, checkIO 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)
......@@ -185,16 +185,21 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
inputs, _ := ioutil.ReadFile(inputFile)
mu.MemWrite(0xB0000000, inputs[0:0xc0])
LoadMappedFile(fn, ram, 0)
LoadMappedFile(inputFile, ram, 0xB0000000)
// load into ram
LoadData(dat, ram, 0)
if checkIO {
LoadData(inputs[0:0xc0], ram, 0xB0000000)
}
mu.Start(0, 0x5ead0004)
real := append([]byte{0x13, 0x37, 0xf0, 0x0d}, inputs[0xc0:]...)
output, _ := mu.MemRead(0xB0000800, 0x44)
if bytes.Compare(real, output) != 0 {
log.Fatal("mismatch output")
} else {
fmt.Println("output match")
if checkIO {
real := append([]byte{0x13, 0x37, 0xf0, 0x0d}, inputs[0xc0:]...)
output, _ := mu.MemRead(0xB0000800, 0x44)
if bytes.Compare(real, output) != 0 {
log.Fatal("mismatch output")
} else {
fmt.Println("output match")
}
}
}
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