Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

fix bug in trace_api_plugin no params returned GH issue 10435 / EPE 1066 https://github.com/EOSIO/eos/issues/10435 #10449

Merged
merged 4 commits into from
Jun 23, 2021
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
14 changes: 9 additions & 5 deletions plugins/trace_api_plugin/abi_data_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ namespace eosio::trace_api {
};
return std::visit([&](auto &&action) -> std::tuple<fc::variant, std::optional<fc::variant>> {
using T = std::decay_t<decltype(action)>;
if constexpr (std::is_same_v<T, action_trace_v0>) {
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<fc::variant> ret_data;
auto params = serializer_p->binary_to_variant(type_name, action.data, abi_yield);
if constexpr (std::is_same_v<T, action_trace_v1>) {
// 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()));
Expand Down
13 changes: 12 additions & 1 deletion tests/trace_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import time
import unittest
import os

from testUtils import Utils
from Cluster import Cluster
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down