Commit 56805303 authored by aniket-engg's avatar aniket-engg Committed by Aniket

0.5.0 contracts integration tests updated

parent 52000695
......@@ -448,18 +448,18 @@ function getFullQuallyfiedFuncDefinitionIdent (contract: ContractDefinitionAstNo
function getUnAssignedTopLevelBinOps (subScope: BlockAstNode | IfStatementAstNode | WhileStatementAstNode | ForStatementAstNode): ExpressionStatementAstNode[] {
let result: ExpressionStatementAstNode[] = []
if(subScope.nodeType === 'Block')
if(subScope && subScope.nodeType === 'Block')
result = subScope.statements.filter(isBinaryOpInExpression)
// for 'without braces' loops
else if (subScope && subScope.nodeType && isSubScopeStatement(subScope)) {
if (subScope.nodeType === 'IfStatement'){
if((subScope.trueBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.trueBody)))
if((subScope.trueBody && subScope.trueBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.trueBody)))
result.push(subScope.trueBody)
if (subScope.falseBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.falseBody))
if (subScope.falseBody && subScope.falseBody.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.falseBody))
result.push(subScope.falseBody)
}
else {
if(subScope.body.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.body))
if(subScope.body && subScope.body.nodeType === "ExpressionStatement" && isBinaryOpInExpression(subScope.body))
result.push(subScope.body)
}
}
......@@ -982,7 +982,7 @@ function isStringToBytesConversion (node: FunctionCallAstNode): boolean {
function isExplicitCast (node: FunctionCallAstNode, castFromType: string, castToType: string): boolean {
return node.kind === "typeConversion" &&
nodeType(node.expression, exactMatch(nodeTypes.ELEMENTARYTYPENAMEEXPRESSION)) && node.expression.typeName.name === castToType &&
nodeType(node.expression, exactMatch(nodeTypes.ELEMENTARYTYPENAMEEXPRESSION)) && node.expression.typeName === castToType &&
nodeType(node.arguments[0], exactMatch(nodeTypes.IDENTIFIER)) && typeDescription(node.arguments[0], castFromType)
}
......
// 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'
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'
// function compile (fileName) {
// const content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
// return JSON.parse(compiler.compile(compilerInput(content)))
// }
function compile (fileName) {
const content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
return JSON.parse(compiler.compile(compilerInput(content)))
}
// test('staticAnalysisIssues.functionParameterPassingError', function (t) {
// // https://github.com/ethereum/remix-ide/issues/889#issuecomment-351746474
// t.plan(2)
// const res = compile('functionParameters.sol')
// const Module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default
// const statRunner = new StatRunner()
test('staticAnalysisIssues.functionParameterPassingError', function (t) {
// https://github.com/ethereum/remix-ide/issues/889#issuecomment-351746474
t.plan(2)
const res = compile('functionParameters.sol')
const Module = require('../../dist/src/solidity-analyzer/modules/checksEffectsInteraction').default
const statRunner = new StatRunner()
// t.doesNotThrow(() => {
// statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
// })
// }, 'Analysis should not throw')
t.doesNotThrow(() => {
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports) => {
})
}, 'Analysis should not throw')
// 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'))
// })
// })
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'))
})
})
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