|
|
|
@ -4,7 +4,7 @@ const path = require('path'); |
|
|
|
|
const istanbul = require('istanbul'); |
|
|
|
|
const util = require('util'); |
|
|
|
|
const assert = require('assert'); |
|
|
|
|
const memdown = require('memdown'); |
|
|
|
|
const pify = require('pify'); |
|
|
|
|
|
|
|
|
|
const Instrumenter = require('./instrumenter'); |
|
|
|
|
const Coverage = require('./coverage'); |
|
|
|
@ -34,7 +34,9 @@ class App { |
|
|
|
|
this.originalContractsDir = config.originalContractsDir |
|
|
|
|
|
|
|
|
|
this.client = config.client; |
|
|
|
|
this.server = null; |
|
|
|
|
this.providerOptions = config.providerOptions || {}; |
|
|
|
|
this.defaultPort = 8777; |
|
|
|
|
|
|
|
|
|
this.skippedFolders = []; |
|
|
|
|
this.skipFiles = config.skipFiles || []; |
|
|
|
@ -124,14 +126,13 @@ class App { |
|
|
|
|
|
|
|
|
|
this.providerOptions.gasLimit = this.gasLimitString; |
|
|
|
|
this.providerOptions.allowUnlimitedContractSize = true; |
|
|
|
|
this.providerOptions.db = memdown(); |
|
|
|
|
this.providerOptions.asyncRequestProcessing = true; |
|
|
|
|
|
|
|
|
|
// Try to launch provider and attach to vm step of
|
|
|
|
|
// either plugin's ganache or a provider passed via options
|
|
|
|
|
try { |
|
|
|
|
this.provider = await this.attachToVM(); |
|
|
|
|
} catch(err){ |
|
|
|
|
console.log('err --> ' + err); |
|
|
|
|
retry = true; |
|
|
|
|
this.ui.report('vm-fail', []) |
|
|
|
|
} |
|
|
|
@ -190,8 +191,8 @@ class App { |
|
|
|
|
shell.rm('-Rf', this.artifactsDir); |
|
|
|
|
|
|
|
|
|
if (this.provider && this.provider.close){ |
|
|
|
|
this.log('Shutting down ganache-core') |
|
|
|
|
return new Promise(res => self.provider.close(res)) |
|
|
|
|
this.log('Shutting down ganache-core.server') |
|
|
|
|
await pify(self.server.close)(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// ------------------------------------------ Utils ----------------------------------------------
|
|
|
|
@ -201,7 +202,9 @@ class App { |
|
|
|
|
// ========
|
|
|
|
|
async attachToVM(){ |
|
|
|
|
const self = this; |
|
|
|
|
const provider = this.client.provider(this.providerOptions); |
|
|
|
|
const port = this.providerOptions.port || this.defaultPort; |
|
|
|
|
this.server = this.client.server(this.providerOptions); |
|
|
|
|
const provider = this.server.provider; |
|
|
|
|
|
|
|
|
|
this.assertHasBlockchain(provider); |
|
|
|
|
|
|
|
|
@ -221,6 +224,7 @@ class App { |
|
|
|
|
return vm; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await pify(this.server.listen)(port); |
|
|
|
|
return provider; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|