From e431a23c09b60ce1ae5ce6e313d50b59f102bb48 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Sat, 14 Mar 2020 09:19:35 +0100 Subject: [PATCH] core/vm: fix tests --- core/vm/instructions_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go index bdc62d1777..6b35d762a8 100644 --- a/core/vm/instructions_test.go +++ b/core/vm/instructions_test.go @@ -109,7 +109,7 @@ func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFu expected := new(big.Int).SetBytes(common.Hex2Bytes(test.Expected)) stack.push(x) stack.push(y) - opFn(&pc, evmInterpreter, nil, nil, stack) + opFn(&pc, evmInterpreter, &CallCtx{nil, stack, nil}) actual := stack.pop() if actual.Cmp(expected) != 0 { @@ -223,7 +223,7 @@ func getResult(args []*twoOperandParams, opFn executionFunc) []TwoOperandTestcas y := new(big.Int).SetBytes(common.Hex2Bytes(param.y)) stack.push(x) stack.push(y) - opFn(&pc, interpreter, nil, nil, stack) + opFn(&pc, interpreter, &CallCtx{nil, stack, nil}) actual := stack.pop() result[i] = TwoOperandTestcase{param.x, param.y, fmt.Sprintf("%064x", actual)} } @@ -260,7 +260,7 @@ func TestJsonTestcases(t *testing.T) { } } -func opBenchmark(bench *testing.B, op func(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error), args ...string) { +func opBenchmark(bench *testing.B, op executionFunc, args ...string) { var ( env = NewEVM(Context{}, nil, params.TestChainConfig, Config{}) stack = newstack() @@ -281,7 +281,7 @@ func opBenchmark(bench *testing.B, op func(pc *uint64, interpreter *EVMInterpret a := new(big.Int).SetBytes(arg) stack.push(a) } - op(&pc, evmInterpreter, nil, nil, stack) + op(&pc, evmInterpreter, &CallCtx{nil, stack, nil}) stack.pop() } poolOfIntPools.put(evmInterpreter.intPool) @@ -509,12 +509,12 @@ func TestOpMstore(t *testing.T) { pc := uint64(0) v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700" stack.pushN(new(big.Int).SetBytes(common.Hex2Bytes(v)), big.NewInt(0)) - opMstore(&pc, evmInterpreter, nil, mem, stack) + opMstore(&pc, evmInterpreter, &CallCtx{mem, stack, nil}) if got := common.Bytes2Hex(mem.GetCopy(0, 32)); got != v { t.Fatalf("Mstore fail, got %v, expected %v", got, v) } stack.pushN(big.NewInt(0x1), big.NewInt(0)) - opMstore(&pc, evmInterpreter, nil, mem, stack) + opMstore(&pc, evmInterpreter, &CallCtx{mem, stack, nil}) if common.Bytes2Hex(mem.GetCopy(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" { t.Fatalf("Mstore failed to overwrite previous value") } @@ -539,7 +539,7 @@ func BenchmarkOpMstore(bench *testing.B) { bench.ResetTimer() for i := 0; i < bench.N; i++ { stack.pushN(value, memStart) - opMstore(&pc, evmInterpreter, nil, mem, stack) + opMstore(&pc, evmInterpreter, &CallCtx{mem, stack, nil}) } poolOfIntPools.put(evmInterpreter.intPool) } @@ -560,7 +560,7 @@ func BenchmarkOpSHA3(bench *testing.B) { bench.ResetTimer() for i := 0; i < bench.N; i++ { stack.pushN(big.NewInt(32), start) - opSha3(&pc, evmInterpreter, nil, mem, stack) + opSha3(&pc, evmInterpreter, &CallCtx{mem, stack, nil}) } poolOfIntPools.put(evmInterpreter.intPool) }