linting fixed for remix-debug

pull/4771/head
lianahus 7 months ago
parent f5cdc389a7
commit e5920ae3b2
  1. 2
      libs/remix-debug/src/debugger/debugger.ts
  2. 4
      libs/remix-debug/src/init.ts
  3. 2
      libs/remix-debug/src/solidity-decoder/internalCallTree.ts
  4. 2
      libs/remix-debug/src/trace/traceAnalyser.ts
  5. 2
      libs/remix-debug/test.ts
  6. 2
      libs/remix-debug/test/codeManager.ts
  7. 8
      libs/remix-debug/test/debugger.ts
  8. 2
      libs/remix-debug/test/decoder/contracts/calldata.ts
  9. 2
      libs/remix-debug/test/decoder/contracts/intLocal.ts
  10. 2
      libs/remix-debug/test/decoder/contracts/miscLocal.ts
  11. 2
      libs/remix-debug/test/decoder/contracts/structArrayLocal.ts
  12. 3
      libs/remix-debug/test/decoder/localsTests/calldata.ts
  13. 8
      libs/remix-debug/test/decoder/stateTests/mapping.ts
  14. 4
      libs/remix-debug/test/helpers/compilerHelper.ts
  15. 29
      libs/remix-debug/test/resources/ast.ts
  16. 2
      libs/remix-debug/test/resources/testWeb3.ts
  17. 8
      libs/remix-debug/test/sourceLocationTracker.ts
  18. 2
      libs/remix-debug/test/traceManager.ts
  19. 1
      libs/remix-debug/test/vmCall.ts

@ -97,7 +97,7 @@ export class Debugger {
const instructionIndexes = lineGasCostObj.indexes.map((index) => { // translate from vmtrace index to instruction index
return this.debugger.codeManager.getInstructionIndex(address, index)
})
this.vmDebuggerLogic.event.trigger('lineGasCostChanged', [instructionIndexes, lineColumnPos.start.line ])
this.vmDebuggerLogic.event.trigger('lineGasCostChanged', [instructionIndexes, lineColumnPos.start.line])
this.currentFile = rawLocation.file
this.currentLine = lineColumnPos.start.line
}

