@@ -19,7 +19,7 @@ export default class abstractAstView {
...
@@ -19,7 +19,7 @@ export default class abstractAstView {
Additionally the fullQuallified function names e.g. [contractName].[functionName](param1Type, param2Type, ... ) must be prefixed to
Additionally the fullQuallified function names e.g. [contractName].[functionName](param1Type, param2Type, ... ) must be prefixed to
fully support this and when inheritance is resolved it must include alias resolving e.g x.c = file1.c
fully support this and when inheritance is resolved it must include alias resolving e.g x.c = file1.c
*/
*/
multipleContractsWithSameName=false
multipleContractsWithSameName:boolean=false
/**
/**
...
@@ -47,7 +47,7 @@ export default class abstractAstView {
...
@@ -47,7 +47,7 @@ export default class abstractAstView {
* @contractsOut {list} return list for high level AST view
* @contractsOut {list} return list for high level AST view
* @return {ASTNode -> void} returns a function that can be used as visit function for static analysis modules, to build up a higher level AST view for further analysis.
* @return {ASTNode -> void} returns a function that can be used as visit function for static analysis modules, to build up a higher level AST view for further analysis.
warning:`${funcName} : Variables have very similar names ${sim.var1} and ${sim.var2}. ${hasModifiersComments}${multipleContractsWithSameNameComments}`,
warning:`${funcName} : Variables have very similar names ${sim.var1} and ${sim.var2}. ${hasModifiersComments}${multipleContractsWithSameNameComments}`,
// test('staticAnalysisCommon.getEffectedVariableName', function (t) {
t.plan(3)
// t.plan(3)
t.throws(()=>common.getEffectedVariableName(inlineAssembly),Error,'staticAnalysisCommon.js: not an effect Node or inline assembly, get from inline assembly should throw')
// t.throws(() => common.getEffectedVariableName(inlineAssembly), Error, 'staticAnalysisCommon.js: not an effect Node or inline assembly, get from inline assembly should throw')
t.ok(common.getEffectedVariableName(assignment)==='c','get right name for assignment')
// t.ok(common.getEffectedVariableName(assignment) === 'c', 'get right name for assignment')
t.throws(()=>common.getEffectedVariableName({name:'MemberAccess'}),Error,'should throw on all other nodes')
// t.throws(() => common.getEffectedVariableName({ name: 'MemberAccess' }), Error, 'should throw on all other nodes')
t.ok(common.getFullQuallyfiedFuncDefinitionIdent(contract,fullyQualifiedFunctionDefinition,['uint256','bool'])==='baz.getY(uint256,bool)','creates right signature')
// t.ok(common.getFullQuallyfiedFuncDefinitionIdent(contract, fullyQualifiedFunctionDefinition, ['uint256', 'bool']) === 'baz.getY(uint256,bool)', 'creates right signature')
t.throws(()=>common.getFullQuallyfiedFuncDefinitionIdent(contract,{name:'MemberAccess'},['uint256','bool']),Error,'throws on wrong nodes')
t.throws(()=>common.getFullQuallyfiedFuncDefinitionIdent({name:'FunctionCall'},fullyQualifiedFunctionDefinition,['uint256','bool']),Error,'throws on wrong nodes')
// test('staticAnalysisCommon.isLowLevelCall', function (t) {
t.plan(6)
// t.plan(6)
t.ok(common.isLowLevelSendInst(lowlevelCall.sendAst)&&common.isLowLevelCall(lowlevelCall.sendAst),'send is llc should work')
// t.ok(common.isLowLevelSendInst(lowlevelCall.sendAst) && common.isLowLevelCall(lowlevelCall.sendAst), 'send is llc should work')
t.ok(common.isLowLevelCallInst(lowlevelCall.callAst)&&common.isLowLevelCall(lowlevelCall.callAst),'call is llc should work')
// t.ok(common.isLowLevelCallInst(lowlevelCall.callAst) && common.isLowLevelCall(lowlevelCall.callAst), 'call is llc should work')
t.notOk(common.isLowLevelCallInst(lowlevelCall.callcodeAst),'callcode is not call')
// t.notOk(common.isLowLevelCallInst(lowlevelCall.callcodeAst), 'callcode is not call')
t.ok(common.isLowLevelCallcodeInst(lowlevelCall.callcodeAst)&&common.isLowLevelCall(lowlevelCall.callcodeAst),'callcode is llc should work')
// t.ok(common.isLowLevelCallcodeInst(lowlevelCall.callcodeAst) && common.isLowLevelCall(lowlevelCall.callcodeAst), 'callcode is llc should work')
t.notOk(common.isLowLevelCallcodeInst(lowlevelCall.callAst),'call is not callcode')
// t.notOk(common.isLowLevelCallcodeInst(lowlevelCall.callAst), 'call is not callcode')
t.ok(common.isLowLevelDelegatecallInst(lowlevelCall.delegatecallAst)&&common.isLowLevelCall(lowlevelCall.delegatecallAst),'delegatecall is llc should work')
// t.ok(common.isLowLevelDelegatecallInst(lowlevelCall.delegatecallAst) && common.isLowLevelCall(lowlevelCall.delegatecallAst), 'delegatecall is llc should work')
})
// })
test('staticAnalysisCommon: Call of parameter function',function(t){
// test('staticAnalysisCommon: Call of parameter function', function (t) {
t.plan(7)
// t.plan(7)
t.ok(common.isLocalCall(parameterFunction),'is not LocalCall')
// t.ok(common.isLocalCall(parameterFunction), 'is not LocalCall')
t.notOk(common.isThisLocalCall(parameterFunction),'is not this local call')
// t.notOk(common.isThisLocalCall(parameterFunction), 'is not this local call')
t.notOk(common.isSuperLocalCall(parameterFunction),'is not super local call')
// t.notOk(common.isSuperLocalCall(parameterFunction), 'is not super local call')
t.notOk(common.isExternalDirectCall(parameterFunction),'is not ExternalDirectCall')
// t.notOk(common.isExternalDirectCall(parameterFunction), 'is not ExternalDirectCall')
t.notOk(common.isLibraryCall(parameterFunction),'is not LibraryCall')
// t.notOk(common.isLibraryCall(parameterFunction), 'is not LibraryCall')
t.equals(common.getFunctionCallType(parameterFunction),'function (uint256,uint256) pure returns (uint256)','Extracts right type')
// t.equals(common.getFunctionCallType(parameterFunction), 'function (uint256,uint256) pure returns (uint256)', 'Extracts right type')
t.equals(common.getFunctionCallTypeParameterType(parameterFunction),'uint256,uint256','Extracts param right type')
// t.equals(common.getFunctionCallTypeParameterType(parameterFunction), 'uint256,uint256', 'Extracts param right type')
})
// })
test('staticAnalysisCommon: function call with of function with function parameter',function(t){
// test('staticAnalysisCommon: function call with of function with function parameter', function (t) {
t.plan(2)
// t.plan(2)
t.equals(common.getFunctionCallType(parameterFunctionCall),'function (function (uint256,uint256) pure returns (uint256),uint256,uint256) pure returns (uint256)','Extracts right type')
// t.equals(common.getFunctionCallType(parameterFunctionCall), 'function (function (uint256,uint256) pure returns (uint256),uint256,uint256) pure returns (uint256)', 'Extracts right type')
t.equals(common.getFunctionCallTypeParameterType(parameterFunctionCall),'function (uint256,uint256) pure returns (uint256),uint256,uint256','Extracts param right type')
// t.equals(common.getFunctionCallTypeParameterType(parameterFunctionCall), 'function (uint256,uint256) pure returns (uint256),uint256,uint256', 'Extracts param right type')