tests working

pull/697/head
aniket-engg 4 years ago committed by Aniket
parent 15f3423b8c
commit eaf16db743
  1. 2
      libs/remix-debug/src/solidity-decoder/internalCallTree.ts
  2. 8
      libs/remix-debug/test.ts
  3. 6
      libs/remix-debug/test/codeManager.ts
  4. 16
      libs/remix-debug/test/debugger.ts
  5. 4
      libs/remix-debug/test/decoder/storageDecoder.ts
  6. 32
      libs/remix-debug/test/sourceLocationTracker.ts
  7. 65
      libs/remix-debug/test/sourceMappingDecoder.ts
  8. 2
      libs/remix-debug/test/tests.ts
  9. 2
      libs/remix-debug/test/traceManager.ts

@ -5,7 +5,7 @@ import { SourceLocationTracker } from '../source/sourceLocationTracker'
import { EventManager } from '../eventManager'
import { parseType } from './decodeInfo'
import { isContractCreation, isCallInstruction, isCreateInstruction, isJumpDestInstruction } from '../trace/traceHelper'
import { extractLocationFromAstVariable } from './types/util.js'
import { extractLocationFromAstVariable } from './types/util'
/**
* Tree representing internal jump into function.

@ -1,5 +1,5 @@
// TODO: this file shoudl be removed at some point
var CmdLine = require('./src/cmdline/index.js')
var CmdLine = require('./src/cmdline/index')
// var compilation = require('./compilation.json')
var solc = require('solc')
@ -35,10 +35,10 @@ console.log('compiling...')
let compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(inputJson)))
console.dir(Object.keys(compilationData))
var compilation = {}
compilation.data = compilationData
compilation.source = { sources: inputJson.sources }
compilation['data'] = compilationData
compilation['source'] = { sources: inputJson.sources }
console.dir(compilation)
console.dir(compilation.data.errors)
console.dir(compilation['data'].errors)
var cmdLine = new CmdLine()
cmdLine.connect('http', 'http://localhost:8545')

@ -1,8 +1,8 @@
'use strict'
import tape from 'tape'
const TraceManager = require('../src/trace/traceManager')
const CodeManager = require('../src/code/codeManager')
const web3Test = require('./resources/testWeb3')
import { TraceManager } from '../src/trace/traceManager'
import { CodeManager } from '../src/code/codeManager'
const web3Test = require('./resources/testWeb3.ts')
tape('CodeManager', function (t) {
const traceManager = new TraceManager({web3: web3Test})

@ -1,12 +1,13 @@
import tape from 'tape'
var deepequal = require('deep-equal')
var remixLib = require('@remix-project/remix-lib')
var compilerInput = require('./helpers/compilerHelper').compilerInput
var SourceMappingDecoder = require('../src/source/sourceMappingDecoder')
import deepequal from 'deep-equal'
import { compilerInput } from './helpers/compilerHelper'
import * as sourceMappingDecoder from '../src/source/sourceMappingDecoder'
import { Ethdebugger as Debugger } from '../src/Ethdebugger'
import { BreakpointManager } from '../src/code/breakpointManager'
var vmCall = require('./vmCall')
var Debugger = require('../src/Ethdebugger')
var compiler = require('solc')
var vmCall = require('./vmCall')
var remixLib = require('@remix-project/remix-lib')
var ballot = `pragma solidity >=0.4.22 <0.8.0;
@ -149,8 +150,6 @@ contract Ballot {
}
`
var BreakpointManager = require('../src/code/breakpointManager')
var privateKey = Buffer.from('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex')
var vm = vmCall.initVM(privateKey)
var output = compiler.compile(compilerInput(ballot))
@ -273,7 +272,6 @@ function testDebugging (debugManager) {
tape('breakPointManager', (t) => {
t.plan(2)
var sourceMappingDecoder = new SourceMappingDecoder()
const {traceManager, callTree, solidityProxy} = debugManager
var breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy, locationToRowConverter: async (rawLocation) => {
return sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, sourceMappingDecoder.getLinebreakPositions(ballot))

@ -2,8 +2,8 @@
import tape from 'tape'
var compiler = require('solc')
var stateDecoder = require('../../src/solidity-decoder/stateDecoder')
var MockStorageResolver = require('./mockStorageResolver')
var compilerInput = require('../helpers/compilerHelper').compilerInput
import { MockStorageResolver } from './mockStorageResolver'
import { compilerInput } from '../helpers/compilerHelper'
var testMappingStorage = require('./stateTests/mapping')
tape('solidity', function (t) {

@ -1,12 +1,12 @@
'use strict'
import tape from 'tape'
const TraceManager = require('../src/trace/traceManager')
const CodeManager = require('../src/code/codeManager')
const web3Test = require('./resources/testWeb3')
import { TraceManager } from '../src/trace/traceManager'
import { CodeManager } from '../src/code/codeManager'
const web3Test = require('./resources/testWeb3.ts')
const sourceMapping = require('./resources/sourceMapping')
const SourceLocationTracker = require('../src/source/sourceLocationTracker')
import { SourceLocationTracker } from '../src/source/sourceLocationTracker'
const compiler = require('solc')
const compilerInput = require('./helpers/compilerHelper').compilerInput
import { compilerInput } from './helpers/compilerHelper'
tape('SourceLocationTracker', function (t) {
t.test('SourceLocationTracker.getSourceLocationFromVMTraceIndex - simple contract', async function (st) {
@ -27,8 +27,8 @@ tape('SourceLocationTracker', function (t) {
try {
const map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 0, output.contracts)
st.equal(map.file, 0)
st.equal(map.start, 0)
st.equal(map['file'], 0)
st.equal(map['start'], 0)
} catch (e) {
console.log(e)
}
@ -59,21 +59,21 @@ tape('SourceLocationTracker', function (t) {
try {
let map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 0, output.contracts)
console.log(map)
st.equal(map.file, 0)
st.equal(map.start, 35)
st.equal(map['file'], 0)
st.equal(map['start'], 35)
map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 45, output.contracts)
st.equal(map.file, 1) // 1 refers to the generated source (pragma experimental ABIEncoderV2)
st.equal(map['file'], 1) // 1 refers to the generated source (pragma experimental ABIEncoderV2)
map = await sourceLocationTracker.getValidSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 45, output.contracts)
st.equal(map.file, 1) // 1 refers to the generated source (pragma experimental ABIEncoderV2)
st.equal(map.start, 1293)
st.equal(map.length, 32)
st.equal(map['file'], 1) // 1 refers to the generated source (pragma experimental ABIEncoderV2)
st.equal(map['start'], 1293)
st.equal(map['length'], 32)
map = await sourceLocationTracker.getValidSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 36, output.contracts)
st.equal(map.file, 0) // 0 refers to the initial solidity code. see source below (ABIEncoderV2)
st.equal(map.start, 303)
st.equal(map.length, 448)
st.equal(map['file'], 0) // 0 refers to the initial solidity code. see source below (ABIEncoderV2)
st.equal(map['start'], 303)
st.equal(map['length'], 448)
} catch (e) {
console.log(e)
}

@ -1,7 +1,7 @@
'use strict'
const tape = require('tape')
const sourceMapping = require('./resources/sourceMapping')
const SourceMappingDecoder = require('../src/source/sourceMappingDecoder')
import * as sourceMappingDecoder from '../src/source/sourceMappingDecoder'
const compiler = require('solc')
const compilerInput = require('./helpers/compilerHelper').compilerInput
@ -9,7 +9,7 @@ tape('SourceMappingDecoder', function (t) {
t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) {
let output = compiler.compile(compilerInput(contracts))
output = JSON.parse(output)
const sourceMappingDecoder = new SourceMappingDecoder()
// const sourceMappingDecoder = new SourceMappingDecoder()
let 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.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol'])
@ -23,7 +23,7 @@ tape('SourceMappingDecoder', function (t) {
const testSourceMapping = {}
t.test('sourceMappingDecoder', function (st) {
st.plan(36)
const sourceMappingDecoder = new SourceMappingDecoder()
// const sourceMappingDecoder = new SourceMappingDecoder()
console.log('test decompressAll')
let result = sourceMappingDecoder.decompressAll(sourceMapping.mapping)
st.equal(result[0].start, 0)
@ -50,50 +50,49 @@ tape('SourceMappingDecoder', function (t) {
testSourceMapping['last'] = result[last]
console.log('test decompress')
result = sourceMappingDecoder.atIndex(22, sourceMapping.mapping)
console.log(result)
st.equal(result.start, 55)
st.equal(result.length, 74)
st.equal(result.file, 4)
st.equal(result.jump, '-')
testSourceMapping[22] = result
const result2 = sourceMappingDecoder.atIndex(22, sourceMapping.mapping)
// console.log(result2)
st.equal(result2['start'], 55)
st.equal(result2['length'], 74)
st.equal(result2['file'], 4)
st.equal(result2['jump'], '-')
testSourceMapping[22] = result2
result = sourceMappingDecoder.atIndex(82, sourceMapping.mapping)
console.log(result)
st.equal(result.start, 103)
st.equal(result.length, 2)
st.equal(result.file, 4)
st.equal(result.jump, '-')
testSourceMapping[82] = result
const result3 = sourceMappingDecoder.atIndex(82, sourceMapping.mapping)
// console.log(result)
st.equal(result3['start'], 103)
st.equal(result3['length'], 2)
st.equal(result['file'], 4)
st.equal(result['jump'], '-')
testSourceMapping[82] = result3
result = sourceMappingDecoder.atIndex(85, sourceMapping.mapping)
console.log(result)
st.equal(result.start, 99)
st.equal(result.length, 6)
st.equal(result.file, 4)
st.equal(result.jump, '-')
testSourceMapping[85] = result
const result4 = sourceMappingDecoder.atIndex(85, sourceMapping.mapping)
// console.log(result)
st.equal(result4['start'], 99)
st.equal(result4['length'], 6)
st.equal(result4['file'], 4)
st.equal(result4['jump'], '-')
testSourceMapping[85] = result4
// ballot - function deletegate(address)
const delegateSrcMap = sourceMappingDecoder.atIndex(64, sourceMapping.ballotSourceMap)
console.log(delegateSrcMap)
st.equal(delegateSrcMap.start, 712)
st.equal(delegateSrcMap.length, 577)
st.equal(delegateSrcMap.file, 0)
st.equal(delegateSrcMap.jump, '-')
st.equal(delegateSrcMap['start'], 712)
st.equal(delegateSrcMap['length'], 577)
st.equal(delegateSrcMap['file'], 0)
st.equal(delegateSrcMap['jump'], '-')
// TokenSaleChallenge - function test(uint256)
const tokenSaleChallengeMap = sourceMappingDecoder.atIndex(170, sourceMapping.tokenSaleChallengeSourceMap)
console.log(tokenSaleChallengeMap)
st.equal(tokenSaleChallengeMap.start, 45)
st.equal(tokenSaleChallengeMap.length, 16)
st.equal(tokenSaleChallengeMap.file, -1)
st.equal(tokenSaleChallengeMap.jump, '-')
st.equal(tokenSaleChallengeMap['start'], 45)
st.equal(tokenSaleChallengeMap['length'], 16)
st.equal(tokenSaleChallengeMap['file'], -1)
st.equal(tokenSaleChallengeMap['jump'], '-')
})
t.test('sourceMappingLineColumnConverter', function (st) {
st.plan(14)
const sourceMappingDecoder = new SourceMappingDecoder()
const linesbreak = sourceMappingDecoder.getLinebreakPositions(sourceMapping.source)
st.equal(linesbreak[0], 16)
st.equal(linesbreak[5], 84)

@ -9,4 +9,4 @@ require('./decoder/decodeInfo')
require('./decoder/storageLocation')
require('./decoder/storageDecoder')
require('./decoder/localDecoder')
require('./debugger.js')
require('./debugger')

@ -1,7 +1,7 @@
'use strict'
import { TraceManager } from '../src/trace/traceManager'
import tape from 'tape'
const web3Test = require('./resources/testWeb3')
const web3Test = require('./resources/testWeb3.ts')
tape('TraceManager', function (t) {
let traceManager

Loading…
Cancel
Save