diff --git a/contracts/test_api/test_action.cpp b/contracts/test_api/test_action.cpp index 1bc54cb3d02..496b30fcc37 100644 --- a/contracts/test_api/test_action.cpp +++ b/contracts/test_api/test_action.cpp @@ -174,6 +174,17 @@ void test_action::require_notice(uint64_t receiver, uint64_t code, uint64_t acti eosio_assert(false, "Should've failed"); } +void test_action::require_notice_tests(uint64_t receiver, uint64_t code, uint64_t action) { + eosio::print( "require_notice_tests" ); + if( receiver == N( testapi ) ) { + eosio::print( "require_recipient( N(acc5) )" ); + eosio::require_recipient( N( acc5 ) ); + } else if( receiver == N( acc5 ) ) { + eosio::print( "require_recipient( N(testapi) )" ); + eosio::require_recipient( N( testapi ) ); + } +} + void test_action::require_auth() { prints("require_auth"); eosio::require_auth( N(acc3) ); diff --git a/contracts/test_api/test_api.cpp b/contracts/test_api/test_api.cpp index 8f1922f2d4f..9ddcb712752 100644 --- a/contracts/test_api/test_api.cpp +++ b/contracts/test_api/test_api.cpp @@ -71,6 +71,7 @@ extern "C" { WASM_TEST_HANDLER(test_action, read_action_to_0); WASM_TEST_HANDLER(test_action, read_action_to_64k); WASM_TEST_HANDLER_EX(test_action, require_notice); + WASM_TEST_HANDLER_EX(test_action, require_notice_tests); WASM_TEST_HANDLER(test_action, require_auth); WASM_TEST_HANDLER(test_action, assert_false); WASM_TEST_HANDLER(test_action, assert_true); diff --git a/contracts/test_api/test_api.hpp b/contracts/test_api/test_api.hpp index a8fa3f21d65..4dc5711e3a1 100644 --- a/contracts/test_api/test_api.hpp +++ b/contracts/test_api/test_api.hpp @@ -63,6 +63,7 @@ struct test_action { static void test_dummy_action(); static void test_cf_action(); static void require_notice(uint64_t receiver, uint64_t code, uint64_t action); + static void require_notice_tests(uint64_t receiver, uint64_t code, uint64_t action); static void require_auth(); static void assert_false(); static void assert_true(); diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 8b2be0ad065..b80683b211f 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -437,6 +437,30 @@ BOOST_FIXTURE_TEST_CASE(action_tests, TESTER) { try { BOOST_REQUIRE_EQUAL( validate(), true ); } FC_LOG_AND_RETHROW() } +// test require_recipient loop (doesn't cause infinite loop) +BOOST_FIXTURE_TEST_CASE(require_notice_tests, TESTER) { try { + produce_blocks(2); + create_account( N(testapi) ); + create_account( N(acc5) ); + produce_blocks(1); + set_code( N(testapi), test_api_wast ); + set_code( N(acc5), test_api_wast ); + produce_blocks(1); + + // test require_notice + signed_transaction trx; + auto tm = test_api_action{}; + + action act( std::vector{{N( testapi ), config::active_name}}, tm ); + trx.actions.push_back( act ); + + set_transaction_headers( trx ); + trx.sign( get_private_key( N( testapi ), "active" ), control->get_chain_id() ); + auto res = push_transaction( trx ); + BOOST_CHECK_EQUAL( res->receipt->status, transaction_receipt::executed ); + + } FC_LOG_AND_RETHROW() } + BOOST_FIXTURE_TEST_CASE(ram_billing_in_notify_tests, TESTER) { try { produce_blocks(2); create_account( N(testapi) );