Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

WASM spec tests wasms and cpps #7784

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
154 changes: 154 additions & 0 deletions wasm_spec_tests/address.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_address_0 = base_dir + "/wasm_spec_tests/wasms/address.0.wasm";
std::vector<uint8_t> wasm_address_0= read_wasm(wasm_str_address_0.c_str());

BOOST_DATA_TEST_CASE(address_0_check_throw, boost::unit_test::data::xrange(0,11), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

BOOST_CHECK_THROW(push_action(tester, std::move(test), N(wasmtest).to_uint64_t()), wasm_execution_error);
tester.produce_block();
} FC_LOG_AND_RETHROW() }

BOOST_DATA_TEST_CASE(address_0_pass, boost::unit_test::data::xrange(11,12), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

const string wasm_str_address_2 = base_dir + "/wasm_spec_tests/wasms/address.2.wasm";
std::vector<uint8_t> wasm_address_2= read_wasm(wasm_str_address_2.c_str());

BOOST_DATA_TEST_CASE(address_2_check_throw, boost::unit_test::data::xrange(0,15), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_2);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

BOOST_CHECK_THROW(push_action(tester, std::move(test), N(wasmtest).to_uint64_t()), wasm_execution_error);
tester.produce_block();
} FC_LOG_AND_RETHROW() }

BOOST_DATA_TEST_CASE(address_2_pass, boost::unit_test::data::xrange(15,17), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_2);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

const string wasm_str_address_3 = base_dir + "/wasm_spec_tests/wasms/address.3.wasm";
std::vector<uint8_t> wasm_address_3= read_wasm(wasm_str_address_3.c_str());

BOOST_DATA_TEST_CASE(address_3_check_throw, boost::unit_test::data::xrange(0,3), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_3);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

BOOST_CHECK_THROW(push_action(tester, std::move(test), N(wasmtest).to_uint64_t()), wasm_execution_error);
tester.produce_block();
} FC_LOG_AND_RETHROW() }

BOOST_DATA_TEST_CASE(address_3_pass, boost::unit_test::data::xrange(3,4), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_3);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

const string wasm_str_address_4 = base_dir + "/wasm_spec_tests/wasms/address.4.wasm";
std::vector<uint8_t> wasm_address_4= read_wasm(wasm_str_address_4.c_str());

BOOST_DATA_TEST_CASE(address_4_check_throw, boost::unit_test::data::xrange(0,3), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_4);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

BOOST_CHECK_THROW(push_action(tester, std::move(test), N(wasmtest).to_uint64_t()), wasm_execution_error);
tester.produce_block();
} FC_LOG_AND_RETHROW() }

BOOST_DATA_TEST_CASE(address_4_pass, boost::unit_test::data::xrange(3,4), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_address_4);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

61 changes: 61 additions & 0 deletions wasm_spec_tests/align.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_align_106 = base_dir + "/wasm_spec_tests/wasms/align.106.wasm";
std::vector<uint8_t> wasm_align_106= read_wasm(wasm_str_align_106.c_str());

BOOST_DATA_TEST_CASE(align_106_pass, boost::unit_test::data::xrange(0,1), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_align_106);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

const string wasm_str_align_107 = base_dir + "/wasm_spec_tests/wasms/align.107.wasm";
std::vector<uint8_t> wasm_align_107= read_wasm(wasm_str_align_107.c_str());

BOOST_DATA_TEST_CASE(align_107_check_throw, boost::unit_test::data::xrange(0,1), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_align_107);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

BOOST_CHECK_THROW(push_action(tester, std::move(test), N(wasmtest).to_uint64_t()), wasm_execution_error);
tester.produce_block();
} FC_LOG_AND_RETHROW() }

BOOST_DATA_TEST_CASE(align_107_pass, boost::unit_test::data::xrange(1,2), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_align_107);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

23 changes: 23 additions & 0 deletions wasm_spec_tests/block.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_block_0 = base_dir + "/wasm_spec_tests/wasms/block.0.wasm";
std::vector<uint8_t> wasm_block_0= read_wasm(wasm_str_block_0.c_str());

BOOST_DATA_TEST_CASE(block_0_pass, boost::unit_test::data::xrange(0,1), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_block_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

23 changes: 23 additions & 0 deletions wasm_spec_tests/br.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_br_0 = base_dir + "/wasm_spec_tests/wasms/br.0.wasm";
std::vector<uint8_t> wasm_br_0= read_wasm(wasm_str_br_0.c_str());

BOOST_DATA_TEST_CASE(br_0_pass, boost::unit_test::data::xrange(0,1), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_br_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

23 changes: 23 additions & 0 deletions wasm_spec_tests/br_if.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_br_if_0 = base_dir + "/wasm_spec_tests/wasms/br_if.0.wasm";
std::vector<uint8_t> wasm_br_if_0= read_wasm(wasm_str_br_if_0.c_str());

BOOST_DATA_TEST_CASE(br_if_0_pass, boost::unit_test::data::xrange(0,1), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_br_if_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

23 changes: 23 additions & 0 deletions wasm_spec_tests/br_table.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_br_table_0 = base_dir + "/wasm_spec_tests/wasms/br_table.0.wasm";
std::vector<uint8_t> wasm_br_table_0= read_wasm(wasm_str_br_table_0.c_str());

BOOST_DATA_TEST_CASE(br_table_0_pass, boost::unit_test::data::xrange(0,2), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_br_table_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

23 changes: 23 additions & 0 deletions wasm_spec_tests/break-drop.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_break_drop_0 = base_dir + "/wasm_spec_tests/wasms/break-drop.0.wasm";
std::vector<uint8_t> wasm_break_drop_0= read_wasm(wasm_str_break_drop_0.c_str());

BOOST_DATA_TEST_CASE(break_drop_0_pass, boost::unit_test::data::xrange(0,1), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_break_drop_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

40 changes: 40 additions & 0 deletions wasm_spec_tests/call.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <wasm_spec_tests.hpp>

const string wasm_str_call_0 = base_dir + "/wasm_spec_tests/wasms/call.0.wasm";
std::vector<uint8_t> wasm_call_0= read_wasm(wasm_str_call_0.c_str());

BOOST_DATA_TEST_CASE(call_0_check_throw, boost::unit_test::data::xrange(0,3), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_call_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

BOOST_CHECK_THROW(push_action(tester, std::move(test), N(wasmtest).to_uint64_t()), wasm_execution_error);
tester.produce_block();
} FC_LOG_AND_RETHROW() }

BOOST_DATA_TEST_CASE(call_0_pass, boost::unit_test::data::xrange(3,4), index) { try {
TESTER tester;
tester.produce_block();
tester.create_account( N(wasmtest) );
tester.produce_block();
tester.set_code(N(wasmtest), wasm_call_0);
tester.produce_block();

action test;
test.account = N(wasmtest);
test.name = account_name((uint64_t)index);
test.authorization = {{N(wasmtest), config::active_name}};

push_action(tester, std::move(test), N(wasmtest).to_uint64_t());
tester.produce_block();
BOOST_REQUIRE_EQUAL( tester.validate(), true );
} FC_LOG_AND_RETHROW() }

Loading