foundry
foundry copied to clipboard
Custom errors are not decoded (hex shown)
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (d431f74 2024-04-27T00:16:52.929844000Z)
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
I would like to reopen the issue from here https://github.com/foundry-rs/foundry/issues/6579
I am not sure if the issue has been fixed because I am also getting hexadecimal custom errors.
To recreate the bug, please go to this repo here and use the command ->
forge test --match-path test/scWETHv2.base.t.sol --match-test test_invest_basic -vv
#6579 was done for custom errors within setup, will check the scenario you hit
yep, I managed to recreate with the project above, the error is ErrorNotEnoughBalance
thrown by the ERC20Bridged
contract https://basescan.org/address/0x69ce2505CE515C0203160450157366F927243309 which is not an artifact created during test so the abi to properly decode error is not available - you can check this by for example adding error ErrorNotEnoughBalance();
in contract PriceConverter
which is created during test run, it will output
Failing tests:
Encountered 1 failing test in test/scWETHv2.base.t.sol:scWETHv2Base
[FAIL. Reason: ErrorNotEnoughBalance()] test_invest_basic() (gas: 852945)
yep, I managed to recreate with the project above, the error is
ErrorNotEnoughBalance
thrown by theERC20Bridged
contract https://basescan.org/address/0x69ce2505CE515C0203160450157366F927243309 which is not an artifact created during test so the abi to properly decode error is not available - you can check this by for example addingerror ErrorNotEnoughBalance();
incontract PriceConverter
which is created during test run, it will outputFailing tests: Encountered 1 failing test in test/scWETHv2.base.t.sol:scWETHv2Base [FAIL. Reason: ErrorNotEnoughBalance()] test_invest_basic() (gas: 852945)
I see. Thank you so much. Can you please tell me how did you decode the error is ErrorNotEnoughBalance() from the hex code please? That was really amazing.
I took the code for failing contract and run forge inspect errors
on it, see https://book.getfoundry.sh/reference/cli/forge/inspect?#forge-inspect
You can also use forge selectors list
https://book.getfoundry.sh/reference/cli/forge/selectors/list
(to get the code you can use forge clone
or cast etherscan
to download from verified contracts but you could only get the errors from failing contract, put in a local contract and run the command against)
I took the code for failing contract and run
forge inspect errors
on it, see https://book.getfoundry.sh/reference/cli/forge/inspect?#forge-inspect You can also useforge selectors list
https://book.getfoundry.sh/reference/cli/forge/selectors/list(to get the code you can use
forge clone
orcast etherscan
to download from verified contracts but you could only get the errors from failing contract, put in a local contract and run the command against)
So cooooooooollll. Thank you so much man. That was very helpful.