Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resurrect compiler_builtins_tests for compiler builtins host functions #640

Merged
merged 1 commit into from
Aug 27, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions unittests/api_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,67 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(checktime_start, T, validating_testers) try {
deadline_exception, is_deadline_exception );
} FC_LOG_AND_RETHROW()

/*************************************************************************************
* compiler_builtins_tests test case
*************************************************************************************/
BOOST_AUTO_TEST_CASE_TEMPLATE(compiler_builtins_tests, T, validating_testers) try {
T chain;

chain.produce_blocks(2);
chain.create_account( "testapi"_n );
chain.produce_blocks(10);
chain.set_code( "testapi"_n, test_contracts::test_api_wasm() );
chain.produce_blocks(1);

// test test_multi3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_multi3", {});

// test test_divti3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_divti3", {});

// test test_divti3_by_0
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_divti3_by_0", {}), arithmetic_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "divide by zero");
}
);

// test test_udivti3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_udivti3", {});

// test test_udivti3_by_0
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_udivti3_by_0", {}), arithmetic_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "divide by zero");
}
);

// test test_modti3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_modti3", {});

// test test_modti3_by_0
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_modti3_by_0", {}), arithmetic_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "divide by zero");
}
);

// test test_lshlti3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_lshlti3", {});

// test test_lshrti3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_lshrti3", {});

// test test_ashlti3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_ashlti3", {});

// test test_ashrti3
CALL_TEST_FUNCTION( chain, "test_compiler_builtins", "test_ashrti3", {});

BOOST_REQUIRE_EQUAL( chain.validate(), true );
} FC_LOG_AND_RETHROW()


/*************************************************************************************
* transaction_tests common function
*************************************************************************************/
Expand Down
16 changes: 16 additions & 0 deletions unittests/test-contracts/test_api/test_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "test_action.cpp"
#include "test_chain.cpp"
#include "test_checktime.cpp"
#include "test_compiler_builtins.cpp"
#include "test_crypto.cpp"
#include "test_datastream.cpp"
#include "test_permission.cpp"
Expand Down Expand Up @@ -47,6 +48,21 @@ extern "C" {
WASM_TEST_HANDLER( test_types, char_to_symbol );
WASM_TEST_HANDLER( test_types, string_to_name );

//test_compiler_builtins
WASM_TEST_HANDLER( test_compiler_builtins, test_multi3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_divti3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_divti3_by_0 );
WASM_TEST_HANDLER( test_compiler_builtins, test_udivti3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_udivti3_by_0 );
WASM_TEST_HANDLER( test_compiler_builtins, test_modti3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_modti3_by_0 );
WASM_TEST_HANDLER( test_compiler_builtins, test_umodti3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_umodti3_by_0 );
WASM_TEST_HANDLER( test_compiler_builtins, test_lshlti3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_lshrti3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_ashlti3 );
WASM_TEST_HANDLER( test_compiler_builtins, test_ashrti3 );

//test_action
WASM_TEST_HANDLER ( test_action, read_action_normal );
WASM_TEST_HANDLER ( test_action, read_action );
Expand Down
Binary file modified unittests/test-contracts/test_api/test_api.wasm
Binary file not shown.
Loading