mips_evm_test.go 958 Bytes
Newer Older
George Hotz's avatar
George Hotz committed
1 2 3 4 5 6 7 8 9 10 11 12
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"testing"
	"time"
)

func TestMinigethUnicorn(t *testing.T) {
	uniram := make(map[uint32](uint32))
George Hotz's avatar
George Hotz committed
13
	RunUnicorn("../mipigo/minigeth.bin", uniram, true, nil)
George Hotz's avatar
George Hotz committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
}

func TestSimpleEVM(t *testing.T) {
	files, err := ioutil.ReadDir("test/bin")
	if err != nil {
		log.Fatal(err)
	}
	good := true
	gas := uint64(0)
	for _, f := range files {
		ram := make(map[uint32](uint32))
		ram[0xC000007C] = 0x5EAD0000
		fn := "test/bin/" + f.Name()
		LoadMappedFile(fn, ram, 0)

		start := time.Now()
George Hotz's avatar
George Hotz committed
30
		remainingGas, err := RunWithRam(ram, 100, 0, "testoracle/", nil)
George Hotz's avatar
George Hotz committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
		elapsed := time.Now().Sub(start)

		fmt.Println(err, remainingGas, elapsed,
			ram[0xbffffff4], ram[0xbffffff8], fmt.Sprintf("%x", ram[0xc0000080]), fn)
		if err != nil {
			log.Fatal(err)
		}
		good = good && ((ram[0xbffffff4] & ram[0xbffffff8]) == 1)
		gas += remainingGas
	}
	if !good {
		panic("some tests failed")
	}
	fmt.Println("used", gas, "gas")
}