Commit 534bb0b7 authored by aniket-engg's avatar aniket-engg Committed by Aniket

tests working fine

parent a91d82b2
......@@ -2,7 +2,7 @@
import { AstWalker } from 'remix-astwalker'
import list from './modules/list'
export class staticAnalysisRunner {
export default class staticAnalysisRunner {
run (compilationResult, toRun, callback) {
const modules = toRun.map((i) => {
......
......@@ -17,10 +17,10 @@ export default class checksEffectsInteraction {
visit = this.abstractAst.build_visit((node) => isInteraction(node) || isEffect(node) || isLocalCallGraphRelevantNode(node))
report = this.abstractAst.build_report(this._report)
report = this.abstractAst.build_report(this._report.bind(this))
private _report (contracts, multipleContractsWithSameName) {
const warnings: any = []
const warnings: any[] = []
const hasModifiers = contracts.some((item) => item.modifiers.length > 0)
const callGraph = buildGlobalFuncCallGraph(contracts)
contracts.forEach((contract) => {
......
......@@ -28,7 +28,7 @@ export default class constantFunctions {
isDeleteUnaryOperation(node)
)
report = this.abstractAst.build_report(this._report)
report = this.abstractAst.build_report(this._report.bind(this))
private _report (contracts, multipleContractsWithSameName) {
const warnings: any = []
......@@ -89,7 +89,7 @@ export default class constantFunctions {
}
private checkIfShouldBeConstant (startFuncName, context) {
return !analyseCallGraph(context.callGraph, startFuncName, context, this.isConstBreaker)
return !analyseCallGraph(context.callGraph, startFuncName, context, this.isConstBreaker.bind(this))
}
private isConstBreaker (node, context) {
......
......@@ -12,7 +12,7 @@ export default class erc20Decimals {
abstractAst = new AbstractAst()
visit = this.abstractAst.build_visit((node) => false)
report = this.abstractAst.build_report(this._report)
report = this.abstractAst.build_report(this._report.bind(this))
private _report (contracts, multipleContractsWithSameName) {
const warnings: any = []
......
......@@ -16,7 +16,7 @@ export default class noReturn {
(node) => isReturn(node) || isAssignment(node)
)
report = this.abstractAst.build_report(this._report)
report = this.abstractAst.build_report(this._report.bind(this))
private _report (contracts, multipleContractsWithSameName) {
const warnings: any[] = []
......
......@@ -17,7 +17,7 @@ export default class selfdestruct {
isSelfdestructCall(node)
)
report = this.abstractAst.build_report(this._report)
report = this.abstractAst.build_report(this._report.bind(this))
private _report (contracts, multipleContractsWithSameName) {
const warnings: any[] = []
......
......@@ -17,7 +17,7 @@ export default class similarVariableNames {
(node) => false
)
report = this.abstractAst.build_report(this._report)
report = this.abstractAst.build_report(this._report.bind(this))
private _report (contracts, multipleContractsWithSameName) {
const warnings: any[] = []
......
var test = require('tape')
var remixLib = require('remix-lib')
var StatRunner = require('../../dist/src/solidity-analyzer')
var StatRunner = require('../../dist/src/solidity-analyzer').default
var compilerInput = remixLib.helpers.compiler.compilerInput
const niv = require('npm-install-version')
......@@ -51,7 +51,7 @@ testFiles.forEach((fileName) => {
test('Integration test thisLocal.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/thisLocal')
var module = require('../../dist/src/solidity-analyzer/modules/thisLocal').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -90,7 +90,7 @@ test('Integration test thisLocal.js', function (t) {
test('Integration test checksEffectsInteraction.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction')
var module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 1,
......@@ -129,7 +129,7 @@ test('Integration test checksEffectsInteraction.js', function (t) {
test('Integration test constantFunctions.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/constantFunctions')
var module = require('../../dist/src/solidity-analyzer/modules/constantFunctions').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -168,7 +168,7 @@ test('Integration test constantFunctions.js', function (t) {
test('Integration test inlineAssembly.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/inlineAssembly')
var module = require('../../dist/src/solidity-analyzer/modules/inlineAssembly').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -207,7 +207,7 @@ test('Integration test inlineAssembly.js', function (t) {
test('Integration test txOrigin.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/txOrigin')
var module = require('../../dist/src/solidity-analyzer/modules/txOrigin').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -246,7 +246,7 @@ test('Integration test txOrigin.js', function (t) {
test('Integration test gasCosts.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/gasCosts')
var module = require('../../dist/src/solidity-analyzer/modules/gasCosts').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 2,
......@@ -285,7 +285,7 @@ test('Integration test gasCosts.js', function (t) {
test('Integration test similarVariableNames.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/similarVariableNames')
var module = require('../../dist/src/solidity-analyzer/modules/similarVariableNames').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -324,7 +324,7 @@ test('Integration test similarVariableNames.js', function (t) {
test('Integration test inlineAssembly.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/inlineAssembly')
var module = require('../../dist/src/solidity-analyzer/modules/inlineAssembly').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -363,7 +363,7 @@ test('Integration test inlineAssembly.js', function (t) {
test('Integration test blockTimestamp.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/blockTimestamp')
var module = require('../../dist/src/solidity-analyzer/modules/blockTimestamp').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 1,
......@@ -402,7 +402,7 @@ test('Integration test blockTimestamp.js', function (t) {
test('Integration test lowLevelCalls.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/lowLevelCalls')
var module = require('../../dist/src/solidity-analyzer/modules/lowLevelCalls').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 1,
......@@ -441,7 +441,7 @@ test('Integration test lowLevelCalls.js', function (t) {
test('Integration test blockBlockhash.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/blockBlockhash')
var module = require('../../dist/src/solidity-analyzer/modules/blockBlockhash').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -523,7 +523,7 @@ test('Integration test noReturn.js', function (t) {
test('Integration test selfdestruct.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/selfdestruct')
var module = require('../../dist/src/solidity-analyzer/modules/selfdestruct').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -562,7 +562,7 @@ test('Integration test selfdestruct.js', function (t) {
test('Integration test guardConditions.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/guardConditions')
var module = require('../../dist/src/solidity-analyzer/modules/guardConditions').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -601,7 +601,7 @@ test('Integration test guardConditions.js', function (t) {
test('Integration test deleteDynamicArrays.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/deleteDynamicArrays')
var module = require('../../dist/src/solidity-analyzer/modules/deleteDynamicArrays').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -640,7 +640,7 @@ test('Integration test deleteDynamicArrays.js', function (t) {
test('Integration test deleteFromDynamicArray.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/deleteFromDynamicArray')
var module = require('../../dist/src/solidity-analyzer/modules/deleteFromDynamicArray').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -679,7 +679,7 @@ test('Integration test deleteFromDynamicArray.js', function (t) {
test('Integration test assignAndCompare.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/assignAndCompare')
var module = require('../../dist/src/solidity-analyzer/modules/assignAndCompare').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -718,7 +718,7 @@ test('Integration test assignAndCompare.js', function (t) {
test('Integration test intDivisionTruncate.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/intDivisionTruncate')
var module = require('../../dist/src/solidity-analyzer/modules/intDivisionTruncate').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -757,7 +757,7 @@ test('Integration test intDivisionTruncate.js', function (t) {
test('Integration test erc20Decimal.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/erc20Decimals')
var module = require('../../dist/src/solidity-analyzer/modules/erc20Decimals').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -796,7 +796,7 @@ test('Integration test erc20Decimal.js', function (t) {
test('Integration test stringBytesLength.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/stringBytesLength')
var module = require('../../dist/src/solidity-analyzer/modules/stringBytesLength').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -835,7 +835,7 @@ test('Integration test stringBytesLength.js', function (t) {
test('Integration test etherTransferInLoop.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/etherTransferInLoop')
var module = require('../../dist/src/solidity-analyzer/modules/etherTransferInLoop').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -874,7 +874,7 @@ test('Integration test etherTransferInLoop.js', function (t) {
test('Integration test forLoopIteratesOverDynamicArray.js', function (t) {
t.plan(testFiles.length)
var module = require('../../dist/src/solidity-analyzer/modules/forLoopIteratesOverDynamicArray')
var module = require('../../dist/src/solidity-analyzer/modules/forLoopIteratesOverDynamicArray').default
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,
......@@ -911,11 +911,10 @@ test('Integration test forLoopIteratesOverDynamicArray.js', function (t) {
})
// #################### Helpers
function runModuleOnFiles (module, t, cb) {
function runModuleOnFiles (Module, t, cb) {
var statRunner = new StatRunner()
testFiles.forEach((fileName) => {
statRunner.runWithModuleList(testFileAsts[fileName], [{ name: module.name, mod: new module.Module() }], (reports) => {
statRunner.runWithModuleList(testFileAsts[fileName], [{ name: new Module().name, mod: new Module() }], (reports) => {
let report = reports[0].report
if (report.some((x) => x['warning'].includes('INTERNAL ERROR'))) {
t.comment('Error while executing Module: ' + JSON.stringify(report))
......
var test = require('tape')
var remixLib = require('remix-lib')
var StatRunner = require('../../dist/src/solidity-analyzer')
var StatRunner = require('../../dist/src/solidity-analyzer').default
var compilerInput = remixLib.helpers.compiler.compilerInput
const niv = require('npm-install-version')
......@@ -22,16 +22,16 @@ test('staticAnalysisIssues.functionParameterPassingError', function (t) {
t.plan(2)
var res = compile('functionParameters.sol')
var module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction')
var Module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default
var statRunner = new StatRunner()
t.doesNotThrow(() => {
statRunner.runWithModuleList(res, [{ name: module.name, mod: new module.Module() }], (reports) => {
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
})
}, true, 'Analysis should not throw')
statRunner.runWithModuleList(res, [{ name: module.name, mod: new module.Module() }], (reports) => {
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
t.ok(!reports.some((mod) => mod.report.some((rep) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors'))
})
})
var test = require('tape')
var remixLib = require('remix-lib')
var StatRunner = require('../../dist/src/solidity-analyzer')
var StatRunner = require('../../dist/src/solidity-analyzer').default
var compilerInput = remixLib.helpers.compiler.compilerInput
const niv = require('npm-install-version')
......@@ -22,16 +22,16 @@ test('staticAnalysisIssues.functionParameterPassingError', function (t) {
t.plan(2)
var res = compile('functionParameters.sol')
var module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction')
var Module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default
var statRunner = new StatRunner()
t.doesNotThrow(() => {
statRunner.runWithModuleList(res, [{ name: module.name, mod: new module.Module() }], (reports) => {
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
})
}, true, 'Analysis should not throw')
statRunner.runWithModuleList(res, [{ name: module.name, mod: new module.Module() }], (reports) => {
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
t.ok(!reports.some((mod) => mod.report.some((rep) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors'))
})
})
......@@ -79,8 +79,7 @@ export class AstWalker extends EventEmitter {
this.walk(child, callback);
}
}
}
if (<AstNode>ast) {
} else if (<AstNode>ast) {
if (
this.manageCallback(<AstNode>ast, callback) &&
(<AstNode>ast).nodes &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment