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

Test gives wrong indication I guess #46

Open
tschnoelzer opened this issue May 14, 2021 · 1 comment
Open

Test gives wrong indication I guess #46

tschnoelzer opened this issue May 14, 2021 · 1 comment

Comments

@tschnoelzer
Copy link

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

@vinaykharayat
Copy link

vinaykharayat commented Jan 24, 2022

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)

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

2 participants