tokenika / eosfactory

Python-based EOS smart-contract development & testing framework
http://eosfactory.io/
Other
243 stars 62 forks source link

Not receiving console output with force unique #154

Closed ysoftware closed 5 years ago

ysoftware commented 5 years ago

When using force_unique with push_action, first action in a transaction is (for example) eosio.null <= eosio.null::nonce "6b1f4ff8e2870500"

eosfactory usually takes console output from the first action_trace but I think it should loop through all of them to gather the complete picture. It will also be helpful while debugging and testing nested inline actions.

stefanzarembinski commented 5 years ago

Thank you for the suggestion. I will take it.

stefanzarembinski commented 5 years ago

The PR is included into the release 3.1.1.

With the following test script:

# .............................................................................

HOST.push_action(
    "create",
    {
        "issuer": MASTER,
        "maximum_supply": "1000000000.0000 EOS",
        "can_freeze": "0",
        "can_recall": "0",
        "can_whitelist": "0"
    },
    force_unique=True,
    permission=[(MASTER, Permission.ACTIVE), (HOST, Permission.ACTIVE)])
logger.DEBUG(HOST.action.act)

HOST.push_action(
    "issue",
    {
        "to": ALICE, "quantity": "100.0000 EOS", "memo": ""
    },
    force_unique=True,
    permission=(MASTER, Permission.ACTIVE))
logger.DEBUG(HOST.action.act)

#..............................................................................

It results in the

* push action ``create``:
{"issuer": "eosio", "maximum_supply": "1000000000.0000 EOS", "can_freeze": "0", "can_recall": "0", "can_whitelist": "0"}
eosio.null <= eosio.null::nonce 335ed53171880500
HOST <= HOST::create {'issuer': 'eosio', 'maximum_supply': '1000000000.0000 EOS'}
* push action ``issue``:
{"to": "ALICE", "quantity": "100.0000 EOS", "memo": ""}
eosio.null <= eosio.null::nonce 8c7fd73171880500
HOST <= HOST::issue {'to': 'ALICE', 'quantity': '100.0000 EOS', 'memo': ''}

Is it what you have expected?

ysoftware commented 5 years ago

Is it what you have expected?

Not quite. Can you look at #155 ? I created that PR with the fix. You can better understand what's going on in there.

ysoftware commented 5 years ago

At the very least, in your logs I don't see any console output. (although looking at your code, that is exactly what you did and it should work)

stefanzarembinski commented 5 years ago

The PR is included into the release 3.1.1.

I have seen the PR. You want to collect the trace["console"] items...

self.console = ""
    for trace in self.json["processed"]["action_traces"]:
        self.console += trace["console"]

... and it is done so. But the console thing is empty, for me, as it comes from the blockchain. In my opinion, it contains the output from the print function in the source code.

If the test script is ...

HOST.push_action(
    "create",
    {
        "issuer": MASTER,
        "maximum_supply": "1000000000.0000 EOS",
        "can_freeze": "0",
        "can_recall": "0",
        "can_whitelist": "0"
    },
    force_unique=True,
    permission=[(MASTER, Permission.ACTIVE), (HOST, Permission.ACTIVE)])
print("'trace[\"console\"]' sum is '{}'".format(HOST.action.console))
logger.DEBUG(HOST.action.act)

HOST.push_action(
    "issue",
    {
        "to": ALICE, "quantity": "100.0000 EOS", "memo": ""
    },
    force_unique=True,
    permission=(MASTER, Permission.ACTIVE))
print("'trace[\"console\"]' sum is '{}'".format(HOST.action.console))
logger.DEBUG(HOST.action.act)

... the output is

* push action ``create``:
{"issuer": "eosio", "maximum_supply": "1000000000.0000 EOS", "can_freeze": "0", "can_recall": "0", "can_whitelist": "0"}
'trace["console"]' sum is ''
eosio.null <= eosio.null::nonce d99d361572880500
HOST <= HOST::create {'issuer': 'eosio', 'maximum_supply': '1000000000.0000 EOS'}
* push action ``issue``:
{"to": "ALICE", "quantity": "100.0000 EOS", "memo": ""}
'trace["console"]' sum is ''
eosio.null <= eosio.null::nonce 76b3381572880500
HOST <= HOST::issue {'to': 'ALICE', 'quantity': '100.0000 EOS', 'memo': ''}