diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-06-12 01:48:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-12 01:48:18 +0800 |
commit | 7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5 (patch) | |
tree | c8e47e9e42e58febc45411a360224535786cba48 /packages/sol-cov/src/trace.ts | |
parent | 817c332d11835f02726f0609374d1c25c9ab39b5 (diff) | |
parent | 927ccc489c8cd69723bb2b13f81de150d7b255d0 (diff) | |
download | dexon-sol-tools-7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5.tar dexon-sol-tools-7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5.tar.gz dexon-sol-tools-7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5.tar.bz2 dexon-sol-tools-7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5.tar.lz dexon-sol-tools-7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5.tar.xz dexon-sol-tools-7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5.tar.zst dexon-sol-tools-7e5866ce3fffc67633d3ab84cc3d2a6abdd22ce5.zip |
Merge pull request #675 from 0xProject/feature/sol-cov-geth
`ProfilerSubprovider` & Geth-related fixes for `sol-cov`
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; } |