aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-23 06:14:07 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-05-23 06:27:18 +0800
commit6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b (patch)
tree334b2d718487ca5fca6bb3c9c08abe25ef898517 /packages/sol-cov
parent127b3e7d60aa5b5256d3d77aecf5efb239649957 (diff)
downloaddexon-0x-contracts-6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b.tar
dexon-0x-contracts-6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b.tar.gz
dexon-0x-contracts-6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b.tar.bz2
dexon-0x-contracts-6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b.tar.lz
dexon-0x-contracts-6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b.tar.xz
dexon-0x-contracts-6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b.tar.zst
dexon-0x-contracts-6e0aef5f2bd8cd3ca9086abf4794028feac5ae9b.zip
Fix depth tracking in a tracer
Diffstat (limited to 'packages/sol-cov')
-rw-r--r--packages/sol-cov/src/trace.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/sol-cov/src/trace.ts b/packages/sol-cov/src/trace.ts
index 389bd8309..28fc7d004 100644
--- a/packages/sol-cov/src/trace.ts
+++ b/packages/sol-cov/src/trace.ts
@@ -25,7 +25,7 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress
if (_.includes([OpCode.CallCode, OpCode.StaticCall, OpCode.Call, OpCode.DelegateCall], structLog.op)) {
const currentAddress = _.last(callStack) as string;
- const jumpAddressOffset = structLog.op === OpCode.DelegateCall ? 4 : 2;
+ const jumpAddressOffset = 1;
const newAddress = addressUtils.padZeros(
new BigNumber(addHexPrefix(structLog.stack[structLog.stack.length - jumpAddressOffset - 1])).toString(
16,
@@ -65,6 +65,21 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress
"Detected a contract created from within another contract. Sol-cov currently doesn't support that scenario. We'll just skip that trace",
);
return traceByContractAddress;
+ } else {
+ if (structLog !== _.last(structLogs)) {
+ const nextStructLog = structLogs[i + 1];
+ if (nextStructLog.depth === structLog.depth) {
+ continue;
+ } else if (nextStructLog.depth === structLog.depth - 1) {
+ const currentAddress = callStack.pop() as string;
+ traceByContractAddress[currentAddress] = (traceByContractAddress[currentAddress] || []).concat(
+ currentTraceSegment,
+ );
+ currentTraceSegment = [];
+ } else {
+ throw new Error('Shit broke');
+ }
+ }
}
}
if (callStack.length !== 0) {