I'm checking the balance of an account after a
payable transaction in a Truffle test. Below is my code:
// amount is the value supplied to the txn assert.equal(Number(String(currentBalance)), Number(String(previousBalance)) + amount - (gasUsed * 100000000000), 'Account balance for ' + String(acct) + ' incorrect after txn.'); // previous account bal: 99965457999999999000 // current account bal: 99954881999999998000 // gasUsed: 105760 // amount: 1000
As you can see, I have to multiply the
gasUsed value by
10^11 or my test will fail... I don't really understand why it's
10^11? GWEI (
10^9) makes a lot more sense. At least a multiple of 3 right? This isn't in the web3 documentation at all.
EDIT: to clarify I'm trying to figure out what
gasUsed is and if web3 or Truffle are overwriting the default gas price. The gas price according to my Ganache interface is 20000000000, which doesn't work with my calculations. That's why I was lead to believe
gasUsed is the total txn fee in wei.