I am trying to do some gas transaction cost calculations in a karma test to assert the final balance and I can not understand why the output of this two code snippets is different
Values for variables in order are:
59916559960000000000 3000000000000000000 394980000000000
And the snippets are:
let currentBalance = web3.utils.fromWei(customerBalance.toString(), 'ether')
+ web3.utils.fromWei(customerRefundableEther.toString(), 'ether')
- web3.utils.fromWei(transactionFee.toString(), 'ether');
let currentBalance = (customerBalance / 1e18)
+(customerRefundableEther / 1e18)
- (transactionFee / 1e18);
The second snippet is the correct balance at the user account and the assert is successful. Is not the conversion from wei to ether: value / 1e18?. I can't understand why but the difference between this snippets are more than 3 ether units.
I am using web3 version 1.0.0-beta26.