@@ -140,12 +140,11 @@ BOOST_AUTO_TEST_CASE(mixed_action_call_tags_test) { try {
140140 BOOST_REQUIRE_NO_THROW (t.push_action (" caller" _n, " hstmulprmtst" _n, " caller" _n, {}));
141141
142142 // Make sure we can push an action using `sum`.
143- // BOOST_REQUIRE_NO_THROW(t.push_action("callee"_n, "sum"_n, "callee"_n,
144- t.push_action (" callee" _n, " sum" _n, " callee" _n,
143+ BOOST_REQUIRE_NO_THROW (t.push_action (" callee" _n, " sum" _n, " callee" _n,
145144 mvo ()
146145 (" a" , 1 )
147146 (" b" , 2 )
148- (" c" , 3 )); // );
147+ (" c" , 3 )));
149148} FC_LOG_AND_RETHROW () }
150149
151150// Verify the receiver contract with only one sync call function works
@@ -234,4 +233,43 @@ BOOST_AUTO_TEST_CASE(addr_book_tests) { try {
234233 BOOST_REQUIRE_NO_THROW (t.push_action (" caller" _n, " get" _n, " caller" _n, mvo () (" user" , " alice" )));
235234} FC_LOG_AND_RETHROW () }
236235
236+ // For a function tagged as both `action` and `call`, verify is_sync_call()
237+ // returns true if tagged as `call` and false if tagged as `action`.
238+ BOOST_AUTO_TEST_CASE (is_sync_call_test) { try {
239+ call_tester t ({
240+ {" caller" _n, contracts::caller_wasm (), contracts::caller_abi ().data ()},
241+ {" callee" _n, contracts::callee_wasm (), contracts::callee_abi ().data ()}
242+ });
243+
244+ // issynccall() is tagged as both `action` and `call`, and returns
245+ // is_sync_call(). makesynccall() calls issynccall() as a sync call
246+ // and returns its result. So the current action return value must be
247+ // true.
248+ auto trx_trace = t.push_action (" caller" _n, " makesynccall" _n, " caller" _n, {});
249+ auto & action_trace = trx_trace->action_traces [0 ];
250+ bool return_value = fc::raw::unpack<bool >(action_trace.return_value );
251+ BOOST_REQUIRE (return_value == true );
252+
253+ // Call issynccall() directly as an action. Since issynccall()
254+ // returns is_sync_call(), the current action return value must be false.
255+ trx_trace = t.push_action (" callee" _n, " issynccall" _n, " callee" _n, {});
256+ auto & action_trace1 = trx_trace->action_traces [0 ];
257+ return_value = fc::raw::unpack<bool >(action_trace1.return_value );
258+ BOOST_REQUIRE (return_value == false );
259+ } FC_LOG_AND_RETHROW () }
260+
261+ // Verify customized sync call entry function, without sync call tag
262+ BOOST_AUTO_TEST_CASE (customized_call_entry_func_test1) { try {
263+ call_tester t ({{" receiver" _n, contracts::cust_entry_wasm (), contracts::cust_entry_abi ().data ()}});
264+
265+ BOOST_REQUIRE_NO_THROW (t.push_action (" receiver" _n, " cusentrytst1" _n, " receiver" _n, {}));
266+ } FC_LOG_AND_RETHROW () }
267+
268+ // Verify customized sync call entry function, with sync call tag
269+ BOOST_AUTO_TEST_CASE (customized_call_entry_func_test2) { try {
270+ call_tester t ({{" receiver" _n, contracts::cust_entry_wasm (), contracts::cust_entry_abi ().data ()}});
271+
272+ BOOST_REQUIRE_NO_THROW (t.push_action (" receiver" _n, " cusentrytst2" _n, " receiver" _n, {}));
273+ } FC_LOG_AND_RETHROW () }
274+
237275BOOST_AUTO_TEST_SUITE_END ()
0 commit comments