I've a contract under test and the method I'm checking is supposed to transfer an amount, and in order to check I need to have the cost of the transaction. I'm using this code:
var tx = await instance.withdraw(web3.toWei(25,"finney")); console.log(tx); let ownerBalanceAfter = await web3.eth.getBalance(accounts); assert.equal(ownerBalanceAfter-ownerBalance,web3.toWei(25,"finney")-web3.eth.gasPrice.mul(tx.receipt.gasUsed)); //withdraw done
The test fails with some unexpected small difference, even if I apparently try to compute the gas cost.
Internally the method call transfer(address), that I know it consumes other gas, but shouldn't this be counted in the
So what is wrong in my balance computation?