Open tschnoelzer opened 3 years ago
Same question @gwmccubbin.
You wrote this code
return tokenSaleInstance.buyTokens(800000, { from: buyer, value: numberOfTokens * tokenPrice })
But I think it should be
return tokenSaleInstance.buyTokens(800000)
Hi Gregory,
you are testing bytoken and checking for error:
return tokenSaleInstance.buyTokens(800000, { from: buyer, value: numberOfTokens * tokenPrice }) }).then(assert.fail).catch(function(error) { assert(error.message.indexOf('revert') >= 0, 'cannot purchase more tokens than available');
As the function checks msg.value as numberOfTokens times price first and you are passing 800.000 as product, I think the raised error comes from incorrect product instead of checked "tokens available" ... am I wrong?
require(msg.value == multiply(_numberOfTokens, tokenPrice)); require(tokenContract.balanceOf(this) >= _numberOfTokens);
best
Timo