brownie icon indicating copy to clipboard operation
brownie copied to clipboard

Bytes array not parsed elegantly

Open illuzen opened this issue 2 years ago • 0 comments

Environment information

  • brownie Version: 1.18.1
  • ganache-cli Version: 6.12.2
  • solc Version: 0.8.15
  • Python Version: 3.9.2
  • OS: linux

So I have a solidity function that looks like this:

function checkUpkeep(bytes calldata tournamentIdBytes) external view override returns (bool upkeepNeeded, bytes memory performData) {
        uint tournamentId = abi.decode(tournamentIdBytes, (uint));
...
}

And I call it from brownie tests like this

tournamentIdBytes = '0x0000000000000000000000000000000000000000000000000000000000000001'
needs_upkeep, performData = markets.checkUpkeep(tournamentIdBytes)

This works. However if I do something like

tournamentIdBytes = '0x01'
needs_upkeep, performData = markets.checkUpkeep(tournamentIdBytes)

I get a hard-to-debug error

E brownie.exceptions.VirtualMachineError: revert

I don't know exactly what the right solution is here, but it seems like brownie should pad the zeros or something...

illuzen avatar Jun 27 '22 09:06 illuzen