From 9af19a284c64670f5eddc6013b8a0d6f86584faa Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 16 Dec 2019 22:04:10 +0700 Subject: [PATCH] attempt to make test green --- tests/evmc_c/{example_vm.c => example_vm.cpp} | 7 +++++-- tests/test_host_vm.nim | 8 +------- 2 files changed, 6 insertions(+), 9 deletions(-) rename tests/evmc_c/{example_vm.c => example_vm.cpp} (98%) diff --git a/tests/evmc_c/example_vm.c b/tests/evmc_c/example_vm.cpp similarity index 98% rename from tests/evmc_c/example_vm.c rename to tests/evmc_c/example_vm.cpp index 5884242..cc250bd 100644 --- a/tests/evmc_c/example_vm.c +++ b/tests/evmc_c/example_vm.cpp @@ -17,7 +17,8 @@ #include #include - +extern "C" { + /// The example VM instance struct extending the evmc_vm. struct example_vm { @@ -225,8 +226,10 @@ struct evmc_vm* evmc_create_example_vm() .get_capabilities = get_capabilities, .set_option = set_option, }; - struct example_vm* vm = calloc(1, sizeof(struct example_vm)); + struct example_vm* vm = (example_vm*)calloc(1, sizeof(struct example_vm)); struct evmc_vm* interface = &vm->instance; memcpy(interface, &init, sizeof(init)); return interface; } + +} \ No newline at end of file diff --git a/tests/test_host_vm.nim b/tests/test_host_vm.nim index cb362f4..28f86a5 100644 --- a/tests/test_host_vm.nim +++ b/tests/test_host_vm.nim @@ -3,7 +3,7 @@ import evmc_nim/nim_host import stew/byteutils {.compile: "evmc_c/example_host.cpp".} -{.compile: "evmc_c/example_vm.c".} +{.compile: "evmc_c/example_vm.cpp".} {.passL: "-lstdc++"} when defined(posix): @@ -62,12 +62,6 @@ template runTest(testName: string, create_vm, get_host_interface, create_host_co test "getTxContext": let txc = hc.getTxContext() - - debugEcho tx_context.block_number, " " , txc.block_number - debugEcho tx_context.block_timestamp, " " , txc.block_timestamp - debugEcho tx_context.block_gas_limit, " " , txc.block_gas_limit - - check tx_context.block_number == txc.block_number check tx_context.block_timestamp == txc.block_timestamp check tx_context.block_gas_limit == txc.block_gas_limit