Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mandos: decoding error when dumping the state after sending esdt #101

Open
jacobleygonie opened this issue Feb 3, 2022 · 3 comments
Open
Assignees

Comments

@jacobleygonie
Copy link

I am having decoding errors in mandos tests when dumping the state after sending an ESDT token to a contract. Currently using elrond-wasm v0.27.2. The error is not triggered when sending EGLD to the contract.

Below is an example of contract+test triggering the error:

The Smart Contract

#![no_std]
elrond_wasm::imports!();
elrond_wasm::derive_imports!();

#[elrond_wasm::contract]
pub trait Test {

  #[init]
  fn init(&self) {}

  #[payable(“*”)]
  #[endpoint(AcceptPayment)]
  fn accept_payment(&self) {}
}

The Test (dumpState at the end)

{
  "name": "bug dumpState",
  "steps": [
    {
      "step": "setState",
      "accounts": {
        "address:user": {
          "balance": "1,000",
          "esdt": {
            "str:TOKENA-abcdef": "100"
          }
        },
        "sc:contract": {
          "code": "file:../sc-test/output/arda-test.wasm",
          "owner": "address:user"
        }
      }
    },
    {
      "step": "scCall",
      "txId": "SendTokenToContract",
      "tx": {
        "from": "address:user",
        "to": "sc:contract",
        "esdtValue": {
          "tokenIdentifier": "str:TOKENA-abcdef",
          "value": "100"
        },
        "function": "AcceptPayment",
        "gasLimit": "1,000,000,000",
        "gasPrice": "0"
      }
    },
    { "step": "dumpState" }
  ]
}

The Error

INFO:myprocess:run_process: ['/Users/jacobleygonie/elrondsdk/vmtools/mandos-test', '/Users/jacobleygonie/Dropbox/Mon Mac (pse-senik)/Desktop/arda-sc/test/mandos'], in folder: None
Traceback (most recent call last):
  File "/Users/jacobleygonie/elrondsdk/erdpy", line 8, in <module>
    sys.exit(main())
  File "/Users/jacobleygonie/elrondsdk/erdpy-venv/lib/python3.9/site-packages/erdpy/cli.py", line 32, in main
    _do_main()
  File "/Users/jacobleygonie/elrondsdk/erdpy-venv/lib/python3.9/site-packages/erdpy/cli.py", line 58, in _do_main
    args.func(args)
  File "/Users/jacobleygonie/elrondsdk/erdpy-venv/lib/python3.9/site-packages/erdpy/cli_contracts.py", line 186, in run_tests
    projects.run_tests(args)
  File "/Users/jacobleygonie/elrondsdk/erdpy-venv/lib/python3.9/site-packages/erdpy/projects/core.py", line 65, in run_tests
    project.run_tests(directory, wildcard)
  File "/Users/jacobleygonie/elrondsdk/erdpy-venv/lib/python3.9/site-packages/erdpy/projects/project_base.py", line 105, in run_tests
    myprocess.run_process(args, env=tool_env)
  File "/Users/jacobleygonie/elrondsdk/erdpy-venv/lib/python3.9/site-packages/erdpy/myprocess.py", line 19, in run_process
    output = subprocess.check_output(args, shell=False, universal_newlines=True, stderr=subprocess.STDOUT, env=env, cwd=cwd)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 507, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1121, in communicate
    stdout = self.stdout.read()
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 651: invalid start byte
@Alex1304
Copy link

Alex1304 commented Mar 1, 2022

I get the same error but it is not specific to dumpState, sometimes checkState does it too. It's really annoying.

@andreibancioiu andreibancioiu self-assigned this Mar 2, 2022
@andreibancioiu
Copy link
Contributor

andreibancioiu commented Mar 2, 2022

@jacobleygonie, @Alex1304, thank you for reporting the issue 🙏

Mandos is writing non-printable characters in the stdout, in this case. E.g.

Scenario: adder.scen.json ... world state dump: 
{
    "address:user": {
        "nonce": "1",
        "balance": "1000",
        "esdt": {
            "str:TOKENA-abcdef": {
                "instances": [
                    {
                        "nonce": "0",
                        "balance": "100"
                    }
                ],
                "lastNonce": "0"
            }
        }
    },
    "sc:contract": {
        "nonce": "0",
        "balance": "0",
        "owner": "address:user"
    },     
    "address:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff#ff": {
        "nonce": "0",
        "balance": "0"
    }
}

We are working on a fix.

@mingles
Copy link

mingles commented Jun 29, 2022

Any updates on this? It's pretty grizzly writing these tests without this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants