Merge pull request #690 from 0xProject/feature/truffle-sol-cov-fixes

Sol-cov fixes
This commit is contained in:
Leonid Logvinov
2018-06-11 21:55:38 -07:00
committed by GitHub
4 changed files with 21 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ export const compilerOptionsSchema = {
properties: {
contractsDir: { type: 'string' },
artifactsDir: { type: 'string' },
solcVersion: { type: 'string', pattern: '^d+.d+.d+$' },
solcVersion: { type: 'string', pattern: '^\\d+.\\d+.\\d+$' },
compilerSettings: { type: 'object' },
contracts: {
oneOf: [

View File

@@ -37,6 +37,18 @@
{
"note": "Skip interface artifacts with a warning instead of failing",
"pr": 675
},
{
"note": "Fix solcVersion regex in parameter validation",
"pr": 690
},
{
"note": "Fix a bug when in TruffleArtifactsAdapter causing it to throw if compiler.json is not there",
"pr": 690
},
{
"note": "HUGE perf improvements",
"pr": 690
}
]
},

View File

@@ -1,4 +1,4 @@
import { ContractArtifact } from '@0xproject/sol-compiler';
import { CompilerOptions, ContractArtifact } from '@0xproject/sol-compiler';
import { logUtils } from '@0xproject/utils';
import * as fs from 'fs';
import * as glob from 'glob';
@@ -16,15 +16,17 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter {
private _sourcesPath: string;
constructor(artifactsPath?: string, sourcesPath?: string) {
super();
const config = JSON.parse(fs.readFileSync(CONFIG_FILE).toString());
const config: CompilerOptions = fs.existsSync(CONFIG_FILE)
? JSON.parse(fs.readFileSync(CONFIG_FILE).toString())
: {};
if (_.isUndefined(artifactsPath) && _.isUndefined(config.artifactsDir)) {
throw new Error(`artifactsDir not found in ${CONFIG_FILE}`);
}
this._artifactsPath = artifactsPath || config.artifactsDir;
this._artifactsPath = (artifactsPath || config.artifactsDir) as string;
if (_.isUndefined(sourcesPath) && _.isUndefined(config.contractsDir)) {
throw new Error(`contractsDir not found in ${CONFIG_FILE}`);
}
this._sourcesPath = sourcesPath || config.contractsDir;
this._sourcesPath = (sourcesPath || config.contractsDir) as string;
}
public async collectContractsDataAsync(): Promise<ContractData[]> {
const artifactsGlob = `${this._artifactsPath}/**/*.json`;

View File

@@ -163,7 +163,7 @@ export class TraceCollectionSubprovider extends Subprovider {
cb();
}
private async _recordTxTraceAsync(address: string, data: string | undefined, txHash: string): Promise<void> {
await this._web3Wrapper.awaitTransactionMinedAsync(txHash);
await this._web3Wrapper.awaitTransactionMinedAsync(txHash, 0);
const trace = await this._web3Wrapper.getTransactionTraceAsync(txHash, {
disableMemory: true,
disableStack: false,
@@ -222,7 +222,7 @@ export class TraceCollectionSubprovider extends Subprovider {
};
try {
const txHash = await this._web3Wrapper.sendTransactionAsync(fakeTxData);
await this._web3Wrapper.awaitTransactionMinedAsync(txHash);
await this._web3Wrapper.awaitTransactionMinedAsync(txHash, 0);
} catch (err) {
// Even if this transaction failed - we've already recorded it's trace.
_.noop();