eosfactory icon indicating copy to clipboard operation
eosfactory copied to clipboard

KeyError: 'inline_traces' thrown from gather_console_output function in cleos.py

Open calebmcelroy opened this issue 4 years ago • 1 comments

My Environment: OSX 10.14.6 eosio 2.0.3 eosio.cdt 1.7.0 Python 3.7.4 EOSFactory v3.4.0

Backstory: The code used to produce this error can be found at https://github.com/flair-app/smart-contract. It was working when I was using EOSIO v1.8.0 & eosio.cdt v1.6.1, but just updated to eosio 2.0.3 & eosio.cdt 1.7.0 and it started producing this error.

======================================================================
ERROR: test_edit_profile_modifies_table_when_user_auth (__main__.ProfileActionsUnitTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_profile_actions.py", line 289, in test_edit_profile_modifies_table_when_user_auth
    permission=(HOST, Permission.ACTIVE)
  File "/Users/calebmcelroy/Dev/eosfactory/eosfactory/shell/account.py", line 321, in push_action
    is_verbose=False, json=True)
  File "/Users/calebmcelroy/Dev/eosfactory/eosfactory/core/cleos.py", line 712, in __init__
    self.console += gather_console_output(act)
  File "/Users/calebmcelroy/Dev/eosfactory/eosfactory/core/cleos.py", line 732, in gather_console_output
    for inline in act["inline_traces"]:
KeyError: 'inline_traces'

Reproducing the error:

git clone https://github.com/flair-app/smart-contract.git flair-smart-contract
cd flair-smart-contract/tests
python3 test_profile_actions.py ProfileActionsUnitTest.test_edit_profile_modifies_table_when_user_auth

My solution: Modifying gather_console_output within core/cleos.py to check if that key exists seems to have fixed it. Though, I'm not sure what "inline_traces" actually contains, maybe output of inline actions? If that is the case, I'm not using inline actions.

def gather_console_output(act, padding=""):
    PADDING = "  "
    console = ""
    if len(act["console"]) > 0:
        console += padding + act["act"]["account"] + "@" + act["act"]["name"] + ":\n"
        console += padding + act["console"].replace("\n", "\n" + padding) + "\n"

    if 'inline_traces' in act and isinstance(act["inline_traces"], list):
        for inline in act["inline_traces"]:
            console += gather_console_output(inline, padding + PADDING)
    return (console + "\n").rstrip()

Thanks for this package it's been very useful!

calebmcelroy avatar Mar 12 '20 13:03 calebmcelroy

Well done and thanks, it helped me as well. Do you know if the framework is still actively worked on, can you actually use it for production ?

RAPHAELSTZ avatar Mar 08 '21 08:03 RAPHAELSTZ