@ -29,7 +29,8 @@ var testFiles = [
'forgottenReturn.sol' ,
'selfdestruct.sol' ,
'deleteDynamicArray.sol' ,
'blockLevelCompare.sol'
'blockLevelCompare.sol' ,
'intDivisionTruncate.sol'
]
var testFileAsts = { }
@ -64,7 +65,8 @@ test('Integration test thisLocal.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -97,7 +99,8 @@ test('Integration test checksEffectsInteraction.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -130,7 +133,8 @@ test('Integration test constantFunctions.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 1 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -163,7 +167,8 @@ test('Integration test inlineAssembly.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -196,7 +201,8 @@ test('Integration test txOrigin.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -229,7 +235,8 @@ test('Integration test gasCosts.js', function (t) {
'forgottenReturn.sol' : 3 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 2 ,
'blockLevelCompare.sol' : 1
'blockLevelCompare.sol' : 1 ,
'intDivisionTruncate.sol' : 1
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -262,7 +269,8 @@ test('Integration test similarVariableNames.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 1 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -295,7 +303,8 @@ test('Integration test inlineAssembly.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -328,7 +337,8 @@ test('Integration test blockTimestamp.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -361,7 +371,8 @@ test('Integration test lowLevelCalls.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -394,7 +405,8 @@ test('Integration test blockBlockhash.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -427,7 +439,8 @@ test('Integration test noReturn.js', function (t) {
'forgottenReturn.sol' : 1 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -460,7 +473,8 @@ test('Integration test selfdestruct.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 2 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 1
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -493,7 +507,8 @@ test('Integration test guardConditions.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 1 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 1
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -526,7 +541,8 @@ test('Integration test deleteDynamicArrays.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 2 ,
'blockLevelCompare.sol' : 0
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -559,7 +575,8 @@ test('Integration test assignAndCompare.js', function (t) {
'forgottenReturn.sol' : 0 ,
'selfdestruct.sol' : 0 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 8
'blockLevelCompare.sol' : 8 ,
'intDivisionTruncate.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -567,6 +584,40 @@ test('Integration test assignAndCompare.js', function (t) {
} )
} )
test ( 'Integration test intDivisionTruncate.js' , function ( t ) {
t . plan ( testFiles . length )
var module = require ( '../../src/analysis/modules/intDivisionTruncate' )
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' : 0 ,
'intDivisionTruncate.sol' : 2
}
runModuleOnFiles ( module , t , ( file , report ) => {
t . equal ( report . length , lengthCheck [ file ] , ` ${ file } has right amount of intDivisionTruncate warnings ` )
} )
} )
// #################### Helpers
function runModuleOnFiles ( module , t , cb ) {
var statRunner = new StatRunner ( )