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

Arithmetic performed on String results of toWei in Lottery.test.js #3

Open
samsidx opened this issue Mar 28, 2018 · 0 comments
Open

Comments

@samsidx
Copy link

samsidx commented Mar 28, 2018

Following code in Lotter.test.js should explicitly convert output of web3.utils.toWei to int as parseInt(await web3.utils.toWei('0.01', 'ether'). I understand the type casting implicit conversion but for pedagogical purpose above seems more helpful.

it('sends money to the winner and resets the players array', async () => {
    await lottery.methods.enter().send({
      from: accounts[0],
      value: web3.utils.toWei('2', 'ether')
    });

    const initialBalance = await web3.eth.getBalance(accounts[0]);
    await lottery.methods.pickWinner().send({ from: accounts[0] });
    const finalBalance = await web3.eth.getBalance(accounts[0]);
    const difference = finalBalance - initialBalance;

    assert(difference > web3.utils.toWei('1.8', 'ether'));
  });
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

1 participant