@ -1,9 +1,9 @@
'use strict'
import Web3, { Web3PluginBase } from 'web3'
import {toNumber} from 'web3-utils'
import { toNumber } from 'web3-utils'
export function extendWeb3 (web3) {
if(!web3.debug){
if (!web3.debug){
web3.registerPlugin(new Web3DebugPlugin())
}
}

@ -391,7 +391,7 @@ function getGeneratedSources (tree, scopeId, contractObj) {
async function registerFunctionParameters (tree, functionDefinition, step, scopeId, contractObj, sourceLocation, address) {
tree.functionCallStack.push(step)
const functionDefinitionAndInputs = { functionDefinition, inputs: [] }
const functionDefinitionAndInputs = { functionDefinition, inputs: []}
// means: the previous location was a function definition && JUMPDEST
// => we are at the beginning of the function and input/output are setup
try {

@ -1,5 +1,5 @@
'use strict'
import { util } from '@remix-project/remix-lib'
import { util } from '@remix-project/remix-lib'
import { bytesToHex } from '@ethereumjs/util'
const { toHexPaddedString } = util
import * as traceHelper from './traceHelper'

@ -37,7 +37,7 @@ const compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(in
console.dir(Object.keys(compilationData))
const compilation = {}
compilation['data'] = compilationData
compilation['source'] = {sources: inputJson.sources}
compilation['source'] = { sources: inputJson.sources }
console.dir(compilation)
console.dir(compilation['data'].errors)

@ -5,7 +5,7 @@ import { CodeManager } from '../src/code/codeManager'
const web3Test = require('./resources/testWeb3.ts')
tape('CodeManager', function (t) {
const traceManager = new TraceManager({web3: web3Test})
const traceManager = new TraceManager({ web3: web3Test })
const codeManager = new CodeManager(traceManager)
const contractCode = web3Test.eth.getCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', contractCode) // so a call to web3 is not necessary

@ -156,7 +156,7 @@ contract Ballot {
output = JSON.parse(output)
const param = '0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000148656c6c6f20576f726c64210000000000000000000000000000000000000000'
const web3 = await vmCall.getWeb3()
vmCall.sendTx(web3, {nonce: 0, privateKey: privateKey}, undefined, 0, output.contracts['test.sol']['Ballot'].evm.bytecode.object + param, (error, hash) => {
vmCall.sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, output.contracts['test.sol']['Ballot'].evm.bytecode.object + param, (error, hash) => {
console.log(error, hash)
if (error) {
throw error
@ -279,10 +279,10 @@ function testDebugging (debugManager) {
tape('breakPointManager', (t) => {
t.plan(2)
const {traceManager, callTree, solidityProxy} = debugManager
const breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy})
const { traceManager, callTree, solidityProxy } = debugManager
const breakPointManager = new BreakpointManager({ traceManager, callTree, solidityProxy })
breakPointManager.add({fileName: 'test.sol', row: 39})
breakPointManager.add({ fileName: 'test.sol', row: 39 })
breakPointManager.event.register('breakpointHit', function (sourceLocation, step) {
t.equal(JSON.stringify(sourceLocation), JSON.stringify({ start: 1146, length: 6, file: 0, jump: '-' }))

@ -11,4 +11,4 @@ module.exports = {
uint p = 45;
}
}
`}
` }

@ -39,4 +39,4 @@ contract intLocal {
uint8 ui81 = asd;
}
}
`}
` }

@ -36,4 +36,4 @@ contract miscLocal {
string memory smallstring = "test_test_test";
}
}
`}
` }

@ -81,4 +81,4 @@ contract structArrayLocal {
arrayStruct.c = enumdef.three;
}
}
`}
` }

@ -54,7 +54,7 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe
callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
helper.decodeLocals(st, 140, traceManager, callTree, function (locals) {
try {
const expected = {"p":{"value":"45","type":"uint256"},"foo":{"length":"1","value":[{"value":"3","type":"uint8"}],"type":"uint8[1]"},"boo":{"length":"1","value":[{"length":"2","value":[{"value":"R","type":"string"},{"value":"T","type":"string"}],"type":"string[2]"}],"type":"string[2][1]"}}
const expected = { "p":{ "value":"45","type":"uint256" },"foo":{ "length":"1","value":[{ "value":"3","type":"uint8" }],"type":"uint8[1]" },"boo":{ "length":"1","value":[{ "length":"2","value":[{ "value":"R","type":"string" },{ "value":"T","type":"string" }],"type":"string[2]" }],"type":"string[2][1]" } }
st.deepEqual(locals, expected)
} catch (e) {
st.fail(e.message)
@ -63,7 +63,6 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe
})
})
traceManager.resolveTrace(tx).then(() => {
debuggerEvent.trigger('newTraceLoaded', [traceManager.trace])
}).catch((error) => {

@ -10,7 +10,7 @@ import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree
import * as vmCall from '../../vmCall'
import { StorageResolver } from '../../../src/storage/storageResolver'
import { StorageViewer } from '../../../src/storage/storageViewer'
import { Address, bytesToHex } from '@ethereumjs/util'
import { Address, bytesToHex } from '@ethereumjs/util'
module.exports = async function testMappingStorage (st, cb) {
const mappingStorage = require('../contracts/mappingStorage')
@ -23,7 +23,7 @@ module.exports = async function testMappingStorage (st, cb) {
}
const compilationResults = new CompilerAbstract('json', output, sources)
const web3 = await (vmCall as any).getWeb3();
(vmCall as any).sendTx(web3, {nonce: 0, privateKey: privateKey}, undefined, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, hash) {
(vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, hash) {
if (error) {
console.log(error)
st.end(error)
@ -44,7 +44,7 @@ module.exports = async function testMappingStorage (st, cb) {
}
function testMapping (st, privateKey, contractAddress, output, compilationResults, web3, cb) {
(vmCall as any).sendTx(web3, {nonce: 1, privateKey: privateKey}, contractAddress, 0, '2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000',
(vmCall as any).sendTx(web3, { nonce: 1, privateKey: privateKey }, contractAddress, 0, '2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000',
function (error, hash) {
if (error) {
console.log(error)
@ -74,7 +74,7 @@ function testMapping (st, privateKey, contractAddress, output, compilationResult
stepIndex: 268,
tx: tx,
address: contractAddress
}, new StorageResolver({web3}), traceManager)
}, new StorageResolver({ web3 }), traceManager)
const stateVars = stateDecoder.extractStateVariables('SimpleMappingState', output.sources)
stateDecoder.decodeState(stateVars, storageViewer).then((result) => {
st.equal(result['_num'].value, '1')

@ -13,8 +13,8 @@ export function compilerInput (contracts) {
},
outputSelection: {
'*': {
'': [ 'ast' ],
'*': [ 'abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ]
'': ['ast'],
'*': ['abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates']
}
}
}

@ -1,14 +1,14 @@
const node = {}
node['ast'] = {"legacyAST":{"children":[{"attributes":{"fullyImplemented":true,"isLibrary":false,"linearizedBaseContracts":[5640396],"name":"test"},"children":[{"attributes":{"name":"x","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5657860,"name":"ElementaryTypeName","src":"21:3:11"}],"id":5658100,"name":"VariableDeclaration","src":"21:5:11"},{"attributes":{"name":"y","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658180,"name":"ElementaryTypeName","src":"38:3:11"}],"id":5658268,"name":"VariableDeclaration","src":"38:5:11"},{"attributes":{"constant":false,"name":"set","public":true},"children":[{"children":[{"attributes":{"name":"_x","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658404,"name":"ElementaryTypeName","src":"68:3:11"}],"id":5658492,"name":"VariableDeclaration","src":"68:6:11"}],"id":5658572,"name":"ParameterList","src":"67:8:11"},{"children":[{"attributes":{"name":"_r","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658628,"name":"ElementaryTypeName","src":"85:3:11"}],"id":5658716,"name":"VariableDeclaration","src":"85:6:11"}],"id":5658796,"name":"ParameterList","src":"84:8:11"},{"children":[{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"x"},"id":5658900,"name":"Identifier","src":"108:1:11"},{"attributes":{"type":"int256","value":"_x"},"id":5658980,"name":"Identifier","src":"112:2:11"}],"id":5657492,"name":"Assignment","src":"108:6:11"}],"id":5659028,"name":"ExpressionStatement","src":"108:6:11"},{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"y"},"id":5659116,"name":"Identifier","src":"125:1:11"},{"attributes":{"string":null,"type":"int_const 10","value":"10"},"id":5659196,"name":"Literal","src":"129:2:11"}],"id":5659252,"name":"Assignment","src":"125:6:11"}],"id":5659316,"name":"ExpressionStatement","src":"125:6:11"},{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"_r"},"id":5659428,"name":"Identifier","src":"141:2:11"},{"attributes":{"type":"int256","value":"x"},"id":5639308,"name":"Identifier","src":"146:1:11"}],"id":5639356,"name":"Assignment","src":"141:6:11"}],"id":5639420,"name":"ExpressionStatement","src":"141:6:11"}],"id":5639516,"name":"Block","src":"97:57:11"}],"id":5639612,"name":"FunctionDefinition","src":"55:99:11"},{"attributes":{"constant":false,"name":"get","public":true},"children":[{"children":[],"id":5639764,"name":"ParameterList","src":"179:2:11"},{"children":[{"attributes":{"name":"x","type":"uint256"},"children":[{"attributes":{"name":"uint"},"id":5639820,"name":"ElementaryTypeName","src":"191:4:11"}],"id":5639908,"name":"VariableDeclaration","src":"191:6:11"},{"attributes":{"name":"y","type":"uint256"},"children":[{"attributes":{"name":"uint"},"id":5639988,"name":"ElementaryTypeName","src":"199:4:11"}],"id":5640076,"name":"VariableDeclaration","src":"199:6:11"}],"id":5640156,"name":"ParameterList","src":"190:16:11"},{"children":[],"id":5640212,"name":"Block","src":"212:17:11"}],"id":5640276,"name":"FunctionDefinition","src":"167:62:11"}],"id":5640396,"name":"ContractDefinition","src":"0:231:11"}],"name":"SourceUnit"}}
node['ast'] = { "legacyAST":{ "children":[{ "attributes":{ "fullyImplemented":true,"isLibrary":false,"linearizedBaseContracts":[5640396],"name":"test" },"children":[{ "attributes":{ "name":"x","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5657860,"name":"ElementaryTypeName","src":"21:3:11" }],"id":5658100,"name":"VariableDeclaration","src":"21:5:11" },{ "attributes":{ "name":"y","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658180,"name":"ElementaryTypeName","src":"38:3:11" }],"id":5658268,"name":"VariableDeclaration","src":"38:5:11" },{ "attributes":{ "constant":false,"name":"set","public":true },"children":[{ "children":[{ "attributes":{ "name":"_x","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658404,"name":"ElementaryTypeName","src":"68:3:11" }],"id":5658492,"name":"VariableDeclaration","src":"68:6:11" }],"id":5658572,"name":"ParameterList","src":"67:8:11" },{ "children":[{ "attributes":{ "name":"_r","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658628,"name":"ElementaryTypeName","src":"85:3:11" }],"id":5658716,"name":"VariableDeclaration","src":"85:6:11" }],"id":5658796,"name":"ParameterList","src":"84:8:11" },{ "children":[{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"x" },"id":5658900,"name":"Identifier","src":"108:1:11" },{ "attributes":{ "type":"int256","value":"_x" },"id":5658980,"name":"Identifier","src":"112:2:11" }],"id":5657492,"name":"Assignment","src":"108:6:11" }],"id":5659028,"name":"ExpressionStatement","src":"108:6:11" },{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"y" },"id":5659116,"name":"Identifier","src":"125:1:11" },{ "attributes":{ "string":null,"type":"int_const 10","value":"10" },"id":5659196,"name":"Literal","src":"129:2:11" }],"id":5659252,"name":"Assignment","src":"125:6:11" }],"id":5659316,"name":"ExpressionStatement","src":"125:6:11" },{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"_r" },"id":5659428,"name":"Identifier","src":"141:2:11" },{ "attributes":{ "type":"int256","value":"x" },"id":5639308,"name":"Identifier","src":"146:1:11" }],"id":5639356,"name":"Assignment","src":"141:6:11" }],"id":5639420,"name":"ExpressionStatement","src":"141:6:11" }],"id":5639516,"name":"Block","src":"97:57:11" }],"id":5639612,"name":"FunctionDefinition","src":"55:99:11" },{ "attributes":{ "constant":false,"name":"get","public":true },"children":[{ "children":[],"id":5639764,"name":"ParameterList","src":"179:2:11" },{ "children":[{ "attributes":{ "name":"x","type":"uint256" },"children":[{ "attributes":{ "name":"uint" },"id":5639820,"name":"ElementaryTypeName","src":"191:4:11" }],"id":5639908,"name":"VariableDeclaration","src":"191:6:11" },{ "attributes":{ "name":"y","type":"uint256" },"children":[{ "attributes":{ "name":"uint" },"id":5639988,"name":"ElementaryTypeName","src":"199:4:11" }],"id":5640076,"name":"VariableDeclaration","src":"199:6:11" }],"id":5640156,"name":"ParameterList","src":"190:16:11" },{ "children":[],"id":5640212,"name":"Block","src":"212:17:11" }],"id":5640276,"name":"FunctionDefinition","src":"167:62:11" }],"id":5640396,"name":"ContractDefinition","src":"0:231:11" }],"name":"SourceUnit" } }
node['ast'].ast = {
absolutePath: 'sample.sol',
exportedSymbols: { test: [ 33 ] },
exportedSymbols: { test: [33]},
id: 34,
nodeType: 'SourceUnit',
nodes:
[ {
[{
abstract: false,
baseContracts: [],
contractDependencies: [],
@ -16,11 +16,11 @@ node['ast'].ast = {
documentation: null,
fullyImplemented: true,
id: 33,
linearizedBaseContracts: [ 33 ],
linearizedBaseContracts: [33],
name: 'test',
nodeType: 'ContractDefinition',
nodes:
[ { constant: false,
[{ constant: false,
id: 2,
name: 'x',
nodeType: 'VariableDeclaration',
@ -54,14 +54,14 @@ node['ast'].ast = {
name: 'int',
nodeType: 'ElementaryTypeName',
src: '31:3:0',
typeDescriptions: [Object] },
typeDescriptions: [Object]},
value: null,
visibility: 'internal' },
{ body: { id: 23,
nodeType: 'Block',
src: '96:55:0',
statements:
[ { expression:
[{ expression:
{ argumentTypes: null,
id: 13,
isConstant: false,
@ -69,7 +69,7 @@ node['ast'].ast = {
isPure: false,
lValueRequested: false,
leftHandSide:
{ argumentTypes: null,
{ argumentTypes: null,
id: 11,
name: 'x',
nodeType: 'Identifier',
@ -106,7 +106,7 @@ node['ast'].ast = {
operator: '=',
rightHandSide: [Object],
src: '122:6:0',
typeDescriptions: [Object] },
typeDescriptions: [Object]},
id: 18,
nodeType: 'ExpressionStatement',
src: '122:6:0' },
@ -122,10 +122,10 @@ node['ast'].ast = {
operator: '=',
rightHandSide: [Object],
src: '138:6:0',
typeDescriptions: [Object] },
typeDescriptions: [Object]},
id: 22,
nodeType: 'ExpressionStatement',
src: '138:6:0' } ]
src: '138:6:0' }]
},
documentation: null,
functionSelector: 'e5c19b2d',
@ -149,7 +149,7 @@ node['ast'].ast = {
stateMutability: 'nonpayable',
virtual: false,
visibility: 'public' },
{ body: { id: 31, nodeType: 'Block', src: '214:17:0', statements: [] },
{ body: { id: 31, nodeType: 'Block', src: '214:17:0', statements: []},
documentation: null,
functionSelector: '6d4ce63c',
id: 32,
@ -173,14 +173,13 @@ node['ast'].ast = {
src: '163:68:0',
stateMutability: 'nonpayable',
virtual: false,
visibility: 'public' } ],
visibility: 'public' }],
scope: 34,
src: '0:233:0'
} ],
}],
src: '0:233:0'
}
node['source'] = `contract test {
int x;

@ -48,7 +48,7 @@ web3Override.eth.setProvider = function (provider) {}
web3Override.eth.providers = { 'HttpProvider': function (url) {} }
web3Override.eth.currentProvider = {'host': 'test provider'}
web3Override.eth.currentProvider = { 'host': 'test provider' }
if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') {
module.exports = web3Override

@ -11,7 +11,7 @@ import { compilerInput } from './helpers/compilerHelper'
tape('SourceLocationTracker', function (t) {
t.test('SourceLocationTracker.getSourceLocationFromVMTraceIndex - simple contract', async function (st) {
const traceManager = new TraceManager({web3: web3Test})
const traceManager = new TraceManager({ web3: web3Test })
const codeManager = new CodeManager(traceManager)
let output = compiler.compile(compilerInput(contracts))
@ -23,7 +23,7 @@ tape('SourceLocationTracker', function (t) {
traceManager.resolveTrace(tx).then(async () => {
const sourceLocationTracker = new SourceLocationTracker(codeManager, {debugWithGeneratedSources: false})
const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: false })
try {
const map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 0, output.contracts)
@ -42,7 +42,7 @@ tape('SourceLocationTracker', function (t) {
t.test('SourceLocationTracker.getSourceLocationFromVMTraceIndex - ABIEncoder V2 contract', async function (st) {
const traceManager = new TraceManager({web3: web3Test})
const traceManager = new TraceManager({ web3: web3Test })
const codeManager = new CodeManager(traceManager)
let output = compiler.compile(compilerInput(ABIEncoderV2))
@ -54,8 +54,6 @@ tape('SourceLocationTracker', function (t) {
traceManager.resolveTrace(tx).then(async () => {
try {
// with debugWithGeneratedSources: false
const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: false })

@ -7,7 +7,7 @@ tape('TraceManager', function (t) {
let traceManager
t.test('TraceManager.init', function (st) {
traceManager = new TraceManager({web3: web3Test})
traceManager = new TraceManager({ web3: web3Test })
st.end()
})

@ -4,7 +4,6 @@ import { Address } from '@ethereumjs/util'
import { Web3 } from 'web3';
const { Provider } = require('@remix-project/remix-simulator')
async function getWeb3 () {
const remixSimulatorProvider = new Provider({ fork: 'berlin' })
await remixSimulatorProvider.init()

Loading…
Cancel
Save