Skip to content

Commit

Permalink
We can't measure real gas costs in SC so let's not
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova committed Dec 12, 2017
1 parent e01c685 commit 26b1bfb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions helpers/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ module.exports = {
}
},
async checkAllGasSpent(tx) {
const txid = !tx.tx ? tx : tx.tx;
const transaction = await this.web3GetTransaction(txid);
const receipt = await this.web3GetTransactionReceipt(txid);
const network = await this.web3GetNetwork();

// When a transaction throws, all the gas sent is spent. So let's check that we spent all the gas that we sent.
// When using EtherRouter not all sent gas is spent, it is 73000 gas less than the total.
assert.closeTo(transaction.gas, receipt.gasUsed, 73000, 'didnt fail - didn\'t throw and use all gas');
if (network != "coverage") {
const txid = !tx.tx ? tx : tx.tx;
const transaction = await this.web3GetTransaction(txid);
const receipt = await this.web3GetTransactionReceipt(txid);
// When a transaction throws, all the gas sent is spent. So let's check that we spent all the gas that we sent.
// When using EtherRouter not all sent gas is spent, it is 73000 gas less than the total.
assert.closeTo(transaction.gas, receipt.gasUsed, 73000, 'didnt fail - didn\'t throw and use all gas');
}
},
checkErrorNonPayableFunction(tx) {
assert.equal(tx, 'Error: Cannot send value to non-payable function');
Expand Down

0 comments on commit 26b1bfb

Please sign in to comment.