Skip to content
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

can't catch the error "Error: VM Exception while processing transaction: revert" #668

Closed
leochan007 opened this issue Jan 11, 2018 · 4 comments

Comments

@leochan007
Copy link

leochan007 commented Jan 11, 2018

The Problem

this error can't be caught by expectThrow if execute "web3.eth.sendTransaction" (not contract'call or transaction)

e.g.
expectThrow(web3.eth.sendTransaction({gas: gas_amt, from: accounts[1], to: AAA.address,
value: web3.toWei("1", "Ether")}, ""))

@Stradivario
Copy link

Having the same issue as you described....

screenshot from 2018-01-14 16-09-33

@leochan007
Copy link
Author

@Stradivario yes. if the vm exception is from Contract's function call, it could be caught via expectThrow. and i don't know why.

@Stradivario
Copy link

Take a look here i create issue related with this bug trufflesuite/truffle#748

@frangio
Copy link
Contributor

frangio commented Jan 16, 2018

Hello @Stradivario. The argument to expectThrow should be a Promise as returned by truffle-contract function calls. The reason expectThrow is not working here is that web3.eth.sendTransaction returns a string containing the tx hash.

In order to use expectThrow here, you should probably do the following, as seen in the Truffle documentation.

expectThrow(AAA.send(web3.toWei(1, "ether"), { gas: gas_amt, from: accounts[1] }))

@frangio frangio closed this as completed Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants