refactor getCurrentStep

pull/5370/head
Iuri Matias 4 years ago committed by aniket-engg
parent 12bf5ce4fb
commit 582980d4d3
  1. 9
      libs/remix-debug/src/debugger/VmDebugger.js
  2. 6
      libs/remix-lib/src/trace/traceManager.js
  3. 15
      libs/remix-lib/test/traceManager.js

@ -113,9 +113,12 @@ class VmDebuggerLogic {
} catch (error) { } catch (error) {
} }
this._traceManager.getCurrentStep(index, (error, step) => { try {
this.event.trigger('traceCurrentStepUpdate', [error, step]) const step = this._traceManager.getCurrentStep(index)
}) this.event.trigger('traceCurrentStepUpdate', [null, step])
} catch (error) {
this.event.trigger('traceCurrentStepUpdate', [error])
}
try { try {
const addmem = this._traceManager.getMemExpand(index) const addmem = this._traceManager.getMemExpand(index)

@ -200,13 +200,13 @@ TraceManager.prototype.getReturnValue = function (stepIndex) {
return this.traceCache.returnValues[stepIndex] return this.traceCache.returnValues[stepIndex]
} }
TraceManager.prototype.getCurrentStep = function (stepIndex, callback) { TraceManager.prototype.getCurrentStep = function (stepIndex) {
try { try {
this.checkRequestedStep(stepIndex) this.checkRequestedStep(stepIndex)
} catch (check) { } catch (check) {
return callback(check, null) throw new Error(check)
} }
callback(null, this.traceCache.steps[stepIndex]) return this.traceCache.steps[stepIndex]
} }
TraceManager.prototype.getMemExpand = function (stepIndex) { TraceManager.prototype.getMemExpand = function (stepIndex) {

@ -209,15 +209,14 @@ tape('TraceManager', function (t) {
}) })
t.test('TraceManager.getCurrentStep', function (st) { t.test('TraceManager.getCurrentStep', function (st) {
traceManager.getCurrentStep(66, function (error, result) { try {
const result = traceManager.getCurrentStep(66)
console.log(result) console.log(result)
if (error) { st.ok(result === 2)
st.fail(error) st.end()
} else { } catch (error) {
st.ok(result === 2) st.fail(error)
st.end() }
}
})
}) })
t.test('TraceManager.getMemExpand', function (st) { t.test('TraceManager.getMemExpand', function (st) {

Loading…
Cancel
Save