Merge pull request #851 from embark-framework/bugfix/gasPrice-with-coverage
Gas Price not modified by coverage
This commit is contained in:
commit
11828c3086
|
@ -7,6 +7,7 @@ class EmbarkSpec extends Base {
|
|||
super(runner, options);
|
||||
|
||||
const self = this;
|
||||
self.listenForGas = true;
|
||||
self.embarkEvents = options.reporterOptions.events;
|
||||
self.gasDetails = options.reporterOptions.gasDetails;
|
||||
self.gasLimit = options.reporterOptions.gasLimit;
|
||||
|
@ -27,6 +28,9 @@ class EmbarkSpec extends Base {
|
|||
}
|
||||
|
||||
function onBlockHeader(blockHeader) {
|
||||
if(!self.listenForGas) {
|
||||
return;
|
||||
}
|
||||
self.stats.totalGasCost += blockHeader.gasUsed;
|
||||
self.stats.test.gasUsed += blockHeader.gasUsed;
|
||||
}
|
||||
|
@ -35,6 +39,9 @@ class EmbarkSpec extends Base {
|
|||
self.embarkEvents.on("deploy:contract:receipt", onContractReceipt);
|
||||
}
|
||||
self.embarkEvents.on("block:header", onBlockHeader);
|
||||
self.embarkEvents.setCommandHandler("reporter:toggleGasListener", () => {
|
||||
self.listenForGas = !self.listenForGas;
|
||||
});
|
||||
|
||||
function indent() {
|
||||
return Array(indents).join(' ');
|
||||
|
|
|
@ -61,7 +61,7 @@ module.exports = {
|
|||
},
|
||||
function setupGlobalNamespace(files, next) {
|
||||
// TODO put default config
|
||||
const test = new Test({loglevel, node: options.node});
|
||||
const test = new Test({loglevel, node: options.node, coverage: options.coverage});
|
||||
global.embark = test;
|
||||
global.assert = assert;
|
||||
global.config = test.config.bind(test);
|
||||
|
@ -105,6 +105,7 @@ module.exports = {
|
|||
gasDetails: options.gasDetails,
|
||||
gasLimit: 6000000
|
||||
});
|
||||
|
||||
mocha.addFile(file);
|
||||
|
||||
mocha.suite.timeout(0);
|
||||
|
|
|
@ -102,6 +102,7 @@ class Test {
|
|||
|
||||
let simProvider = this.sim.provider(this.simOptions);
|
||||
|
||||
if (this.options.coverage) {
|
||||
// Here we patch the sendAsync method on the provider. The goal behind this is to force pure/constant/view calls to become
|
||||
// transactions, so that we can pull in execution traces and account for those executions in code coverage.
|
||||
//
|
||||
|
@ -117,7 +118,7 @@ class Test {
|
|||
if(payload.method !== 'eth_call') {
|
||||
return simProvider.realSendAsync(payload, cb);
|
||||
}
|
||||
|
||||
self.engine.events.request('reporter:toggleGasListener');
|
||||
let newParams = Object.assign({}, payload.params[0], {gasPrice: '0x77359400'});
|
||||
let newPayload = {
|
||||
id: payload.id + 1,
|
||||
|
@ -129,10 +130,12 @@ class Test {
|
|||
simProvider.realSendAsync(newPayload, (_err, response) => {
|
||||
let txHash = response.result;
|
||||
self.web3.eth.getTransactionReceipt(txHash, (_err, _res) => {
|
||||
self.engine.events.request('reporter:toggleGasListener');
|
||||
simProvider.realSendAsync(payload, cb);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.web3.setProvider(simProvider);
|
||||
callback();
|
||||
|
|
Loading…
Reference in New Issue