|
|
|
@ -1,17 +1,17 @@ |
|
|
|
|
// import { default as test} from "tape"
|
|
|
|
|
// import { helpers } from 'remix-lib'
|
|
|
|
|
// import { readFileSync } from 'fs'
|
|
|
|
|
// import { join } from 'path'
|
|
|
|
|
// import { default as StatRunner } from '../../dist/src/solidity-analyzer'
|
|
|
|
|
// import { install, require as requireNPMmodule } from 'npm-install-version'
|
|
|
|
|
// install('solc@0.5.0')
|
|
|
|
|
// const compiler = requireNPMmodule('solc@0.5.0')
|
|
|
|
|
// const {compilerInput } = helpers.compiler
|
|
|
|
|
// const folder = 'solidity-v0.5'
|
|
|
|
|
|
|
|
|
|
// const testFiles = [
|
|
|
|
|
// 'KingOfTheEtherThrone.sol',
|
|
|
|
|
// 'assembly.sol',
|
|
|
|
|
import { default as test} from "tape" |
|
|
|
|
import { helpers } from 'remix-lib' |
|
|
|
|
import { readFileSync } from 'fs' |
|
|
|
|
import { join } from 'path' |
|
|
|
|
import { default as StatRunner } from '../../dist/src/solidity-analyzer' |
|
|
|
|
import { install, require as requireNPMmodule } from 'npm-install-version' |
|
|
|
|
install('solc@0.5.0') |
|
|
|
|
const compiler = requireNPMmodule('solc@0.5.0') |
|
|
|
|
const {compilerInput } = helpers.compiler |
|
|
|
|
const folder = 'solidity-v0.5' |
|
|
|
|
|
|
|
|
|
const testFiles = [ |
|
|
|
|
'KingOfTheEtherThrone.sol', |
|
|
|
|
'assembly.sol', |
|
|
|
|
// 'ballot.sol',
|
|
|
|
|
// 'ballot_reentrant.sol',
|
|
|
|
|
// 'ballot_withoutWarnings.sol',
|
|
|
|
@ -36,23 +36,27 @@ |
|
|
|
|
// 'stringBytesLength.sol',
|
|
|
|
|
// 'etherTransferInLoop.sol',
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol'
|
|
|
|
|
// ]
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
// var testFileAsts = {}
|
|
|
|
|
var testFileAsts = {} |
|
|
|
|
|
|
|
|
|
// testFiles.forEach((fileName) => {
|
|
|
|
|
// var content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
|
|
|
|
|
// testFileAsts[fileName] = JSON.parse(compiler.compile(compilerInput(content)))
|
|
|
|
|
// })
|
|
|
|
|
testFiles.forEach((fileName) => { |
|
|
|
|
var content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8') |
|
|
|
|
testFileAsts[fileName] = JSON.parse(compiler.compile(compilerInput(content))) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// console.log(testFileAsts['ballot.sol'].sources['test.sol'].ast.nodes[1].nodes)
|
|
|
|
|
|
|
|
|
|
// test('Integration test thisLocal.js', function (t) {
|
|
|
|
|
test('Integration test thisLocal.js', function (t) { |
|
|
|
|
// console.log('testFileAsts---------',testFileAsts)
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/thisLocal').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/thisLocal').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 1,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -77,21 +81,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of this local warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of this local warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test checksEffectsInteraction.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test checksEffectsInteraction.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 1,
|
|
|
|
|
// 'assembly.sol': 1,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 1, |
|
|
|
|
'assembly.sol': 1, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 1,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -116,21 +120,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of checks-effects-interaction warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of checks-effects-interaction warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test constantFunctions.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test constantFunctions.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/constantFunctions').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/constantFunctions').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -155,21 +159,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of constant warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of constant warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test inlineAssembly.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test inlineAssembly.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/inlineAssembly').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/inlineAssembly').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 2,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 2, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -194,21 +198,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of inline assembly warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of inline assembly warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test txOrigin.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test txOrigin.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/txOrigin').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/txOrigin').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 1,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 1, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -233,21 +237,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of tx.origin warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of tx.origin warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test gasCosts.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test gasCosts.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/gasCosts').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/gasCosts').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 2,
|
|
|
|
|
// 'assembly.sol': 2,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 2, |
|
|
|
|
'assembly.sol': 2, |
|
|
|
|
// 'ballot.sol': 3,
|
|
|
|
|
// 'ballot_reentrant.sol': 2,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -272,21 +276,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 1,
|
|
|
|
|
// 'etherTransferInLoop.sol': 3,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 2
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of gasCost warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of gasCost warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test similarVariableNames.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test similarVariableNames.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/similarVariableNames').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/similarVariableNames').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 2,
|
|
|
|
|
// 'ballot_reentrant.sol': 11,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -311,60 +315,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of similarVariableNames warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of similarVariableNames warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test inlineAssembly.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test blockTimestamp.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/inlineAssembly').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/blockTimestamp').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 2,
|
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
|
// 'cross_contract.sol': 0,
|
|
|
|
|
// 'inheritance.sol': 0,
|
|
|
|
|
// 'modifier1.sol': 0,
|
|
|
|
|
// 'modifier2.sol': 0,
|
|
|
|
|
// 'notReentrant.sol': 0,
|
|
|
|
|
// 'structReentrant.sol': 0,
|
|
|
|
|
// 'thisLocal.sol': 0,
|
|
|
|
|
// 'globals.sol': 0,
|
|
|
|
|
// 'library.sol': 0,
|
|
|
|
|
// 'transfer.sol': 0,
|
|
|
|
|
// 'ctor.sol': 0,
|
|
|
|
|
// 'forgottenReturn.sol': 0,
|
|
|
|
|
// 'selfdestruct.sol': 0,
|
|
|
|
|
// 'deleteDynamicArray.sol': 0,
|
|
|
|
|
// 'deleteFromDynamicArray.sol': 0,
|
|
|
|
|
// 'blockLevelCompare.sol': 0,
|
|
|
|
|
// 'intDivisionTruncate.sol': 0,
|
|
|
|
|
// 'ERC20.sol': 0,
|
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of inlineAssembly warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// test('Integration test blockTimestamp.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/blockTimestamp').default
|
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 1,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 1, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 3,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -389,21 +354,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of blockTimestamp warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of blockTimestamp warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test lowLevelCalls.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test lowLevelCalls.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/lowLevelCalls').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/lowLevelCalls').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 1,
|
|
|
|
|
// 'assembly.sol': 1,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 1, |
|
|
|
|
'assembly.sol': 1, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 7,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -428,21 +393,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of lowLevelCalls warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of lowLevelCalls warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test blockBlockhash.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test blockBlockhash.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/blockBlockhash').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/blockBlockhash').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -467,12 +432,12 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of blockBlockhash warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of blockBlockhash warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// /*
|
|
|
|
|
|
|
|
|
@ -517,14 +482,14 @@ |
|
|
|
|
// })
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
|
|
// test('Integration test selfdestruct.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test selfdestruct.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/selfdestruct').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/selfdestruct').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -549,21 +514,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of selfdestruct warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of selfdestruct warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test guardConditions.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test guardConditions.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/guardConditions').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/guardConditions').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 1,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 1, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -588,21 +553,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of guardCondition warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of guardCondition warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test deleteDynamicArrays.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test deleteDynamicArrays.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/deleteDynamicArrays').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/deleteDynamicArrays').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -627,21 +592,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of deleteDynamicArrays warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of deleteDynamicArrays warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test deleteFromDynamicArray.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test deleteFromDynamicArray.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/deleteFromDynamicArray').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/deleteFromDynamicArray').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -666,21 +631,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of deleteFromDynamicArray warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of deleteFromDynamicArray warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test assignAndCompare.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test assignAndCompare.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/assignAndCompare').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/assignAndCompare').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -705,21 +670,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of assignAndCompare warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of assignAndCompare warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test intDivisionTruncate.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test intDivisionTruncate.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/intDivisionTruncate').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/intDivisionTruncate').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -744,21 +709,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of intDivisionTruncate warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of intDivisionTruncate warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test erc20Decimal.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test erc20Decimal.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/erc20Decimals').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/erc20Decimals').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -783,21 +748,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of erc20Decimals warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of erc20Decimals warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test stringBytesLength.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test stringBytesLength.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/stringBytesLength').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/stringBytesLength').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -822,21 +787,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 1,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of stringBytesLength warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of stringBytesLength warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test etherTransferInLoop.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test etherTransferInLoop.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/etherTransferInLoop').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/etherTransferInLoop').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 0,
|
|
|
|
|
// 'ballot_reentrant.sol': 0,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -861,21 +826,21 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 3,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 0
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of etherTransferInLoop warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of etherTransferInLoop warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// test('Integration test forLoopIteratesOverDynamicArray.js', function (t) {
|
|
|
|
|
// t.plan(testFiles.length)
|
|
|
|
|
test('Integration test forLoopIteratesOverDynamicArray.js', function (t) { |
|
|
|
|
t.plan(2) |
|
|
|
|
|
|
|
|
|
// var module = require('../../dist/src/solidity-analyzer/modules/forLoopIteratesOverDynamicArray').default
|
|
|
|
|
var module = require('../../dist/src/solidity-analyzer/modules/forLoopIteratesOverDynamicArray').default |
|
|
|
|
|
|
|
|
|
// var lengthCheck = {
|
|
|
|
|
// 'KingOfTheEtherThrone.sol': 0,
|
|
|
|
|
// 'assembly.sol': 0,
|
|
|
|
|
var lengthCheck = { |
|
|
|
|
'KingOfTheEtherThrone.sol': 0, |
|
|
|
|
'assembly.sol': 0, |
|
|
|
|
// 'ballot.sol': 2,
|
|
|
|
|
// 'ballot_reentrant.sol': 1,
|
|
|
|
|
// 'ballot_withoutWarnings.sol': 0,
|
|
|
|
@ -900,23 +865,24 @@ |
|
|
|
|
// 'stringBytesLength.sol': 0,
|
|
|
|
|
// 'etherTransferInLoop.sol': 0,
|
|
|
|
|
// 'forLoopIteratesOverDynamicArray.sol': 2
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// runModuleOnFiles(module, t, (file, report) => {
|
|
|
|
|
// t.equal(report.length, lengthCheck[file], `${file} has right amount of forLoopIteratesOverDynamicArray warnings`)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// // #################### Helpers
|
|
|
|
|
// function runModuleOnFiles (Module, t, cb) {
|
|
|
|
|
// var statRunner = new StatRunner()
|
|
|
|
|
// testFiles.forEach((fileName) => {
|
|
|
|
|
// 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))
|
|
|
|
|
// }
|
|
|
|
|
// cb(fileName, report)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
runModuleOnFiles(module, t, (file, report) => { |
|
|
|
|
t.equal(report.length, lengthCheck[file], `${file} has right amount of forLoopIteratesOverDynamicArray warnings`) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// #################### Helpers
|
|
|
|
|
function runModuleOnFiles (Module, t, cb) { |
|
|
|
|
var statRunner = new StatRunner() |
|
|
|
|
testFiles.forEach((fileName) => { |
|
|
|
|
statRunner.runWithModuleList(testFileAsts[fileName], [{ name: new Module().name, mod: new Module() }], (reports) => { |
|
|
|
|
let report = reports[0].report |
|
|
|
|
// console.log('reports----', report)
|
|
|
|
|
if (report.some((x) => x['warning'].includes('INTERNAL ERROR'))) { |
|
|
|
|
t.comment('Error while executing Module: ' + JSON.stringify(report)) |
|
|
|
|
} |
|
|
|
|
cb(fileName, report) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|