I've been using truffle for unit testing and I can't find a way to execute two excludent tests. I mean, I'm creating an ICO contract and my tests depend on lower and upper cap limit, start and end blocks. Sometimes when I execute a series of tests I would need to restart the blockchain (of course only possible in dev chain) to be able to execute the other tests and I don't know how to do this or if this is possible.
I'm using truffle + testrpc for unit testing.
Here is one example of two tests that can't happen at the same test flow:
it("User trying to send eth after max pre ico cap reached by last user", function () {
return AuctusPreIco.deployed().then(function (instance) {
// send a 5 eth transaction from user test account to contract
var account = web3.eth.accounts[3]
return instance.sendTransaction({ from: account, value: web3.toWei(3, "ether") })
.then(assert.fail)
.catch(function (error) {
if (invalidOpCodeException(error)) {
assert(
true, 'max cap reached. Can\'t send more eth to contract.'
)
}
else {
unexceptedException(error)
}
})
})
})
and
it("Sending eth after ico max block limit", function () {
return AuctusPreIco.deployed().then(function (instance) {
// send a 5 eth transaction from user test account to contract
var account = web3.eth.accounts[4]
return instance.revoke({from: account})
.then(assert.fail)
.catch(function (error) {
if (invalidOpCodeException(error)) {
assert(
true, 'revoke not allowed yet'
)
}
else {
unexceptedException(error)
}
})
})
})
So, I don't know if I was clear enough, but if the max cap was already reached, the second test that tests if it will fail because of the max block limit wouldn't throw anyway.
How can I deal with this scenario? I want to execute all tests in a row.