From 321f13dc19081d18e11d119068478f360abc408f Mon Sep 17 00:00:00 2001 From: andri lim Date: Sat, 21 Sep 2019 12:45:23 +0700 Subject: [PATCH] attempt to add simple cli to all_tests --- tests/all_tests.nim | 88 +- tests/test_code_stream.nim | 183 ++-- tests/test_difficulty.nim | 13 +- tests/test_gas_meter.nim | 74 +- tests/test_generalstate_json.nim | 7 +- tests/test_genesis.nim | 11 +- tests/test_memory.nim | 89 +- tests/test_op_arith.nim | 767 +++++++-------- tests/test_op_bit.nim | 1307 +++++++++++++------------- tests/test_op_custom.nim | 533 +++++------ tests/test_op_env.nim | 569 ++++++------ tests/test_op_memory.nim | 1483 +++++++++++++++--------------- tests/test_op_misc.nim | 323 +++---- tests/test_persistblock_json.nim | 5 +- tests/test_precompiles.nim | 5 +- tests/test_stack.nim | 131 +-- tests/test_state_db.nim | 55 +- tests/test_tracer_json.nim | 5 +- tests/test_transaction_json.nim | 8 +- tests/test_vm_json.nim | 5 +- 20 files changed, 2864 insertions(+), 2797 deletions(-) diff --git a/tests/all_tests.nim b/tests/all_tests.nim index 7ad99f87c..6f8a405aa 100644 --- a/tests/all_tests.nim +++ b/tests/all_tests.nim @@ -5,24 +5,72 @@ # * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) # at your option. This file may not be copied, modified, or distributed except according to those terms. -import ./test_code_stream, - ./test_gas_meter, - ./test_memory, - ./test_stack, - ./test_genesis, - ./test_vm_json, - ./test_precompiles, - ./test_generalstate_json, - ./test_tracer_json, - ./test_persistblock_json, - #./test_rpc, # it crash if we combine it here - ./test_op_arith, - ./test_op_bit, - ./test_op_env, - ./test_op_memory, - ./test_op_misc, - ./test_op_custom, - ./test_state_db, - ./test_difficulty, - ./test_transaction_json +import macros, strutils, os, unittest, osproc +proc executeMyself(numModules: int) = + let appName = getAppFilename() + for i in 0.. 0: echo message quit(QuitSuccess) - -main() + generalStateJsonMain(true) diff --git a/tests/test_genesis.nim b/tests/test_genesis.nim index 460ee8d9a..28ce84b50 100644 --- a/tests/test_genesis.nim +++ b/tests/test_genesis.nim @@ -1,7 +1,8 @@ import unittest, ../nimbus/[genesis, config], eth/common, nimcrypto/hash -suite "Genesis": - test "Correct mainnet hash": - let g = defaultGenesisBlockForNetwork(MainNet) - let b = g.toBlock - check(b.blockHash == "D4E56740F876AEF8C010B86A40D5F56745A118D0906A34E69AEC8C0DB1CB8FA3".toDigest) +proc genesisMain*() = + suite "Genesis": + test "Correct mainnet hash": + let g = defaultGenesisBlockForNetwork(MainNet) + let b = g.toBlock + check(b.blockHash == "D4E56740F876AEF8C010B86A40D5F56745A118D0906A34E69AEC8C0DB1CB8FA3".toDigest) diff --git a/tests/test_memory.nim b/tests/test_memory.nim index 5186ef50f..8df01af1e 100644 --- a/tests/test_memory.nim +++ b/tests/test_memory.nim @@ -18,53 +18,54 @@ proc memory128: Memory = result = newMemory() result.extend(0, 128) -suite "memory": - test "write": - var mem = memory32() - # Test that write creates 32byte string == value padded with zeros - mem.write(startPos = 0, value = @[1.byte, 0.byte, 1.byte, 0.byte]) - check(mem.bytes == @[1.byte, 0.byte, 1.byte, 0.byte].concat(repeat(0.byte, 28))) +proc memoryMain*() = + suite "memory": + test "write": + var mem = memory32() + # Test that write creates 32byte string == value padded with zeros + mem.write(startPos = 0, value = @[1.byte, 0.byte, 1.byte, 0.byte]) + check(mem.bytes == @[1.byte, 0.byte, 1.byte, 0.byte].concat(repeat(0.byte, 28))) - # test "write rejects invalid position": - # expect(ValidationError): - # var mem = memory32() - # mem.write(startPosition = -1.i256, size = 2.i256, value = @[1.byte, 0.byte]) - # expect(ValidationError): - # TODO: work on 256 - # var mem = memory32() - # echo "pow ", pow(2.i256, 255) - 1.i256 - # mem.write(startPosition = pow(2.i256, 256), size = 2.i256, value = @[1.byte, 0.byte]) + # test "write rejects invalid position": + # expect(ValidationError): + # var mem = memory32() + # mem.write(startPosition = -1.i256, size = 2.i256, value = @[1.byte, 0.byte]) + # expect(ValidationError): + # TODO: work on 256 + # var mem = memory32() + # echo "pow ", pow(2.i256, 255) - 1.i256 + # mem.write(startPosition = pow(2.i256, 256), size = 2.i256, value = @[1.byte, 0.byte]) - # test "write rejects invalid size": - # # expect(ValidationError): - # # var mem = memory32() - # # mem.write(startPosition = 0.i256, size = -1.i256, value = @[1.byte, 0.byte]) + # test "write rejects invalid size": + # # expect(ValidationError): + # # var mem = memory32() + # # mem.write(startPosition = 0.i256, size = -1.i256, value = @[1.byte, 0.byte]) - # #TODO deactivated because of no pow support in Stint: https://github.com/status-im/nim-stint/issues/37 - # expect(ValidationError): - # var mem = memory32() - # mem.write(startPosition = 0.u256, size = pow(2.u256, 256), value = @[1.byte, 0.byte]) + # #TODO deactivated because of no pow support in Stint: https://github.com/status-im/nim-stint/issues/37 + # expect(ValidationError): + # var mem = memory32() + # mem.write(startPosition = 0.u256, size = pow(2.u256, 256), value = @[1.byte, 0.byte]) - test "write rejects valyes beyond memory size": - expect(ValidationError): - var mem = memory128() - mem.write(startPos = 128, value = @[1.byte, 0.byte, 1.byte, 0.byte]) + test "write rejects valyes beyond memory size": + expect(ValidationError): + var mem = memory128() + mem.write(startPos = 128, value = @[1.byte, 0.byte, 1.byte, 0.byte]) - test "extends appropriately extends memory": - var mem = newMemory() - # Test extends to 32 byte array: 0 < (start_position + size) <= 32 - mem.extend(startPos = 0, size = 10) - check(mem.bytes == repeat(0.byte, 32)) - # Test will extend past length if params require: 32 < (start_position + size) <= 64 - mem.extend(startPos = 28, size = 32) - check(mem.bytes == repeat(0.byte, 64)) - # Test won't extend past length unless params require: 32 < (start_position + size) <= 64 - mem.extend(startPos = 48, size = 10) - check(mem.bytes == repeat(0.byte, 64)) + test "extends appropriately extends memory": + var mem = newMemory() + # Test extends to 32 byte array: 0 < (start_position + size) <= 32 + mem.extend(startPos = 0, size = 10) + check(mem.bytes == repeat(0.byte, 32)) + # Test will extend past length if params require: 32 < (start_position + size) <= 64 + mem.extend(startPos = 28, size = 32) + check(mem.bytes == repeat(0.byte, 64)) + # Test won't extend past length unless params require: 32 < (start_position + size) <= 64 + mem.extend(startPos = 48, size = 10) + check(mem.bytes == repeat(0.byte, 64)) - test "read returns correct bytes": - var mem = memory32() - mem.write(startPos = 5, value = @[1.byte, 0.byte, 1.byte, 0.byte]) - check(mem.read(startPos = 5, size = 4) == @[1.byte, 0.byte, 1.byte, 0.byte]) - check(mem.read(startPos = 6, size = 4) == @[0.byte, 1.byte, 0.byte, 0.byte]) - check(mem.read(startPos = 1, size = 3) == @[0.byte, 0.byte, 0.byte]) + test "read returns correct bytes": + var mem = memory32() + mem.write(startPos = 5, value = @[1.byte, 0.byte, 1.byte, 0.byte]) + check(mem.read(startPos = 5, size = 4) == @[1.byte, 0.byte, 1.byte, 0.byte]) + check(mem.read(startPos = 6, size = 4) == @[0.byte, 1.byte, 0.byte, 0.byte]) + check(mem.read(startPos = 1, size = 3) == @[0.byte, 0.byte, 0.byte]) diff --git a/tests/test_op_arith.nim b/tests/test_op_arith.nim index c8372ada9..d70b086c0 100644 --- a/tests/test_op_arith.nim +++ b/tests/test_op_arith.nim @@ -1,439 +1,440 @@ import macro_assembler, unittest -suite "Arithmetic Opcodes": - let (blockNumber, chainDB) = initDatabase() +proc opArithMain*() = + suite "Arithmetic Opcodes": + let (blockNumber, chainDB) = initDatabase() - assembler: - title: "ADD_1" - code: - PUSH1 "0x02" - PUSH1 "0x02" - ADD - stack: "0x04" + assembler: + title: "ADD_1" + code: + PUSH1 "0x02" + PUSH1 "0x02" + ADD + stack: "0x04" - assembler: - title: "ADD_2" - code: - PUSH2 "0x1002" - PUSH1 "0x02" - ADD - stack: "0x1004" + assembler: + title: "ADD_2" + code: + PUSH2 "0x1002" + PUSH1 "0x02" + ADD + stack: "0x1004" - assembler: - title: "ADD_3" - code: - PUSH2 "0x1002" - PUSH6 "0x123456789009" - ADD - stack: "0x12345678A00B" + assembler: + title: "ADD_3" + code: + PUSH2 "0x1002" + PUSH6 "0x123456789009" + ADD + stack: "0x12345678A00B" - assembler: - title: "ADD_4" - code: - PUSH2 "0x1234" - ADD - success: false - stack: "0x1234" + assembler: + title: "ADD_4" + code: + PUSH2 "0x1234" + ADD + success: false + stack: "0x1234" - assembler: - title: "ADDMOD_1" - code: - PUSH1 "0x02" - PUSH1 "0x02" - PUSH1 "0x03" - ADDMOD - stack: "0x01" + assembler: + title: "ADDMOD_1" + code: + PUSH1 "0x02" + PUSH1 "0x02" + PUSH1 "0x03" + ADDMOD + stack: "0x01" - assembler: - title: "ADDMOD_2" - code: - PUSH2 "0x1000" - PUSH1 "0x02" - PUSH2 "0x1002" - ADDMOD - PUSH1 "0x00" - stack: - "0x04" - "0x00" + assembler: + title: "ADDMOD_2" + code: + PUSH2 "0x1000" + PUSH1 "0x02" + PUSH2 "0x1002" + ADDMOD + PUSH1 "0x00" + stack: + "0x04" + "0x00" - assembler: - title: "ADDMOD_3" - code: - PUSH2 "0x1002" - PUSH6 "0x123456789009" - PUSH1 "0x02" - ADDMOD - stack: "0x093B" + assembler: + title: "ADDMOD_3" + code: + PUSH2 "0x1002" + PUSH6 "0x123456789009" + PUSH1 "0x02" + ADDMOD + stack: "0x093B" - assembler: - title: "ADDMOD_4" - code: - PUSH2 "0x1234" - ADDMOD - stack: "0x1234" - success: false + assembler: + title: "ADDMOD_4" + code: + PUSH2 "0x1234" + ADDMOD + stack: "0x1234" + success: false - assembler: - title: "MUL_1" - code: - PUSH1 "0x03" - PUSH1 "0x02" - MUL - stack: "0x06" + assembler: + title: "MUL_1" + code: + PUSH1 "0x03" + PUSH1 "0x02" + MUL + stack: "0x06" - assembler: - title: "MUL_2" - code: - PUSH3 "0x222222" - PUSH1 "0x03" - MUL - stack: "0x666666" + assembler: + title: "MUL_2" + code: + PUSH3 "0x222222" + PUSH1 "0x03" + MUL + stack: "0x666666" - assembler: - title: "MUL_3" - code: - PUSH3 "0x222222" - PUSH3 "0x333333" - MUL - stack: "0x6D3A05F92C6" + assembler: + title: "MUL_3" + code: + PUSH3 "0x222222" + PUSH3 "0x333333" + MUL + stack: "0x6D3A05F92C6" - assembler: - title: "MUL_4" - code: - PUSH1 "0x01" - MUL - stack: "0x01" - success: false + assembler: + title: "MUL_4" + code: + PUSH1 "0x01" + MUL + stack: "0x01" + success: false - assembler: # MULMOD OP - title: "MULMOD_2" - code: - PUSH3 "0x222222" - PUSH1 "0x03" - PUSH1 "0x04" - MULMOD - stack: "0x000000000000000000000000000000000000000000000000000000000000000C" + assembler: # MULMOD OP + title: "MULMOD_2" + code: + PUSH3 "0x222222" + PUSH1 "0x03" + PUSH1 "0x04" + MULMOD + stack: "0x000000000000000000000000000000000000000000000000000000000000000C" - assembler: # MULMOD OP - title: "MULMOD_3" - code: - PUSH3 "0x222222" - PUSH3 "0x333333" - PUSH3 "0x444444" - MULMOD - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + assembler: # MULMOD OP + title: "MULMOD_3" + code: + PUSH3 "0x222222" + PUSH3 "0x333333" + PUSH3 "0x444444" + MULMOD + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler: # MULMOD OP mal - title: "MULMOD_4" - code: - PUSH1 "0x01" - MULMOD - success: false - stack: "0x01" + assembler: # MULMOD OP mal + title: "MULMOD_4" + code: + PUSH1 "0x01" + MULMOD + success: false + stack: "0x01" - assembler: # DIV OP - title: "DIV_1" - code: - PUSH1 "0x02" - PUSH1 "0x04" - DIV - stack: "0x0000000000000000000000000000000000000000000000000000000000000002" + assembler: # DIV OP + title: "DIV_1" + code: + PUSH1 "0x02" + PUSH1 "0x04" + DIV + stack: "0x0000000000000000000000000000000000000000000000000000000000000002" - assembler: # DIV OP - title: "DIV_2" - code: - PUSH1 "0x33" - PUSH1 "0x99" - DIV - stack: "0x0000000000000000000000000000000000000000000000000000000000000003" + assembler: # DIV OP + title: "DIV_2" + code: + PUSH1 "0x33" + PUSH1 "0x99" + DIV + stack: "0x0000000000000000000000000000000000000000000000000000000000000003" - assembler: # DIV OP - title: "DIV_3" - code: - PUSH1 "0x22" - PUSH1 "0x99" - DIV - stack: "0x0000000000000000000000000000000000000000000000000000000000000004" + assembler: # DIV OP + title: "DIV_3" + code: + PUSH1 "0x22" + PUSH1 "0x99" + DIV + stack: "0x0000000000000000000000000000000000000000000000000000000000000004" - assembler: # DIV OP - title: "DIV_4" - code: - PUSH1 "0x15" - PUSH1 "0x99" - DIV - stack: "0x0000000000000000000000000000000000000000000000000000000000000007" + assembler: # DIV OP + title: "DIV_4" + code: + PUSH1 "0x15" + PUSH1 "0x99" + DIV + stack: "0x0000000000000000000000000000000000000000000000000000000000000007" - assembler: # DIV OP - title: "DIV_5" - code: - PUSH1 "0x04" - PUSH1 "0x07" - DIV - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + assembler: # DIV OP + title: "DIV_5" + code: + PUSH1 "0x04" + PUSH1 "0x07" + DIV + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - assembler: # DIV OP - title: "DIV_6" - code: - PUSH1 "0x07" - DIV - success: false - stack: "0x07" + assembler: # DIV OP + title: "DIV_6" + code: + PUSH1 "0x07" + DIV + success: false + stack: "0x07" - assembler: # SDIV OP - title: "SDIV_1" - code: - PUSH2 "0x03E8" - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC18" - SDIV - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + assembler: # SDIV OP + title: "SDIV_1" + code: + PUSH2 "0x03E8" + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC18" + SDIV + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - assembler: # SDIV OP - title: "SDIV_2" - code: - PUSH1 "0xFF" - PUSH1 "0xFF" - SDIV - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + assembler: # SDIV OP + title: "SDIV_2" + code: + PUSH1 "0xFF" + PUSH1 "0xFF" + SDIV + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - assembler: # SDIV OP, SDIV by zero should be zero - title: "SDIV_3" - code: - PUSH1 "0x00" - PUSH1 "0xFF" - SDIV - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + assembler: # SDIV OP, SDIV by zero should be zero + title: "SDIV_3" + code: + PUSH1 "0x00" + PUSH1 "0xFF" + SDIV + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler: # SDIV OP mal - title: "SDIV_4" - code: - PUSH1 "0xFF" - SDIV - success: false - stack: "0xFF" + assembler: # SDIV OP mal + title: "SDIV_4" + code: + PUSH1 "0xFF" + SDIV + success: false + stack: "0xFF" - assembler: # -2^255 SDIV -1 = -2^255 (special case in yellow paper) - title: "SDIV_5" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1 - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) - SDIV - stack: "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) + assembler: # -2^255 SDIV -1 = -2^255 (special case in yellow paper) + title: "SDIV_5" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1 + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) + SDIV + stack: "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) - assembler: # -2^255 SDIV 1 = -2^255 - title: "SDIV_6" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" # 1 - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) - SDIV - stack: "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) + assembler: # -2^255 SDIV 1 = -2^255 + title: "SDIV_6" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" # 1 + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) + SDIV + stack: "0x8000000000000000000000000000000000000000000000000000000000000000" # -2^255 == low(int256) - assembler: # -2 SDIV 2 = -1 - title: "SDIV_7" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 - SDIV - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1 + assembler: # -2 SDIV 2 = -1 + title: "SDIV_7" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 + SDIV + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1 - assembler: # 4 SDIV -2 = -2 - title: "SDIV_8" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000004" # 4 - SDIV - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 + assembler: # 4 SDIV -2 = -2 + title: "SDIV_8" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000004" # 4 + SDIV + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 - assembler: # -4 SDIV 2 = -2 - title: "SDIV_9" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # -4 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC" # 2 - SDIV - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 + assembler: # -4 SDIV 2 = -2 + title: "SDIV_9" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # -4 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC" # 2 + SDIV + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 - assembler: # -1 SDIV 2 = 0 - title: "SDIV_10" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1 - SDIV - stack: "0x00" # 0 + assembler: # -1 SDIV 2 = 0 + title: "SDIV_10" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" # -1 + SDIV + stack: "0x00" # 0 - assembler: # low(int256) SDIV low(int256) = 1 - title: "SDIV_11" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) - SDIV - stack: "0x01" # 1 + assembler: # low(int256) SDIV low(int256) = 1 + title: "SDIV_11" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) + SDIV + stack: "0x01" # 1 - assembler: # low(int256) SDIV 2 - title: "SDIV_12" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2 - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) - SDIV - stack: "0xC000000000000000000000000000000000000000000000000000000000000000" # negative half low(int256) + assembler: # low(int256) SDIV 2 + title: "SDIV_12" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000002" # 2 + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) + SDIV + stack: "0xC000000000000000000000000000000000000000000000000000000000000000" # negative half low(int256) - assembler: # low(int256) SDIV -2 - title: "SDIV_13" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) - SDIV - stack: "0x4000000000000000000000000000000000000000000000000000000000000000" # positive version of SDIV_12 + assembler: # low(int256) SDIV -2 + title: "SDIV_13" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" # -2 + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" # low(int256) + SDIV + stack: "0x4000000000000000000000000000000000000000000000000000000000000000" # positive version of SDIV_12 - assembler: - title: "SDIV_14" - code: - PUSH1 "0x01" # 1 - PUSH1 "0x7F" # 127 - SHL # 1 shl 127 (move the bit to the center or 128th position) + assembler: + title: "SDIV_14" + code: + PUSH1 "0x01" # 1 + PUSH1 "0x7F" # 127 + SHL # 1 shl 127 (move the bit to the center or 128th position) - PUSH1 "0x01" # 1 - PUSH1 "0xFF" # 255 - SHL # 1 shl 255 (create low(int256)) + PUSH1 "0x01" # 1 + PUSH1 "0xFF" # 255 + SHL # 1 shl 255 (create low(int256)) - SDIV - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000" # half of the hi bits are set - fork: constantinople + SDIV + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000" # half of the hi bits are set + fork: constantinople - assembler: # SUB OP - title: "SUB_1" - code: - PUSH1 "0x04" - PUSH1 "0x06" - SUB - stack: "0x0000000000000000000000000000000000000000000000000000000000000002" + assembler: # SUB OP + title: "SUB_1" + code: + PUSH1 "0x04" + PUSH1 "0x06" + SUB + stack: "0x0000000000000000000000000000000000000000000000000000000000000002" - assembler: # SUB OP - title: "SUB_2" - code: - PUSH2 "0x4444" - PUSH2 "0x6666" - SUB - stack: "0x0000000000000000000000000000000000000000000000000000000000002222" + assembler: # SUB OP + title: "SUB_2" + code: + PUSH2 "0x4444" + PUSH2 "0x6666" + SUB + stack: "0x0000000000000000000000000000000000000000000000000000000000002222" - assembler: # SUB OP - title: "SUB_3" - code: - PUSH2 "0x4444" - PUSH4 "0x99996666" - SUB - stack: "0x0000000000000000000000000000000000000000000000000000000099992222" + assembler: # SUB OP + title: "SUB_3" + code: + PUSH2 "0x4444" + PUSH4 "0x99996666" + SUB + stack: "0x0000000000000000000000000000000000000000000000000000000099992222" - assembler: # SUB OP mal - title: "SUB_4" - code: - PUSH4 "0x99996666" - SUB - success: false - stack: "0x99996666" + assembler: # SUB OP mal + title: "SUB_4" + code: + PUSH4 "0x99996666" + SUB + success: false + stack: "0x99996666" - assembler: # EXP OP - title: "EXP_1" - code: - PUSH1 "0x03" - PUSH1 "0x02" - EXP - stack: "0x0000000000000000000000000000000000000000000000000000000000000008" - #assertEquals(4, gas); + assembler: # EXP OP + title: "EXP_1" + code: + PUSH1 "0x03" + PUSH1 "0x02" + EXP + stack: "0x0000000000000000000000000000000000000000000000000000000000000008" + #assertEquals(4, gas); - assembler: # EXP OP - title: "EXP_2" - code: - PUSH1 "0x00" - PUSH3 "0x123456" - EXP - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - #assertEquals(3, gas); + assembler: # EXP OP + title: "EXP_2" + code: + PUSH1 "0x00" + PUSH3 "0x123456" + EXP + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + #assertEquals(3, gas); - assembler: # EXP OP - title: "EXP_3" - code: - PUSH2 "0x1122" - PUSH1 "0x01" - EXP - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - #assertEquals(5, gas); + assembler: # EXP OP + title: "EXP_3" + code: + PUSH2 "0x1122" + PUSH1 "0x01" + EXP + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + #assertEquals(5, gas); - assembler: # EXP OP mal - title: "EXP_4" - code: - PUSH3 "0x123456" - EXP - success: false - stack: "0x123456" + assembler: # EXP OP mal + title: "EXP_4" + code: + PUSH3 "0x123456" + EXP + success: false + stack: "0x123456" - assembler: # MOD OP - title: "MOD_1" - code: - PUSH1 "0x03" - PUSH1 "0x04" - MOD - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + assembler: # MOD OP + title: "MOD_1" + code: + PUSH1 "0x03" + PUSH1 "0x04" + MOD + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - assembler: # MOD OP - title: "MOD_2" - code: - PUSH2 "0x012C" - PUSH2 "0x01F4" - MOD - stack: "0x00000000000000000000000000000000000000000000000000000000000000C8" + assembler: # MOD OP + title: "MOD_2" + code: + PUSH2 "0x012C" + PUSH2 "0x01F4" + MOD + stack: "0x00000000000000000000000000000000000000000000000000000000000000C8" - assembler: # MOD OP - title: "MOD_3" - code: - PUSH1 "0x04" - PUSH1 "0x02" - MOD - stack: "0x0000000000000000000000000000000000000000000000000000000000000002" + assembler: # MOD OP + title: "MOD_3" + code: + PUSH1 "0x04" + PUSH1 "0x02" + MOD + stack: "0x0000000000000000000000000000000000000000000000000000000000000002" - assembler: # MOD OP mal - title: "MOD_4" - code: - PUSH1 "0x04" - MOD - success: false - stack: "0x04" + assembler: # MOD OP mal + title: "MOD_4" + code: + PUSH1 "0x04" + MOD + success: false + stack: "0x04" - assembler: # SMOD OP - title: "SMOD_1" - code: - PUSH1 "0x03" - PUSH1 "0x04" - SMOD - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + assembler: # SMOD OP + title: "SMOD_1" + code: + PUSH1 "0x03" + PUSH1 "0x04" + SMOD + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - assembler: # SMOD OP - title: "SMOD_2" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE2" # -30 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - SMOD - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC" + assembler: # SMOD OP + title: "SMOD_2" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE2" # -30 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + SMOD + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC" - assembler: # SMOD OP - title: "SMOD_3" - code: - PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - SMOD - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC" + assembler: # SMOD OP + title: "SMOD_3" + code: + PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + SMOD + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC" - assembler: # SMOD OP mal - title: "SMOD_4" - code: - PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 - SMOD - success: false - stack: "0x000000000000000000000000000000000000000000000000000000000000001E" + assembler: # SMOD OP mal + title: "SMOD_4" + code: + PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 + SMOD + success: false + stack: "0x000000000000000000000000000000000000000000000000000000000000001E" - # real case, EVM bug, integer over flow - assembler: # SIGNEXTEND OP - title: "SIGNEXTEND_1" - code: - PUSH32 "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307" - PUSH1 "0x0F" - SIGNEXTEND - stack: "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307" + # real case, EVM bug, integer over flow + assembler: # SIGNEXTEND OP + title: "SIGNEXTEND_1" + code: + PUSH32 "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307" + PUSH1 "0x0F" + SIGNEXTEND + stack: "0x000000000000000000000000000000003f9b347132d29b62d161117bca8c7307" diff --git a/tests/test_op_bit.nim b/tests/test_op_bit.nim index 6a889a87e..f0051bd84 100644 --- a/tests/test_op_bit.nim +++ b/tests/test_op_bit.nim @@ -1,655 +1,656 @@ import macro_assembler, unittest -suite "Bitwise Opcodes": - let (blockNumber, chainDB) = initDatabase() - - assembler: # AND OP - title: "AND_1" - code: - PUSH1 "0x0A" - PUSH1 "0x0A" - AND - stack: "0x000000000000000000000000000000000000000000000000000000000000000A" - - assembler: # AND OP - title: "AND_2" - code: - PUSH1 "0xC0" - PUSH1 "0x0A" - AND - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # AND OP mal data - title: "AND_3" - code: - PUSH1 "0xC0" - AND - success: false - stack: "0xC0" - - assembler: # OR OP - title: "OR_1" - code: - PUSH1 "0xF0" - PUSH1 "0x0F" - OR - stack: "0x00000000000000000000000000000000000000000000000000000000000000FF" - - assembler: # OR OP - title: "OR_2" - code: - PUSH1 "0xC3" - PUSH1 "0x3C" - OR - stack: "0x00000000000000000000000000000000000000000000000000000000000000FF" - - assembler: # OR OP mal data - title: "OR_3" - code: - PUSH1 "0xC0" - OR - success: false - stack: "0xC0" - - assembler: # XOR OP - title: "XOR_1" - code: - PUSH1 "0xFF" - PUSH1 "0xFF" - XOR - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # XOR OP - title: "XOR_2" - code: - PUSH1 "0x0F" - PUSH1 "0xF0" - XOR - stack: "0x00000000000000000000000000000000000000000000000000000000000000FF" - - assembler: # XOR OP mal data - title: "XOR_3" - code: - PUSH1 "0xC0" - XOR - success: false - stack: "0xC0" - - assembler: # BYTE OP - title: "BYTE_1" - code: - PUSH6 "0xAABBCCDDEEFF" - PUSH1 "0x1E" - BYTE - stack: "0x00000000000000000000000000000000000000000000000000000000000000EE" - - assembler: # BYTE OP - title: "BYTE_2" - code: - PUSH6 "0xAABBCCDDEEFF" - PUSH1 "0x20" - BYTE - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # BYTE OP - title: "BYTE_3" - code: - PUSH6 "0xAABBCCDDEE3A" - PUSH1 "0x1F" - BYTE - stack: "0x000000000000000000000000000000000000000000000000000000000000003A" - - assembler: # BYTE OP mal data - title: "BYTE_4" - code: - PUSH6 "0xAABBCCDDEE3A" - BYTE - success: false - stack: "0xAABBCCDDEE3A" - - assembler: # SHL OP - title: "SHL_1" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH1 "0x00" - SHL - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SHL OP - title: "SHL_2" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH1 "0x01" - SHL - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000002" - - assembler: # SHL OP - title: "SHL_3" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH1 "0xff" - SHL - fork: constantinople - stack: "0x8000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHL OP - title: "SHL_4" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH2 "0x0100" - SHL - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHL OP - title: "SHL_5" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH2 "0x0101" - SHL - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHL OP - title: "SHL_6" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0x00" - SHL - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SHL OP - title: "SHL_7" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0x01" - SHL - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" - - assembler: # SHL OP - title: "SHL_8" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0xff" - SHL - fork: constantinople - stack: "0x8000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHL OP - title: "SHL_9" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH2 "0x0100" - SHL - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHL OP - title: "SHL_10" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0x01" - SHL - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHL OP - title: "SHL_11" - code: - PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0x01" - SHL - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" - - assembler: # SHR OP - title: "SHR_1" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH1 "0x00" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SHR OP - title: "SHR_2" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH1 "0x01" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHR OP - title: "SHR_3" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0x01" - SHR - fork: constantinople - stack: "0x4000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHR OP - title: "SHR_4" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0xff" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SHR OP - title: "SHR_5" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH2 "0x0100" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHR OP - title: "SHR_6" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH2 "0x0101" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHR OP - title: "SHR_7" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0x00" - SHR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SHR OP - title: "SHR_8" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0x01" - SHR - fork: constantinople - stack: "0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SHR OP - title: "SHR_9" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0xff" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SHR OP - title: "SHR_10" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH2 "0x0100" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SHR OP - title: "SHR_11" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0x01" - SHR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SAR OP - title: "SAR_1" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH1 "0x00" - SAR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SAR OP - title: "SAR_2" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" - PUSH1 "0x01" - SAR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SAR OP - title: "SAR_3" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0x01" - SAR - fork: constantinople - stack: "0xC000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SAR OP - title: "SAR_4" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0xff" - SAR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SAR OP - title: "SAR_5" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH2 "0x0100" - SAR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SAR OP - title: "SAR_6" - code: - PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" - PUSH2 "0x0101" - SAR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SAR OP - title: "SAR_7" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0x00" - SAR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SAR OP - title: "SAR_8" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0x01" - SAR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SAR OP - title: "SAR_9" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0xff" - SAR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SAR OP - title: "SAR_10" - code: - PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH2 "0x0100" - SAR - fork: constantinople - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - - assembler: # SAR OP - title: "SAR_11" - code: - PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0x01" - SAR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SAR OP - title: "SAR_12" - code: - PUSH32 "0x4000000000000000000000000000000000000000000000000000000000000000" - PUSH1 "0xfe" - SAR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SAR OP - title: "SAR_13" - code: - PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0xf8" - SAR - fork: constantinople - stack: "0x000000000000000000000000000000000000000000000000000000000000007F" - - assembler: # SAR OP - title: "SAR_14" - code: - PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0xfe" - SAR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SAR OP - title: "SAR_15" - code: - PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH1 "0xff" - SAR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SAR OP - title: "SAR_16" - code: - PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - PUSH2 "0x0100" - SAR - fork: constantinople - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # ISZERO OP - title: "ISZERO_1" - code: - PUSH1 "0x00" - ISZERO - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # ISZERO OP - title: "ISZERO_2" - code: - PUSH1 "0x2A" - ISZERO - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # ISZERO OP mal data - title: "ISZERO_3" - code: ISZERO - success: false - - assembler: # EQ OP - title: "EQ_1" - code: - PUSH1 "0x2A" - PUSH1 "0x2A" - EQ - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # EQ OP - title: "EQ_2" - code: - PUSH3 "0x2A3B4C" - PUSH3 "0x2A3B4C" - EQ - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # EQ OP - title: "EQ_3" - code: - PUSH3 "0x2A3B5C" - PUSH3 "0x2A3B4C" - EQ - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # EQ OP mal data - title: "EQ_4" - code: - PUSH3 "0x2A3B4C" - EQ - success: false - stack: "0x2A3B4C" - - assembler: # GT OP - title: "GT_1" - code: - PUSH1 "0x01" - PUSH1 "0x02" - GT - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # GT OP - title: "GT_2" - code: - PUSH1 "0x01" - PUSH2 "0x0F00" - GT - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # GT OP - title: "GT_3" - code: - PUSH4 "0x01020304" - PUSH2 "0x0F00" - GT - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # GT OP mal data - title: "GT_4" - code: - PUSH3 "0x2A3B4C" - GT - success: false - stack: "0x2A3B4C" - - assembler: # SGT OP - title: "SGT_1" - code: - PUSH1 "0x01" - PUSH1 "0x02" - SGT - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SGT OP - title: "SGT_2" - code: - PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - SGT - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SGT OP - title: "SGT_3" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" # -169 - SGT - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SGT OP mal - title: "SGT_4" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - SGT - success: false - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" - - assembler: # LT OP - title: "LT_1" - code: - PUSH1 "0x01" - PUSH1 "0x02" - LT - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # LT OP - title: "LT_2" - code: - PUSH1 "0x01" - PUSH2 "0x0F00" - LT - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # LT OP - title: "LT_3" - code: - PUSH4 "0x01020304" - PUSH2 "0x0F00" - LT - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # LT OP mal data - title: "LT_4" - code: - PUSH3 "0x2A3B4C" - LT - success: false - stack: "0x2A3B4C" - - assembler: # SLT OP - title: "SLT_1" - code: - PUSH1 "0x01" - PUSH1 "0x02" - SLT - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SLT OP - title: "SLT_2" - code: - PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - SLT - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - - assembler: # SLT OP - title: "SLT_3" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" # -169 - SLT - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - - assembler: # SLT OP mal - title: "SLT_4" - code: - PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 - SLT - success: false - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" - - assembler: # NOT OP - title: "NOT_1" - code: - PUSH1 "0x01" - NOT - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" - - assembler: # NOT OP - title: "NOT_2" - code: - PUSH2 "0xA003" - NOT - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FFC" - - assembler: # BNOT OP - title: "BNOT_4" - code: NOT - success: false - - assembler: # NOT OP - title: "NOT_5" - code: - PUSH1 "0x00" - NOT - stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +proc opBitMain*() = + suite "Bitwise Opcodes": + let (blockNumber, chainDB) = initDatabase() + + assembler: # AND OP + title: "AND_1" + code: + PUSH1 "0x0A" + PUSH1 "0x0A" + AND + stack: "0x000000000000000000000000000000000000000000000000000000000000000A" + + assembler: # AND OP + title: "AND_2" + code: + PUSH1 "0xC0" + PUSH1 "0x0A" + AND + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # AND OP mal data + title: "AND_3" + code: + PUSH1 "0xC0" + AND + success: false + stack: "0xC0" + + assembler: # OR OP + title: "OR_1" + code: + PUSH1 "0xF0" + PUSH1 "0x0F" + OR + stack: "0x00000000000000000000000000000000000000000000000000000000000000FF" + + assembler: # OR OP + title: "OR_2" + code: + PUSH1 "0xC3" + PUSH1 "0x3C" + OR + stack: "0x00000000000000000000000000000000000000000000000000000000000000FF" + + assembler: # OR OP mal data + title: "OR_3" + code: + PUSH1 "0xC0" + OR + success: false + stack: "0xC0" + + assembler: # XOR OP + title: "XOR_1" + code: + PUSH1 "0xFF" + PUSH1 "0xFF" + XOR + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # XOR OP + title: "XOR_2" + code: + PUSH1 "0x0F" + PUSH1 "0xF0" + XOR + stack: "0x00000000000000000000000000000000000000000000000000000000000000FF" + + assembler: # XOR OP mal data + title: "XOR_3" + code: + PUSH1 "0xC0" + XOR + success: false + stack: "0xC0" + + assembler: # BYTE OP + title: "BYTE_1" + code: + PUSH6 "0xAABBCCDDEEFF" + PUSH1 "0x1E" + BYTE + stack: "0x00000000000000000000000000000000000000000000000000000000000000EE" + + assembler: # BYTE OP + title: "BYTE_2" + code: + PUSH6 "0xAABBCCDDEEFF" + PUSH1 "0x20" + BYTE + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # BYTE OP + title: "BYTE_3" + code: + PUSH6 "0xAABBCCDDEE3A" + PUSH1 "0x1F" + BYTE + stack: "0x000000000000000000000000000000000000000000000000000000000000003A" + + assembler: # BYTE OP mal data + title: "BYTE_4" + code: + PUSH6 "0xAABBCCDDEE3A" + BYTE + success: false + stack: "0xAABBCCDDEE3A" + + assembler: # SHL OP + title: "SHL_1" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH1 "0x00" + SHL + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SHL OP + title: "SHL_2" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH1 "0x01" + SHL + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000002" + + assembler: # SHL OP + title: "SHL_3" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH1 "0xff" + SHL + fork: constantinople + stack: "0x8000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHL OP + title: "SHL_4" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH2 "0x0100" + SHL + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHL OP + title: "SHL_5" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH2 "0x0101" + SHL + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHL OP + title: "SHL_6" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0x00" + SHL + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SHL OP + title: "SHL_7" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0x01" + SHL + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" + + assembler: # SHL OP + title: "SHL_8" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0xff" + SHL + fork: constantinople + stack: "0x8000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHL OP + title: "SHL_9" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH2 "0x0100" + SHL + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHL OP + title: "SHL_10" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0x01" + SHL + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHL OP + title: "SHL_11" + code: + PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0x01" + SHL + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" + + assembler: # SHR OP + title: "SHR_1" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH1 "0x00" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SHR OP + title: "SHR_2" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH1 "0x01" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHR OP + title: "SHR_3" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0x01" + SHR + fork: constantinople + stack: "0x4000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHR OP + title: "SHR_4" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0xff" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SHR OP + title: "SHR_5" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH2 "0x0100" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHR OP + title: "SHR_6" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH2 "0x0101" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHR OP + title: "SHR_7" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0x00" + SHR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SHR OP + title: "SHR_8" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0x01" + SHR + fork: constantinople + stack: "0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SHR OP + title: "SHR_9" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0xff" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SHR OP + title: "SHR_10" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH2 "0x0100" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SHR OP + title: "SHR_11" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0x01" + SHR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SAR OP + title: "SAR_1" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH1 "0x00" + SAR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SAR OP + title: "SAR_2" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000001" + PUSH1 "0x01" + SAR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SAR OP + title: "SAR_3" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0x01" + SAR + fork: constantinople + stack: "0xC000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SAR OP + title: "SAR_4" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0xff" + SAR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SAR OP + title: "SAR_5" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH2 "0x0100" + SAR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SAR OP + title: "SAR_6" + code: + PUSH32 "0x8000000000000000000000000000000000000000000000000000000000000000" + PUSH2 "0x0101" + SAR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SAR OP + title: "SAR_7" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0x00" + SAR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SAR OP + title: "SAR_8" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0x01" + SAR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SAR OP + title: "SAR_9" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0xff" + SAR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SAR OP + title: "SAR_10" + code: + PUSH32 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH2 "0x0100" + SAR + fork: constantinople + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + + assembler: # SAR OP + title: "SAR_11" + code: + PUSH32 "0x0000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0x01" + SAR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SAR OP + title: "SAR_12" + code: + PUSH32 "0x4000000000000000000000000000000000000000000000000000000000000000" + PUSH1 "0xfe" + SAR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SAR OP + title: "SAR_13" + code: + PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0xf8" + SAR + fork: constantinople + stack: "0x000000000000000000000000000000000000000000000000000000000000007F" + + assembler: # SAR OP + title: "SAR_14" + code: + PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0xfe" + SAR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SAR OP + title: "SAR_15" + code: + PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH1 "0xff" + SAR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SAR OP + title: "SAR_16" + code: + PUSH32 "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + PUSH2 "0x0100" + SAR + fork: constantinople + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # ISZERO OP + title: "ISZERO_1" + code: + PUSH1 "0x00" + ISZERO + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # ISZERO OP + title: "ISZERO_2" + code: + PUSH1 "0x2A" + ISZERO + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # ISZERO OP mal data + title: "ISZERO_3" + code: ISZERO + success: false + + assembler: # EQ OP + title: "EQ_1" + code: + PUSH1 "0x2A" + PUSH1 "0x2A" + EQ + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # EQ OP + title: "EQ_2" + code: + PUSH3 "0x2A3B4C" + PUSH3 "0x2A3B4C" + EQ + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # EQ OP + title: "EQ_3" + code: + PUSH3 "0x2A3B5C" + PUSH3 "0x2A3B4C" + EQ + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # EQ OP mal data + title: "EQ_4" + code: + PUSH3 "0x2A3B4C" + EQ + success: false + stack: "0x2A3B4C" + + assembler: # GT OP + title: "GT_1" + code: + PUSH1 "0x01" + PUSH1 "0x02" + GT + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # GT OP + title: "GT_2" + code: + PUSH1 "0x01" + PUSH2 "0x0F00" + GT + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # GT OP + title: "GT_3" + code: + PUSH4 "0x01020304" + PUSH2 "0x0F00" + GT + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # GT OP mal data + title: "GT_4" + code: + PUSH3 "0x2A3B4C" + GT + success: false + stack: "0x2A3B4C" + + assembler: # SGT OP + title: "SGT_1" + code: + PUSH1 "0x01" + PUSH1 "0x02" + SGT + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SGT OP + title: "SGT_2" + code: + PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + SGT + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SGT OP + title: "SGT_3" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" # -169 + SGT + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SGT OP mal + title: "SGT_4" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + SGT + success: false + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + + assembler: # LT OP + title: "LT_1" + code: + PUSH1 "0x01" + PUSH1 "0x02" + LT + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # LT OP + title: "LT_2" + code: + PUSH1 "0x01" + PUSH2 "0x0F00" + LT + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # LT OP + title: "LT_3" + code: + PUSH4 "0x01020304" + PUSH2 "0x0F00" + LT + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # LT OP mal data + title: "LT_4" + code: + PUSH3 "0x2A3B4C" + LT + success: false + stack: "0x2A3B4C" + + assembler: # SLT OP + title: "SLT_1" + code: + PUSH1 "0x01" + PUSH1 "0x02" + SLT + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SLT OP + title: "SLT_2" + code: + PUSH32 "0x000000000000000000000000000000000000000000000000000000000000001E" # 30 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + SLT + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + + assembler: # SLT OP + title: "SLT_3" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" # -169 + SLT + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # SLT OP mal + title: "SLT_4" + code: + PUSH32 "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" # -170 + SLT + success: false + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + + assembler: # NOT OP + title: "NOT_1" + code: + PUSH1 "0x01" + NOT + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE" + + assembler: # NOT OP + title: "NOT_2" + code: + PUSH2 "0xA003" + NOT + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FFC" + + assembler: # BNOT OP + title: "BNOT_4" + code: NOT + success: false + + assembler: # NOT OP + title: "NOT_5" + code: + PUSH1 "0x00" + NOT + stack: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" diff --git a/tests/test_op_custom.nim b/tests/test_op_custom.nim index 2eb7540ea..9bde15da3 100644 --- a/tests/test_op_custom.nim +++ b/tests/test_op_custom.nim @@ -3,301 +3,302 @@ import stew/byteutils, eth/common, ../nimbus/db/state_db, ../nimbus/db/db_chain, stew/ranges -suite "Custom Opcodes Test": - let (blockNumber, chainDB) = initDatabase() +proc opCustomMain*() = + suite "Custom Opcodes Test": + let (blockNumber, chainDB) = initDatabase() - assembler: # CALLDATASIZE OP - title: "CALLDATASIZE_1" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - CallDataSize - stack: "0x0000000000000000000000000000000000000000000000000000000000000040" + assembler: # CALLDATASIZE OP + title: "CALLDATASIZE_1" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + CallDataSize + stack: "0x0000000000000000000000000000000000000000000000000000000000000040" - assembler: # CALLDATALOAD OP - title: "CALLDATALOAD_1" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x00" - CallDataLoad - stack: "0x00000000000000000000000000000000000000000000000000000000000000A1" + assembler: # CALLDATALOAD OP + title: "CALLDATALOAD_1" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x00" + CallDataLoad + stack: "0x00000000000000000000000000000000000000000000000000000000000000A1" - assembler: # CALLDATALOAD OP - title: "CALLDATALOAD_2" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x02" - CallDataLoad - stack: "0x0000000000000000000000000000000000000000000000000000000000A10000" + assembler: # CALLDATALOAD OP + title: "CALLDATALOAD_2" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x02" + CallDataLoad + stack: "0x0000000000000000000000000000000000000000000000000000000000A10000" - assembler: # CALLDATALOAD OP - title: "CALLDATALOAD_3" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x20" - CallDataLoad - stack: "0x00000000000000000000000000000000000000000000000000000000000000B1" + assembler: # CALLDATALOAD OP + title: "CALLDATALOAD_3" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x20" + CallDataLoad + stack: "0x00000000000000000000000000000000000000000000000000000000000000B1" - assembler: # CALLDATALOAD OP - title: "CALLDATALOAD_4" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x23" - CallDataLoad - stack: "0x00000000000000000000000000000000000000000000000000000000B1000000" + assembler: # CALLDATALOAD OP + title: "CALLDATALOAD_4" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x23" + CallDataLoad + stack: "0x00000000000000000000000000000000000000000000000000000000B1000000" - assembler: # CALLDATALOAD OP - title: "CALLDATALOAD_5" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x3F" - CallDataLoad - stack: "0xB100000000000000000000000000000000000000000000000000000000000000" + assembler: # CALLDATALOAD OP + title: "CALLDATALOAD_5" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x3F" + CallDataLoad + stack: "0xB100000000000000000000000000000000000000000000000000000000000000" - assembler: # CALLDATALOAD OP mal - title: "CALLDATALOAD_6" - code: - CallDataLoad - success: false + assembler: # CALLDATALOAD OP mal + title: "CALLDATALOAD_6" + code: + CallDataLoad + success: false - assembler: # CALLDATALOAD OP - title: "CALLDATALOAD_7" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x40" - CallDataLoad - stack: "0x00" + assembler: # CALLDATALOAD OP + title: "CALLDATALOAD_7" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x40" + CallDataLoad + stack: "0x00" - assembler: # CALLDATACOPY OP - title: "CALLDATACOPY_1" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x20" - Push1 "0x00" - Push1 "0x00" - CallDataCopy - memory: "0x00000000000000000000000000000000000000000000000000000000000000A1" + assembler: # CALLDATACOPY OP + title: "CALLDATACOPY_1" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x20" + Push1 "0x00" + Push1 "0x00" + CallDataCopy + memory: "0x00000000000000000000000000000000000000000000000000000000000000A1" - assembler: # CALLDATACOPY OP - title: "CALLDATACOPY_2" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x40" - Push1 "0x00" - Push1 "0x00" - CallDataCopy - memory: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" + assembler: # CALLDATACOPY OP + title: "CALLDATACOPY_2" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x40" + Push1 "0x00" + Push1 "0x00" + CallDataCopy + memory: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" - assembler: # CALLDATACOPY OP - title: "CALLDATACOPY_3" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x40" - Push1 "0x04" - Push1 "0x00" - CallDataCopy - memory: - "0x000000000000000000000000000000000000000000000000000000A100000000" - "0x000000000000000000000000000000000000000000000000000000B100000000" + assembler: # CALLDATACOPY OP + title: "CALLDATACOPY_3" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x40" + Push1 "0x04" + Push1 "0x00" + CallDataCopy + memory: + "0x000000000000000000000000000000000000000000000000000000A100000000" + "0x000000000000000000000000000000000000000000000000000000B100000000" - assembler: # CALLDATACOPY OP - title: "CALLDATACOPY_4" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x40" - Push1 "0x00" - Push1 "0x04" - CallDataCopy - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x000000A100000000000000000000000000000000000000000000000000000000" - "0x000000B100000000000000000000000000000000000000000000000000000000" + assembler: # CALLDATACOPY OP + title: "CALLDATACOPY_4" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x40" + Push1 "0x00" + Push1 "0x04" + CallDataCopy + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x000000A100000000000000000000000000000000000000000000000000000000" + "0x000000B100000000000000000000000000000000000000000000000000000000" - assembler: # CALLDATACOPY OP - title: "CALLDATACOPY_5" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x40" - Push1 "0x00" - Push1 "0x04" - CallDataCopy - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x000000A100000000000000000000000000000000000000000000000000000000" - "0x000000B100000000000000000000000000000000000000000000000000000000" + assembler: # CALLDATACOPY OP + title: "CALLDATACOPY_5" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x40" + Push1 "0x00" + Push1 "0x04" + CallDataCopy + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x000000A100000000000000000000000000000000000000000000000000000000" + "0x000000B100000000000000000000000000000000000000000000000000000000" - assembler: # CALLDATACOPY OP mal - title: "CALLDATACOPY_6" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: - Push1 "0x40" - Push1 "0x00" - CallDataCopy - success: false - stack: - "0x40" - "0x00" + assembler: # CALLDATACOPY OP mal + title: "CALLDATACOPY_6" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: + Push1 "0x40" + Push1 "0x00" + CallDataCopy + success: false + stack: + "0x40" + "0x00" - assembler: # CALLDATACOPY OP mal - title: "CALLDATACOPY_7" - data: - "0x00000000000000000000000000000000000000000000000000000000000000A1" - "0x00000000000000000000000000000000000000000000000000000000000000B1" - code: "0x6020600073CC0929EB16730E7C14FEFC63006AC2D794C5795637" - success: false + assembler: # CALLDATACOPY OP mal + title: "CALLDATACOPY_7" + data: + "0x00000000000000000000000000000000000000000000000000000000000000A1" + "0x00000000000000000000000000000000000000000000000000000000000000B1" + code: "0x6020600073CC0929EB16730E7C14FEFC63006AC2D794C5795637" + success: false - assembler: # ADDRESS OP - title: "ADDRESS_1" - code: - Address - stack: "0x000000000000000000000000c669eaad75042be84daaf9b461b0e868b9ac1871" + assembler: # ADDRESS OP + title: "ADDRESS_1" + code: + Address + stack: "0x000000000000000000000000c669eaad75042be84daaf9b461b0e868b9ac1871" - assembler: # BALANCE OP - title: "BALANCE_1" - code: - Address - Balance - stack: "0x000000000000000000000000000000000000000000000000cff56a1b273a8000" + assembler: # BALANCE OP + title: "BALANCE_1" + code: + Address + Balance + stack: "0x000000000000000000000000000000000000000000000000cff56a1b273a8000" - assembler: # ORIGIN OP - title: "ORIGIN_1" - code: - Origin - stack: "0x000000000000000000000000fbe0afcd7658ba86be41922059dd879c192d4c73" + assembler: # ORIGIN OP + title: "ORIGIN_1" + code: + Origin + stack: "0x000000000000000000000000fbe0afcd7658ba86be41922059dd879c192d4c73" - assembler: # CALLER OP - title: "CALLER_1" - code: - Caller - stack: "0x000000000000000000000000fbe0afcd7658ba86be41922059dd879c192d4c73" + assembler: # CALLER OP + title: "CALLER_1" + code: + Caller + stack: "0x000000000000000000000000fbe0afcd7658ba86be41922059dd879c192d4c73" - assembler: # CALLVALUE OP - title: "CALLVALUE_1" - code: - CallValue - stack: "0xcff56a1b273a8000" + assembler: # CALLVALUE OP + title: "CALLVALUE_1" + code: + CallValue + stack: "0xcff56a1b273a8000" - assembler: # SHA3 OP - title: "SHA3_1" - code: - Push1 "0x01" - Push1 "0x00" - Mstore8 - Push1 "0x01" - Push1 "0x00" - Sha3 - stack: "0x5FE7F977E71DBA2EA1A68E21057BEEBB9BE2AC30C6410AA38D4F3FBE41DCFFD2" - memory: "0x0100000000000000000000000000000000000000000000000000000000000000" + assembler: # SHA3 OP + title: "SHA3_1" + code: + Push1 "0x01" + Push1 "0x00" + Mstore8 + Push1 "0x01" + Push1 "0x00" + Sha3 + stack: "0x5FE7F977E71DBA2EA1A68E21057BEEBB9BE2AC30C6410AA38D4F3FBE41DCFFD2" + memory: "0x0100000000000000000000000000000000000000000000000000000000000000" - assembler: # SHA3 OP - title: "SHA3_2" - code: - Push2 "0x0201" - Push1 "0x00" - Mstore - Push1 "0x02" - Push1 "0x1E" - Sha3 - stack: "0x114A3FE82A0219FCC31ABD15617966A125F12B0FD3409105FC83B487A9D82DE4" - memory: "0x0000000000000000000000000000000000000000000000000000000000000201" + assembler: # SHA3 OP + title: "SHA3_2" + code: + Push2 "0x0201" + Push1 "0x00" + Mstore + Push1 "0x02" + Push1 "0x1E" + Sha3 + stack: "0x114A3FE82A0219FCC31ABD15617966A125F12B0FD3409105FC83B487A9D82DE4" + memory: "0x0000000000000000000000000000000000000000000000000000000000000201" - assembler: # SHA3 OP mal - title: "SHA3_3" - code: - Push2 "0x0201" - Push1 "0x00" - Mstore - Push1 "0x02" - Sha3 - success: false - stack: "0x02" - memory: "0x0000000000000000000000000000000000000000000000000000000000000201" + assembler: # SHA3 OP mal + title: "SHA3_3" + code: + Push2 "0x0201" + Push1 "0x00" + Mstore + Push1 "0x02" + Sha3 + success: false + stack: "0x02" + memory: "0x0000000000000000000000000000000000000000000000000000000000000201" - assembler: # BLOCKHASH OP - title: "BLOCKHASH_1" - code: - Push2 "0xb864" # 47204, parent header number - Blockhash - stack: "0xa85842a20755232169db76c5bd4ad4672c1551fca4b07d0bd139cd0e6fef684d" + assembler: # BLOCKHASH OP + title: "BLOCKHASH_1" + code: + Push2 "0xb864" # 47204, parent header number + Blockhash + stack: "0xa85842a20755232169db76c5bd4ad4672c1551fca4b07d0bd139cd0e6fef684d" - # current block coinbase/miner - assembler: # COINBASE OP - title: "COINBASE_1" - code: - Coinbase - stack: "0x000000000000000000000000bb7b8287f3f0a933474a79eae42cbca977791171" + # current block coinbase/miner + assembler: # COINBASE OP + title: "COINBASE_1" + code: + Coinbase + stack: "0x000000000000000000000000bb7b8287f3f0a933474a79eae42cbca977791171" - # current block timestamp - assembler: # TIMESTAMP OP - title: "TIMESTAMP_1" - code: - TimeStamp - stack: "0x0000000000000000000000000000000000000000000000000000000055c46bba" + # current block timestamp + assembler: # TIMESTAMP OP + title: "TIMESTAMP_1" + code: + TimeStamp + stack: "0x0000000000000000000000000000000000000000000000000000000055c46bba" - # current block number - assembler: # NUMBER OP - title: "NUMBER_1" - code: - Number - stack: "0x000000000000000000000000000000000000000000000000000000000000b865" + # current block number + assembler: # NUMBER OP + title: "NUMBER_1" + code: + Number + stack: "0x000000000000000000000000000000000000000000000000000000000000b865" - # current difficulty - assembler: # DIFFICULTY OP - title: "DIFFICULTY_1" - code: - Difficulty - stack: "0x000000000000000000000000000000000000000000000000000001547c73822d" + # current difficulty + assembler: # DIFFICULTY OP + title: "DIFFICULTY_1" + code: + Difficulty + stack: "0x000000000000000000000000000000000000000000000000000001547c73822d" - # ?? - assembler: # GASPRICE OP - title: "GASPRICE_1" - code: - GasPrice - stack: "0x000000000000000000000000000000000000000000000000000000746a528800" + # ?? + assembler: # GASPRICE OP + title: "GASPRICE_1" + code: + GasPrice + stack: "0x000000000000000000000000000000000000000000000000000000746a528800" - # ?? - assembler: # GAS OP - title: "GAS_1" - code: - Gas - stack: "0x000000000000000000000000000000000000000000000000000000001dcd64fe" + # ?? + assembler: # GAS OP + title: "GAS_1" + code: + Gas + stack: "0x000000000000000000000000000000000000000000000000000000001dcd64fe" - # ?? - assembler: # GASLIMIT OP - title: "GASLIMIT_1" - code: - GasLimit - stack: "0x000000000000000000000000000000000000000000000000000000000000a298" + # ?? + assembler: # GASLIMIT OP + title: "GASLIMIT_1" + code: + GasLimit + stack: "0x000000000000000000000000000000000000000000000000000000000000a298" - assembler: # INVALID OP - title: "INVALID_1" - code: "0x60012F6002" - stack: "0x0000000000000000000000000000000000000000000000000000000000000001" - success: false + assembler: # INVALID OP + title: "INVALID_1" + code: "0x60012F6002" + stack: "0x0000000000000000000000000000000000000000000000000000000000000001" + success: false diff --git a/tests/test_op_env.nim b/tests/test_op_env.nim index 33f7c8eb7..c659c3925 100644 --- a/tests/test_op_env.nim +++ b/tests/test_op_env.nim @@ -3,302 +3,303 @@ import stew/byteutils, eth/common, ../nimbus/db/state_db, ../nimbus/db/db_chain, stew/ranges -suite "Environmental Information Opcodes": - let (blockNumber, chainDB) = initDatabase() +proc opEnvMain*() = + suite "Environmental Information Opcodes": + let (blockNumber, chainDB) = initDatabase() - assembler: # CODECOPY OP - title: "CODECOPY_1" - code: - PUSH1 "0x03" # size - PUSH1 "0x08" # copy start pos - PUSH1 "0x00" # mem start pos - CODECOPY - STOP - SLT - CALLVALUE - JUMP - memory: "0x1234560000000000000000000000000000000000000000000000000000000000" - # assertEquals(6, gas); ?? + assembler: # CODECOPY OP + title: "CODECOPY_1" + code: + PUSH1 "0x03" # size + PUSH1 "0x08" # copy start pos + PUSH1 "0x00" # mem start pos + CODECOPY + STOP + SLT + CALLVALUE + JUMP + memory: "0x1234560000000000000000000000000000000000000000000000000000000000" + # assertEquals(6, gas); ?? - assembler: # CODECOPY OP - title: "CODECOPY_2" - code: - PUSH1 "0x5E" # size - PUSH1 "0x08" # copy start pos - PUSH1 "0x00" # mem start pos - CODECOPY - STOP - PUSH1 "0x00" - PUSH1 "0x5f" - SSTORE - PUSH1 "0x14" - PUSH1 "0x00" - SLOAD - PUSH1 "0x1e" - PUSH1 "0x20" - SLOAD - PUSH4 "0xabcddcba" - PUSH1 "0x40" - SLOAD - JUMPDEST - MLOAD - PUSH1 "0x20" - ADD - PUSH1 "0x0a" - MSTORE - SLOAD - MLOAD - PUSH1 "0x40" - ADD - PUSH1 "0x14" - MSTORE - SLOAD - MLOAD - PUSH1 "0x60" - ADD - PUSH1 "0x1e" - MSTORE - SLOAD - MLOAD - PUSH1 "0x80" - ADD - PUSH1 "0x28" - MSTORE - SLOAD - PUSH1 "0xa0" - MSTORE - SLOAD - PUSH1 "0x16" - PUSH1 "0x48" - PUSH1 "0x00" - CODECOPY - PUSH1 "0x16" - PUSH1 "0x00" - CALLCODE - PUSH1 "0x00" - PUSH1 "0x3f" - SSTORE - PUSH2 "0x03e7" - JUMP - PUSH1 "0x00" - SLOAD - PUSH1 "0x00" - MSTORE8 - PUSH1 "0x20" - MUL - CALLDATALOAD - PUSH1 "0x20" - SLOAD - memory: - "0x6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254" - "0x516040016014525451606001601E5254516080016028525460A0525460166048" - "0x60003960166000F26000603F556103E756600054600053602002356020540000" - #assertEquals(10, gas); ?? + assembler: # CODECOPY OP + title: "CODECOPY_2" + code: + PUSH1 "0x5E" # size + PUSH1 "0x08" # copy start pos + PUSH1 "0x00" # mem start pos + CODECOPY + STOP + PUSH1 "0x00" + PUSH1 "0x5f" + SSTORE + PUSH1 "0x14" + PUSH1 "0x00" + SLOAD + PUSH1 "0x1e" + PUSH1 "0x20" + SLOAD + PUSH4 "0xabcddcba" + PUSH1 "0x40" + SLOAD + JUMPDEST + MLOAD + PUSH1 "0x20" + ADD + PUSH1 "0x0a" + MSTORE + SLOAD + MLOAD + PUSH1 "0x40" + ADD + PUSH1 "0x14" + MSTORE + SLOAD + MLOAD + PUSH1 "0x60" + ADD + PUSH1 "0x1e" + MSTORE + SLOAD + MLOAD + PUSH1 "0x80" + ADD + PUSH1 "0x28" + MSTORE + SLOAD + PUSH1 "0xa0" + MSTORE + SLOAD + PUSH1 "0x16" + PUSH1 "0x48" + PUSH1 "0x00" + CODECOPY + PUSH1 "0x16" + PUSH1 "0x00" + CALLCODE + PUSH1 "0x00" + PUSH1 "0x3f" + SSTORE + PUSH2 "0x03e7" + JUMP + PUSH1 "0x00" + SLOAD + PUSH1 "0x00" + MSTORE8 + PUSH1 "0x20" + MUL + CALLDATALOAD + PUSH1 "0x20" + SLOAD + memory: + "0x6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254" + "0x516040016014525451606001601E5254516080016028525460A0525460166048" + "0x60003960166000F26000603F556103E756600054600053602002356020540000" + #assertEquals(10, gas); ?? - assembler: # CODECOPY OP - title: "CODECOPY_3" - # cost for that: - # 94 - data copied - # 95 - new bytes allocated - code: - Push1 "0x5E" - Push1 "0x08" - Push1 "0x00" - CodeCopy - STOP - "0x6000605f556014600054601e60205463abcddcba6040545b" - "0x51602001600a5254516040016014525451606001601e52545160800160285254" - "0x60a052546016604860003960166000f26000603f556103e75660005460005360" - "0x20023500" - memory: - "0x6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254" - "0x516040016014525451606001601E5254516080016028525460A0525460166048" - "0x60003960166000F26000603F556103E756600054600053602002350000000000" - #assertEquals(10, program.getResult().getGasUsed()); + assembler: # CODECOPY OP + title: "CODECOPY_3" + # cost for that: + # 94 - data copied + # 95 - new bytes allocated + code: + Push1 "0x5E" + Push1 "0x08" + Push1 "0x00" + CodeCopy + STOP + "0x6000605f556014600054601e60205463abcddcba6040545b" + "0x51602001600a5254516040016014525451606001601e52545160800160285254" + "0x60a052546016604860003960166000f26000603f556103e75660005460005360" + "0x20023500" + memory: + "0x6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254" + "0x516040016014525451606001601E5254516080016028525460A0525460166048" + "0x60003960166000F26000603F556103E756600054600053602002350000000000" + #assertEquals(10, program.getResult().getGasUsed()); - assembler: # CODECOPY OP - title: "CODECOPY_4" - code: - Push1 "0x5E" - Push1 "0x07" - Push1 "0x00" - CodeCopy - STOP - "0x6000605f556014600054601e60205463abcddcba6040545b51" - "0x602001600a5254516040016014525451606001601e5254516080016028525460" - "0xa052546016604860003960166000f26000603f556103e756600054600053602002351234" - memory: - "0x006000605F556014600054601E60205463ABCDDCBA6040545B51602001600A52" - "0x54516040016014525451606001601E5254516080016028525460A05254601660" - "0x4860003960166000F26000603F556103E7566000546000536020023512340000" - #assertEquals(10, program.getResult().getGasUsed()); + assembler: # CODECOPY OP + title: "CODECOPY_4" + code: + Push1 "0x5E" + Push1 "0x07" + Push1 "0x00" + CodeCopy + STOP + "0x6000605f556014600054601e60205463abcddcba6040545b51" + "0x602001600a5254516040016014525451606001601e5254516080016028525460" + "0xa052546016604860003960166000f26000603f556103e756600054600053602002351234" + memory: + "0x006000605F556014600054601E60205463ABCDDCBA6040545B51602001600A52" + "0x54516040016014525451606001601E5254516080016028525460A05254601660" + "0x4860003960166000F26000603F556103E7566000546000536020023512340000" + #assertEquals(10, program.getResult().getGasUsed()); - assembler: # CODECOPY OP - title: "CODECOPY_5" - code: - Push2 "0x1234" - Push1 "0x00" - Sload - Push2 "0x5566" - Push1 "0x20" - Sload - Push1 "0x70" - Push1 "0x00" - Push1 "0x20" - CodeCopy - STOP - "0x6000605f55601460" - "0x0054601e60205463abcddcba6040545b51602001600a525451604001" - "0x6014525451606001601e5254516080016028525460a0525460166048" - "0x60003960166000f26000603f556103e75660005460005360200235123400" - stack: - "0x1234" - "0x00" - "0x5566" - "0x00" - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x61123460005461556660205460706000602039006000605f556014600054601e" - "0x60205463abcddcba6040545b51602001600a5254516040016014525451606001" - "0x601e5254516080016028525460a052546016604860003960166000f26000603f" - "0x556103e756600054600053602002351200000000000000000000000000000000" + assembler: # CODECOPY OP + title: "CODECOPY_5" + code: + Push2 "0x1234" + Push1 "0x00" + Sload + Push2 "0x5566" + Push1 "0x20" + Sload + Push1 "0x70" + Push1 "0x00" + Push1 "0x20" + CodeCopy + STOP + "0x6000605f55601460" + "0x0054601e60205463abcddcba6040545b51602001600a525451604001" + "0x6014525451606001601e5254516080016028525460a0525460166048" + "0x60003960166000f26000603f556103e75660005460005360200235123400" + stack: + "0x1234" + "0x00" + "0x5566" + "0x00" + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x61123460005461556660205460706000602039006000605f556014600054601e" + "0x60205463abcddcba6040545b51602001600a5254516040016014525451606001" + "0x601e5254516080016028525460a052546016604860003960166000f26000603f" + "0x556103e756600054600053602002351200000000000000000000000000000000" - assembler: # CODECOPY OP mal - title: "CODECOPY_6" - code: - "0x605E6007396000605f556014600054601e60205463abcddcba604054" - "0x5b51602001600a5254516040016014525451606001601e5254516080" - "0x016028525460a052546016604860003960166000f26000603f556103" - "0xe756600054600053602002351234" - success: false - stack: - "0x5e" - "0x07" + assembler: # CODECOPY OP mal + title: "CODECOPY_6" + code: + "0x605E6007396000605f556014600054601e60205463abcddcba604054" + "0x5b51602001600a5254516040016014525451606001601e5254516080" + "0x016028525460a052546016604860003960166000f26000603f556103" + "0xe756600054600053602002351234" + success: false + stack: + "0x5e" + "0x07" - var acc: EthAddress - hexToByteArray("0xfbe0afcd7658ba86be41922059dd879c192d4c73", acc) - var - parent = chainDB.getBlockHeader(blockNumber - 1) - stateDB = newAccountStateDB(chainDB.db, parent.stateRoot, false) - code = hexToSeqByte("0x0102030405060708090A0B0C0D0E0F" & - "611234600054615566602054603E6000602073471FD3AD3E9EEADEEC4608B92D" & - "16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b" & - "51602001600a5254516040016014525451606001601e52545160800160285254" & - "60a052546016604860003960166000f26000603f556103e756600054600053602002351234") + var acc: EthAddress + hexToByteArray("0xfbe0afcd7658ba86be41922059dd879c192d4c73", acc) + var + parent = chainDB.getBlockHeader(blockNumber - 1) + stateDB = newAccountStateDB(chainDB.db, parent.stateRoot, false) + code = hexToSeqByte("0x0102030405060708090A0B0C0D0E0F" & + "611234600054615566602054603E6000602073471FD3AD3E9EEADEEC4608B92D" & + "16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b" & + "51602001600a5254516040016014525451606001601e52545160800160285254" & + "60a052546016604860003960166000f26000603f556103e756600054600053602002351234") - stateDB.setCode(acc, code.toRange) - parent.stateRoot = stateDB.rootHash - chainDB.setHead(parent, true) + stateDB.setCode(acc, code.toRange) + parent.stateRoot = stateDB.rootHash + chainDB.setHead(parent, true) - assembler: # EXTCODECOPY OP - title: "EXTCODECOPY_1" - code: - Push1 "0x04" # size - Push1 "0x07" # code pos - Push1 "0x00" # mem pos - Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" - ExtCodeCopy - STOP - Slt - CallValue - Jump - Stop - memory: "0x08090a0b00000000000000000000000000000000000000000000000000000000" + assembler: # EXTCODECOPY OP + title: "EXTCODECOPY_1" + code: + Push1 "0x04" # size + Push1 "0x07" # code pos + Push1 "0x00" # mem pos + Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" + ExtCodeCopy + STOP + Slt + CallValue + Jump + Stop + memory: "0x08090a0b00000000000000000000000000000000000000000000000000000000" - assembler: # EXTCODECOPY OP - title: "EXTCODECOPY_2" - code: - Push1 "0x3E" - Push1 "0x07" - Push1 "0x00" - Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" - ExtCodeCopy - STOP - "0x6000605f" - "0x556014600054601e60205463abcddcba6040545b51602001600a525451604001" - "0x6014525451606001601e5254516080016028525460a052546016604860003960" - "0x166000f26000603f556103e75660005460005360200235602054" - memory: - "0x08090a0b0c0d0e0f611234600054615566602054603e6000602073471fd3ad3e" - "0x9eeadeec4608b92d16ce6b500704cc3c6000605f556014600054601e60200000" + assembler: # EXTCODECOPY OP + title: "EXTCODECOPY_2" + code: + Push1 "0x3E" + Push1 "0x07" + Push1 "0x00" + Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" + ExtCodeCopy + STOP + "0x6000605f" + "0x556014600054601e60205463abcddcba6040545b51602001600a525451604001" + "0x6014525451606001601e5254516080016028525460a052546016604860003960" + "0x166000f26000603f556103e75660005460005360200235602054" + memory: + "0x08090a0b0c0d0e0f611234600054615566602054603e6000602073471fd3ad3e" + "0x9eeadeec4608b92d16ce6b500704cc3c6000605f556014600054601e60200000" - assembler: # EXTCODECOPY OP - title: "EXTCODECOPY_3" - code: - Push1 "0x5E" - Push1 "0x07" - Push1 "0x00" - Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" - ExtCodeCopy - STOP - "0x6000605f" - "0x556014600054601e60205463abcddcba6040545b51602001600a525451604001" - "0x6014525451606001601e5254516080016028525460a052546016604860003960" - "0x166000f26000603f556103e75660005460005360200235" - memory: - "0x08090a0b0c0d0e0f611234600054615566602054603e6000602073471fd3ad3e" - "0x9eeadeec4608b92d16ce6b500704cc3c6000605f556014600054601e60205463" - "0xabcddcba6040545b51602001600a5254516040016014525451606001601e0000" + assembler: # EXTCODECOPY OP + title: "EXTCODECOPY_3" + code: + Push1 "0x5E" + Push1 "0x07" + Push1 "0x00" + Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" + ExtCodeCopy + STOP + "0x6000605f" + "0x556014600054601e60205463abcddcba6040545b51602001600a525451604001" + "0x6014525451606001601e5254516080016028525460a052546016604860003960" + "0x166000f26000603f556103e75660005460005360200235" + memory: + "0x08090a0b0c0d0e0f611234600054615566602054603e6000602073471fd3ad3e" + "0x9eeadeec4608b92d16ce6b500704cc3c6000605f556014600054601e60205463" + "0xabcddcba6040545b51602001600a5254516040016014525451606001601e0000" - assembler: # EXTCODECOPY OP - title: "EXTCODECOPY_4" - code: - Push2 "0x1234" - Push1 "0x00" - Sload - Push2 "0x5566" - Push1 "0x20" - Sload - Push1 "0x3E" - Push1 "0x00" - Push1 "0x20" - Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" - ExtCodeCopy - STOP - "0x6000605f556014600054601e60205463abcddcba6040545b" - "0x51602001600a5254516040016014525451606001601e52545160800160285254" - "0x60a052546016604860003960166000f26000603f556103e756600054600053602002351234" - stack: - "0x1234" - "0x00" - "0x5566" - "0x00" - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0102030405060708090a0b0c0d0e0f611234600054615566602054603e600060" - "0x2073471fd3ad3e9eeadeec4608b92d16ce6b500704cc3c6000605f5560140000" + assembler: # EXTCODECOPY OP + title: "EXTCODECOPY_4" + code: + Push2 "0x1234" + Push1 "0x00" + Sload + Push2 "0x5566" + Push1 "0x20" + Sload + Push1 "0x3E" + Push1 "0x00" + Push1 "0x20" + Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" + ExtCodeCopy + STOP + "0x6000605f556014600054601e60205463abcddcba6040545b" + "0x51602001600a5254516040016014525451606001601e52545160800160285254" + "0x60a052546016604860003960166000f26000603f556103e756600054600053602002351234" + stack: + "0x1234" + "0x00" + "0x5566" + "0x00" + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0102030405060708090a0b0c0d0e0f611234600054615566602054603e600060" + "0x2073471fd3ad3e9eeadeec4608b92d16ce6b500704cc3c6000605f5560140000" - assembler: # EXTCODECOPY OP mal - title: "EXTCODECOPY_5" - code: - Push1 "0x5E" - Push1 "0x07" - Push20 "0x471FD3AD3E9EEADEEC4608B92D16CE6B500704CC" - ExtCodeCopy - success: false - stack: - "0x5E" - "0x07" + assembler: # EXTCODECOPY OP mal + title: "EXTCODECOPY_5" + code: + Push1 "0x5E" + Push1 "0x07" + Push20 "0x471FD3AD3E9EEADEEC4608B92D16CE6B500704CC" + ExtCodeCopy + success: false + stack: + "0x5E" + "0x07" - assembler: # CODESIZE OP - title: "CODESIZE_1" - code: - "0x385E60076000396000605f556014600054601e60205463abcddcba6040545b51" - "0x602001600a5254516040016014525451606001601e5254516080016028525460" - "0xa052546016604860003960166000f26000603f556103e75660005460005360200235" - stack: - "0x0000000000000000000000000000000000000000000000000000000000000062" - success: false + assembler: # CODESIZE OP + title: "CODESIZE_1" + code: + "0x385E60076000396000605f556014600054601e60205463abcddcba6040545b51" + "0x602001600a5254516040016014525451606001601e5254516080016028525460" + "0xa052546016604860003960166000f26000603f556103e75660005460005360200235" + stack: + "0x0000000000000000000000000000000000000000000000000000000000000062" + success: false - # 0x94 == 148 bytes - assembler: # EXTCODESIZE OP - title: "EXTCODESIZE_1" - code: - Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" - ExtCodeSize - STOP - "0x5E60076000396000605f" - "0x556014600054601e60205463abcddcba6040545b51602001600a525451604001" - "0x6014525451606001601e5254516080016028525460a052546016604860003960" - "0x166000f26000603f556103e75660005460005360200235" - stack: "0x94" + # 0x94 == 148 bytes + assembler: # EXTCODESIZE OP + title: "EXTCODESIZE_1" + code: + Push20 "0xfbe0afcd7658ba86be41922059dd879c192d4c73" + ExtCodeSize + STOP + "0x5E60076000396000605f" + "0x556014600054601e60205463abcddcba6040545b51602001600a525451604001" + "0x6014525451606001601e5254516080016028525460a052546016604860003960" + "0x166000f26000603f556103e75660005460005360200235" + stack: "0x94" diff --git a/tests/test_op_memory.nim b/tests/test_op_memory.nim index 0c80601ad..bc79f573c 100644 --- a/tests/test_op_memory.nim +++ b/tests/test_op_memory.nim @@ -1,840 +1,841 @@ import macro_assembler, unittest, macros, strutils -suite "Memory Opcodes": - let (blockNumber, chainDB) = initDatabase() +proc opMemoryMain*() = + suite "Memory Opcodes": + let (blockNumber, chainDB) = initDatabase() - assembler: # PUSH1 OP - title: "PUSH1" - code: - PUSH1 "0xa0" - stack: "0x00000000000000000000000000000000000000000000000000000000000000A0" + assembler: # PUSH1 OP + title: "PUSH1" + code: + PUSH1 "0xa0" + stack: "0x00000000000000000000000000000000000000000000000000000000000000A0" - assembler: # PUSH2 OP - title: "PUSH2" - code: - PUSH2 "0xa0b0" - stack: "0x000000000000000000000000000000000000000000000000000000000000A0B0" + assembler: # PUSH2 OP + title: "PUSH2" + code: + PUSH2 "0xa0b0" + stack: "0x000000000000000000000000000000000000000000000000000000000000A0B0" - assembler: # PUSH3 OP - title: "PUSH3" - code: - PUSH3 "0xA0B0C0" - stack: "0x0000000000000000000000000000000000000000000000000000000000A0B0C0" + assembler: # PUSH3 OP + title: "PUSH3" + code: + PUSH3 "0xA0B0C0" + stack: "0x0000000000000000000000000000000000000000000000000000000000A0B0C0" - assembler: # PUSH4 OP - title: "PUSH4" - code: - PUSH4 "0xA0B0C0D0" - stack: "0x00000000000000000000000000000000000000000000000000000000A0B0C0D0" + assembler: # PUSH4 OP + title: "PUSH4" + code: + PUSH4 "0xA0B0C0D0" + stack: "0x00000000000000000000000000000000000000000000000000000000A0B0C0D0" - assembler: # PUSH5 OP - title: "PUSH5" - code: - PUSH5 "0xA0B0C0D0E0" - stack: "0x000000000000000000000000000000000000000000000000000000A0B0C0D0E0" + assembler: # PUSH5 OP + title: "PUSH5" + code: + PUSH5 "0xA0B0C0D0E0" + stack: "0x000000000000000000000000000000000000000000000000000000A0B0C0D0E0" - assembler: # PUSH6 OP - title: "PUSH6" - code: - PUSH6 "0xA0B0C0D0E0F0" - stack: "0x0000000000000000000000000000000000000000000000000000A0B0C0D0E0F0" + assembler: # PUSH6 OP + title: "PUSH6" + code: + PUSH6 "0xA0B0C0D0E0F0" + stack: "0x0000000000000000000000000000000000000000000000000000A0B0C0D0E0F0" - assembler: # PUSH7 OP - title: "PUSH7" - code: - PUSH7 "0xA0B0C0D0E0F0A1" - stack: "0x00000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1" + assembler: # PUSH7 OP + title: "PUSH7" + code: + PUSH7 "0xA0B0C0D0E0F0A1" + stack: "0x00000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1" - assembler: # PUSH8 OP - title: "PUSH8" - code: - PUSH8 "0xA0B0C0D0E0F0A1B1" - stack: "0x000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1" + assembler: # PUSH8 OP + title: "PUSH8" + code: + PUSH8 "0xA0B0C0D0E0F0A1B1" + stack: "0x000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1" - assembler: # PUSH9 OP - title: "PUSH9" - code: - PUSH9 "0xA0B0C0D0E0F0A1B1C1" - stack: "0x0000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1" + assembler: # PUSH9 OP + title: "PUSH9" + code: + PUSH9 "0xA0B0C0D0E0F0A1B1C1" + stack: "0x0000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1" - assembler: # PUSH10 OP - title: "PUSH10" - code: - PUSH10 "0xA0B0C0D0E0F0A1B1C1D1" - stack: "0x00000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1" + assembler: # PUSH10 OP + title: "PUSH10" + code: + PUSH10 "0xA0B0C0D0E0F0A1B1C1D1" + stack: "0x00000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1" - assembler: # PUSH11 OP - title: "PUSH11" - code: - PUSH11 "0xA0B0C0D0E0F0A1B1C1D1E1" - stack: "0x000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1" + assembler: # PUSH11 OP + title: "PUSH11" + code: + PUSH11 "0xA0B0C0D0E0F0A1B1C1D1E1" + stack: "0x000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1" - assembler: # PUSH12 OP - title: "PUSH12" - code: - PUSH12 "0xA0B0C0D0E0F0A1B1C1D1E1F1" - stack: "0x0000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1" + assembler: # PUSH12 OP + title: "PUSH12" + code: + PUSH12 "0xA0B0C0D0E0F0A1B1C1D1E1F1" + stack: "0x0000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1" - assembler: # PUSH13 OP - title: "PUSH13" - code: - PUSH13 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2" - stack: "0x00000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2" + assembler: # PUSH13 OP + title: "PUSH13" + code: + PUSH13 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2" + stack: "0x00000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2" - assembler: # PUSH14 OP - title: "PUSH14" - code: - PUSH14 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2" - stack: "0x000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2" + assembler: # PUSH14 OP + title: "PUSH14" + code: + PUSH14 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2" + stack: "0x000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2" - assembler: # PUSH15 OP - title: "PUSH15" - code: - PUSH15 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2" - stack: "0x0000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2" + assembler: # PUSH15 OP + title: "PUSH15" + code: + PUSH15 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2" + stack: "0x0000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2" - assembler: # PUSH16 OP - title: "PUSH16" - code: - PUSH16 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2" - stack: "0x00000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2" + assembler: # PUSH16 OP + title: "PUSH16" + code: + PUSH16 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2" + stack: "0x00000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2" - assembler: # PUSH17 OP - title: "PUSH17" - code: - PUSH17 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2" - stack: "0x000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2" + assembler: # PUSH17 OP + title: "PUSH17" + code: + PUSH17 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2" + stack: "0x000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2" - assembler: # PUSH18 OP - title: "PUSH18" - code: - PUSH18 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2" - stack: "0x0000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2" + assembler: # PUSH18 OP + title: "PUSH18" + code: + PUSH18 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2" + stack: "0x0000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2" - assembler: # PUSH19 OP - title: "PUSH19" - code: - PUSH19 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3" - stack: "0x00000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3" + assembler: # PUSH19 OP + title: "PUSH19" + code: + PUSH19 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3" + stack: "0x00000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3" - assembler: # PUSH20 OP - title: "PUSH20" - code: - PUSH20 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3" - stack: "0x000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3" + assembler: # PUSH20 OP + title: "PUSH20" + code: + PUSH20 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3" + stack: "0x000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3" - assembler: # PUSH21 OP - title: "PUSH21" - code: - PUSH21 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3" - stack: "0x0000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3" + assembler: # PUSH21 OP + title: "PUSH21" + code: + PUSH21 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3" + stack: "0x0000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3" - assembler: # PUSH22 OP - title: "PUSH22" - code: - PUSH22 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3" - stack: "0x00000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3" + assembler: # PUSH22 OP + title: "PUSH22" + code: + PUSH22 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3" + stack: "0x00000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3" - assembler: # PUSH23 OP - title: "PUSH23" - code: - PUSH23 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3" - stack: "0x000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3" + assembler: # PUSH23 OP + title: "PUSH23" + code: + PUSH23 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3" + stack: "0x000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3" - assembler: # PUSH24 OP - title: "PUSH24" - code: - PUSH24 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3" - stack: "0x0000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3" + assembler: # PUSH24 OP + title: "PUSH24" + code: + PUSH24 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3" + stack: "0x0000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3" - assembler: # PUSH25 OP - title: "PUSH25" - code: - PUSH25 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4" - stack: "0x00000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4" + assembler: # PUSH25 OP + title: "PUSH25" + code: + PUSH25 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4" + stack: "0x00000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4" - assembler: # PUSH26 OP - title: "PUSH26" - code: - PUSH26 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4" - stack: "0x000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4" + assembler: # PUSH26 OP + title: "PUSH26" + code: + PUSH26 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4" + stack: "0x000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4" - assembler: # PUSH27 OP - title: "PUSH27" - code: - PUSH27 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4" - stack: "0x0000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4" + assembler: # PUSH27 OP + title: "PUSH27" + code: + PUSH27 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4" + stack: "0x0000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4" - assembler: # PUSH28 OP - title: "PUSH28" - code: - PUSH28 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4" - stack: "0x00000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4" + assembler: # PUSH28 OP + title: "PUSH28" + code: + PUSH28 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4" + stack: "0x00000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4" - assembler: # PUSH29 OP - title: "PUSH29" - code: - PUSH29 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4" - stack: "0x000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4" + assembler: # PUSH29 OP + title: "PUSH29" + code: + PUSH29 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4" + stack: "0x000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4" - assembler: # PUSH30 OP - title: "PUSH30" - code: - PUSH30 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4" - stack: "0x0000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4" + assembler: # PUSH30 OP + title: "PUSH30" + code: + PUSH30 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4" + stack: "0x0000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4" - assembler: # PUSH31 OP - title: "PUSH31" - code: - PUSH31 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1" - stack: "0x00A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1" + assembler: # PUSH31 OP + title: "PUSH31" + code: + PUSH31 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1" + stack: "0x00A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1" - assembler: # PUSH32 OP - title: "PUSH32" - code: - PUSH32 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" - stack: "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" + assembler: # PUSH32 OP + title: "PUSH32" + code: + PUSH32 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" + stack: "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" - # macro assembler prevented this - #assembler: # PUSHN OP not enough data - # title: "PUSHN_1" - # code: - # PUSH2 "0xAA" - # stack: "0x000000000000000000000000000000000000000000000000000000000000AA00" - # success: false - # - #assembler: # PUSHN OP not enough data - # title: "PUSHN_2" - # code: - # PUSH32 "0xAABB" - # stack: "0xAABB000000000000000000000000000000000000000000000000000000000000" - # success: false + # macro assembler prevented this + #assembler: # PUSHN OP not enough data + # title: "PUSHN_1" + # code: + # PUSH2 "0xAA" + # stack: "0x000000000000000000000000000000000000000000000000000000000000AA00" + # success: false + # + #assembler: # PUSHN OP not enough data + # title: "PUSHN_2" + # code: + # PUSH32 "0xAABB" + # stack: "0xAABB000000000000000000000000000000000000000000000000000000000000" + # success: false - assembler: # POP OP - title: "POP_1" - code: - PUSH2 "0x0000" - PUSH1 "0x01" - PUSH3 "0x000002" - POP - stack: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000001" + assembler: # POP OP + title: "POP_1" + code: + PUSH2 "0x0000" + PUSH1 "0x01" + PUSH3 "0x000002" + POP + stack: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000001" - assembler: # POP OP - title: "POP_2" - code: - PUSH2 "0x0000" - PUSH1 "0x01" - PUSH3 "0x000002" - POP - POP - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + assembler: # POP OP + title: "POP_2" + code: + PUSH2 "0x0000" + PUSH1 "0x01" + PUSH3 "0x000002" + POP + POP + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler:# POP OP mal data - title: "POP_3" - code: - PUSH2 "0x0000" - PUSH1 "0x01" - PUSH3 "0x000002" - POP - POP - POP - POP - success: false + assembler:# POP OP mal data + title: "POP_3" + code: + PUSH2 "0x0000" + PUSH1 "0x01" + PUSH3 "0x000002" + POP + POP + POP + POP + success: false - macro generateDUPS(): untyped = - result = newStmtList() + macro generateDUPS(): untyped = + result = newStmtList() - for i in 1 .. 16: - let title = newStmtList(newLit("DUP_" & $i)) - let pushIdent = ident("PUSH1") - var body = newStmtList() - var stack = newStmtList() + for i in 1 .. 16: + let title = newStmtList(newLit("DUP_" & $i)) + let pushIdent = ident("PUSH1") + var body = newStmtList() + var stack = newStmtList() - for x in 0 ..< i: - let val = newLit("0x" & toHex(x+10, 2)) - body.add quote do: - `pushIdent` `val` + for x in 0 ..< i: + let val = newLit("0x" & toHex(x+10, 2)) + body.add quote do: + `pushIdent` `val` + stack.add quote do: + `val` + + let stackVal = newLit("0x" & toHex(10, 2)) stack.add quote do: - `val` + `stackVal` - let stackVal = newLit("0x" & toHex(10, 2)) - stack.add quote do: - `stackVal` - - let dupIdent = ident("DUP" & $i) - body.add quote do: - `dupIdent` - - let titleCall = newCall(ident("title"), title) - let codeCall = newCall(ident("code"), body) - let stackCall = newCall(ident("stack"), stack) - - result.add quote do: - assembler: - `titleCall` - `codeCall` - `stackCall` - - generateDUPS() - - assembler: # DUPN OP mal data - title: "DUPN_2" - code: - DUP1 - success: false - - macro generateSWAPS(): untyped = - result = newStmtList() - - for i in 1 .. 16: - let title = newStmtList(newLit("SWAP_" & $i)) - let pushIdent = ident("PUSH1") - var body = newStmtList() - var stack = newStmtList() - - for x in countDown(i, 0): - let val = newLit("0x" & toHex(x+10, 2)) + let dupIdent = ident("DUP" & $i) body.add quote do: - `pushIdent` `val` - if x == i: - let val = newLit("0x" & toHex(0+10, 2)) - stack.add quote do: - `val` - elif x == 0: - let val = newLit("0x" & toHex(i+10, 2)) - stack.add quote do: - `val` - else: - stack.add quote do: - `val` + `dupIdent` - let swapIdent = ident("SWAP" & $i) - body.add quote do: - `swapIdent` + let titleCall = newCall(ident("title"), title) + let codeCall = newCall(ident("code"), body) + let stackCall = newCall(ident("stack"), stack) - let titleCall = newCall(ident("title"), title) - let codeCall = newCall(ident("code"), body) - let stackCall = newCall(ident("stack"), stack) + result.add quote do: + assembler: + `titleCall` + `codeCall` + `stackCall` - result.add quote do: - assembler: - `titleCall` - `codeCall` - `stackCall` + generateDUPS() - generateSWAPS() + assembler: # DUPN OP mal data + title: "DUPN_2" + code: + DUP1 + success: false - assembler:# SWAPN OP mal data - title: "SWAPN_2" - code: - SWAP1 - success: false + macro generateSWAPS(): untyped = + result = newStmtList() - assembler: # MSTORE OP - title: "MSTORE_1" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - memory: "0x0000000000000000000000000000000000000000000000000000000000001234" + for i in 1 .. 16: + let title = newStmtList(newLit("SWAP_" & $i)) + let pushIdent = ident("PUSH1") + var body = newStmtList() + var stack = newStmtList() - assembler: # MSTORE OP - title: "MSTORE_2" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH2 "0x5566" - PUSH1 "0x20" - MSTORE - memory: - "0x0000000000000000000000000000000000000000000000000000000000001234" - "0x0000000000000000000000000000000000000000000000000000000000005566" + for x in countDown(i, 0): + let val = newLit("0x" & toHex(x+10, 2)) + body.add quote do: + `pushIdent` `val` + if x == i: + let val = newLit("0x" & toHex(0+10, 2)) + stack.add quote do: + `val` + elif x == 0: + let val = newLit("0x" & toHex(i+10, 2)) + stack.add quote do: + `val` + else: + stack.add quote do: + `val` - assembler: # MSTORE OP - title: "MSTORE_3" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH2 "0x5566" - PUSH1 "0x20" - MSTORE - PUSH2 "0x8888" - PUSH1 "0x00" - MSTORE - memory: - "0x0000000000000000000000000000000000000000000000000000000000008888" - "0x0000000000000000000000000000000000000000000000000000000000005566" + let swapIdent = ident("SWAP" & $i) + body.add quote do: + `swapIdent` - assembler: # MSTORE OP - title: "MSTORE_4" - code: - PUSH2 "0x1234" - PUSH1 "0xA0" - MSTORE - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000001234" + let titleCall = newCall(ident("title"), title) + let codeCall = newCall(ident("code"), body) + let stackCall = newCall(ident("stack"), stack) - assembler: # MSTORE OP - title: "MSTORE_5" - code: - PUSH2 "0x1234" - MSTORE - success: false - stack: "0x1234" + result.add quote do: + assembler: + `titleCall` + `codeCall` + `stackCall` - assembler: # MLOAD OP - title: "MLOAD_1" - code: - PUSH1 "0x00" - MLOAD - memory: "0x0000000000000000000000000000000000000000000000000000000000000000" - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + generateSWAPS() - assembler: # MLOAD OP - title: "MLOAD_2" - code: - PUSH1 "0x22" - MLOAD - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000000" - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + assembler:# SWAPN OP mal data + title: "SWAPN_2" + code: + SWAP1 + success: false - assembler: # MLOAD OP - title: "MLOAD_3" - code: - PUSH1 "0x20" - MLOAD - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000000000" - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + assembler: # MSTORE OP + title: "MSTORE_1" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + memory: "0x0000000000000000000000000000000000000000000000000000000000001234" - assembler: # MLOAD OP - title: "MLOAD_4" - code: - PUSH2 "0x1234" - PUSH1 "0x20" - MSTORE - PUSH1 "0x20" - MLOAD - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000001234" - stack: "0x0000000000000000000000000000000000000000000000000000000000001234" + assembler: # MSTORE OP + title: "MSTORE_2" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH2 "0x5566" + PUSH1 "0x20" + MSTORE + memory: + "0x0000000000000000000000000000000000000000000000000000000000001234" + "0x0000000000000000000000000000000000000000000000000000000000005566" - assembler: # MLOAD OP - title: "MLOAD_5" - code: - PUSH2 "0x1234" - PUSH1 "0x20" - MSTORE - PUSH1 "0x1F" - MLOAD - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0000000000000000000000000000000000000000000000000000000000001234" - stack: "0x0000000000000000000000000000000000000000000000000000000000000012" + assembler: # MSTORE OP + title: "MSTORE_3" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH2 "0x5566" + PUSH1 "0x20" + MSTORE + PUSH2 "0x8888" + PUSH1 "0x00" + MSTORE + memory: + "0x0000000000000000000000000000000000000000000000000000000000008888" + "0x0000000000000000000000000000000000000000000000000000000000005566" - assembler: # MLOAD OP mal data - title: "MLOAD_6" - code: - MLOAD - success: false + assembler: # MSTORE OP + title: "MSTORE_4" + code: + PUSH2 "0x1234" + PUSH1 "0xA0" + MSTORE + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000001234" - assembler: # MSTORE8 OP - title: "MSTORE8_1" - code: - PUSH1 "0x11" - PUSH1 "0x00" - MSTORE8 - memory: "0x1100000000000000000000000000000000000000000000000000000000000000" + assembler: # MSTORE OP + title: "MSTORE_5" + code: + PUSH2 "0x1234" + MSTORE + success: false + stack: "0x1234" - assembler: # MSTORE8 OP - title: "MSTORE8_2" - code: - PUSH1 "0x22" - PUSH1 "0x01" - MSTORE8 - memory: "0x0022000000000000000000000000000000000000000000000000000000000000" + assembler: # MLOAD OP + title: "MLOAD_1" + code: + PUSH1 "0x00" + MLOAD + memory: "0x0000000000000000000000000000000000000000000000000000000000000000" + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler: # MSTORE8 OP - title: "MSTORE8_3" - code: - PUSH1 "0x22" - PUSH1 "0x21" - MSTORE8 - memory: - "0x0000000000000000000000000000000000000000000000000000000000000000" - "0x0022000000000000000000000000000000000000000000000000000000000000" + assembler: # MLOAD OP + title: "MLOAD_2" + code: + PUSH1 "0x22" + MLOAD + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000" + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler: # MSTORE8 OP mal - title: "MSTORE8_4" - code: - PUSH1 "0x22" - MSTORE8 - success: false - stack: "0x22" + assembler: # MLOAD OP + title: "MLOAD_3" + code: + PUSH1 "0x20" + MLOAD + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000" + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler: # SSTORE OP - title: "SSTORE_1" - code: - PUSH1 "0x22" - PUSH1 "0xAA" - SSTORE - storage: - "0xAA": "0x22" + assembler: # MLOAD OP + title: "MLOAD_4" + code: + PUSH2 "0x1234" + PUSH1 "0x20" + MSTORE + PUSH1 "0x20" + MLOAD + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000001234" + stack: "0x0000000000000000000000000000000000000000000000000000000000001234" - assembler: # SSTORE OP - title: "SSTORE_2" - code: - PUSH1 "0x22" - PUSH1 "0xAA" - SSTORE - PUSH1 "0x22" - PUSH1 "0xBB" - SSTORE - storage: - "0xAA": "0x22" - "0xBB": "0x22" + assembler: # MLOAD OP + title: "MLOAD_5" + code: + PUSH2 "0x1234" + PUSH1 "0x20" + MSTORE + PUSH1 "0x1F" + MLOAD + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000001234" + stack: "0x0000000000000000000000000000000000000000000000000000000000000012" - assembler: # SSTORE OP - title: "SSTORE_3" - code: - PUSH1 "0x22" - SSTORE - success: false - stack: "0x22" -#[ - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_1" - code: "60006000556000600055" - fork: constantinople - # assertEquals(412, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + assembler: # MLOAD OP mal data + title: "MLOAD_6" + code: + MLOAD + success: false - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_2" - code: "60006000556001600055" - fork: constantinople - # assertEquals(20212, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + assembler: # MSTORE8 OP + title: "MSTORE8_1" + code: + PUSH1 "0x11" + PUSH1 "0x00" + MSTORE8 + memory: "0x1100000000000000000000000000000000000000000000000000000000000000" - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_3" - code: "60016000556000600055" - fork: constantinople - # assertEquals(20212, program.getResult().getGasUsed()) - # assertEquals(19800, program.getResult().getFutureRefund()) + assembler: # MSTORE8 OP + title: "MSTORE8_2" + code: + PUSH1 "0x22" + PUSH1 "0x01" + MSTORE8 + memory: "0x0022000000000000000000000000000000000000000000000000000000000000" - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_4" - code: "60016000556002600055" - fork: constantinople - # assertEquals(20212, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + assembler: # MSTORE8 OP + title: "MSTORE8_3" + code: + PUSH1 "0x22" + PUSH1 "0x21" + MSTORE8 + memory: + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0022000000000000000000000000000000000000000000000000000000000000" - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_5" - code: "60016000556001600055" - fork: constantinople - # assertEquals(20212, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + assembler: # MSTORE8 OP mal + title: "MSTORE8_4" + code: + PUSH1 "0x22" + MSTORE8 + success: false + stack: "0x22" - # Sets Storage row on "cow" address: - # 0: 1 - # private void setStorageToOne(VM vm) { - # # Sets storage value to 1 and commits - # code: "60006000556001600055" - # fork: constantinople - # invoke.getRepository().commit() - # invoke.setOrigRepository(invoke.getRepository()) + assembler: # SSTORE OP + title: "SSTORE_1" + code: + PUSH1 "0x22" + PUSH1 "0xAA" + SSTORE + storage: + "0xAA": "0x22" - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_6" - code: "60006000556000600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(15000, program.getResult().getFutureRefund()) + assembler: # SSTORE OP + title: "SSTORE_2" + code: + PUSH1 "0x22" + PUSH1 "0xAA" + SSTORE + PUSH1 "0x22" + PUSH1 "0xBB" + SSTORE + storage: + "0xAA": "0x22" + "0xBB": "0x22" - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_7" - code: "60006000556001600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(4800, program.getResult().getFutureRefund()) + assembler: # SSTORE OP + title: "SSTORE_3" + code: + PUSH1 "0x22" + SSTORE + success: false + stack: "0x22" + #[ + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_1" + code: "60006000556000600055" + fork: constantinople + # assertEquals(412, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_8" - code: "60006000556002600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_2" + code: "60006000556001600055" + fork: constantinople + # assertEquals(20212, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_9" - code: "60026000556000600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(15000, program.getResult().getFutureRefund()) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_3" + code: "60016000556000600055" + fork: constantinople + # assertEquals(20212, program.getResult().getGasUsed()) + # assertEquals(19800, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_10" - code: "60026000556003600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_4" + code: "60016000556002600055" + fork: constantinople + # assertEquals(20212, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_11" - code: "60026000556001600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(4800, program.getResult().getFutureRefund()) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_5" + code: "60016000556001600055" + fork: constantinople + # assertEquals(20212, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_12" - code: "60026000556002600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + # Sets Storage row on "cow" address: + # 0: 1 + # private void setStorageToOne(VM vm) { + # # Sets storage value to 1 and commits + # code: "60006000556001600055" + # fork: constantinople + # invoke.getRepository().commit() + # invoke.setOrigRepository(invoke.getRepository()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_13" - code: "60016000556000600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(15000, program.getResult().getFutureRefund()) + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_6" + code: "60006000556000600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(15000, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_14" - code: "60016000556002600055" - fork: constantinople - # assertEquals(5212, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_7" + code: "60006000556001600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(4800, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_15" - code: "60016000556001600055" - fork: constantinople - # assertEquals(412, program.getResult().getGasUsed()) - # assertEquals(0, program.getResult().getFutureRefund()) + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_8" + code: "60006000556002600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_16" - code: "600160005560006000556001600055" - fork: constantinople - # assertEquals(40218, program.getResult().getGasUsed()) - # assertEquals(19800, program.getResult().getFutureRefund()) + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_9" + code: "60026000556000600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(15000, program.getResult().getFutureRefund()) - setStorageToOne(vm) - assembler: # SSTORE EIP1283 - title: "SSTORE_NET_17" - code: "600060005560016000556000600055" - fork: constantinople - # assertEquals(10218, program.getResult().getGasUsed()) - # assertEquals(19800, program.getResult().getFutureRefund()) -]# - assembler: # SLOAD OP - title: "SLOAD_1" - code: - PUSH1 "0xAA" - SLOAD - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_10" + code: "60026000556003600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - assembler: # SLOAD OP - title: "SLOAD_2" - code: - PUSH1 "0x22" - PUSH1 "0xAA" - SSTORE - PUSH1 "0xAA" - SLOAD - stack: "0x0000000000000000000000000000000000000000000000000000000000000022" + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_11" + code: "60026000556001600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(4800, program.getResult().getFutureRefund()) - assembler: # SLOAD OP - title: "SLOAD_3" - code: - PUSH1 "0x22" - PUSH1 "0xAA" - SSTORE - PUSH1 "0x33" - PUSH1 "0xCC" - SSTORE - PUSH1 "0xCC" - SLOAD - stack: "0x0000000000000000000000000000000000000000000000000000000000000033" + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_12" + code: "60026000556002600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - assembler: # SLOAD OP - title: "SLOAD_4" - code: SLOAD - success: false + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_13" + code: "60016000556000600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(15000, program.getResult().getFutureRefund()) - assembler: # PC OP - title: "PC_1" - code: PC - stack: - "0x0000000000000000000000000000000000000000000000000000000000000000" + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_14" + code: "60016000556002600055" + fork: constantinople + # assertEquals(5212, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - assembler: # PC OP - title: "PC_2" - code: - PUSH1 "0x22" - PUSH1 "0xAA" - MSTORE - PUSH1 "0xAA" - SLOAD - PC - stack: - "0x00" - "0x0000000000000000000000000000000000000000000000000000000000000008" - memory: - "0x00" - "0x00" - "0x00" - "0x00" - "0x00" - "0x00" - "0x0000000000000000002200000000000000000000000000000000000000000000" + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_15" + code: "60016000556001600055" + fork: constantinople + # assertEquals(412, program.getResult().getGasUsed()) + # assertEquals(0, program.getResult().getFutureRefund()) - assembler: # JUMP OP mal data - title: "JUMP_1" - code: - PUSH1 "0xAA" - PUSH1 "0xBB" - PUSH1 "0x0E" - JUMP - PUSH1 "0xCC" - PUSH1 "0xDD" - PUSH1 "0xEE" - JUMPDEST - PUSH1 "0xFF" - stack: - "0xaa" - "0x00000000000000000000000000000000000000000000000000000000000000bb" - success: false + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_16" + code: "600160005560006000556001600055" + fork: constantinople + # assertEquals(40218, program.getResult().getGasUsed()) + # assertEquals(19800, program.getResult().getFutureRefund()) - assembler: # JUMP OP mal data - title: "JUMP_2" - code: - PUSH1 "0x0C" - PUSH1 "0x0C" - SWAP1 - JUMP - PUSH1 "0xCC" - PUSH1 "0xDD" - PUSH1 "0xEE" - PUSH1 "0xFF" - success: false - stack : "0x0C" + setStorageToOne(vm) + assembler: # SSTORE EIP1283 + title: "SSTORE_NET_17" + code: "600060005560016000556000600055" + fork: constantinople + # assertEquals(10218, program.getResult().getGasUsed()) + # assertEquals(19800, program.getResult().getFutureRefund()) + ]# + assembler: # SLOAD OP + title: "SLOAD_1" + code: + PUSH1 "0xAA" + SLOAD + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler: # JUMPI OP - title: "JUMPI_1" - code: - PUSH1 "0x01" - PUSH1 "0x05" - JUMPI - JUMPDEST - PUSH1 "0xCC" - stack: "0x00000000000000000000000000000000000000000000000000000000000000CC" + assembler: # SLOAD OP + title: "SLOAD_2" + code: + PUSH1 "0x22" + PUSH1 "0xAA" + SSTORE + PUSH1 "0xAA" + SLOAD + stack: "0x0000000000000000000000000000000000000000000000000000000000000022" - assembler: # JUMPI OP - title: "JUMPI_2" - code: - PUSH4 "0x00000000" - PUSH1 "0x44" - JUMPI - PUSH1 "0xCC" - PUSH1 "0xDD" - stack: - "0x00000000000000000000000000000000000000000000000000000000000000CC" - "0x00000000000000000000000000000000000000000000000000000000000000DD" + assembler: # SLOAD OP + title: "SLOAD_3" + code: + PUSH1 "0x22" + PUSH1 "0xAA" + SSTORE + PUSH1 "0x33" + PUSH1 "0xCC" + SSTORE + PUSH1 "0xCC" + SLOAD + stack: "0x0000000000000000000000000000000000000000000000000000000000000033" - assembler: # JUMPI OP mal - title: "JUMPI_3" - code: - PUSH1 "0x01" - JUMPI - success: false - stack: "0x01" + assembler: # SLOAD OP + title: "SLOAD_4" + code: SLOAD + success: false - assembler: # JUMPI OP mal - title: "JUMPI_4" - code: - PUSH1 "0x01" - PUSH1 "0x22" - SWAP1 - SWAP1 - JUMPI - success: false + assembler: # PC OP + title: "PC_1" + code: PC + stack: + "0x0000000000000000000000000000000000000000000000000000000000000000" - assembler: # JUMP OP mal data - title: "JUMPDEST_1" - code: - PUSH1 "0x23" - PUSH1 "0x08" - JUMP - PUSH1 "0x01" - JUMPDEST - PUSH1 "0x02" - SSTORE - storage: - "0x02": "0x00" - stack: "0x23" - success: false + assembler: # PC OP + title: "PC_2" + code: + PUSH1 "0x22" + PUSH1 "0xAA" + MSTORE + PUSH1 "0xAA" + SLOAD + PC + stack: + "0x00" + "0x0000000000000000000000000000000000000000000000000000000000000008" + memory: + "0x00" + "0x00" + "0x00" + "0x00" + "0x00" + "0x00" + "0x0000000000000000002200000000000000000000000000000000000000000000" - # success or not? - assembler: # JUMPDEST OP for JUMPI - title: "JUMPDEST_2" - code: - PUSH1 "0x23" - PUSH1 "0x01" - PUSH1 "0x09" - JUMPI - PUSH1 "0x01" - JUMPDEST - PUSH1 "0x02" - SSTORE - #success: false - storage: - "0x02": "0x23" + assembler: # JUMP OP mal data + title: "JUMP_1" + code: + PUSH1 "0xAA" + PUSH1 "0xBB" + PUSH1 "0x0E" + JUMP + PUSH1 "0xCC" + PUSH1 "0xDD" + PUSH1 "0xEE" + JUMPDEST + PUSH1 "0xFF" + stack: + "0xaa" + "0x00000000000000000000000000000000000000000000000000000000000000bb" + success: false - assembler: # MSIZE OP - title: "MSIZE_1" - code: - MSIZE - stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + assembler: # JUMP OP mal data + title: "JUMP_2" + code: + PUSH1 "0x0C" + PUSH1 "0x0C" + SWAP1 + JUMP + PUSH1 "0xCC" + PUSH1 "0xDD" + PUSH1 "0xEE" + PUSH1 "0xFF" + success: false + stack : "0x0C" - assembler: # MSIZE OP - title: "MSIZE_2" - code: - PUSH1 "0x20" - PUSH1 "0x30" - MSTORE - MSIZE - stack: - "0x60" - memory: - "0x00" - "0x00" - "0x0000000000000000000000000000002000000000000000000000000000000000" + assembler: # JUMPI OP + title: "JUMPI_1" + code: + PUSH1 "0x01" + PUSH1 "0x05" + JUMPI + JUMPDEST + PUSH1 "0xCC" + stack: "0x00000000000000000000000000000000000000000000000000000000000000CC" + + assembler: # JUMPI OP + title: "JUMPI_2" + code: + PUSH4 "0x00000000" + PUSH1 "0x44" + JUMPI + PUSH1 "0xCC" + PUSH1 "0xDD" + stack: + "0x00000000000000000000000000000000000000000000000000000000000000CC" + "0x00000000000000000000000000000000000000000000000000000000000000DD" + + assembler: # JUMPI OP mal + title: "JUMPI_3" + code: + PUSH1 "0x01" + JUMPI + success: false + stack: "0x01" + + assembler: # JUMPI OP mal + title: "JUMPI_4" + code: + PUSH1 "0x01" + PUSH1 "0x22" + SWAP1 + SWAP1 + JUMPI + success: false + + assembler: # JUMP OP mal data + title: "JUMPDEST_1" + code: + PUSH1 "0x23" + PUSH1 "0x08" + JUMP + PUSH1 "0x01" + JUMPDEST + PUSH1 "0x02" + SSTORE + storage: + "0x02": "0x00" + stack: "0x23" + success: false + + # success or not? + assembler: # JUMPDEST OP for JUMPI + title: "JUMPDEST_2" + code: + PUSH1 "0x23" + PUSH1 "0x01" + PUSH1 "0x09" + JUMPI + PUSH1 "0x01" + JUMPDEST + PUSH1 "0x02" + SSTORE + #success: false + storage: + "0x02": "0x23" + + assembler: # MSIZE OP + title: "MSIZE_1" + code: + MSIZE + stack: "0x0000000000000000000000000000000000000000000000000000000000000000" + + assembler: # MSIZE OP + title: "MSIZE_2" + code: + PUSH1 "0x20" + PUSH1 "0x30" + MSTORE + MSIZE + stack: + "0x60" + memory: + "0x00" + "0x00" + "0x0000000000000000000000000000002000000000000000000000000000000000" diff --git a/tests/test_op_misc.nim b/tests/test_op_misc.nim index da15338a6..368d39e68 100644 --- a/tests/test_op_misc.nim +++ b/tests/test_op_misc.nim @@ -3,174 +3,175 @@ import stew/byteutils, eth/common, ../nimbus/db/state_db, ../nimbus/db/db_chain, stew/ranges -suite "Misc Opcodes": - let (blockNumber, chainDB) = initDatabase() +proc opMiscMain*() = + suite "Misc Opcodes": + let (blockNumber, chainDB) = initDatabase() - assembler: # LOG0 OP - title: "Log0" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH1 "0x20" - PUSH1 "0x00" - LOG0 - memory: - "0x1234" - logs: - ( - address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", - data: "0x0000000000000000000000000000000000000000000000000000000000001234" - ) + assembler: # LOG0 OP + title: "Log0" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH1 "0x20" + PUSH1 "0x00" + LOG0 + memory: + "0x1234" + logs: + ( + address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", + data: "0x0000000000000000000000000000000000000000000000000000000000001234" + ) - assembler: # LOG1 OP - title: "Log1" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH2 "0x9999" - PUSH1 "0x20" - PUSH1 "0x00" - LOG1 - memory: - "0x1234" - logs: - ( - address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", - topics: ["0x9999"], - data: "0x0000000000000000000000000000000000000000000000000000000000001234" - ) + assembler: # LOG1 OP + title: "Log1" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH2 "0x9999" + PUSH1 "0x20" + PUSH1 "0x00" + LOG1 + memory: + "0x1234" + logs: + ( + address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", + topics: ["0x9999"], + data: "0x0000000000000000000000000000000000000000000000000000000000001234" + ) - assembler: # LOG2 OP - title: "Log2" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH2 "0x9999" - PUSH2 "0x6666" - PUSH1 "0x20" - PUSH1 "0x00" - LOG2 - memory: - "0x1234" - logs: - ( - address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", - topics: ["0x6666", "0x9999"], - data: "0x0000000000000000000000000000000000000000000000000000000000001234" - ) + assembler: # LOG2 OP + title: "Log2" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH2 "0x9999" + PUSH2 "0x6666" + PUSH1 "0x20" + PUSH1 "0x00" + LOG2 + memory: + "0x1234" + logs: + ( + address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", + topics: ["0x6666", "0x9999"], + data: "0x0000000000000000000000000000000000000000000000000000000000001234" + ) - assembler: # LOG3 OP - title: "Log3" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH2 "0x9999" - PUSH2 "0x6666" - PUSH2 "0x3333" - PUSH1 "0x20" - PUSH1 "0x00" - LOG3 - memory: - "0x1234" - logs: - ( - address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", - topics: ["0x3333", "0x6666", "0x9999"], - data: "0x0000000000000000000000000000000000000000000000000000000000001234" - ) + assembler: # LOG3 OP + title: "Log3" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH2 "0x9999" + PUSH2 "0x6666" + PUSH2 "0x3333" + PUSH1 "0x20" + PUSH1 "0x00" + LOG3 + memory: + "0x1234" + logs: + ( + address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", + topics: ["0x3333", "0x6666", "0x9999"], + data: "0x0000000000000000000000000000000000000000000000000000000000001234" + ) - assembler: # LOG4 OP - title: "Log4" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH2 "0x9999" - PUSH2 "0x6666" - PUSH2 "0x3333" - PUSH2 "0x5555" - PUSH1 "0x20" - PUSH1 "0x00" - LOG4 - memory: - "0x1234" - logs: - ( - address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", - topics: ["0x5555", "0x3333", "0x6666", "0x9999"], - data: "0x0000000000000000000000000000000000000000000000000000000000001234" - ) + assembler: # LOG4 OP + title: "Log4" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH2 "0x9999" + PUSH2 "0x6666" + PUSH2 "0x3333" + PUSH2 "0x5555" + PUSH1 "0x20" + PUSH1 "0x00" + LOG4 + memory: + "0x1234" + logs: + ( + address: "0xc669eaad75042be84daaf9b461b0e868b9ac1871", + topics: ["0x5555", "0x3333", "0x6666", "0x9999"], + data: "0x0000000000000000000000000000000000000000000000000000000000001234" + ) - assembler: # STOP OP - title: "STOP_1" - code: - PUSH1 "0x20" - PUSH1 "0x30" - PUSH1 "0x10" - PUSH1 "0x30" - PUSH1 "0x11" - PUSH1 "0x23" - STOP - stack: - "0x20" - "0x30" - "0x10" - "0x30" - "0x11" - "0x23" + assembler: # STOP OP + title: "STOP_1" + code: + PUSH1 "0x20" + PUSH1 "0x30" + PUSH1 "0x10" + PUSH1 "0x30" + PUSH1 "0x11" + PUSH1 "0x23" + STOP + stack: + "0x20" + "0x30" + "0x10" + "0x30" + "0x11" + "0x23" - assembler: # RETURN OP - title: "RETURN_1" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH1 "0x20" - PUSH1 "0x00" - RETURN - memory: "0x1234" - output: "0x0000000000000000000000000000000000000000000000000000000000001234" + assembler: # RETURN OP + title: "RETURN_1" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH1 "0x20" + PUSH1 "0x00" + RETURN + memory: "0x1234" + output: "0x0000000000000000000000000000000000000000000000000000000000001234" - assembler: # RETURN OP - title: "RETURN_2" - code: - PUSH2 "0x1234" - PUSH1 "0x00" - MSTORE - PUSH1 "0x20" - PUSH1 "0x1F" - RETURN - memory: - "0x1234" - "0x00" - output: "0x3400000000000000000000000000000000000000000000000000000000000000" + assembler: # RETURN OP + title: "RETURN_2" + code: + PUSH2 "0x1234" + PUSH1 "0x00" + MSTORE + PUSH1 "0x20" + PUSH1 "0x1F" + RETURN + memory: + "0x1234" + "0x00" + output: "0x3400000000000000000000000000000000000000000000000000000000000000" - assembler: # RETURN OP - title: "RETURN_3" - code: - PUSH32 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" - PUSH1 "0x00" - MSTORE - PUSH1 "0x20" - PUSH1 "0x00" - RETURN - memory: "0xa0b0c0d0e0f0a1b1c1d1e1f1a2b2c2d2e2f2a3b3c3d3e3f3a4b4c4d4e4f4a1b1" - output: "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" + assembler: # RETURN OP + title: "RETURN_3" + code: + PUSH32 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" + PUSH1 "0x00" + MSTORE + PUSH1 "0x20" + PUSH1 "0x00" + RETURN + memory: "0xa0b0c0d0e0f0a1b1c1d1e1f1a2b2c2d2e2f2a3b3c3d3e3f3a4b4c4d4e4f4a1b1" + output: "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" - assembler: # RETURN OP - title: "RETURN_4" - code: - PUSH32 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" - PUSH1 "0x00" - MSTORE - PUSH1 "0x20" - PUSH1 "0x10" - RETURN - output: "0xE2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B100000000000000000000000000000000" - memory: - "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" - "0x00" + assembler: # RETURN OP + title: "RETURN_4" + code: + PUSH32 "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" + PUSH1 "0x00" + MSTORE + PUSH1 "0x20" + PUSH1 "0x10" + RETURN + output: "0xE2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B100000000000000000000000000000000" + memory: + "0xA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1" + "0x00" diff --git a/tests/test_persistblock_json.nim b/tests/test_persistblock_json.nim index 852bd4c87..24f844e7f 100644 --- a/tests/test_persistblock_json.nim +++ b/tests/test_persistblock_json.nim @@ -13,8 +13,9 @@ import proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) -suite "persist block json tests": - jsonTest("PersistBlockTests", testFixture) +proc persistBlockJsonMain*() = + suite "persist block json tests": + jsonTest("PersistBlockTests", testFixture) # use tracerTestGen.nim to generate additional test data proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) = diff --git a/tests/test_precompiles.nim b/tests/test_precompiles.nim index 580f84c84..3e9d54892 100644 --- a/tests/test_precompiles.nim +++ b/tests/test_precompiles.nim @@ -51,5 +51,6 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) = #raise newException(ValueError, "Unknown test vector '" & $label & "'") echo "Unknown test vector '" & $label & "'" -suite "Precompiles": - jsonTest("PrecompileTests", testFixture) +proc precompilesMain*() = + suite "Precompiles": + jsonTest("PrecompileTests", testFixture) diff --git a/tests/test_stack.nim b/tests/test_stack.nim index 6a0e463ff..e71da752f 100644 --- a/tests/test_stack.nim +++ b/tests/test_stack.nim @@ -27,77 +27,78 @@ func toBytes(s: string): seq[byte] = func bigEndianToInt*(value: openarray[byte]): UInt256 = result.initFromBytesBE(value) -suite "stack": - test "push only valid": - testPush(0'u, 0.u256) - testPush(UINT_256_MAX, UINT_256_MAX) - testPush("ves".toBytes, "ves".toBytes.bigEndianToInt) +proc stackMain*() = + suite "stack": + test "push only valid": + testPush(0'u, 0.u256) + testPush(UINT_256_MAX, UINT_256_MAX) + testPush("ves".toBytes, "ves".toBytes.bigEndianToInt) - testFailPush("yzyzyzyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz".toBytes) + testFailPush("yzyzyzyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz".toBytes) - test "push does not allow stack to exceed 1024": - var stack = newStack() - for z in 0 .. < 1024: - stack.push(z.uint) - check(stack.len == 1024) - expect(FullStack): - stack.push(1025) + test "push does not allow stack to exceed 1024": + var stack = newStack() + for z in 0 .. < 1024: + stack.push(z.uint) + check(stack.len == 1024) + expect(FullStack): + stack.push(1025) - test "dup does not allow stack to exceed 1024": - var stack = newStack() - stack.push(1.u256) - for z in 0 ..< 1023: - stack.dup(1) - check(stack.len == 1024) - expect(FullStack): + test "dup does not allow stack to exceed 1024": + var stack = newStack() + stack.push(1.u256) + for z in 0 ..< 1023: + stack.dup(1) + check(stack.len == 1024) + expect(FullStack): + stack.dup(1) + + test "pop returns latest stack item": + var stack = newStack() + for element in @[1'u, 2'u, 3'u]: + stack.push(element) + check(stack.popInt == 3.u256) + + test "swap correct": + var stack = newStack() + for z in 0 ..< 5: + stack.push(z.uint) + check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256]) + stack.swap(3) + check(stack.values == @[0.u256, 4.u256, 2.u256, 3.u256, 1.u256]) + stack.swap(1) + check(stack.values == @[0.u256, 4.u256, 2.u256, 1.u256, 3.u256]) + + test "dup correct": + var stack = newStack() + for z in 0 ..< 5: + stack.push(z.uint) + check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256]) stack.dup(1) + check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256, 4.u256]) + stack.dup(5) + check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256, 4.u256, 1.u256]) - test "pop returns latest stack item": - var stack = newStack() - for element in @[1'u, 2'u, 3'u]: - stack.push(element) - check(stack.popInt == 3.u256) + test "pop raises InsufficientStack appropriately": + var stack = newStack() + expect(InsufficientStack): + discard stack.popInt() - test "swap correct": - var stack = newStack() - for z in 0 ..< 5: - stack.push(z.uint) - check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256]) - stack.swap(3) - check(stack.values == @[0.u256, 4.u256, 2.u256, 3.u256, 1.u256]) - stack.swap(1) - check(stack.values == @[0.u256, 4.u256, 2.u256, 1.u256, 3.u256]) + test "swap raises InsufficientStack appropriately": + var stack = newStack() + expect(InsufficientStack): + stack.swap(0) - test "dup correct": - var stack = newStack() - for z in 0 ..< 5: - stack.push(z.uint) - check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256]) - stack.dup(1) - check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256, 4.u256]) - stack.dup(5) - check(stack.values == @[0.u256, 1.u256, 2.u256, 3.u256, 4.u256, 4.u256, 1.u256]) + test "dup raises InsufficientStack appropriately": + var stack = newStack() + expect(InsufficientStack): + stack.dup(0) - test "pop raises InsufficientStack appropriately": - var stack = newStack() - expect(InsufficientStack): - discard stack.popInt() + test "binary operations raises InsufficientStack appropriately": + # https://github.com/status-im/nimbus/issues/31 + # ./tests/fixtures/VMTests/vmArithmeticTest/mulUnderFlow.json - test "swap raises InsufficientStack appropriately": - var stack = newStack() - expect(InsufficientStack): - stack.swap(0) - - test "dup raises InsufficientStack appropriately": - var stack = newStack() - expect(InsufficientStack): - stack.dup(0) - - test "binary operations raises InsufficientStack appropriately": - # https://github.com/status-im/nimbus/issues/31 - # ./tests/fixtures/VMTests/vmArithmeticTest/mulUnderFlow.json - - var stack = newStack() - stack.push(123) - expect(InsufficientStack): - discard stack.popInt(2) + var stack = newStack() + stack.push(123) + expect(InsufficientStack): + discard stack.popInt(2) diff --git a/tests/test_state_db.nim b/tests/test_state_db.nim index eedb415b0..07f01fcd9 100644 --- a/tests/test_state_db.nim +++ b/tests/test_state_db.nim @@ -9,37 +9,38 @@ import unittest, strutils, eth/trie/[hexary, db], ../nimbus/db/state_db, stew/byteutils, eth/common, stew/ranges -suite "Account State DB": - var - memDB = newMemoryDB() - trie = initHexaryTrie(memDB) - stateDB = newAccountStateDB(memDB, trie.rootHash, true) - address: EthAddress +proc stateDBMain*() = + suite "Account State DB": + var + memDB = newMemoryDB() + trie = initHexaryTrie(memDB) + stateDB = newAccountStateDB(memDB, trie.rootHash, true) + address: EthAddress - hexToByteArray("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", address) + hexToByteArray("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", address) - test "accountExists and isDeadAccount": - check stateDB.accountExists(address) == false - check stateDB.isDeadAccount(address) == true + test "accountExists and isDeadAccount": + check stateDB.accountExists(address) == false + check stateDB.isDeadAccount(address) == true - var acc = stateDB.getAccount(address) - acc.balance = 1000.u256 - stateDB.setAccount(address, acc) + var acc = stateDB.getAccount(address) + acc.balance = 1000.u256 + stateDB.setAccount(address, acc) - check stateDB.accountExists(address) == true - check stateDB.isDeadAccount(address) == false + check stateDB.accountExists(address) == true + check stateDB.isDeadAccount(address) == false - acc.balance = 0.u256 - acc.nonce = 1 - stateDB.setAccount(address, acc) - check stateDB.isDeadAccount(address) == false + acc.balance = 0.u256 + acc.nonce = 1 + stateDB.setAccount(address, acc) + check stateDB.isDeadAccount(address) == false - var code = hexToSeqByte("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6") - stateDB.setCode(address, code.toRange) - stateDB.setNonce(address, 0) - check stateDB.isDeadAccount(address) == false + var code = hexToSeqByte("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6") + stateDB.setCode(address, code.toRange) + stateDB.setNonce(address, 0) + check stateDB.isDeadAccount(address) == false - code = @[] - stateDB.setCode(address, code.toRange) - check stateDB.isDeadAccount(address) == true - check stateDB.accountExists(address) == true + code = @[] + stateDB.setCode(address, code.toRange) + check stateDB.isDeadAccount(address) == true + check stateDB.accountExists(address) == true diff --git a/tests/test_tracer_json.nim b/tests/test_tracer_json.nim index 64dbbb9ee..e2061359a 100644 --- a/tests/test_tracer_json.nim +++ b/tests/test_tracer_json.nim @@ -12,8 +12,9 @@ import proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) -suite "tracer json tests": - jsonTest("TracerTests", testFixture) +proc tracerJsonMain*() = + suite "tracer json tests": + jsonTest("TracerTests", testFixture) # use tracerTestGen.nim to generate additional test data proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) = diff --git a/tests/test_transaction_json.nim b/tests/test_transaction_json.nim index 099816ee0..334ecb211 100644 --- a/tests/test_transaction_json.nim +++ b/tests/test_transaction_json.nim @@ -8,8 +8,12 @@ const proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) -suite "Transactions tests": - jsonTest("TransactionTests", testFixture) +proc transactionJsonMain*() = + suite "Transactions tests": + jsonTest("TransactionTests", testFixture) + +when isMainModule: + transactionJsonMain() proc txHash(tx: Transaction): string = toLowerAscii($keccakHash(rlp.encode(tx))) diff --git a/tests/test_vm_json.nim b/tests/test_vm_json.nim index 91eade51c..cb3b2ec3c 100644 --- a/tests/test_vm_json.nim +++ b/tests/test_vm_json.nim @@ -14,8 +14,9 @@ import proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) -suite "vm json tests": - jsonTest("VMTests", testFixture) +proc vmJsonMain*() = + suite "vm json tests": + jsonTest("VMTests", testFixture) proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) = var fixture: JsonNode