Lesson 7 - 11:36 - Why are we adding gasCost to the endingDeployerBalance? #272
-
In this test case, could someone please explain why the is "deployer" getting the gasCost? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Whoever calls the transaction, pays the gas costs associated with it. In this function, we are calling the Take this scenario.
If the 1 + 1 = 2 ETH... but they also paid the gas of calling the So they would have 1 + 1 - (gascosts) = ~1.9(ish) In our tests, we want to account for the gas costs to make it accurate. So, following our example, if you take the test: assert.equal(
//BigNumber.add() function is better to perform math operations, makes it easier
startingFundMeBalance.add(startingDeployerBalance),
endingDeployerBalance.add(gasCost).toString()
)We are saying that: Does this make sense? |
Beta Was this translation helpful? Give feedback.
Whoever calls the transaction, pays the gas costs associated with it. In this function, we are calling the
withdrawfunction.Take this scenario.
deployeraddress has 1 ETHFundMecontract has 1 ETHIf the
deployeraddress calls thewithdrawfunction and pulls the 1 ETH out of theFundMecontract, how much ETH will they have?1 + 1 = 2 ETH... but they also paid the gas of calling the
withdrawfunction.So they would have 1 + 1 - (gascosts) = ~1.9(ish)
In our tests, we want to account for the gas costs to make it accurate.
So, following our example, if you take the test: