aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/trace.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-12 01:54:59 +0800
committerFabio Berger <me@fabioberger.com>2018-06-12 01:54:59 +0800
commit60f5a52964d6965d35eb3c3cb15abc8471de6fd6 (patch)
tree3912c687aa7e3eb9891d1f4d5a46d516805a4503 /packages/sol-cov/src/trace.ts
parent89b7b56a2cb38d95f65067e5493e8135cb1e7e98 (diff)
parent7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5 (diff)
downloaddexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar
dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.gz
dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.bz2
dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.lz
dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.xz
dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.tar.zst
dexon-sol-tools-60f5a52964d6965d35eb3c3cb15abc8471de6fd6.zip
Merge branch 'v2-prototype' into fix/contract-wrappers/exchangeTransferSimulator
* v2-prototype: Fix a bug in SolCompilerArtifacts adapter config overriding Increase timeout for contract migrations Remove some copy-paste code Await transactions in migrations Fix typos Await transactions in migrations Await fake transactions Fix a typo Implement SolidityProfiler & adapt sol-cov to work with Geth # Conflicts: # packages/migrations/CHANGELOG.json
Diffstat (limited to 'packages/sol-cov/src/trace.ts')
-rw-r--r--packages/sol-cov/src/trace.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/packages/sol-cov/src/trace.ts b/packages/sol-cov/src/trace.ts
index c725de3d0..45e45e9c5 100644
--- a/packages/sol-cov/src/trace.ts
+++ b/packages/sol-cov/src/trace.ts
@@ -16,6 +16,13 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress
const traceByContractAddress: TraceByContractAddress = {};
let currentTraceSegment = [];
const callStack = [startAddress];
+ if (_.isEmpty(structLogs)) {
+ return traceByContractAddress;
+ }
+ if (structLogs[0].depth === 1) {
+ // Geth uses 1-indexed depth counter whilst ganache starts from 0
+ _.forEach(structLogs, structLog => structLog.depth--);
+ }
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < structLogs.length; i++) {
const structLog = structLogs[i];
@@ -95,10 +102,15 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress
}
}
if (callStack.length !== 0) {
- throw new Error('Malformed trace. Call stack non empty at the end');
+ logUtils.warn('Malformed trace. Call stack non empty at the end');
}
if (currentTraceSegment.length !== 0) {
- throw new Error('Malformed trace. Current trace segment non empty at the end');
+ const currentAddress = callStack.pop() as string;
+ traceByContractAddress[currentAddress] = (traceByContractAddress[currentAddress] || []).concat(
+ currentTraceSegment,
+ );
+ currentTraceSegment = [];
+ logUtils.warn('Malformed trace. Current trace segment non empty at the end');
}
return traceByContractAddress;
}