diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-06-13 05:01:19 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-06-13 05:01:19 +0800 |
commit | 39692a8b3fd69e5b37e2de568ee74766840ad4b8 (patch) | |
tree | cc2d1ec295d987a360ce07a5c80723b96b0d1816 /packages/sol-cov/src/trace.ts | |
parent | 2af6d3f6bc03932f53d199971694c3c0d9441ba8 (diff) | |
parent | 787015f5370718e31c7990446fb1da298ed13e6b (diff) | |
download | dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.gz dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.bz2 dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.lz dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.xz dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.zst dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.zip |
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into feature/website/onboarding-flow-allowances
Diffstat (limited to 'packages/sol-cov/src/trace.ts')
-rw-r--r-- | packages/sol-cov/src/trace.ts | 16 |
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; } |