From ffa2f6fbf05aa3c6ce9302e4263737d3aff7fe0b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 10 Oct 2018 14:52:10 -0400 Subject: [PATCH] update test script --- remix-debug/test.js | 81 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/remix-debug/test.js b/remix-debug/test.js index 124a7dca9b..1b7264619f 100644 --- a/remix-debug/test.js +++ b/remix-debug/test.js @@ -17,8 +17,8 @@ var compilation = { compilation.lastCompilationResult = require('./compilation.json') // connecting to a node -// var Web3 = require('web3') -// web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) +var Web3 = require('web3') +web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) // global.my_web3 = web3 // with vm @@ -40,7 +40,10 @@ contextManager.event.register('providerChanged', () => { contextManager.initProviders() -contextManager.switchProvider('vm') +contextManager.addProvider('myweb3', web3) +contextManager.switchProvider('myweb3') + +//contextManager.switchProvider('vm') _debugger.event.register('debuggerStatus', function (isActive) { console.dir("debugger status") @@ -49,6 +52,18 @@ _debugger.event.register('debuggerStatus', function (isActive) { _debugger.event.register('newSourceLocation', function (lineColumnPos, rawLocation) { console.dir("newSourceLocation") + + if (!lineColumnPos || !lineColumnPos.start) return; + + let line + //let line = compilation.lastCompilationResult.source.sources['browser/ballot.sol'].content.split("\n")[lineColumnPos.start.line].slice(lineColumnPos.start.column, lineColumnPos.start.column + lineColumnPos.end.column) + line = compilation.lastCompilationResult.source.sources['browser/ballot.sol'].content.split("\n")[lineColumnPos.start.line - 1] + console.dir(line) + line = compilation.lastCompilationResult.source.sources['browser/ballot.sol'].content.split("\n")[lineColumnPos.start.line] + console.dir(line) + console.dir("^^^^^^^^^^^^^^^ ") + line = compilation.lastCompilationResult.source.sources['browser/ballot.sol'].content.split("\n")[lineColumnPos.start.line + 1] + console.dir(line) }); _debugger.event.register('debuggerUnloaded', function() { @@ -64,18 +79,54 @@ let blockNumber = null let txNumber = null let tx = null -// let code = compilation.lastCompilationResult.data.contracts['browser/ballot.sol'].Ballot.evm.bytecode.object -// _web3.eth.sendTransaction({data: "0x" + code, from: _web3.eth.accounts[0], gas: 800000}, (err, txHash) => { -// console.dir(err) -// console.dir(txHash) -// -// txNumber = txHash -// -// _debugger.debug(blockNumber, txNumber, tx, () => { -// console.dir('debugger started') -// }) -// -// }) +let code = compilation.lastCompilationResult.data.contracts['browser/ballot.sol'].Ballot.evm.bytecode.object +_web3.eth.sendTransaction({data: "0x" + code, from: _web3.eth.accounts[0], gas: 800000}, (err, txHash) => { + //console.dir(err) + //console.dir(txHash) + + + txNumber = txHash + global.mytx = txHash + + _debugger.event.register('newSourceLocation', (lineColumnPos, rawLocation) => { + console.dir("************ new source location *********") + console.dir(lineColumnPos) + console.dir(rawLocation) + }) + + _debugger.debug(blockNumber, txNumber, tx, () => { + + _debugger.step_manager.event.register('stepChanged', (stepIndex) => { + console.dir("---------") + console.dir("stepChanged: " + stepIndex) + console.dir("---------") + }) + + _debugger.step_manager.event.register('traceLengthChanged', (traceLength) => { + console.dir("---------") + console.dir("traceLengthChanged: " + traceLength) + console.dir("---------") + }); + + _debugger.vmDebuggerLogic.event.register('codeManagerChanged', (code, address, index) => { + console.dir("---------") + console.dir("codeManagerChanged") + console.dir("address: " + address) + console.dir("asm code: " + code[index]) + console.dir("---------") + }); + + _debugger.vmDebuggerLogic.event.register('traceManagerMemoryUpdate', (data) => { + console.dir("---------") + console.dir("traceManagerMemoryUpdate") + console.dir(data) + console.dir("---------") + }); + + console.dir('debugger started') + }) + +}) //_debugger.debug(blockNumber, txNumber, tx, () => { // console.dir('debugger started')