hedera-json-rpc-relay
hedera-json-rpc-relay copied to clipboard
Allow for clients to assert expected revert messages
Currently the following syntax:
await expect(contract.connect(spenderWallet).transferFrom(tokenOwner, to, amount))
.to.be.revertedWith('ERC20: transfer amount exceeds balance');
will not catch the error properly and will evaluate that the transaction was successful, however the transaction indeed reverts.
We are using custom expectReverts in the acceptance tests right now, but we should change that and use the waffle provided asserts as relay clients will be using those libraries.
There is potential inconsistency bug given that existing tooling cannot parse the transaction as failed using the expect.to.be.reverted syntax
https://testnet.mirrornode.hedera.com/api/v1/contracts/results/0.0.29631749-1656082936-152570528 -> error_message: ``` 0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001564732d6d6174682d7375622d756e646572666c6f770000000000000000000000 0x08c379a0 <- error signature 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001564732d6d6174682d7375622d756e646572666c6f770000000000000000000000 <- hex error message 0000000000000000000000000000000000000000000000000000000000000020 <- argument 1 0000000000000000000000000000000000000000000000000000000000000015 <- count of symbols in error message 64732d6d6174682d7375622d756e646572666c6f770000000000000000000000 <- error message in hex ds-math-sub-underflow <- hex of error message to utf8
The observed behaviour is the same as in the public Ethereum networks. In order for this kind of assert to work sendRawTransaction will need to be modified to return the transaction receipt on success and to throw an error on failiure, instead of returning a computed hash. This could be enabled with a feature flag so it would be possible to assert error messages when using hardhat-hedera-plugin for development.
With support for HIP 584 this should be resolved as eth_estimateGas no thrown errors if the occur
@Ivo-Yankov noted this is resolved