fix conflict in test and provider

This commit is contained in:
Jonathan Rainville 2018-07-06 15:16:04 -04:00 committed by Iuri Matias
parent 5ccd8f6333
commit a81ed322d1
3 changed files with 21 additions and 15 deletions

View File

@ -189,7 +189,7 @@ class Cmd {
test() {
program
.command('test [file]')
.option('-d , --gasDetails', __('When set, will print the gas cost for each contract'))
.option('-d , --gasDetails', __('When set, will print the gas cost for each contract deploy'))
.option('--locale [locale]', __('language to use (default: en)'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn')
.description(__('run tests'))

View File

@ -17,23 +17,23 @@ class EmbarkSpec extends Base {
self.stats.test.gasUsed = 0;
function onContractReceipt(receipt) {
self.stats.totalGasCost += receipt.gasUsed;
if (self.gasDetails) {
const fmt = color('bright pass', ' ') +
color('green', ' %s') +
' deployed for ' +
color(self.getGasColor(receipt.gasUsed), '%s') +
color('light', ' gas');
const fmt = color('bright pass', ' ') +
color('suite', ' %s') +
color('light', ' deployed for ') +
color(self.getGasColor(receipt.gasUsed), '%s') +
color('light', ' gas');
console.log(fmt, receipt.className, receipt.gasUsed);
}
console.log(fmt, receipt.className, receipt.gasUsed);
}
function onBlockHeader(blockHeader) {
self.stats.totalGasCost += blockHeader.gasUsed;
self.stats.test.gasUsed += blockHeader.gasUsed;
}
self.embarkEvents.on("deploy:contract:receipt", onContractReceipt);
if (self.gasDetails) {
self.embarkEvents.on("deploy:contract:receipt", onContractReceipt);
}
self.embarkEvents.on("block:header", onBlockHeader);
function indent() {
@ -94,10 +94,10 @@ class EmbarkSpec extends Base {
}
getGasColor(gasCost) {
if (gasCost <= this.gasLimit/10) {
if (gasCost <= this.gasLimit / 10) {
return 'fast';
}
if (gasCost <= 3 * (this.gasLimit/4)) {
if (gasCost <= 3 * (this.gasLimit / 4)) {
return 'medium';
}
return 'slow';

View File

@ -45,6 +45,7 @@ class Test {
}
initWeb3Provider(callback) {
const self = this;
if (this.provider) {
this.provider.stop();
}
@ -71,8 +72,13 @@ class Test {
return callback(err);
}
this.provider = new Provider(providerOptions);
this.provider.startWeb3Provider(callback);
return self.provider.startWeb3Provider((err) => {
if (err) {
return callback(err);
}
self.subscribeToPendingTransactions();
callback();
});
});
}