@ -28,7 +28,8 @@ var testFiles = [
'ctor.sol' ,
'ctor.sol' ,
'forgottenReturn.sol' ,
'forgottenReturn.sol' ,
'selfdestruct.sol' ,
'selfdestruct.sol' ,
'deleteDynamicArray.sol'
'deleteDynamicArray.sol' ,
'blockLevelCompare.sol'
]
]
var testFileAsts = { }
var testFileAsts = { }
@ -62,7 +63,8 @@ test('Integration test thisLocal.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -94,7 +96,8 @@ test('Integration test checksEffectsInteraction.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -126,7 +129,8 @@ test('Integration test constantFunctions.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 1 ,
'selfdestruct.sol' : 1 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -158,7 +162,8 @@ test('Integration test inlineAssembly.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -190,7 +195,8 @@ test('Integration test txOrigin.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -222,7 +228,8 @@ test('Integration test gasCosts.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 3 ,
'forgottenReturn.sol' : 3 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 2
'deleteDynamicArray.sol' : 2 ,
'blockLevelCompare.sol' : 1
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -254,7 +261,8 @@ test('Integration test similarVariableNames.js', function (t) {
'ctor.sol' : 1 ,
'ctor.sol' : 1 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 1
'deleteDynamicArray.sol' : 1 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -286,7 +294,8 @@ test('Integration test inlineAssembly.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -318,7 +327,8 @@ test('Integration test blockTimestamp.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -350,7 +360,8 @@ test('Integration test lowLevelCalls.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -382,7 +393,8 @@ test('Integration test blockBlockhash.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -414,7 +426,8 @@ test('Integration test noReturn.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 1 ,
'forgottenReturn.sol' : 1 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -446,7 +459,8 @@ test('Integration test selfdestruct.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 2 ,
'selfdestruct.sol' : 2 ,
'deleteDynamicArray.sol' : 0
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -478,7 +492,8 @@ test('Integration test guardConditions.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 1
'deleteDynamicArray.sol' : 1 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -510,7 +525,8 @@ test('Integration test deleteDynamicArrays.js', function (t) {
'ctor.sol' : 0 ,
'ctor.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 2
'deleteDynamicArray.sol' : 2 ,
'blockLevelCompare.sol' : 0
}
}
runModuleOnFiles ( module , t , ( file , report ) => {
runModuleOnFiles ( module , t , ( file , report ) => {
@ -518,13 +534,50 @@ test('Integration test deleteDynamicArrays.js', function (t) {
} )
} )
} )
} )
test ( 'Integration test assignAndCompare.js' , function ( t ) {
t . plan ( testFiles . length )
var module = require ( '../../src/analysis/modules/assignAndCompare' )
var lengthCheck = {
'KingOfTheEtherThrone.sol' : 0 ,
'assembly.sol' : 0 ,
'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 ,
'blockLevelCompare.sol' : 6
}
runModuleOnFiles ( module , t , ( file , report ) => {
t . equal ( report . length , lengthCheck [ file ] , ` ${ file } has right amount of assignAndCompare warnings ` )
} )
} )
// #################### Helpers
// #################### Helpers
function runModuleOnFiles ( module , t , cb ) {
function runModuleOnFiles ( module , t , cb ) {
var statRunner = new StatRunner ( )
var statRunner = new StatRunner ( )
testFiles . forEach ( ( fileName ) => {
testFiles . forEach ( ( fileName ) => {
statRunner . runWithModuleList ( testFileAsts [ fileName ] , [ { name : module . name , mod : new module . Module ( ) } ] , ( reports ) => {
statRunner . runWithModuleList ( testFileAsts [ fileName ] , [ { name : module . name , mod : new module . Module ( ) } ] , ( reports ) => {
cb ( fileName , reports [ 0 ] . report )
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 )
} )
} )
} )
} )
}
}