aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/instructions_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/vm/instructions_test.go')
-rw-r--r--core/vm/instructions_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go
index 0de558612..f51e6363f 100644
--- a/core/vm/instructions_test.go
+++ b/core/vm/instructions_test.go
@@ -425,3 +425,42 @@ func BenchmarkOpIsZero(b *testing.B) {
x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
opBenchmark(b, opIszero, x)
}
+
+func TestOpMstore(t *testing.T) {
+ var (
+ env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
+ stack = newstack()
+ mem = NewMemory()
+ )
+ mem.Resize(64)
+ pc := uint64(0)
+ v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
+ stack.pushN(new(big.Int).SetBytes(common.Hex2Bytes(v)), big.NewInt(0))
+ opMstore(&pc, env, nil, mem, stack)
+ if got := common.Bytes2Hex(mem.Get(0, 32)); got != v {
+ t.Fatalf("Mstore fail, got %v, expected %v", got, v)
+ }
+ stack.pushN(big.NewInt(0x1), big.NewInt(0))
+ opMstore(&pc, env, nil, mem, stack)
+ if common.Bytes2Hex(mem.Get(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" {
+ t.Fatalf("Mstore failed to overwrite previous value")
+ }
+}
+
+func BenchmarkOpMstore(bench *testing.B) {
+ var (
+ env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
+ stack = newstack()
+ mem = NewMemory()
+ )
+ mem.Resize(64)
+ pc := uint64(0)
+ memStart := big.NewInt(0)
+ value := big.NewInt(0x1337)
+
+ bench.ResetTimer()
+ for i := 0; i < bench.N; i++ {
+ stack.pushN(value, memStart)
+ opMstore(&pc, env, nil, mem, stack)
+ }
+}