I want to know if my syntax is correct not how to catch a revert.
the task is: Call bid method from accounts[1] of Auction.sol using auctionInstance and pass itemId=0, count=6 as arguments
it("Should NOT allow to bid more than remaining tokens", function() {
return auctionInstance.bid(itemId[0],count[6],{from:account[1]})
.then(function (result) {
/*
We are testing for a negative condition and hence this particular block will not have executed if our test case was correct. If this part is executed then we throw an error and catch the error to assert false
*/
revert("Failed to check remaining tokens less than count");
}).catch(function (e) {
var a = e.toString();
if(e === "Failed to check remaining tokens less than count") {
assert(false);
} else {
assert(true);
}
})
The project code looks like this I had to complete it that is the code at the top.
//Test Case for checking if the bid is more than the token amount it("Should NOT allow to bid more than remaining tokens", function() { /********** TASK 1: Call bid method from accounts[1] of Auction.sol using auctionInstance and pass itemId=0, count=6 as arguments HINT: To make a function call from account 1 use {from: accounts[1]} as an extra argument ***********/ return // .then(function (result) { /* We are testing for a negative condition and hence this particular block will not have executed if our test case was correct. If this part is executed then we throw an error and catch the error to assert false */ throw("Failed to check remaining tokens less than count"); }).catch(function (e) { var a = e.toString(); if(e === "Failed to check remaining tokens less than count") { /********** TASK 2: This is the error which we had thrown. Should you assert true or false? HINT: Use assert(false) to assert false Use assert(true) to assert true ***********/ // } else { /********** TASK 3: assert the opposite here ***********/ // } }) });