How to use @0x/sol-coverage - 10 common examples

To help you get started, we’ve selected a few @0x/sol-coverage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LimeChain / etherlime / packages / etherlime / cli-commands / etherlime-test / etherlime-coverage.js View on Github external
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
}
github celo-org / celo-monorepo / packages / protocol / truffle-config.js View on Github external
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({
github sablierhq / sablier / packages / protocol / truffle-config.js View on Github external
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;
github LimeChain / etherlime / test / etherlime-lib / deployer / jsonrpc-deployer / jsonrpc-private-key-deployer.js View on Github external
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");

		})
github LimeChain / etherlime / test / etherlime-lib / deployer / jsonrpc-deployer / jsonrpc-private-key-deployer.js View on Github external
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");

		})
github LimeChain / etherlime / packages / etherlime / cli-commands / etherlime-test / etherlime-coverage.js View on Github external
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
	);
github 0xProject / 0x-monorepo / contracts / test-utils / src / coverage.ts View on Github external
_getCoverageSubprovider(): CoverageSubprovider {
        const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS;
        const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter();
        const isVerbose = true;
        const subprovider = new CoverageSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose);
        return subprovider;
    },
};
github poanetwork / tokenbridge-contracts / truffle-config.js View on Github external
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)
github poanetwork / tokenbridge-contracts / truffle-config.js View on Github external
process.env.GASREPORT === 'true'
    ? {
        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)
    }
github 0xProject / dev-tools-truffle-example / truffle-config.js View on Github external
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);
  }

@0x/sol-coverage

Generate coverage reports for Solidity code

Apache-2.0
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages