use solidity jsonio

pull/7/head
yann300 7 years ago
parent b90bca181d
commit fb3aeb9184
  1. 20
      src/code/sourceLocationTracker.js
  2. 2
      src/solidity/astHelper.js
  3. 17
      src/solidity/solidityProxy.js
  4. 2
      src/util/astWalker.js
  5. 3
      src/util/internalCallTree.js
  6. 4
      src/util/sourceMappingDecoder.js
  7. 4
      test/astwalker.js
  8. 26
      test/helpers.js
  9. 2
      test/resources/ast.js
  10. 23
      test/solidity/decodeInfo.js
  11. 21
      test/solidity/localDecoder.js
  12. 3
      test/solidity/localsTests/int.js
  13. 10
      test/solidity/storageDecoder.js
  14. 4
      test/solidity/storageLocation.js
  15. 8
      test/sourceMappingDecoder.js

@ -57,19 +57,15 @@ SourceLocationTracker.prototype.getSourceLocationFromVMTraceIndex = function (ad
})
}
/**
* backwards compatibility - attribute name will certainly be changed
*/
function srcmapRuntime (contract) {
return contract.srcmapRuntime ? contract.srcmapRuntime : contract['srcmap-runtime']
}
function getSourceMap (address, code, contracts) {
var isCreation = helper.isContractCreation(address)
var byteProp = isCreation ? 'bytecode' : 'runtimeBytecode'
for (var k in contracts) {
if (util.compareByteCode(code, '0x' + contracts[k][byteProp])) {
return isCreation ? contracts[k].srcmap : srcmapRuntime(contracts[k])
var bytes
for (var file in contracts) {
for (var contract in contracts[file]) {
bytes = isCreation ? contracts[file][contract].evm.bytecode.object : contracts[file][contract].evm.deployedBytecode.object
if (util.compareByteCode(code, '0x' + bytes)) {
return isCreation ? contracts[file][contract].evm.bytecode.sourceMap : contracts[file][contract].evm.deployedBytecode.sourceMap
}
}
}
return null
@ -82,7 +78,7 @@ function extractSourceMap (codeManager, address, contracts, cb) {
if (sourceMap) {
cb(null, sourceMap)
} else {
cb('no srcmap associated with the code ' + address)
cb('no sourcemap associated with the code ' + address)
}
} else {
cb(error)

@ -15,7 +15,7 @@ function extractContractDefinitions (sourcesList) {
}
var walker = new AstWalker()
for (var k in sourcesList) {
walker.walk(sourcesList[k].AST, { 'ContractDefinition': function (node) {
walker.walk(sourcesList[k].legacyAST, { 'ContractDefinition': function (node) {
ret.contractsById[node.id] = node
ret.sourcesByContract[node.id] = k
ret.contractsByName[k + ':' + node.attributes.name] = node

@ -19,7 +19,6 @@ class SolidityProxy {
*/
reset (compilationResult) {
this.sources = compilationResult.sources
this.sourceList = compilationResult.sourceList
this.contracts = compilationResult.contracts
this.cache.reset()
}
@ -113,9 +112,9 @@ class SolidityProxy {
* @return {Object} - AST of the current file
*/
ast (sourceLocation) {
var file = this.sourceList[sourceLocation.file]
var file = this.fileNameFromIndex(sourceLocation.file)
if (this.sources[file]) {
return this.sources[file].AST
return this.sources[file].legacyAST
} else {
console.log('AST not found for file id ' + sourceLocation.file)
return null
@ -129,16 +128,18 @@ class SolidityProxy {
* @return {String} - filename
*/
fileNameFromIndex (index) {
return this.sourceList[index]
return Object.keys(this.contracts)[index]
}
}
function contractNameFromCode (contracts, code, address) {
var isCreation = traceHelper.isContractCreation(address)
var byteProp = isCreation ? 'bytecode' : 'runtimeBytecode'
for (var k in contracts) {
if (util.compareByteCode(code, '0x' + contracts[k][byteProp])) {
return k
for (var file in contracts) {
for (var contract in contracts[file]) {
var bytecode = isCreation ? contracts[file][contract].evm.bytecode.object : contracts[file][contract].evm.deployedBytecode.object
if (util.compareByteCode(code, '0x' + bytecode)) {
return contract
}
}
}
return null

@ -39,7 +39,7 @@ AstWalker.prototype.walk = function (ast, callback) {
AstWalker.prototype.walkAstList = function (sourcesList, callback) {
var walker = new AstWalker()
for (var k in sourcesList) {
walker.walk(sourcesList[k].AST, callback)
walker.walk(sourcesList[k].legacyAST, callback)
}
}

@ -40,6 +40,9 @@ class InternalCallTree {
createReducedTrace(this, traceManager.trace.length - 1)
this.event.trigger('callTreeReady', [this.scopes, this.scopeStarts])
}
}, (reason) => {
console.log('analyzing trace falls ' + reason)
this.event.trigger('callTreeNotReady', [reason])
})
}
})

@ -161,7 +161,7 @@ function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) {
return false
}
}
astWalker.walk(ast.AST, callback)
astWalker.walk(ast.legacyAST, callback)
return found
}
@ -184,7 +184,7 @@ function nodesAtPosition (astNodeType, position, ast) {
return false
}
}
astWalker.walk(ast.AST, callback)
astWalker.walk(ast.legacyAST, callback)
return found
}

@ -8,7 +8,7 @@ tape('ASTWalker', function (t) {
st.plan(24)
var astwalker = new AstWalker()
astwalker.walk(node.ast.AST, function (node) {
astwalker.walk(node.ast.legacyAST, function (node) {
if (node.name === 'ContractDefinition') {
checkContract(st, node)
}
@ -24,7 +24,7 @@ tape('ASTWalker', function (t) {
st.equal(node.attributes.name === 'set' || node.attributes.name === 'get', true)
return true
}
astwalker.walk(node.ast.AST, callback)
astwalker.walk(node.ast.legacyAST, callback)
})
})

@ -0,0 +1,26 @@
'use strict'
module.exports = {
compilerInput: (contracts) => {
return JSON.stringify({
language: 'Solidity',
sources: {
'test.sol': {
content: contracts
}
},
settings: {
optimizer: {
enabled: false,
runs: 500
}
},
outputSelection: {
'*': {
'*': [ 'metadata', 'evm.bytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ]
}
}
})
}
}

@ -1,6 +1,6 @@
var node = {}
node.ast = {"AST":{"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.source = `contract test {
int x;

@ -4,12 +4,14 @@ var compiler = require('solc')
var index = require('../../src/index')
var contracts = require('./contracts/miscContracts')
var simplecontracts = require('./contracts/simpleContract')
var helpers = require('../helpers.js')
tape('solidity', function (t) {
t.test('astHelper, decodeInfo', function (st) {
var output = compiler.compile(contracts, 0)
var output = compiler.compileStandardWrapper(helpers.compilerInput(contracts))
output = JSON.parse(output)
var state = index.solidity.astHelper.extractStateDefinitions(':contractUint', output.sources)
var state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractUint', output.sources)
var states = index.solidity.astHelper.extractStatesDefinitions(output.sources)
var stateDef = state.stateDefinitions
var decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractUint')
@ -21,7 +23,7 @@ tape('solidity', function (t) {
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[4].attributes.type, states, 'contractUint')
checkDecodeInfo(st, decodeInfo, 1, 16, 'bytes16')
state = index.solidity.astHelper.extractStateDefinitions(':contractStructAndArray', output.sources)
state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractStructAndArray', output.sources)
stateDef = state.stateDefinitions
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractStructAndArray')
checkDecodeInfo(st, decodeInfo, 2, 32, 'struct contractStructAndArray.structDef')
@ -30,7 +32,7 @@ tape('solidity', function (t) {
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[3].attributes.type, states, 'contractStructAndArray')
checkDecodeInfo(st, decodeInfo, 2, 32, 'bytes12[4]')
state = index.solidity.astHelper.extractStateDefinitions(':contractArray', output.sources)
state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractArray', output.sources)
stateDef = state.stateDefinitions
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractArray')
checkDecodeInfo(st, decodeInfo, 1, 32, 'uint32[5]')
@ -39,12 +41,12 @@ tape('solidity', function (t) {
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractArray')
checkDecodeInfo(st, decodeInfo, 4, 32, 'int16[][3][][4]')
state = index.solidity.astHelper.extractStateDefinitions(':contractEnum', output.sources)
state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractEnum', output.sources)
stateDef = state.stateDefinitions
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractEnum')
checkDecodeInfo(st, decodeInfo, 1, 2, 'enum')
state = index.solidity.astHelper.extractStateDefinitions(':contractSmallVariable', output.sources)
state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractSmallVariable', output.sources)
stateDef = state.stateDefinitions
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractSmallVariable')
checkDecodeInfo(st, decodeInfo, 1, 1, 'int8')
@ -59,9 +61,10 @@ tape('solidity', function (t) {
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[5].attributes.type, states, 'contractSmallVariable')
checkDecodeInfo(st, decodeInfo, 1, 2, 'int16')
output = compiler.compile(simplecontracts, 0)
output = compiler.compileStandardWrapper(helpers.compilerInput(simplecontracts))
output = JSON.parse(output)
state = index.solidity.astHelper.extractStateDefinitions(':simpleContract', output.sources)
state = index.solidity.astHelper.extractStateDefinitions('test.sol:simpleContract', output.sources)
states = index.solidity.astHelper.extractStatesDefinitions(output.sources)
stateDef = state.stateDefinitions
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[2].attributes.type, states, 'simpleContract')
@ -71,12 +74,12 @@ tape('solidity', function (t) {
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[4].attributes.type, states, 'simpleContract')
checkDecodeInfo(st, decodeInfo, 1, 1, 'enum')
state = index.solidity.astHelper.extractStateDefinitions(':test2', output.sources)
state = index.solidity.astHelper.extractStateDefinitions('test.sol:test2', output.sources)
stateDef = state.stateDefinitions
decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'test1')
checkDecodeInfo(st, decodeInfo, 0, 32, 'struct test1.str')
state = index.solidity.stateDecoder.extractStateVariables(':test2', output.sources)
state = index.solidity.stateDecoder.extractStateVariables('test.sol:test2', output.sources)
checkDecodeInfo(st, decodeInfo, 0, 32, 'struct test1.str')
st.end()

@ -12,6 +12,7 @@ var intLocalTest = require('./localsTests/int')
var miscLocalTest = require('./localsTests/misc')
var misc2LocalTest = require('./localsTests/misc2')
var structArrayLocalTest = require('./localsTests/structArray')
var helpers = require('../helpers.js')
tape('solidity', function (t) {
t.test('local decoder', function (st) {
@ -47,14 +48,18 @@ function initVM (st, address) {
}
function test (st, vm, privateKey) {
var output = compiler.compile(intLocal.contract, 0)
intLocalTest(st, vm, privateKey, output.contracts[':intLocal'].bytecode, output, function () {
output = compiler.compile(miscLocal.contract, 0)
miscLocalTest(st, vm, privateKey, output.contracts[':miscLocal'].bytecode, output, function () {
output = compiler.compile(miscLocal.contract, 0)
misc2LocalTest(st, vm, privateKey, output.contracts[':miscLocal2'].bytecode, output, function () {
output = compiler.compile(structArrayLocal.contract, 0)
structArrayLocalTest(st, vm, privateKey, output.contracts[':structArrayLocal'].bytecode, output, function () {})
var output = compiler.compileStandardWrapper(helpers.compilerInput(intLocal.contract))
output = JSON.parse(output)
intLocalTest(st, vm, privateKey, output.contracts['test.sol']['intLocal'].evm.bytecode.object, output, function () {
output = compiler.compileStandardWrapper(helpers.compilerInput(miscLocal.contract))
output = JSON.parse(output)
miscLocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal'].evm.bytecode.object, output, function () {
output = compiler.compileStandardWrapper(helpers.compilerInput(miscLocal.contract))
output = JSON.parse(output)
misc2LocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal2'].evm.bytecode.object, output, function () {
output = compiler.compileStandardWrapper(helpers.compilerInput(structArrayLocal.contract))
output = JSON.parse(output)
structArrayLocalTest(st, vm, privateKey, output.contracts['test.sol']['structArrayLocal'].evm.bytecode.object, output, function () {})
})
})
})

@ -29,6 +29,9 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
callTree.event.register('callTreeBuildFailed', (error) => {
st.fail(error)
})
callTree.event.register('callTreeNotReady', (reason) => {
st.fail(reason)
})
callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
try {
st.equals(scopeStarts[0], '')

@ -3,6 +3,7 @@ var tape = require('tape')
var compiler = require('solc')
var stateDecoder = require('../../src/index').solidity.stateDecoder
var MockStorageResolver = require('./mockStorageResolver')
var helpers = require('../helpers.js')
tape('solidity', function (t) {
t.test('storage decoder', function (st) {
@ -18,7 +19,8 @@ tape('solidity', function (t) {
function testIntStorage (st, cb) {
var intStorage = require('./contracts/intStorage')
var output = compiler.compile(intStorage.contract, 0)
var output = compiler.compileStandardWrapper(helpers.compilerInput(intStorage.contract))
output = JSON.parse(output)
var mockStorageResolver
for (var storage of [intStorage.fullStorage, shrinkStorage(intStorage.fullStorage)]) {
mockStorageResolver = new MockStorageResolver(storage)
@ -64,7 +66,8 @@ function testIntStorage (st, cb) {
function testByteStorage (st, cb) {
var byteStorage = require('./contracts/byteStorage')
var output = compiler.compile(byteStorage.contract, 0)
var output = compiler.compileStandardWrapper(helpers.compilerInput(byteStorage.contract))
output = JSON.parse(output)
var mockStorageResolver
for (var storage of [byteStorage.storage, shrinkStorage(byteStorage.storage)]) {
mockStorageResolver = new MockStorageResolver(storage)
@ -176,7 +179,8 @@ function shrinkStorage (storage) {
function testStructArrayStorage (st, cb) {
var structArrayStorage = require('./contracts/structArrayStorage')
var output = compiler.compile(structArrayStorage.contract, 0)
var output = compiler.compileStandardWrapper(helpers.compilerInput(structArrayStorage.contract))
output = JSON.parse(output)
var mockStorageResolver = new MockStorageResolver(structArrayStorage.storage)
stateDecoder.solidityState(mockStorageResolver, output.sources, 'structArrayStorage').then((decoded) => {
st.equal(decoded['intStructDec'].value['i8'].value, '32')

@ -3,10 +3,12 @@ var tape = require('tape')
var compiler = require('solc')
var index = require('../../src/index')
var contracts = require('./contracts/miscContracts')
var helpers = require('../helpers.js')
tape('solidity', function (t) {
t.test('storage location', function (st) {
var output = compiler.compile(contracts, 0)
var output = compiler.compileStandardWrapper(helpers.compilerInput(contracts))
output = JSON.parse(output)
var stateDec = index.solidity.stateDecoder.extractStateVariables('contractUint', output.sources)
checkLocation(st, stateDec[0].storagelocation, 0, 0)
checkLocation(st, stateDec[1].storagelocation, 1, 0)

@ -2,14 +2,16 @@
var tape = require('tape')
var SourceMappingDecoder = require('../src/util/sourceMappingDecoder')
var compiler = require('solc')
var helpers = require('./helpers.js')
tape('SourceMappingDecoder', function (t) {
t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) {
var output = compiler.compile(contracts, 0)
var output = compiler.compileStandardWrapper(helpers.compilerInput(contracts))
output = JSON.parse(output)
var sourceMappingDecoder = new SourceMappingDecoder()
var node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 2, output.contracts[':test'].srcmapRuntime, output.sources[''])
var node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 2, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol'])
st.equal(node, null)
node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 80, output.contracts[':test'].srcmapRuntime, output.sources[''])
node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 80, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol'])
st.notEqual(node, null)
if (node) {
st.equal(node.attributes.name, 'f1')

Loading…
Cancel
Save