diff --git a/plugins/trace_api_plugin/abi_data_handler.cpp b/plugins/trace_api_plugin/abi_data_handler.cpp index 06462d7e5a4..28e6c1228fb 100644 --- a/plugins/trace_api_plugin/abi_data_handler.cpp +++ b/plugins/trace_api_plugin/abi_data_handler.cpp @@ -27,12 +27,16 @@ namespace eosio::trace_api { }; return std::visit([&](auto &&action) -> std::tuple> { using T = std::decay_t; - if constexpr (std::is_same_v) { - return {serializer_p->binary_to_variant(type_name, action.data, abi_yield), {}}; - } else { - return {serializer_p->binary_to_variant(type_name, action.data, abi_yield), - {serializer_p->binary_to_variant(type_name, action.return_value, abi_yield)}}; + std::optional ret_data; + auto params = serializer_p->binary_to_variant(type_name, action.data, abi_yield); + if constexpr (std::is_same_v) { + // if there is no return data, an exception will be thrown, so catch it here + try { + ret_data = serializer_p->binary_to_variant(type_name, action.return_value, abi_yield); + } + catch(...) { } } + return {params, ret_data}; }, action); } catch (...) { except_handler(MAKE_EXCEPTION_WITH_CONTEXT(std::current_exception())); diff --git a/tests/trace_plugin_test.py b/tests/trace_plugin_test.py index 9b0e7fd2318..119717fa51c 100755 --- a/tests/trace_plugin_test.py +++ b/tests/trace_plugin_test.py @@ -2,6 +2,7 @@ import json import time import unittest +import os from testUtils import Utils from Cluster import Cluster @@ -29,7 +30,8 @@ def cleanEnv(self, shouldCleanup: bool) : # start keosd and nodeos def startEnv(self) : account_names = ["alice", "bob", "charlie"] - traceNodeosArgs = " --plugin eosio::trace_api_plugin --trace-no-abis --trace-dir=." + abs_path = os.path.abspath(os.getcwd() + '/../unittests/contracts/eosio.token/eosio.token.abi') + traceNodeosArgs = " --plugin eosio::trace_api_plugin --trace-rpc-abi eosio.token=" + abs_path + " --trace-dir=." self.cluster.launch(totalNodes=1, extraNodeosArgs=traceNodeosArgs) self.walletMgr.launch() testWalletName="testwallet" @@ -90,6 +92,15 @@ def test_TraceApi(self) : self.assertIn("id", trx) if (trx["id"] == transId) : isTrxInBlockFromTraceApi = True + self.assertIn('actions', trx) + actions = trx['actions'] + for act in actions: + self.assertIn('params', act) + prms = act['params'] + self.assertIn('from', prms) + self.assertIn('to', prms) + self.assertIn('quantity', prms) + self.assertIn('memo', prms) break self.assertTrue(isTrxInBlockFromTraceApi)