From 4f7ffce31143374d9e256ac9e7222918d10e7f9e Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 8 Dec 2022 09:19:22 +0100 Subject: [PATCH] fix test --- libs/remix-debug/src/code/breakpointManager.ts | 9 ++++----- libs/remix-debug/test/debugger.ts | 11 +++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libs/remix-debug/src/code/breakpointManager.ts b/libs/remix-debug/src/code/breakpointManager.ts index e1d6617aba..fb250b6c85 100644 --- a/libs/remix-debug/src/code/breakpointManager.ts +++ b/libs/remix-debug/src/code/breakpointManager.ts @@ -22,13 +22,12 @@ export class BreakpointManager { * @param {Object} _debugger - type of EthDebugger * @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location */ - constructor ({ traceManager, callTree, solidityProxy, locationToRowConverter }) { + constructor ({ traceManager, callTree, solidityProxy }) { this.event = new EventManager() this.traceManager = traceManager this.callTree = callTree this.solidityProxy = solidityProxy this.breakpoints = {} - this.locationToRowConverter = locationToRowConverter } setManagers ({ traceManager, callTree, solidityProxy }) { @@ -43,7 +42,7 @@ export class BreakpointManager { * */ async jumpNextBreakpoint (fromStep, defaultToLimit) { - if (!this.locationToRowConverter) { + if (!this.callTree.locationAndOpcodePerVMTraceIndex[fromStep]) { return console.log('row converter not provided') } this.jump(fromStep || 0, 1, defaultToLimit, this.traceManager.trace) @@ -55,7 +54,7 @@ export class BreakpointManager { * */ async jumpPreviousBreakpoint (fromStep, defaultToLimit) { - if (!this.locationToRowConverter) { + if (!this.callTree.locationAndOpcodePerVMTraceIndex[fromStep]) { return console.log('row converter not provided') } this.jump(fromStep || 0, -1, defaultToLimit, this.traceManager.trace) @@ -97,7 +96,7 @@ export class BreakpointManager { while (currentStep > 0 && currentStep < trace.length) { try { previousSourceLocation = sourceLocation - const stepInfo = await this.callTree.locationAndOpcodePerVMTraceIndex[currentStep] + const stepInfo = this.callTree.locationAndOpcodePerVMTraceIndex[currentStep] sourceLocation = stepInfo.sourceLocation lineColumn = stepInfo.lineColumnPos } catch (e) { diff --git a/libs/remix-debug/test/debugger.ts b/libs/remix-debug/test/debugger.ts index 4486760f1b..608b285ddb 100644 --- a/libs/remix-debug/test/debugger.ts +++ b/libs/remix-debug/test/debugger.ts @@ -168,7 +168,12 @@ contract Ballot { compilationResult: function () { return { data: output } }, - web3: web3 + web3: web3, + offsetToLineColumnConverter: { + offsetToLineColumn: async (rawLocation) => { + return sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, sourceMappingDecoder.getLinebreakPositions(ballot)) + } + } }) debugManager.callTree.event.register('callTreeReady', () => { @@ -273,9 +278,7 @@ function testDebugging (debugManager) { tape('breakPointManager', (t) => { t.plan(2) const {traceManager, callTree, solidityProxy} = debugManager - var breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy, locationToRowConverter: async (rawLocation) => { - return sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, sourceMappingDecoder.getLinebreakPositions(ballot)) - }}) + var breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy}) breakPointManager.add({fileName: 'test.sol', row: 39})