Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const prepareCoverage = async (workingDirectory, port, ignoreFiles) => {
let artifactAdapter = new SolCompilerArtifactAdapter(artifacts, workingDirectory);
let coverageSubproviderConfig = {
isVerbose,
ignoreFilesGlobs: ['**/node_modules/**']
}
if (ignoreFiles) {
ignoreFiles = ignoreFiles.split(',')
ignoreFiles = ignoreFiles.map(file => "**/" + file)
coverageSubproviderConfig.ignoreFilesGlobs = coverageSubproviderConfig.ignoreFilesGlobs.concat(ignoreFiles)
}
global.coverageSubprovider = new CoverageSubprovider(
artifactAdapter,
defaultFromAddress,
coverageSubproviderConfig
);
provider.addProvider(global.coverageSubprovider);
provider.addProvider(new RpcProvider({ rpcUrl: `http://localhost:${port}` }));
global.provider = provider;
// start pulling blocks
provider.start();
return provider
}
provider: function() {
if (coverageProvider == null) {
console.log('building provider!')
coverageProvider = new ProviderEngine()
const projectRoot = ''
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, SOLC_VERSION)
global.coverageSubprovider = new CoverageSubprovider(artifactAdapter, DEVELOPMENT_FROM, {
isVerbose: true,
ignoreFilesGlobs: [
// Proxies
'**/*Proxy.sol',
// Test contracts
'**/test/*.sol',
// Interfaces
'**/interfaces/*.sol',
],
})
coverageProvider.addProvider(global.coverageSubprovider)
coverageProvider.addProvider(
new WebsocketSubprovider({
const projectRoot = "";
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, compilerConfig.solcVersion);
const provider = new ProviderEngine();
let kovanProvider;
let rinkebyProvider;
let ropstenProvider;
switch (process.env.MODE) {
case "profile":
global.profilerSubprovider = new ProfilerSubprovider(artifactAdapter, defaultFromAddress, isVerbose);
global.profilerSubprovider.stop();
provider.addProvider(global.profilerSubprovider);
break;
case "coverage":
global.coverageSubprovider = new CoverageSubprovider(
artifactAdapter,
defaultFromAddress,
coverageSubproviderConfig,
);
provider.addProvider(global.coverageSubprovider);
break;
case "trace":
provider.addProvider(new RevertTraceSubprovider(artifactAdapter, defaultFromAddress, isVerbose));
break;
default:
// Due to some strange error, contracts do not get deployed when using the ganache subprovider
// required by the 0x tools
kovanProvider = createProvider("kovan");
rinkebyProvider = createProvider("rinkeby");
ropstenProvider = createProvider("ropsten");
break;
it('Should set the right localNodeProvider if the deployer is runned from coverage command', () => {
const provider = new ProviderEngine();
global.coverageSubprovider = new CoverageSubprovider();
provider.addProvider(global.coverageSubprovider);
provider.addProvider(new RpcProvider({ rpcUrl: `http://localhost:${config.alternativePort}` }));
global.provider = provider;
const deployer = new etherlime.JSONRPCPrivateKeyDeployer(config.randomPrivateKey, config.alternativeNodeUrl, defaultConfigs);
assert.deepEqual(global.provider._providers[1].rpcUrl, config.alternativeNodeUrl, "The stored provider url does not match the inputted one");
assert.deepEqual(global.provider._providers[1].rpcUrl, deployer.provider.connection.url, "The stored connection url does not match the inputted one");
})
it('Should set the right localNodeProvider if the deployer is runned from coverage command', () => {
const provider = new ProviderEngine();
global.coverageSubprovider = new CoverageSubprovider();
provider.addProvider(global.coverageSubprovider);
provider.addProvider(new RpcProvider({ rpcUrl: `http://localhost:${config.alternativePort}` }));
global.provider = provider;
const deployer = new etherlime.JSONRPCPrivateKeyDeployer(config.randomPrivateKey, config.alternativeNodeUrl, defaultConfigs);
assert.deepEqual(global.provider._providers[1].rpcUrl, config.alternativeNodeUrl, "The stored provider url does not match the inputted one");
assert.deepEqual(global.provider._providers[1].rpcUrl, deployer.provider.connection.url, "The stored connection url does not match the inputted one");
})
reporter: 'eth-gas-reporter',
reporterOptions: {
currency: 'USD',
gasPrice: 1
}
}
: {}
const projectRoot = ''
const solcVersion = '0.4.24'
const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631'
const isVerbose = true
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion)
const provider = new Web3ProviderEngine()
if (process.env.SOLIDITY_COVERAGE === 'true') {
global.coverageSubprovider = new CoverageSubprovider(artifactAdapter, defaultFromAddress, {
isVerbose,
ignoreFilesGlobs: ['**/Migrations.sol', '**/node_modules/**', '**/mocks/**', '**/interfaces/**']
})
provider.addProvider(global.coverageSubprovider)
const ganacheSubprovider = new GanacheSubprovider({
default_balance_ether: '1000000000000000000000000',
total_accounts: 10,
port: 8545
})
provider.addProvider(ganacheSubprovider)
provider.start(err => {
if (err !== undefined) {
process.exit(1)
}
})
provider.send = provider.sendAsync.bind(provider)
const isVerbose = true;
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);
const provider = new ProviderEngine();
if (mode === "profile") {
global.profilerSubprovider = new ProfilerSubprovider(
artifactAdapter,
defaultFromAddress,
isVerbose
);
global.profilerSubprovider.stop();
provider.addProvider(global.profilerSubprovider);
provider.addProvider(new WebsocketSubprovider({ rpcUrl: "http://localhost:8545" }));
} else {
if (mode === "coverage") {
global.coverageSubprovider = new CoverageSubprovider(
artifactAdapter,
defaultFromAddress,
{
isVerbose,
}
);
provider.addProvider(global.coverageSubprovider);
} else if (mode === "trace") {
const revertTraceSubprovider = new RevertTraceSubprovider(
artifactAdapter,
defaultFromAddress,
isVerbose
);
provider.addProvider(revertTraceSubprovider);
}
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, compilerConfig.solcVersion);
const engine = new ProviderEngine();
let defaultFromAddress;
const testModes = ['profile', 'coverage', 'trace'];
if (testModes.includes(process.env.MODE)) {
defaultFromAddress = getFirstAddress();
}
switch (process.env.MODE) {
case 'profile':
global.profilerSubprovider = new ProfilerSubprovider(artifactAdapter, defaultFromAddress, isVerbose);
engine.addProvider(global.profilerSubprovider);
break;
case 'coverage':
global.coverageSubprovider = new CoverageSubprovider(artifactAdapter, defaultFromAddress, coverageSubproviderConfig);
engine.addProvider(global.coverageSubprovider);
break;
case 'trace':
engine.addProvider(new RevertTraceSubprovider(artifactAdapter, defaultFromAddress, isVerbose));
break;
default:
rinkebyProvider = createProvider('rinkeby');
mainnetProvider = createProvider('mainnet');
ropstenProvider = createProvider('ropsten');
break;
}
let ganacheSubprovider = {};
ganacheSubprovider = new GanacheSubprovider({ mnemonic: process.env.TEST_MNEMONIC });
engine.addProvider(ganacheSubprovider);
const createTestProvider = projectRoot => {
const testProvider = new ProviderEngine();
const artifactAdapter = new TruffleArtifactAdapter(
`${projectRoot}`,
solcVersion
);
const coverageSubProvider = new CoverageSubprovider(
artifactAdapter,
defaultFromAddress,
isVerbose
);
global.coverageSubProvider = coverageSubProvider;
testProvider.addProvider(coverageSubProvider);
testProvider.addProvider(
new RevertTraceSubprovider(artifactAdapter, defaultFromAddress, isVerbose)
);
testProvider.send = testProvider.sendAsync.bind(testProvider);
return testProvider;