This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
truffle test
fails to decode custom errors
#5753
Labels
Comments
I see this that I may try out: OpenZeppelin/openzeppelin-test-helpers#180 Nevermind. This wont help. My issue is the custom message is not decoded Before hitting the asserts within the javascript test. |
gnidan
changed the title
VM Exception revert -- Reason given: Custom error (could not decode) in Javascript Tests
Dec 8, 2022
truffle test
fails to decode custom errors
We'll leave this open as an issue related to supporting custom error decoding directly in Thanks again! |
Note to truffle devs: TomiOhl/custom-error-test-helper does basically what you want to do with ganache (doesn't work with hardhat network etc, but for that you could look at their official chai matchers). |
Looking forward this too #4123 💥 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Issue
I have a test which passes using string messages. Ive changed the contract to use custom error messages and get the error "VM Exception revert -- Reason given: Custom error (could not decode)".
Steps to Reproduce
Compile contract
Run test
Case should be able to compare error message
Here is a portion of the test_contract.js
The solidity code which will pass using error strings:
function someFunction(address nftContract, unint256 tokenId) {
// some logic here
require(IERC721(nftContract).ownerOf(tokenId) == msg.sender, "Not owner of nft 721");
// some more logic
}
The new solidity code which does not pass because it cannot decode the custom error message
When running newcontract.sol against the test it will provide the exception error. If I recall correctly, truffle now supports reading custom error codes. But it does not?
Expected Behavior
Custom error message should be read and returned in the test as a pass or fail. Instead it says cannot decode.
Actual Results
What actually happened. Please give examples and support it with screenshots, copied output or error messages.
Environment
truffle version
): 5.6.7node --version
): 14.18.1npm --version
): 8.13.2The text was updated successfully, but these errors were encountered: