Commit a2056a49 authored by Iuri Matias's avatar Iuri Matias Committed by aniket-engg

refactor getCallDataAt

parent 97a19aa2
...@@ -60,14 +60,14 @@ class VmDebuggerLogic { ...@@ -60,14 +60,14 @@ class VmDebuggerLogic {
this.event.trigger('functionsStackUpdate', [this._callTree.retrieveFunctionsStack(index)]) this.event.trigger('functionsStackUpdate', [this._callTree.retrieveFunctionsStack(index)])
this._traceManager.getCallDataAt(index, (error, calldata) => { try {
if (error) { const calldata = this._traceManager.getCallDataAt(index)
// console.log(error) if (this.stepManager.currentStepIndex === index) {
this.event.trigger('traceManagerCallDataUpdate', [{}])
} else if (this.stepManager.currentStepIndex === index) {
this.event.trigger('traceManagerCallDataUpdate', [calldata]) this.event.trigger('traceManagerCallDataUpdate', [calldata])
} }
}) } catch (error) {
this.event.trigger('traceManagerCallDataUpdate', [{}])
}
try { try {
const memory = this._traceManager.getMemoryAt(index) const memory = this._traceManager.getMemoryAt(index)
......
...@@ -88,15 +88,17 @@ TraceManager.prototype.getAddresses = function () { ...@@ -88,15 +88,17 @@ TraceManager.prototype.getAddresses = function () {
return this.traceCache.addresses return this.traceCache.addresses
} }
TraceManager.prototype.getCallDataAt = function (stepIndex, callback) { TraceManager.prototype.getCallDataAt = function (stepIndex) {
try { try {
this.checkRequestedStep(stepIndex) this.checkRequestedStep(stepIndex)
} catch (check) { } catch (check) {
return callback(check, null) throw new Error(check)
} }
const callDataChange = util.findLowerBoundValue(stepIndex, this.traceCache.callDataChanges) const callDataChange = util.findLowerBoundValue(stepIndex, this.traceCache.callDataChanges)
if (callDataChange === null) return callback('no calldata found', null) if (callDataChange === null) {
callback(null, [this.traceCache.callsData[callDataChange]]) throw new Error('no calldata found')
}
return [this.traceCache.callsData[callDataChange]]
} }
TraceManager.prototype.buildCallPath = function (stepIndex, callback) { TraceManager.prototype.buildCallPath = function (stepIndex, callback) {
......
...@@ -61,15 +61,14 @@ tape('TraceManager', function (t) { ...@@ -61,15 +61,14 @@ tape('TraceManager', function (t) {
}) })
t.test('TraceManager.getCallData', function (st) { t.test('TraceManager.getCallData', function (st) {
traceManager.getCallDataAt(0, function (error, result) { try {
if (error) { const result = traceManager.getCallDataAt(0)
st.fail(error)
} else {
st.ok(result[0] === '0x60fe47b10000000000000000000000000000000000000000000000000000000000000038') st.ok(result[0] === '0x60fe47b10000000000000000000000000000000000000000000000000000000000000038')
st.end() st.end()
} catch (error) {
st.fail(error)
} }
}) })
})
t.test('TraceManager.getCallStackAt', function (st) { t.test('TraceManager.getCallStackAt', function (st) {
st.plan(3) st.plan(3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment