I'm testing the ERC20 standard. I try to send a transaction from an account with balance=0, which should throw an error. I'm trying to catch it.
In my test function, I'm using the following:
contract('erc20 deployed', function(accounts) {
it("should not transfer 1 token from address[0] to address[1]", function(done) {
try{
return erc20Instance.transfer(accounts[1], 1);
should.fail("No error was thrown trying to cheat balance");
}
catch(error){
done();
}
});
});
When I execute it with truffle test I get the following error:
1) Contract: erc20 deployed
should not transfer 1 token from address[0] to address[1]:
Uncaught Error: VM Exception while processing transaction: revert
How can I catch it? My goal is to test the the transfer function, testing that address[0] can not effectively make the transaction.