aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/test/artifacts_test.ts4
-rw-r--r--packages/sol-cov/src/coverage_subprovider.ts36
2 files changed, 28 insertions, 12 deletions
diff --git a/packages/0x.js/test/artifacts_test.ts b/packages/0x.js/test/artifacts_test.ts
index ca554a4f5..982fb8e63 100644
--- a/packages/0x.js/test/artifacts_test.ts
+++ b/packages/0x.js/test/artifacts_test.ts
@@ -15,7 +15,7 @@ const TIMEOUT = 10000;
describe('Artifacts', () => {
describe('contracts are deployed on kovan', () => {
const kovanRpcUrl = constants.KOVAN_RPC_URL;
- const provider = web3Factory.create({ rpcUrl: kovanRpcUrl }).currentProvider;
+ const provider = web3Factory.getRpcProvider({ rpcUrl: kovanRpcUrl });
const config = {
networkId: constants.KOVAN_NETWORK_ID,
};
@@ -32,7 +32,7 @@ describe('Artifacts', () => {
});
describe('contracts are deployed on ropsten', () => {
const ropstenRpcUrl = constants.ROPSTEN_RPC_URL;
- const provider = web3Factory.create({ rpcUrl: ropstenRpcUrl }).currentProvider;
+ const provider = web3Factory.getRpcProvider({ rpcUrl: ropstenRpcUrl });
const config = {
networkId: constants.ROPSTEN_NETWORK_ID,
};
diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts
index 3fd45bbd1..45b479c0e 100644
--- a/packages/sol-cov/src/coverage_subprovider.ts
+++ b/packages/sol-cov/src/coverage_subprovider.ts
@@ -123,16 +123,32 @@ export class CoverageSubprovider extends Subprovider {
const jsonRPCResponsePayload = await this.emitPayloadAsync(payload);
const trace: TransactionTrace = jsonRPCResponsePayload.result;
if (address === constants.NEW_CONTRACT) {
- // TODO handle calls to external contracts and contract creations from within the constructor
- const structLogsOnDepth0 = _.filter(trace.structLogs, { depth: 0 });
- const coveredPcs = _.map(structLogsOnDepth0, log => log.pc);
- const traceInfo: TraceInfoNewContract = {
- coveredPcs,
- txHash,
- address: address as 'NEW_CONTRACT',
- bytecode: data as string,
- };
- this._coverageManager.appendTraceInfo(traceInfo);
+ const tracesByContractAddress = getTracesByContractAddress(trace.structLogs, address);
+ for (const subcallAddress of _.keys(tracesByContractAddress)) {
+ let traceInfo: TraceInfoNewContract | TraceInfoExistingContract;
+ if (subcallAddress === 'NEW_CONTRACT') {
+ const traceForThatSubcall = tracesByContractAddress[subcallAddress];
+ const coveredPcs = _.map(traceForThatSubcall, log => log.pc);
+ traceInfo = {
+ coveredPcs,
+ txHash,
+ address: address as 'NEW_CONTRACT',
+ bytecode: data as string,
+ };
+ } else {
+ payload = { method: 'eth_getCode', params: [subcallAddress, BlockParamLiteral.Latest] };
+ const runtimeBytecode = (await this.emitPayloadAsync(payload)).result;
+ const traceForThatSubcall = tracesByContractAddress[subcallAddress];
+ const coveredPcs = _.map(traceForThatSubcall, log => log.pc);
+ traceInfo = {
+ coveredPcs,
+ txHash,
+ address: subcallAddress,
+ runtimeBytecode,
+ };
+ }
+ this._coverageManager.appendTraceInfo(traceInfo);
+ }
} else {
const tracesByContractAddress = getTracesByContractAddress(trace.structLogs, address);
for (const subcallAddress of _.keys(tracesByContractAddress)) {