I am creating a test.js for my smart contract. I forgot to use "toNumber" while testing some uint variables to be equal in some cases and it executed without any error. So in what all cases do we actually need to use "toNumber".

    //   const address = await dstock.address
    //   oldBalanceContract = await address.balance
    //   {calling a function that alters contract balance
    //   newBalanceContract = await address.balance
    //   difference = newBalanceContract - oldBalanceContract
    //   assert.equal(difference,5000000000000000,"Value should be added to contracts worth")
  • I'd recommend to use OpenZeppelin Test Helpers. They provide a way to easily wrapp BigNumber in javascript and make comparison with other numbers. – Ismael Jan 10 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.