update tests for a function tagged both as an action and a call

This commit is contained in:
Lin Huang
2025-07-13 23:15:42 -04:00
parent ecb339bb64
commit 4c56554cdf
4 changed files with 33 additions and 53 deletions
+22
View File
@@ -126,6 +126,28 @@ BOOST_AUTO_TEST_CASE(void_func_test) { try {
check(trx_trace);
} FC_LOG_AND_RETHROW() }
// Verify a function tagged as both `action` and `call` works
BOOST_AUTO_TEST_CASE(mixed_action_call_tags_test) { try {
call_tester t({
{"caller"_n, contracts::caller_wasm(), contracts::caller_abi().data()},
{"callee"_n, contracts::callee_wasm(), contracts::callee_abi().data()}
});
// `sum` in `callee` contract is tagged as `action` and `call`
// Make sure we can make a sync call to `sum` (`mulparamtest` in `caller` does
// a sync call to `sum`)
BOOST_REQUIRE_NO_THROW(t.push_action("caller"_n, "hstmulprmtst"_n, "caller"_n, {}));
// Make sure we can push an action using `sum`.
//BOOST_REQUIRE_NO_THROW(t.push_action("callee"_n, "sum"_n, "callee"_n,
t.push_action("callee"_n, "sum"_n, "callee"_n,
mvo()
("a", 1)
("b", 2)
("c", 3)); //);
} FC_LOG_AND_RETHROW() }
// Verify the receiver contract with only one sync call function works
// (for testing the sync_call entry point dispatcher)
BOOST_AUTO_TEST_CASE(single_function_test) { try {
+9 -51
View File
@@ -3,38 +3,15 @@
"version": "eosio::abi/1.3",
"types": [],
"structs": [
{
"name": "call_data_header",
"base": "",
"fields": [
{
"name": "version",
"type": "uint32"
},
{
"name": "func_name",
"type": "uint64"
}
]
},
{
"name": "noparam",
"base": "",
"fields": [
{
"name": "header",
"type": "call_data_header"
}
]
"fields": []
},
{
"name": "sum",
"base": "",
"fields": [
{
"name": "header",
"type": "call_data_header"
},
{
"name": "a",
"type": "uint32"
@@ -52,21 +29,12 @@
{
"name": "voidfunc",
"base": "",
"fields": [
{
"name": "header",
"type": "call_data_header"
}
]
"fields": []
},
{
"name": "withparam",
"base": "",
"fields": [
{
"name": "header",
"type": "call_data_header"
},
{
"name": "in",
"type": "uint32"
@@ -83,35 +51,25 @@
{
"name": "noparam",
"type": "noparam",
"id": 229476383600947
"id": 229476383600947,
"result_type": "uint32"
},
{
"name": "sum",
"type": "sum",
"id": 193506202
"id": 193506202,
"result_type": "uint32"
},
{
"name": "voidfunc",
"type": "voidfunc",
"id": 7573061335575747
"id": 7573061335575747,
"result_type": ""
},
{
"name": "withparam",
"type": "withparam",
"id": 249912189145794130
}
],
"call_results": [
{
"name": "noparam",
"result_type": "uint32"
},
{
"name": "sum",
"result_type": "uint32"
},
{
"name": "withparam",
"id": 249912189145794130,
"result_type": "uint32"
}
]
@@ -16,7 +16,7 @@ void sync_call_callee::void_func() {
eosio::print("I am a void function");
}
[[eosio::call]]
[[eosio::action, eosio::call]]
uint32_t sync_call_callee::sum(uint32_t a, uint32_t b, uint32_t c) {
return a + b + c;
}
@@ -26,7 +26,7 @@ public:
[[eosio::call]]
void void_func();
[[eosio::call]]
[[eosio::action, eosio::call]]
uint32_t sum(uint32_t a, uint32_t b, uint32_t c);
// pass in a struct and return it