-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error string in require is unexpectedly failing the test cases #3971
Comments
Sorry, but this is very hard to debug without the full context. Can you try to slim down the contract to something you can post in full here? |
Also, did you try to run a debugger and see where exactly it fails? |
@chriseth I think the require error messages are getting returned as values. I've ran into the same problem. I created a token where you can map a string to token id. Most of the code is standard but here is the important part:
You can test it live here: https://rinkeby.etherscan.io/address/0xae85aeb0c17abf5df49fe7538ffb275c8804f742#readContract I have created 0 tokens so all UUIDs should not exist. If I try the first function If I try |
Are you sure this is a compiler error and not an error in Etherscans VM implementation? Those They may not check for failed transactions properly and just take the returndata in every case. |
I had to update my backend code to accommodate for this new behavior. Before web3 would throw an error on revert, now it just returns the value. Here is some code that I just ran with the output from my personal Rinkeby geth node:
Output:
|
That really feels like a limitation in web3.js. Can you try it in Remix? |
@chriseth debugger is not working with truffle v4.1.7. It always gives some This is a very random error. It comes to a lot of the places in my contracts repo even when I declare one more variable which has no use still cause the test case failure. One of my colleague comes with the understanding that using the Just I want to confirm with you that this may be the reason, or something else. If yes then I think need to optimize the gas usage because It increases the tx cost too much. If you still think that you need to look up the contract as well please let me know I will send you the contract. |
Any update on this? This is still an issue. |
@kingjerod this really looks like an issue in web3.js. Could you please provide a minimal example to reproduce this issue? |
It is possible, I don't know what library Remix/Etherscan are using. I created this contract for you: https://rinkeby.etherscan.io/address/0xc431b94051b1ec1a454bc427ddc5ff87fd6a69d1#code I added two people, with names "test" and "earth". If I try to look up a name that does not exist like "bob" it returns this If I deploy this contract in Remix on the Javascript VM, it returns the error message properly. Seems to only happen when I deploy the contract to a real network (it also works fine in Truffle tests). |
Note, that Remix uses a browser-based VM which makes it possible to exactly tell if a transaction resulted in a revert or not. On a real chain, The client then needs to figure out if it was a revert (one heuristic is to check if not all gas was used on a failing transaction) and decode the revert data appropriate. I do not think your client does that and tries to decode the revert output as a regular output data of the contract. |
That makes sense. Bummer the clients seem slow to adopt the new features. |
@ChrisChinchilla maybe you want to document this based on my last comment. |
I don't see anything we can do here. |
I am updating the contracts for solidity version v0.4.23. Cause of updating is to write the error strings in the
require
andrevert
for error handling. But somehow when I am adding the error string in some ofrequire
expression, It gets failed in test cases.require
function in the above function cause a failure because of error string, If i remove that error string then it will run fine.Any help is very appreciable
The text was updated successfully, but these errors were encountered: