embark icon indicating copy to clipboard operation
embark copied to clipboard

gas counter in test sums deploy cost to first transaction

Open 3esmit opened this issue 5 years ago • 3 comments

The gas is counted incorrect in the first time .send() is invoked, because it also sums the cost of deploy the transaction.

I had to do a workaround (see https://github.com/status-im/account-contracts/commit/291fd9b872685e66bd7aa02d9ab8b44cc43e6bd8#diff-8ae90872f0505462a211bc1fa2f5f03eR28 ) to show proper gas, which is a transaction to anywhere before doing the other transactions I want to test.

3esmit avatar Jan 26 '20 13:01 3esmit

Just to be sure, you mean the gas counted in the little parenthesizes next to the test name? eg: verifyMultiProof > deploy cost (12345 Wei Gas)

So 12345 is wrong because it adds the cost of deploying the contracts?

jrainville avatar Jan 27 '20 14:01 jrainville

Yes! Exactly. So I am developing something and I got scared that I screw it up because it was too expansive! So I was refactoring until figure out that the problem was with the gas counter, not with my logic.

I would expect that this counter only shows the gas cost into the transactions that occurred within, not what happened before (such as deploying through Embark config): https://github.com/status-im/account-contracts/blob/40d0d6c8f745299b7ea569cd9f64384d59ac570b/test/multimerkleproof.spec.js#L7-L10

This cost is added to the first case of the tests.

3esmit avatar Jan 27 '20 15:01 3esmit

Yeah you are totally right, it's a mistake on our part.

We'll fix it soon:tm:

Thanks for reporting it!

jrainville avatar Jan 27 '20 15:01 jrainville