aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov
diff options
context:
space:
mode:
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) {