@ -31,7 +31,8 @@ var testFiles = [
'deleteDynamicArray.sol' ,
'blockLevelCompare.sol' ,
'intDivisionTruncate.sol' ,
'ERC20.sol'
'ERC20.sol' ,
'stringBytesLength.sol'
]
var testFileAsts = { }
@ -68,7 +69,8 @@ test('Integration test thisLocal.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -103,7 +105,8 @@ test('Integration test checksEffectsInteraction.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -138,7 +141,8 @@ test('Integration test constantFunctions.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -173,7 +177,8 @@ test('Integration test inlineAssembly.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -208,7 +213,8 @@ test('Integration test txOrigin.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -243,7 +249,8 @@ test('Integration test gasCosts.js', function (t) {
'deleteDynamicArray.sol' : 2 ,
'blockLevelCompare.sol' : 1 ,
'intDivisionTruncate.sol' : 1 ,
'ERC20.sol' : 2
'ERC20.sol' : 2 ,
'stringBytesLength.sol' : 1
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -278,7 +285,8 @@ test('Integration test similarVariableNames.js', function (t) {
'deleteDynamicArray.sol' : 1 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -313,7 +321,8 @@ test('Integration test inlineAssembly.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -348,7 +357,8 @@ test('Integration test blockTimestamp.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -383,7 +393,8 @@ test('Integration test lowLevelCalls.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -418,7 +429,8 @@ test('Integration test blockBlockhash.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -453,7 +465,8 @@ test('Integration test noReturn.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -487,8 +500,9 @@ test('Integration test selfdestruct.js', function (t) {
'selfdestruct.sol' : 3 ,
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'ERC20.sol' : 0 ,
'intDivisionTruncate.sol' : 5 ,
'ERC20 .sol' : 0
'stringBytesLength .sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -523,7 +537,8 @@ test('Integration test guardConditions.js', function (t) {
'deleteDynamicArray.sol' : 1 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 1 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -558,7 +573,8 @@ test('Integration test deleteDynamicArrays.js', function (t) {
'deleteDynamicArray.sol' : 2 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -593,7 +609,8 @@ test('Integration test assignAndCompare.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 8 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -628,7 +645,8 @@ test('Integration test intDivisionTruncate.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 2 ,
'ERC20.sol' : 0
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -663,7 +681,8 @@ test('Integration test erc20Decimal.js', function (t) {
'deleteDynamicArray.sol' : 0 ,
'blockLevelCompare.sol' : 0 ,
'intDivisionTruncate.sol' : 0 ,
'ERC20.sol' : 1
'ERC20.sol' : 1 ,
'stringBytesLength.sol' : 0
}
runModuleOnFiles ( module , t , ( file , report ) => {
@ -671,6 +690,42 @@ test('Integration test erc20Decimal.js', function (t) {
} )
} )
test ( 'Integration test stringBytesLength.js' , function ( t ) {
t . plan ( testFiles . length )
var module = require ( '../../src/solidity-analyzer/modules/stringBytesLength' )
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' : 0 ,
'ERC20.sol' : 0 ,
'stringBytesLength.sol' : 1
}
runModuleOnFiles ( module , t , ( file , report ) => {
t . equal ( report . length , lengthCheck [ file ] , ` ${ file } has right amount of stringBytesLength warnings ` )
} )
} )
// #################### Helpers
function runModuleOnFiles ( module , t , cb ) {
var statRunner = new StatRunner ( )