mirror of https://github.com/embarklabs/embark.git
fix conflict in test and provider
This commit is contained in:
parent
5ccd8f6333
commit
a81ed322d1
|
@ -189,7 +189,7 @@ class Cmd {
|
||||||
test() {
|
test() {
|
||||||
program
|
program
|
||||||
.command('test [file]')
|
.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('--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')
|
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn')
|
||||||
.description(__('run tests'))
|
.description(__('run tests'))
|
||||||
|
|
|
@ -17,23 +17,23 @@ class EmbarkSpec extends Base {
|
||||||
self.stats.test.gasUsed = 0;
|
self.stats.test.gasUsed = 0;
|
||||||
|
|
||||||
function onContractReceipt(receipt) {
|
function onContractReceipt(receipt) {
|
||||||
self.stats.totalGasCost += receipt.gasUsed;
|
const fmt = color('bright pass', ' ') +
|
||||||
if (self.gasDetails) {
|
color('suite', ' %s') +
|
||||||
const fmt = color('bright pass', ' ') +
|
color('light', ' deployed for ') +
|
||||||
color('green', ' %s') +
|
color(self.getGasColor(receipt.gasUsed), '%s') +
|
||||||
' deployed for ' +
|
color('light', ' gas');
|
||||||
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) {
|
function onBlockHeader(blockHeader) {
|
||||||
self.stats.totalGasCost += blockHeader.gasUsed;
|
self.stats.totalGasCost += blockHeader.gasUsed;
|
||||||
self.stats.test.gasUsed += 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);
|
self.embarkEvents.on("block:header", onBlockHeader);
|
||||||
|
|
||||||
function indent() {
|
function indent() {
|
||||||
|
@ -94,10 +94,10 @@ class EmbarkSpec extends Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
getGasColor(gasCost) {
|
getGasColor(gasCost) {
|
||||||
if (gasCost <= this.gasLimit/10) {
|
if (gasCost <= this.gasLimit / 10) {
|
||||||
return 'fast';
|
return 'fast';
|
||||||
}
|
}
|
||||||
if (gasCost <= 3 * (this.gasLimit/4)) {
|
if (gasCost <= 3 * (this.gasLimit / 4)) {
|
||||||
return 'medium';
|
return 'medium';
|
||||||
}
|
}
|
||||||
return 'slow';
|
return 'slow';
|
||||||
|
|
|
@ -45,6 +45,7 @@ class Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
initWeb3Provider(callback) {
|
initWeb3Provider(callback) {
|
||||||
|
const self = this;
|
||||||
if (this.provider) {
|
if (this.provider) {
|
||||||
this.provider.stop();
|
this.provider.stop();
|
||||||
}
|
}
|
||||||
|
@ -71,8 +72,13 @@ class Test {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.provider = new Provider(providerOptions);
|
return self.provider.startWeb3Provider((err) => {
|
||||||
this.provider.startWeb3Provider(callback);
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
self.subscribeToPendingTransactions();
|
||||||
|
callback();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue