parent
2d28606ca4
commit
a2cf573a79
@ -0,0 +1,84 @@ |
|||||||
|
'use strict' |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
contract: ` |
||||||
|
contract structArrayLocal { |
||||||
|
struct teststruct { |
||||||
|
string a; |
||||||
|
int b; |
||||||
|
string c; |
||||||
|
int d; |
||||||
|
bool e; |
||||||
|
} |
||||||
|
|
||||||
|
enum enumdef |
||||||
|
{ |
||||||
|
one, |
||||||
|
two, |
||||||
|
three |
||||||
|
}
|
||||||
|
|
||||||
|
struct teststructArray { |
||||||
|
string[] a; |
||||||
|
int8[3] b; |
||||||
|
enumdef c; |
||||||
|
}
|
||||||
|
|
||||||
|
function structArrayLocal () { |
||||||
|
bytes memory bytesSimple = "test_super"; |
||||||
|
teststruct memory e; |
||||||
|
e.a = "test"; |
||||||
|
e.b = 5; |
||||||
|
string memory f = "test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_"; |
||||||
|
e.c = "test_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_test"; |
||||||
|
e.d = 3; |
||||||
|
e.e = true; |
||||||
|
|
||||||
|
int[5] memory simpleArray; |
||||||
|
simpleArray[0] = 45; |
||||||
|
simpleArray[1] = 324324; |
||||||
|
simpleArray[2] = -333; |
||||||
|
simpleArray[3] = 5656; |
||||||
|
simpleArray[4] = -1111; |
||||||
|
|
||||||
|
string[3] memory stringArray; |
||||||
|
stringArray[0] = "long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_"; |
||||||
|
stringArray[1] = "two"; |
||||||
|
stringArray[2] = "three"; |
||||||
|
|
||||||
|
int[][3] memory dynArray; |
||||||
|
dynArray[0] = new int[](1); |
||||||
|
dynArray[1] = new int[](2); |
||||||
|
dynArray[2] = new int[](3); |
||||||
|
dynArray[0][0] = 3423423532; |
||||||
|
dynArray[1][0] = -342343323532; |
||||||
|
dynArray[1][1] = 23432; |
||||||
|
dynArray[2][0] = -432432; |
||||||
|
dynArray[2][1] = 3423423532; |
||||||
|
dynArray[2][2] = -432432; |
||||||
|
|
||||||
|
teststruct[3] memory structArray; |
||||||
|
structArray[0] = e; |
||||||
|
|
||||||
|
structArray[1].a = "item1 a"; |
||||||
|
structArray[1].b = 20; |
||||||
|
structArray[1].c = "item1 c"; |
||||||
|
structArray[1].d = -45; |
||||||
|
structArray[1].e = false; |
||||||
|
|
||||||
|
structArray[2].a = "item2 a"; |
||||||
|
structArray[2].b = 200; |
||||||
|
structArray[2].c = "item2 c"; |
||||||
|
structArray[2].d = -450; |
||||||
|
structArray[2].e = true; |
||||||
|
|
||||||
|
teststructArray memory arrayStruct; |
||||||
|
arrayStruct.a = new string[](1); |
||||||
|
arrayStruct.a[0] = "string"; |
||||||
|
arrayStruct.b[0] = 34; |
||||||
|
arrayStruct.b[1] = -23; |
||||||
|
arrayStruct.b[2] = -3; |
||||||
|
arrayStruct.c = enumdef.three; |
||||||
|
} |
||||||
|
} |
||||||
|
`}
|
@ -0,0 +1,118 @@ |
|||||||
|
'use strict' |
||||||
|
var TraceManager = require('../../../src/trace/traceManager') |
||||||
|
var CodeManager = require('../../../src/code/codeManager') |
||||||
|
var vmSendTx = require('./vmCall') |
||||||
|
var traceHelper = require('../../../src/helpers/traceHelper') |
||||||
|
var util = require('../../../src/helpers/global') |
||||||
|
var SolidityProxy = require('../../../src/solidity/solidityProxy') |
||||||
|
var InternalCallTree = require('../../../src/util/internalCallTree') |
||||||
|
var EventManager = require('../../../src/lib/eventManager') |
||||||
|
var helper = require('./helper') |
||||||
|
|
||||||
|
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { |
||||||
|
vmSendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) { |
||||||
|
if (error) { |
||||||
|
st.fail(error) |
||||||
|
} else { |
||||||
|
util.web3.getTransaction(txHash, function (error, tx) { |
||||||
|
if (error) { |
||||||
|
st.fail(error) |
||||||
|
} else { |
||||||
|
tx.to = traceHelper.contractCreationToken('0') |
||||||
|
var traceManager = new TraceManager() |
||||||
|
var codeManager = new CodeManager(traceManager) |
||||||
|
codeManager.clear() |
||||||
|
var solidityProxy = new SolidityProxy(traceManager, codeManager) |
||||||
|
solidityProxy.reset(compilationResult) |
||||||
|
var debuggerEvent = new EventManager() |
||||||
|
var callTree = new InternalCallTree(debuggerEvent, traceManager, solidityProxy, codeManager, { includeLocalsVariables: true }) |
||||||
|
callTree.event.register('callTreeReady', (scopes, scopeStarts) => { |
||||||
|
helper.decodeLocals(st, 1899, traceManager, callTree, function (locals) { |
||||||
|
try { |
||||||
|
st.equals(locals['bytesSimple'].length, '0x14') |
||||||
|
st.equals(locals['bytesSimple'].value, '0x746573745f7375706572') |
||||||
|
st.equals(locals['e']['a'].value, 'test') |
||||||
|
st.equals(locals['e']['a'].length, '0x8') |
||||||
|
st.equals(locals['e']['a'].raw, '0x74657374') |
||||||
|
st.equals(locals['e']['b'], '5') |
||||||
|
st.equals(locals['e']['c'].length, '0x220') |
||||||
|
st.equals(locals['e']['c'].raw, '0x746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374') |
||||||
|
st.equals(locals['e']['c'].value, 'test_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_test') |
||||||
|
st.equals(locals['e']['d'], '3') |
||||||
|
st.equals(locals['f'].length, '0x1b8') |
||||||
|
st.equals(locals['f'].raw, '0x746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f') |
||||||
|
st.equals(locals['f'].value, 'test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_') |
||||||
|
st.equals(locals['e']['e'], true) |
||||||
|
|
||||||
|
st.equals(locals['simpleArray'][0], '45') |
||||||
|
st.equals(locals['simpleArray'][1], '324324') |
||||||
|
st.equals(locals['simpleArray'][2], '-333') |
||||||
|
st.equals(locals['simpleArray'][3], '5656') |
||||||
|
st.equals(locals['simpleArray'][4], '-1111') |
||||||
|
|
||||||
|
st.equals(locals['stringArray'][0].value, 'long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_') |
||||||
|
st.equals(locals['stringArray'][1].value, 'two') |
||||||
|
st.equals(locals['stringArray'][2].value, 'three') |
||||||
|
|
||||||
|
st.equals(locals['dynArray'][0][0], '3423423532') |
||||||
|
st.equals(locals['dynArray'][1][0], '-342343323532') |
||||||
|
st.equals(locals['dynArray'][1][1], '23432') |
||||||
|
st.equals(locals['dynArray'][2][0], '-432432') |
||||||
|
st.equals(locals['dynArray'][2][1], '3423423532') |
||||||
|
st.equals(locals['dynArray'][2][2], '-432432') |
||||||
|
|
||||||
|
st.equals(locals['structArray'][0]['a'].value, 'test') |
||||||
|
st.equals(locals['structArray'][0]['a'].length, '0x8') |
||||||
|
st.equals(locals['structArray'][0]['a'].raw, '0x74657374') |
||||||
|
st.equals(locals['structArray'][0]['b'], '5') |
||||||
|
st.equals(locals['structArray'][0]['c'].length, '0x220') |
||||||
|
st.equals(locals['structArray'][0]['c'].raw, '0x746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f74657374') |
||||||
|
st.equals(locals['structArray'][0]['c'].value, 'test_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_test') |
||||||
|
st.equals(locals['structArray'][0]['d'], '3') |
||||||
|
st.equals(locals['structArray'][0]['e'], true) |
||||||
|
|
||||||
|
st.equals(locals['structArray'][1]['a'].value, 'item1 a') |
||||||
|
st.equals(locals['structArray'][1]['b'], '20') |
||||||
|
st.equals(locals['structArray'][1]['c'].value, 'item1 c') |
||||||
|
st.equals(locals['structArray'][1]['d'], '-45') |
||||||
|
st.equals(locals['structArray'][1]['e'], false) |
||||||
|
|
||||||
|
st.equals(locals['structArray'][2]['a'].value, 'item2 a') |
||||||
|
st.equals(locals['structArray'][2]['b'], '200') |
||||||
|
st.equals(locals['structArray'][2]['c'].value, 'item2 c') |
||||||
|
st.equals(locals['structArray'][2]['d'], '-450') |
||||||
|
st.equals(locals['structArray'][2]['e'], true) |
||||||
|
|
||||||
|
st.equals(locals['arrayStruct'].a[0].value, 'string') |
||||||
|
st.equals(locals['arrayStruct'].b[0], '34') |
||||||
|
st.equals(locals['arrayStruct'].b[1], '-23') |
||||||
|
st.equals(locals['arrayStruct'].b[2], '-3') |
||||||
|
st.equals(locals['arrayStruct'].c, 'three') |
||||||
|
|
||||||
|
st.equals(Object.keys(locals).length, 8) |
||||||
|
} catch (e) { |
||||||
|
st.fail(e.message) |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { |
||||||
|
try { |
||||||
|
st.equals(Object.keys(locals).length, 8) |
||||||
|
} catch (e) { |
||||||
|
st.fail(e.message) |
||||||
|
} |
||||||
|
cb() |
||||||
|
}) |
||||||
|
}) |
||||||
|
traceManager.resolveTrace(tx, (error, result) => { |
||||||
|
if (error) { |
||||||
|
st.fail(error) |
||||||
|
} else { |
||||||
|
debuggerEvent.trigger('newTraceLoaded', [traceManager.trace]) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
Loading…
Reference in new issue