You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.4 KiB
60 lines
2.4 KiB
'use strict'
|
|
var TraceManager = require('../../../babelify-src/trace/traceManager')
|
|
var CodeManager = require('../../../babelify-src/code/codeManager')
|
|
var vmSendTx = require('./vmCall')
|
|
var traceHelper = require('../../../babelify-src/helpers/traceHelper')
|
|
var util = require('../../../babelify-src/helpers/global')
|
|
var SolidityProxy = require('../../../babelify-src/solidity/solidityProxy')
|
|
var InternalCallTree = require('../../../babelify-src/util/internalCallTree')
|
|
var EventManager = require('../../../babelify-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, { includeLocalVariables: true })
|
|
callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
|
|
helper.decodeLocals(st, 82, traceManager, callTree, function (locals) {
|
|
try {
|
|
st.equals(locals['dynbytes'].value, '0x64796e616d69636279746573')
|
|
st.equals(locals['smallstring'].value, 'test_test_test')
|
|
st.equals(Object.keys(locals).length, 2)
|
|
} catch (e) {
|
|
st.fail(e.message)
|
|
}
|
|
})
|
|
|
|
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
|
|
try {
|
|
st.equals(Object.keys(locals).length, 2)
|
|
} catch (e) {
|
|
st.fail(e.message)
|
|
}
|
|
cb()
|
|
})
|
|
})
|
|
traceManager.resolveTrace(tx, (error, result) => {
|
|
if (error) {
|
|
st.fail(error)
|
|
} else {
|
|
debuggerEvent.trigger('newTraceLoaded', [traceManager.trace])
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|