localTests code updated

pull/5370/head
aniket-engg 4 years ago committed by Aniket
parent a7dba18904
commit e26e27ccb0
  1. 10
      libs/remix-debug/test/decoder/localsTests/helper.ts
  2. 23
      libs/remix-debug/test/decoder/localsTests/int.ts
  3. 21
      libs/remix-debug/test/decoder/localsTests/misc.ts
  4. 22
      libs/remix-debug/test/decoder/localsTests/misc2.ts
  5. 21
      libs/remix-debug/test/decoder/localsTests/structArray.ts
  6. 8
      libs/remix-debug/test/decoder/vmCall.ts

@ -1,10 +1,10 @@
'use strict' 'use strict'
var localDecoder = require('../../../src/solidity-decoder/localDecoder') import { solidityLocals } from '../../../src/solidity-decoder/localDecoder'
/* /*
Decode local variable Decode local variable
*/ */
function decodeLocal (st, index, traceManager, callTree, verifier) { export function decodeLocals (st, index, traceManager, callTree, verifier) {
try { try {
traceManager.waterfall([ traceManager.waterfall([
function getStackAt (stepIndex, callback) { function getStackAt (stepIndex, callback) {
@ -28,7 +28,7 @@ function decodeLocal (st, index, traceManager, callTree, verifier) {
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
localDecoder.solidityLocals(index, callTree, result[0].value, result[1].value, {}, { start: 5000 }).then((locals) => { solidityLocals(index, callTree, result[0].value, result[1].value, {}, { start: 5000 }, null).then((locals) => {
verifier(locals) verifier(locals)
}) })
}) })
@ -36,7 +36,3 @@ function decodeLocal (st, index, traceManager, callTree, verifier) {
st.fail(e.message) st.fail(e.message)
} }
} }
module.exports = {
decodeLocals: decodeLocal
}

@ -1,19 +1,16 @@
'use strict' 'use strict'
var vmCall = require('../vmCall') import { sendTx } from '../vmCall'
var remixLib = require('@remix-project/remix-lib') import { TraceManager } from '../../../src/trace/traceManager'
import { CodeManager } from '../../../src/code/codeManager'
var TraceManager = require('../../../src/trace/traceManager') import { contractCreationToken } from '../../../src/trace/traceHelper'
var CodeManager = require('../../../src/code/codeManager') import { SolidityProxy } from '../../../src/solidity-decoder/solidityProxy'
import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree'
var traceHelper = require('../../../src/trace/traceHelper') import { EventManager } from '../../../src/eventManager'
var SolidityProxy = require('../../../src/solidity-decoder/solidityProxy') import * as helper from './helper'
var InternalCallTree = require('../../../src/solidity-decoder/internalCallTree')
var EventManager = require('../../../src/eventManager')
var helper = require('./helper')
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
vmCall.sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) { sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) {
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
@ -21,7 +18,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
tx.to = traceHelper.contractCreationToken('0') tx.to = contractCreationToken('0')
var traceManager = new TraceManager({ web3: vm.web3 }) var traceManager = new TraceManager({ web3: vm.web3 })
var codeManager = new CodeManager(traceManager) var codeManager = new CodeManager(traceManager)
codeManager.clear() codeManager.clear()

@ -1,16 +1,15 @@
'use strict' 'use strict'
var vmCall = require('../vmCall') import { sendTx } from '../vmCall'
var traceHelper = require('../../../src/trace/traceHelper') import { contractCreationToken } from '../../../src/trace/traceHelper'
var SolidityProxy = require('../../../src/solidity-decoder/solidityProxy') import { SolidityProxy } from '../../../src/solidity-decoder/solidityProxy'
var InternalCallTree = require('../../../src/solidity-decoder/internalCallTree') import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree'
var EventManager = require('../../../src/eventManager') import { EventManager } from '../../../src/eventManager'
var helper = require('./helper') import * as helper from './helper'
import { TraceManager } from '../../../src/trace/traceManager'
var TraceManager = require('../../../src/trace/traceManager') import { CodeManager } from '../../../src/code/codeManager'
var CodeManager = require('../../../src/code/codeManager')
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
vmCall.sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) { sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) {
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
@ -18,7 +17,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
tx.to = traceHelper.contractCreationToken('0') tx.to = contractCreationToken('0')
var traceManager = new TraceManager({ web3: vm.web3 }) var traceManager = new TraceManager({ web3: vm.web3 })
var codeManager = new CodeManager(traceManager) var codeManager = new CodeManager(traceManager)
codeManager.clear() codeManager.clear()

@ -1,17 +1,15 @@
'use strict' 'use strict'
var vmCall = require('../vmCall') import { sendTx } from '../vmCall'
var traceHelper = require('../../../src/trace/traceHelper') import { contractCreationToken } from '../../../src/trace/traceHelper'
var SolidityProxy = require('../../../src/solidity-decoder/solidityProxy') import { SolidityProxy } from '../../../src/solidity-decoder/solidityProxy'
var InternalCallTree = require('../../../src/solidity-decoder/internalCallTree') import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree'
var EventManager = require('../../../src/eventManager') import { EventManager } from '../../../src/eventManager'
import * as helper from './helper'
var helper = require('./helper') import { TraceManager } from '../../../src/trace/traceManager'
import { CodeManager } from '../../../src/code/codeManager'
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
vmCall.sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) { sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) {
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
@ -19,7 +17,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
tx.to = traceHelper.contractCreationToken('0') tx.to = contractCreationToken('0')
var traceManager = new TraceManager({ web3: vm.web3 }) var traceManager = new TraceManager({ web3: vm.web3 })
var codeManager = new CodeManager(traceManager) var codeManager = new CodeManager(traceManager)
codeManager.clear() codeManager.clear()

@ -1,16 +1,15 @@
'use strict' 'use strict'
var vmCall = require('../vmCall') import { sendTx } from '../vmCall'
var traceHelper = require('../../../src/trace/traceHelper') import { contractCreationToken } from '../../../src/trace/traceHelper'
var SolidityProxy = require('../../../src/solidity-decoder/solidityProxy') import { SolidityProxy } from '../../../src/solidity-decoder/solidityProxy'
var InternalCallTree = require('../../../src/solidity-decoder/internalCallTree') import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree'
var EventManager = require('../../../src/eventManager') import { EventManager } from '../../../src/eventManager'
var helper = require('./helper') import * as helper from './helper'
import { TraceManager } from '../../../src/trace/traceManager'
var TraceManager = require('../../../src/trace/traceManager') import { CodeManager } from '../../../src/code/codeManager'
var CodeManager = require('../../../src/code/codeManager')
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
vmCall.sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) { sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) {
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
@ -18,7 +17,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
if (error) { if (error) {
return st.fail(error) return st.fail(error)
} }
tx.to = traceHelper.contractCreationToken('0') tx.to = contractCreationToken('0')
var traceManager = new TraceManager({ web3: vm.web3 }) var traceManager = new TraceManager({ web3: vm.web3 })
var codeManager = new CodeManager(traceManager) var codeManager = new CodeManager(traceManager)
codeManager.clear() codeManager.clear()

@ -6,7 +6,7 @@ var BN = require('ethereumjs-util').BN
var remixLib = require('@remix-project/remix-lib') var remixLib = require('@remix-project/remix-lib')
var EthJSVM = require('ethereumjs-vm').default var EthJSVM = require('ethereumjs-vm').default
function sendTx (vm, from, to, value, data, cb) { export function sendTx (vm, from, to, value, data, cb) {
var tx = new Tx({ var tx = new Tx({
nonce: new BN(from.nonce++), nonce: new BN(from.nonce++),
gasPrice: new BN(1), gasPrice: new BN(1),
@ -52,7 +52,7 @@ function createVm (hardfork) {
/* /*
Init VM / Send Transaction Init VM / Send Transaction
*/ */
function initVM (st, privateKey) { export function initVM (st, privateKey) {
var VM = createVm('muirGlacier') var VM = createVm('muirGlacier')
const vm = VM.vm const vm = VM.vm
@ -72,7 +72,3 @@ function initVM (st, privateKey) {
return vm return vm
} }
module.exports = {
sendTx: sendTx,
initVM: initVM
}

Loading…
Cancel
Save