hedera-json-rpc-relay icon indicating copy to clipboard operation
hedera-json-rpc-relay copied to clipboard

Allow for clients to assert expected revert messages

Open Daniel-K-Ivanov opened this issue 3 years ago • 3 comments
trafficstars

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

Daniel-K-Ivanov avatar Jun 28 '22 16:06 Daniel-K-Ivanov

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

Kalina-Todorova avatar Jul 01 '22 12:07 Kalina-Todorova

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.

Ivo-Yankov avatar Aug 03 '22 12:08 Ivo-Yankov

With support for HIP 584 this should be resolved as eth_estimateGas no thrown errors if the occur

Nana-EC avatar Apr 17 '24 01:04 Nana-EC

@Ivo-Yankov noted this is resolved

Nana-EC avatar Jul 12 '24 14:07 Nana-EC