Enables logging.

pull/238/head
rajeevgopalakrishna 6 years ago
parent fda131811e
commit 99c1fcdd10
  1. 9
      utils/slither_format/format_constable_states.py
  2. 9
      utils/slither_format/format_constant_function.py
  3. 7
      utils/slither_format/format_external_function.py
  4. 57
      utils/slither_format/format_naming_convention.py
  5. 11
      utils/slither_format/format_pragma.py
  6. 9
      utils/slither_format/format_solc_version.py
  7. 37
      utils/slither_format/slither_format.py
  8. 64
      utils/slither_format/tests/test_constable_states.py
  9. 56
      utils/slither_format/tests/test_constant_function.py
  10. 2
      utils/slither_format/tests/test_data/naming_convention.sol
  11. 34
      utils/slither_format/tests/test_detector_combinations.py
  12. 70
      utils/slither_format/tests/test_external_function.py
  13. 572
      utils/slither_format/tests/test_naming_convention.py
  14. 52
      utils/slither_format/tests/test_pragma.py
  15. 96
      utils/slither_format/tests/test_solc_version.py
  16. 24
      utils/slither_format/tests/test_unused_state_vars.py

@ -1,4 +1,9 @@
import re import re, logging
from slither.utils.colors import red, yellow, set_colorization_enabled
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('Slither.Format')
set_colorization_enabled(True)
class FormatConstableStates: class FormatConstableStates:
@ -21,5 +26,5 @@ class FormatConstableStates:
"new_string" : new_str_of_interest "new_string" : new_str_of_interest
}) })
else: else:
print("Error: State variable not found?!") logger.error(red("State variable not found?!"))
sys.exit(-1) sys.exit(-1)

@ -1,4 +1,9 @@
import re import re, logging
from slither.utils.colors import red, yellow, set_colorization_enabled
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('Slither.Format')
set_colorization_enabled(True)
class FormatConstantFunction: class FormatConstantFunction:
@ -30,5 +35,5 @@ class FormatConstantFunction:
"new_string" : replace_text "new_string" : replace_text
}) })
else: else:
print("Error: No view/pure/constant specifier exists. Regex failed to remove specifier!") logger.error(red("No view/pure/constant specifier exists. Regex failed to remove specifier!"))
sys.exit(-1) sys.exit(-1)

@ -1,4 +1,9 @@
import re import re, logging
from slither.utils.colors import red, yellow, set_colorization_enabled
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('Slither.Format')
set_colorization_enabled(True)
class FormatExternalFunction: class FormatExternalFunction:

@ -1,8 +1,13 @@
import re, sys import re, sys, logging
from slither.core.expressions.identifier import Identifier from slither.core.expressions.identifier import Identifier
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.slithir.operations import NewContract from slither.slithir.operations import NewContract
from slither.slithir.operations import Member from slither.slithir.operations import Member
from slither.utils.colors import red, yellow, set_colorization_enabled
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('Slither.Format')
set_colorization_enabled(True)
class FormatNamingConvention: class FormatNamingConvention:
@ -44,7 +49,7 @@ class FormatNamingConvention:
FormatNamingConvention.create_patch_modifier_definition(slither, patches, name, contract_name, in_file, modify_loc_start, modify_loc_end) FormatNamingConvention.create_patch_modifier_definition(slither, patches, name, contract_name, in_file, modify_loc_start, modify_loc_end)
FormatNamingConvention.create_patch_modifier_uses(slither, patches, name, contract_name, in_file) FormatNamingConvention.create_patch_modifier_uses(slither, patches, name, contract_name, in_file)
else: else:
print("Unknown naming convention! " + _target) logger.error(red("Unknown naming convention! " + _target))
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -67,9 +72,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find contract?!") logger.error(red("Could not find contract?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Contract : " + name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -130,9 +133,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find new object?!") logger.error(red("Could not find new object?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Contract : " + name)
sys.exit(-1) sys.exit(-1)
else: else:
@ -161,9 +162,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find modifier?!") logger.error(red("Could not find modifier?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Modifier: " + name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -190,9 +189,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find modifier name?!") logger.error(red("Could not find modifier name?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Modifier: " + name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -217,9 +214,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find function?!") logger.error(red("Could not find function?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Function: " + name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -281,9 +276,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find event?!") logger.error(red("Could not find event?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Event: " + name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -333,9 +326,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find parameter declaration?!") logger.error(red("Could not find parameter declaration?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Parameter: " + name + " of Function: " + function_name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -367,9 +358,9 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find parameter use?!") logger.error(red("Could not find parameter use?!"))
print("old_str_of_interest: " + old_str_of_interest) sys.exit(-1)
print("Parameter: " + name + " of Function: " + function_name + " in Contract : " + contract_name)
# Process function parameters passed to modifiers # Process function parameters passed to modifiers
for modifier in function._expression_modifiers: for modifier in function._expression_modifiers:
for arg in modifier.arguments: for arg in modifier.arguments:
@ -391,9 +382,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find parameter use in modifier?!") logger.error(red("Could not find parameter use in modifier?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Parameter: " + name + " of Function: " + function_name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -473,9 +462,7 @@ class FormatNamingConvention:
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find enum?!") logger.error(red("Could not find enum?!"))
print("old_str_of_interest: " + old_str_of_interest)
print("Enum: " + name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod
@ -542,8 +529,7 @@ t']:(node.source_mapping['start']+node.source_mapping['length'])].split('=')[0])
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find new object?!") logger.error(red("Could not find new object?!"))
print("Enum: " + name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
# To-do: Check any other place/way where enum type is used # To-do: Check any other place/way where enum type is used
@ -567,8 +553,7 @@ t']:(node.source_mapping['start']+node.source_mapping['length'])].split('=')[0])
if not patch in patches[in_file]: if not patch in patches[in_file]:
patches[in_file].append(patch) patches[in_file].append(patch)
else: else:
print("Error: Could not find struct?!") logger.error(red("Could not find struct?!"))
print("Struct: " + name + " in Contract : " + contract_name)
sys.exit(-1) sys.exit(-1)
@staticmethod @staticmethod

@ -1,4 +1,9 @@
import re import re, logging
from slither.utils.colors import red, yellow, set_colorization_enabled
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('Slither.Format')
set_colorization_enabled(True)
class FormatPragma: class FormatPragma:
@ -28,7 +33,7 @@ class FormatPragma:
for version in used_solc_versions: for version in used_solc_versions:
replace_solc_versions.append(FormatPragma.determine_solc_version_replacement(version)) replace_solc_versions.append(FormatPragma.determine_solc_version_replacement(version))
if not all(version == replace_solc_versions[0] for version in replace_solc_versions): if not all(version == replace_solc_versions[0] for version in replace_solc_versions):
print("Multiple incompatible versions!") logger.error(red("Multiple incompatible versions!"))
sys.exit(-1) sys.exit(-1)
else: else:
return replace_solc_versions[0] return replace_solc_versions[0]
@ -44,7 +49,7 @@ class FormatPragma:
elif minor_version == '5': elif minor_version == '5':
return "pragma solidity " + FormatPragma.REPLACEMENT_VERSIONS[1] + ';' return "pragma solidity " + FormatPragma.REPLACEMENT_VERSIONS[1] + ';'
else: else:
print("Unknown version!") logger.error(red("Unknown version!"))
sys.exit(-1) sys.exit(-1)
elif len(versions) == 2: elif len(versions) == 2:
version_left = versions[0] version_left = versions[0]

@ -1,4 +1,9 @@
import re import re, logging
from slither.utils.colors import red, yellow, set_colorization_enabled
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('Slither.Format')
set_colorization_enabled(True)
class FormatSolcVersion: class FormatSolcVersion:
@ -30,7 +35,7 @@ class FormatSolcVersion:
elif minor_version == '5': elif minor_version == '5':
return "pragma solidity " + FormatSolcVersion.REPLACEMENT_VERSIONS[1] + ';' return "pragma solidity " + FormatSolcVersion.REPLACEMENT_VERSIONS[1] + ';'
else: else:
print("Unknown version!") logger.error(red("Unknown version!"))
sys.exit(-1) sys.exit(-1)
elif len(versions) == 2: elif len(versions) == 2:
version_left = versions[0] version_left = versions[0]

@ -1,5 +1,6 @@
import sys, re import sys, re, logging
from collections import defaultdict from collections import defaultdict
from slither.utils.colors import red, yellow, set_colorization_enabled
from slither.detectors.variables.unused_state_variables import UnusedStateVars from slither.detectors.variables.unused_state_variables import UnusedStateVars
from slither.detectors.attributes.incorrect_solc import IncorrectSolc from slither.detectors.attributes.incorrect_solc import IncorrectSolc
from slither.detectors.attributes.constant_pragma import ConstantPragma from slither.detectors.attributes.constant_pragma import ConstantPragma
@ -19,6 +20,10 @@ from slither_format.format_external_function import FormatExternalFunction
from slither_format.format_constable_states import FormatConstableStates from slither_format.format_constable_states import FormatConstableStates
from slither_format.format_constant_function import FormatConstantFunction from slither_format.format_constant_function import FormatConstantFunction
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('Slither.Format')
set_colorization_enabled(True)
all_detectors = { all_detectors = {
'unused-state': UnusedStateVars, 'unused-state': UnusedStateVars,
'solc-version': IncorrectSolc, 'solc-version': IncorrectSolc,
@ -68,12 +73,12 @@ def sort_and_flag_overlapping_patches(patches):
def is_overlap_patch(args, patch): def is_overlap_patch(args, patch):
if 'overlaps' in patch: if 'overlaps' in patch:
if args.verbose_test: if args.verbose_test:
print("Overlapping patch won't be applied!") logger.info("Overlapping patch won't be applied!")
print("xDetector: " + patch['detector']) logger.info("xDetector: " + patch['detector'])
print("xOld string: " + patch['old_string'].replace("\n","")) logger.info("xOld string: " + patch['old_string'].replace("\n",""))
print("xNew string: " + patch['new_string'].replace("\n","")) logger.info("xNew string: " + patch['new_string'].replace("\n",""))
print("xLocation start: " + str(patch['start'])) logger.info("xLocation start: " + str(patch['start']))
print("xLocation end: " + str(patch['end'])) logger.info("xLocation end: " + str(patch['end']))
return True return True
return False return False
@ -100,19 +105,19 @@ def apply_patches(slither, patches):
out_file.close() out_file.close()
def print_patches(number_of_slither_results, patches): def print_patches(number_of_slither_results, patches):
print("Number of Slither results: " + str(number_of_slither_results)) logger.info("Number of Slither results: " + str(number_of_slither_results))
number_of_patches = 0 number_of_patches = 0
for file in patches: for file in patches:
number_of_patches += len(patches[file]) number_of_patches += len(patches[file])
print("Number of patches: " + str(number_of_patches)) logger.info("Number of patches: " + str(number_of_patches))
for file in patches: for file in patches:
print("Patch file: " + file) logger.info("Patch file: " + file)
for patch in patches[file]: for patch in patches[file]:
print("Detector: " + patch['detector']) logger.info("Detector: " + patch['detector'])
print("Old string: " + patch['old_string'].replace("\n","")) logger.info("Old string: " + patch['old_string'].replace("\n",""))
print("New string: " + patch['new_string'].replace("\n","")) logger.info("New string: " + patch['new_string'].replace("\n",""))
print("Location start: " + str(patch['start'])) logger.info("Location start: " + str(patch['start']))
print("Location end: " + str(patch['end'])) logger.info("Location end: " + str(patch['end']))
def print_patches_json(number_of_slither_results, patches): def print_patches_json(number_of_slither_results, patches):
print('{',end='') print('{',end='')
@ -175,7 +180,7 @@ def apply_detector_results(slither, patches, detector_results):
elif result['check'] == 'constant-function': elif result['check'] == 'constant-function':
FormatConstantFunction.format(slither, patches, result['elements']) FormatConstantFunction.format(slither, patches, result['elements'])
else: else:
print("Not Supported Yet.") logger.error(red("Not Supported Yet."))
sys.exit(-1) sys.exit(-1)
def get_number_of_slither_results (detector_results): def get_number_of_slither_results (detector_results):

@ -19,39 +19,39 @@ class TestConstableState(unittest.TestCase):
p.wait() p.wait()
def test_constable_states(self): def test_constable_states(self):
outFD = open(self.testFilePath+".out","r") errFD = open(self.testFilePath+".err","r")
outFD_lines = outFD.readlines() errFD_lines = errFD.readlines()
for i in range(len(outFD_lines)): for i in range(len(errFD_lines)):
outFD_lines[i] = outFD_lines[i].strip() errFD_lines[i] = errFD_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD_lines[0].rstrip(),"Number of Slither results: 6") self.assertEqual(errFD_lines[0].rstrip(),"INFO:Slither.Format:Number of Slither results: 6")
self.assertEqual(outFD_lines[1].rstrip(),"Number of patches: 6") self.assertEqual(errFD_lines[1].rstrip(),"INFO:Slither.Format:Number of patches: 6")
self.assertEqual(outFD_lines.count("Detector: constable-states"), 6) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Detector: constable-states"), 6)
self.assertEqual(outFD_lines.count("Old string: address public myFriendsAddress = 0xc0ffee254729296a45a3885639AC7E10F9d54979"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Old string: address public myFriendsAddress = 0xc0ffee254729296a45a3885639AC7E10F9d54979"), 1)
self.assertEqual(outFD_lines.count("New string: address public constant myFriendsAddress = 0xc0ffee254729296a45a3885639AC7E10F9d54979"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:New string: address public constant myFriendsAddress = 0xc0ffee254729296a45a3885639AC7E10F9d54979"), 1)
self.assertEqual(outFD_lines.count("Location start: 132"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location start: 132"), 1)
self.assertEqual(outFD_lines.count("Location end: 208"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location end: 208"), 1)
self.assertEqual(outFD_lines.count("Old string: uint public test = 5"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Old string: uint public test = 5"), 1)
self.assertEqual(outFD_lines.count("New string: uint public constant test = 5"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:New string: uint public constant test = 5"), 1)
self.assertEqual(outFD_lines.count("Location start: 237"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location start: 237"), 1)
self.assertEqual(outFD_lines.count("Location end: 257"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location end: 257"), 1)
self.assertEqual(outFD_lines.count("Old string: string text2 = \"xyz\""), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Old string: string text2 = \"xyz\""), 1)
self.assertEqual(outFD_lines.count("New string: string constant text2 = \"xyz\""), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:New string: string constant text2 = \"xyz\""), 1)
self.assertEqual(outFD_lines.count("Location start: 333"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location start: 333"), 1)
self.assertEqual(outFD_lines.count("Location end: 353"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location end: 353"), 1)
self.assertEqual(outFD_lines.count("Old string: address public mySistersAddress = 0x999999cf1046e68e36E1aA2E0E07105eDDD1f08E"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Old string: address public mySistersAddress = 0x999999cf1046e68e36E1aA2E0E07105eDDD1f08E"), 1)
self.assertEqual(outFD_lines.count("New string: address public constant mySistersAddress = 0x999999cf1046e68e36E1aA2E0E07105eDDD1f08E"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:New string: address public constant mySistersAddress = 0x999999cf1046e68e36E1aA2E0E07105eDDD1f08E"), 1)
self.assertEqual(outFD_lines.count("Location start: 496"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location start: 496"), 1)
self.assertEqual(outFD_lines.count("Location end: 572"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location end: 572"), 1)
self.assertEqual(outFD_lines.count("Old string: bytes32 should_be_constant = sha256('abc')"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Old string: bytes32 should_be_constant = sha256('abc')"), 1)
self.assertEqual(outFD_lines.count("New string: bytes32 constant should_be_constant = sha256('abc')"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:New string: bytes32 constant should_be_constant = sha256('abc')"), 1)
self.assertEqual(outFD_lines.count("Location start: 793"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location start: 793"), 1)
self.assertEqual(outFD_lines.count("Location end: 835"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location end: 835"), 1)
self.assertEqual(outFD_lines.count("Old string: uint should_be_constant_2 = A + 1"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Old string: uint should_be_constant_2 = A + 1"), 1)
self.assertEqual(outFD_lines.count("New string: uint constant should_be_constant_2 = A + 1"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:New string: uint constant should_be_constant_2 = A + 1"), 1)
self.assertEqual(outFD_lines.count("Location start: 841"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location start: 841"), 1)
self.assertEqual(outFD_lines.count("Location end: 874"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location end: 874"), 1)
outFD.close() errFD.close()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -29,37 +29,37 @@ class TestConstantFunctions(unittest.TestCase):
p2.wait() p2.wait()
def test_constant_function(self): def test_constant_function(self):
outFD1 = open(self.testFilePath1+".out","r") errFD1 = open(self.testFilePath1+".err","r")
outFD1_lines = outFD1.readlines() errFD1_lines = errFD1.readlines()
for i in range(len(outFD1_lines)): for i in range(len(errFD1_lines)):
outFD1_lines[i] = outFD1_lines[i].strip() errFD1_lines[i] = errFD1_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD1_lines[0],"Number of Slither results: 3") self.assertEqual(errFD1_lines[0],"INFO:Slither.Format:Number of Slither results: 3")
self.assertEqual(outFD1_lines[1],"Number of patches: 3") self.assertEqual(errFD1_lines[1],"INFO:Slither.Format:Number of patches: 3")
self.assertEqual(outFD1_lines.count("Detector: constant-function"), 3) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: constant-function"), 3)
self.assertEqual(outFD1_lines.count("Old string: view"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: view"), 2)
self.assertEqual(outFD1_lines.count("Old string: constant"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: constant"), 1)
self.assertEqual(outFD1_lines.count("New string:"), 3) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string:"), 3)
self.assertEqual(outFD1_lines.count("Location start: 77"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 77"), 1)
self.assertEqual(outFD1_lines.count("Location end: 81"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 81"), 1)
self.assertEqual(outFD1_lines.count("Location start: 149"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 149"), 1)
self.assertEqual(outFD1_lines.count("Location end: 157"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 157"), 1)
self.assertEqual(outFD1_lines.count("Location start: 360"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 360"), 1)
self.assertEqual(outFD1_lines.count("Location end: 364"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 364"), 1)
outFD1.close() errFD1.close()
outFD2 = open(self.testFilePath2+".out","r") errFD2 = open(self.testFilePath2+".err","r")
outFD2_lines = outFD2.readlines() errFD2_lines = errFD2.readlines()
for i in range(len(outFD2_lines)): for i in range(len(errFD2_lines)):
outFD2_lines[i] = outFD2_lines[i].strip() errFD2_lines[i] = errFD2_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD2_lines[0],"Number of Slither results: 1") self.assertEqual(errFD2_lines[0],"INFO:Slither.Format:Number of Slither results: 1")
self.assertEqual(outFD2_lines[1],"Number of patches: 1") self.assertEqual(errFD2_lines[1],"INFO:Slither.Format:Number of patches: 1")
self.assertEqual(outFD2_lines.count("Old string: view"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: view"), 1)
self.assertEqual(outFD2_lines.count("New string:"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:New string:"), 1)
self.assertEqual(outFD2_lines.count("Location start: 221"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 221"), 1)
self.assertEqual(outFD2_lines.count("Location end: 225"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 225"), 1)
outFD2.close() errFD2.close()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -1,4 +1,4 @@
//pragma solidity ^0.4.24; pragma solidity ^0.4.24;
contract naming { contract naming {

@ -19,23 +19,23 @@ class TestDetectorCombinations(unittest.TestCase):
p1.wait() p1.wait()
def test_detector_combinations(self): def test_detector_combinations(self):
outFD1 = open(self.testFilePath1+".out","r") errFD1 = open(self.testFilePath1+".err","r")
outFD1_lines = outFD1.readlines() errFD1_lines = errFD1.readlines()
outFD1.close() errFD1.close()
for i in range(len(outFD1_lines)): for i in range(len(errFD1_lines)):
outFD1_lines[i] = outFD1_lines[i].strip() errFD1_lines[i] = errFD1_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD1_lines.count("Number of Slither results: 12"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Number of Slither results: 12"), 1)
self.assertEqual(outFD1_lines.count("Number of patches: 19"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Number of patches: 19"), 1)
self.assertEqual(outFD1_lines.count("Overlapping patch won't be applied!"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Overlapping patch won't be applied!"), 2)
self.assertEqual(outFD1_lines.count("xDetector: unused-state"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:xDetector: unused-state"), 1)
self.assertEqual(outFD1_lines.count("xDetector: constable-states"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:xDetector: constable-states"), 1)
self.assertEqual(outFD1_lines.count("Detector: naming-convention (state variable declaration)"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (state variable declaration)"), 2)
self.assertEqual(outFD1_lines.count("Detector: naming-convention (state variable uses)"), 3) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (state variable uses)"), 3)
self.assertEqual(outFD1_lines.count("Detector: naming-convention (parameter declaration)"), 4) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (parameter declaration)"), 4)
self.assertEqual(outFD1_lines.count("Detector: naming-convention (parameter uses)"), 6) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (parameter uses)"), 6)
self.assertEqual(outFD1_lines.count("Detector: external-function"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: external-function"), 2)
self.assertEqual(outFD1_lines.count("Detector: constant-function"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: constant-function"), 1)
self.assertEqual(outFD1_lines.count("Detector: solc-version"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: solc-version"), 1)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -29,44 +29,44 @@ class TestExternalFunctions(unittest.TestCase):
p2.wait() p2.wait()
def test_external_function(self): def test_external_function(self):
outFD1 = open(self.testFilePath1+".out","r") errFD1 = open(self.testFilePath1+".err","r")
outFD1_lines = outFD1.readlines() errFD1_lines = errFD1.readlines()
for i in range(len(outFD1_lines)): for i in range(len(errFD1_lines)):
outFD1_lines[i] = outFD1_lines[i].strip() errFD1_lines[i] = errFD1_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD1_lines[0],"Number of Slither results: 9") self.assertEqual(errFD1_lines[0],"INFO:Slither.Format:Number of Slither results: 9")
self.assertEqual(outFD1_lines[1],"Number of patches: 8") self.assertEqual(errFD1_lines[1],"INFO:Slither.Format:Number of patches: 8")
self.assertEqual(outFD1_lines.count("Detector: external-function"), 8) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: external-function"), 8)
self.assertEqual(outFD1_lines.count("Old string: public"), 6) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: public"), 6)
self.assertEqual(outFD1_lines.count("New string: external"), 6) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: external"), 6)
self.assertEqual(outFD1_lines.count("Location start: 384"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 384"), 1)
self.assertEqual(outFD1_lines.count("Location end: 390"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 390"), 1)
self.assertEqual(outFD1_lines.count("Location start: 562"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 562"), 1)
self.assertEqual(outFD1_lines.count("Location end: 568"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 568"), 1)
self.assertEqual(outFD1_lines.count("Location start: 642"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 642"), 1)
self.assertEqual(outFD1_lines.count("Location end: 648"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 648"), 1)
self.assertEqual(outFD1_lines.count("Location start: 685"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 685"), 1)
self.assertEqual(outFD1_lines.count("Location end: 691"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 691"), 1)
self.assertEqual(outFD1_lines.count("Location start: 1022"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 1022"), 1)
self.assertEqual(outFD1_lines.count("Location end: 1028"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 1028"), 1)
self.assertEqual(outFD1_lines.count("Location start: 1305"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 1305"), 1)
self.assertEqual(outFD1_lines.count("Location end: 1311"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 1311"), 1)
self.assertEqual(outFD1_lines.count("Old string:"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string:"), 2)
self.assertEqual(outFD1_lines.count("New string: external"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: external"), 2)
self.assertEqual(outFD1_lines.count("Location start: 524"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 524"), 1)
self.assertEqual(outFD1_lines.count("Location end: 524"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 524"), 1)
self.assertEqual(outFD1_lines.count("Location start: 1142"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 1142"), 1)
self.assertEqual(outFD1_lines.count("Location end: 1142"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 1142"), 1)
outFD1.close() errFD1.close()
outFD2 = open(self.testFilePath2+".out","r") errFD2 = open(self.testFilePath2+".err","r")
outFD2_lines = outFD2.readlines() errFD2_lines = errFD2.readlines()
for i in range(len(outFD2_lines)): for i in range(len(errFD2_lines)):
outFD2_lines[i] = outFD2_lines[i].strip() errFD2_lines[i] = errFD2_lines[i].strip()
self.assertFalse(os.path.isfile(self.testFilePath2+".format"),"Patched .format file _is_ created?!") self.assertFalse(os.path.isfile(self.testFilePath2+".format"),"Patched .format file _is_ created?!")
self.assertEqual(outFD2_lines[0],"Number of Slither results: 0") self.assertEqual(errFD2_lines[0],"INFO:Slither.Format:Number of Slither results: 0")
self.assertEqual(outFD2_lines[1],"Number of patches: 0") self.assertEqual(errFD2_lines[1],"INFO:Slither.Format:Number of patches: 0")
outFD2.close() errFD2.close()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -96,314 +96,314 @@ class TestNamingConvention(unittest.TestCase):
p8.wait() p8.wait()
def test_naming_convention_contract(self): def test_naming_convention_contract(self):
outFD1 = open(self.testFilePath1+".out","r") errFD1 = open(self.testFilePath1+".err","r")
outFD1_lines = outFD1.readlines() errFD1_lines = errFD1.readlines()
outFD1.close() errFD1.close()
for i in range(len(outFD1_lines)): for i in range(len(errFD1_lines)):
outFD1_lines[i] = outFD1_lines[i].strip() errFD1_lines[i] = errFD1_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD1_lines[0],"Number of Slither results: 2") self.assertEqual(errFD1_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD1_lines[1],"Number of patches: 10") self.assertEqual(errFD1_lines[1],"INFO:Slither.Format:Number of patches: 10")
self.assertEqual(outFD1_lines.count("Detector: naming-convention (contract definition)"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (contract definition)"), 2)
self.assertEqual(outFD1_lines.count("Detector: naming-convention (contract state variable)"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (contract state variable)"), 2)
self.assertEqual(outFD1_lines.count("Detector: naming-convention (contract function variable)"), 5) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (contract function variable)"), 5)
self.assertEqual(outFD1_lines.count("Detector: naming-convention (contract new object)"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: naming-convention (contract new object)"), 1)
self.assertEqual(outFD1_lines.count("Old string: contract one"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: contract one"), 1)
self.assertEqual(outFD1_lines.count("New string: contract One"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: contract One"), 1)
self.assertEqual(outFD1_lines.count("Location start: 53"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 53"), 1)
self.assertEqual(outFD1_lines.count("Location end: 65"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 65"), 1)
self.assertEqual(outFD1_lines.count("Old string: three k"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: three k"), 1)
self.assertEqual(outFD1_lines.count("New string: Three k"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: Three k"), 1)
self.assertEqual(outFD1_lines.count("Location start: 117"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 117"), 1)
self.assertEqual(outFD1_lines.count("Location end: 124"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 124"), 1)
self.assertEqual(outFD1_lines.count("Old string: three l"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: three l"), 1)
self.assertEqual(outFD1_lines.count("New string: Three l"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: Three l"), 1)
self.assertEqual(outFD1_lines.count("Location start: 206"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 206"), 1)
self.assertEqual(outFD1_lines.count("Location end: 213"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 213"), 1)
self.assertEqual(outFD1_lines.count("Old string: one m"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: one m"), 1)
self.assertEqual(outFD1_lines.count("New string: One m"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: One m"), 1)
self.assertEqual(outFD1_lines.count("Location start: 343"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 343"), 1)
self.assertEqual(outFD1_lines.count("Location end: 348"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 348"), 1)
self.assertEqual(outFD1_lines.count("Old string: one n"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: one n"), 1)
self.assertEqual(outFD1_lines.count("New string: One n"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: One n"), 1)
self.assertEqual(outFD1_lines.count("Location start: 423"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 423"), 1)
self.assertEqual(outFD1_lines.count("Location end: 428"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 428"), 1)
self.assertEqual(outFD1_lines.count("Old string: contract three"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: contract three"), 1)
self.assertEqual(outFD1_lines.count("New string: contract Three"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: contract Three"), 1)
self.assertEqual(outFD1_lines.count("Location start: 498"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 498"), 1)
self.assertEqual(outFD1_lines.count("Location end: 512"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 512"), 1)
self.assertEqual(outFD1_lines.count("Old string: one"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: one"), 1)
self.assertEqual(outFD1_lines.count("New string: One"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: One"), 1)
self.assertEqual(outFD1_lines.count("Location start: 646"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 646"), 1)
self.assertEqual(outFD1_lines.count("Location end: 649"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 649"), 1)
self.assertEqual(outFD1_lines.count("Old string: one r = new one()"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: one r = new one()"), 1)
self.assertEqual(outFD1_lines.count("New string: One r = new one()"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: One r = new one()"), 1)
self.assertEqual(outFD1_lines.count("Location start: 773"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 773"), 1)
self.assertEqual(outFD1_lines.count("Location end: 790"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 790"), 1)
self.assertEqual(outFD1_lines.count("Old string: one q"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: one q"), 1)
self.assertEqual(outFD1_lines.count("New string: One q"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: One q"), 1)
self.assertEqual(outFD1_lines.count("Location start: 871"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 871"), 1)
self.assertEqual(outFD1_lines.count("Location end: 876"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 876"), 1)
self.assertEqual(outFD1_lines.count("Old string: new one()"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: new one()"), 1)
self.assertEqual(outFD1_lines.count("New string: new One()"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: new One()"), 1)
self.assertEqual(outFD1_lines.count("Location start: 781"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 781"), 1)
self.assertEqual(outFD1_lines.count("Location end: 788"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 788"), 1)
def test_naming_convention_modifier(self): def test_naming_convention_modifier(self):
outFD2 = open(self.testFilePath2+".out","r") errFD2 = open(self.testFilePath2+".err","r")
outFD2_lines = outFD2.readlines() errFD2_lines = errFD2.readlines()
outFD2.close() errFD2.close()
for i in range(len(outFD2_lines)): for i in range(len(errFD2_lines)):
outFD2_lines[i] = outFD2_lines[i].strip() errFD2_lines[i] = errFD2_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD2_lines[0],"Number of Slither results: 2") self.assertEqual(errFD2_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD2_lines[1],"Number of patches: 5") self.assertEqual(errFD2_lines[1],"INFO:Slither.Format:Number of patches: 5")
self.assertEqual(outFD2_lines.count("Detector: naming-convention (modifier definition)"), 2) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Detector: naming-convention (modifier definition)"), 2)
self.assertEqual(outFD2_lines.count("Detector: naming-convention (modifier uses)"), 3) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Detector: naming-convention (modifier uses)"), 3)
self.assertEqual(outFD2_lines.count("Old string: modifier One"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: modifier One"), 1)
self.assertEqual(outFD2_lines.count("New string: modifier one"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:New string: modifier one"), 1)
self.assertEqual(outFD2_lines.count("Location start: 215"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 215"), 1)
self.assertEqual(outFD2_lines.count("Location end: 227"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 227"), 1)
self.assertEqual(outFD2_lines.count("Old string: () One"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: () One"), 1)
self.assertEqual(outFD2_lines.count("New string: () one"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:New string: () one"), 1)
self.assertEqual(outFD2_lines.count("Location start: 288"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 288"), 1)
self.assertEqual(outFD2_lines.count("Location end: 295"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 295"), 1)
self.assertEqual(outFD2_lines.count("Old string: modifier Two"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: modifier Two"), 1)
self.assertEqual(outFD2_lines.count("New string: modifier two"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:New string: modifier two"), 1)
self.assertEqual(outFD2_lines.count("Location start: 423"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 423"), 1)
self.assertEqual(outFD2_lines.count("Location end: 435"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 435"), 1)
self.assertEqual(outFD2_lines.count("Old string: () one Two returns"), 2) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: () one Two returns"), 2)
self.assertEqual(outFD2_lines.count("New string: () one two returns"), 2) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:New string: () one two returns"), 2)
self.assertEqual(outFD2_lines.count("Location start: 503"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 503"), 1)
self.assertEqual(outFD2_lines.count("Location end: 522"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 522"), 1)
self.assertEqual(outFD2_lines.count("Location start: 718"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 718"), 1)
self.assertEqual(outFD2_lines.count("Location end: 737"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 737"), 1)
def test_naming_convention_structure(self): def test_naming_convention_structure(self):
outFD3 = open(self.testFilePath3+".out","r") errFD3 = open(self.testFilePath3+".err","r")
outFD3_lines = outFD3.readlines() errFD3_lines = errFD3.readlines()
outFD3.close() errFD3.close()
for i in range(len(outFD3_lines)): for i in range(len(errFD3_lines)):
outFD3_lines[i] = outFD3_lines[i].strip() errFD3_lines[i] = errFD3_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath3+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath3+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD3_lines[0],"Number of Slither results: 2") self.assertEqual(errFD3_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD3_lines[1],"Number of patches: 8") self.assertEqual(errFD3_lines[1],"INFO:Slither.Format:Number of patches: 8")
self.assertEqual(outFD3_lines.count("Detector: naming-convention (struct definition)"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Detector: naming-convention (struct definition)"), 2)
self.assertEqual(outFD3_lines.count("Detector: naming-convention (struct use)"), 6) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Detector: naming-convention (struct use)"), 6)
self.assertEqual(outFD3_lines.count("Old string: struct s { uint i; }"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Old string: struct s { uint i; }"), 2)
self.assertEqual(outFD3_lines.count("New string: struct S { uint i; }"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:New string: struct S { uint i; }"), 2)
self.assertEqual(outFD3_lines.count("Location start: 108"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 108"), 1)
self.assertEqual(outFD3_lines.count("Location end: 134"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 134"), 1)
self.assertEqual(outFD3_lines.count("Location start: 434"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 434"), 1)
self.assertEqual(outFD3_lines.count("Location end: 460"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 460"), 1)
self.assertEqual(outFD3_lines.count("Old string: s s1"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Old string: s s1"), 2)
self.assertEqual(outFD3_lines.count("New string: S s1"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:New string: S s1"), 2)
self.assertEqual(outFD3_lines.count("Location start: 171"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 171"), 1)
self.assertEqual(outFD3_lines.count("Location end: 175"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 175"), 1)
self.assertEqual(outFD3_lines.count("Location start: 497"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 497"), 1)
self.assertEqual(outFD3_lines.count("Location end: 501"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 501"), 1)
self.assertEqual(outFD3_lines.count("Old string: s sA"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Old string: s sA"), 2)
self.assertEqual(outFD3_lines.count("New string: S sA"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:New string: S sA"), 2)
self.assertEqual(outFD3_lines.count("Location start: 570"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 570"), 1)
self.assertEqual(outFD3_lines.count("Location end: 574"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 574"), 1)
self.assertEqual(outFD3_lines.count("Location start: 715"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 715"), 1)
self.assertEqual(outFD3_lines.count("Location end: 719"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 719"), 1)
self.assertEqual(outFD3_lines.count("Old string: s"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Old string: s"), 2)
self.assertEqual(outFD3_lines.count("New string: S"), 2) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:New string: S"), 2)
self.assertEqual(outFD3_lines.count("Location start: 585"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 585"), 1)
self.assertEqual(outFD3_lines.count("Location end: 586"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 586"), 1)
self.assertEqual(outFD3_lines.count("Location start: 730"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 730"), 1)
self.assertEqual(outFD3_lines.count("Location end: 731"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 731"), 1)
def test_naming_convention_enum(self): def test_naming_convention_enum(self):
outFD4 = open(self.testFilePath4+".out","r") errFD4 = open(self.testFilePath4+".err","r")
outFD4_lines = outFD4.readlines() errFD4_lines = errFD4.readlines()
outFD4.close() errFD4.close()
for i in range(len(outFD4_lines)): for i in range(len(errFD4_lines)):
outFD4_lines[i] = outFD4_lines[i].strip() errFD4_lines[i] = errFD4_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath4+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath4+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD4_lines[0],"Number of Slither results: 2") self.assertEqual(errFD4_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD4_lines[1],"Number of patches: 11") self.assertEqual(errFD4_lines[1],"INFO:Slither.Format:Number of patches: 11")
self.assertEqual(outFD4_lines.count("Detector: naming-convention (enum definition)"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Detector: naming-convention (enum definition)"), 2)
self.assertEqual(outFD4_lines.count("Detector: naming-convention (enum use)"), 9) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Detector: naming-convention (enum use)"), 9)
self.assertEqual(outFD4_lines.count("Old string: enum e {ONE, TWO}"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Old string: enum e {ONE, TWO}"), 2)
self.assertEqual(outFD4_lines.count("New string: enum E {ONE, TWO}"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:New string: enum E {ONE, TWO}"), 2)
self.assertEqual(outFD4_lines.count("Location start: 73"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 73"), 1)
self.assertEqual(outFD4_lines.count("Location end: 90"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 90"), 1)
self.assertEqual(outFD4_lines.count("Location start: 426"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 426"), 1)
self.assertEqual(outFD4_lines.count("Location end: 443"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 443"), 1)
self.assertEqual(outFD4_lines.count("Old string: e e1"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Old string: e e1"), 2)
self.assertEqual(outFD4_lines.count("New string: E e1"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:New string: E e1"), 2)
self.assertEqual(outFD4_lines.count("Location start: 125"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 125"), 1)
self.assertEqual(outFD4_lines.count("Location end: 129"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 129"), 1)
self.assertEqual(outFD4_lines.count("Location start: 478"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 478"), 1)
self.assertEqual(outFD4_lines.count("Location end: 482"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 482"), 1)
self.assertEqual(outFD4_lines.count("Old string: e eA"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Old string: e eA"), 2)
self.assertEqual(outFD4_lines.count("New string: E eA"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:New string: E eA"), 2)
self.assertEqual(outFD4_lines.count("Location start: 549"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 549"), 1)
self.assertEqual(outFD4_lines.count("Location end: 553"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 553"), 1)
self.assertEqual(outFD4_lines.count("Location start: 690"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 690"), 1)
self.assertEqual(outFD4_lines.count("Location end: 694"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 694"), 1)
self.assertEqual(outFD4_lines.count("Old string: e e2 = eA"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Old string: e e2 = eA"), 2)
self.assertEqual(outFD4_lines.count("New string: E e2 = eA"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:New string: E e2 = eA"), 2)
self.assertEqual(outFD4_lines.count("Location start: 573"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 573"), 1)
self.assertEqual(outFD4_lines.count("Location end: 582"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 582"), 1)
self.assertEqual(outFD4_lines.count("Location start: 714"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 714"), 1)
self.assertEqual(outFD4_lines.count("Location end: 723"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 723"), 1)
self.assertEqual(outFD4_lines.count("Old string: e.ONE"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Old string: e.ONE"), 1)
self.assertEqual(outFD4_lines.count("New string: E.ONE"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:New string: E.ONE"), 1)
self.assertEqual(outFD4_lines.count("Location start: 186"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 186"), 1)
self.assertEqual(outFD4_lines.count("Location end: 192"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 192"), 1)
self.assertEqual(outFD4_lines.count("Old string: e"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Old string: e"), 2)
self.assertEqual(outFD4_lines.count("New string: E"), 2) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:New string: E"), 2)
self.assertEqual(outFD4_lines.count("Location start: 564"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 564"), 1)
self.assertEqual(outFD4_lines.count("Location end: 565"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 565"), 1)
self.assertEqual(outFD4_lines.count("Location start: 705"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 705"), 1)
self.assertEqual(outFD4_lines.count("Location end: 706"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 706"), 1)
def test_naming_convention_event(self): def test_naming_convention_event(self):
outFD5 = open(self.testFilePath5+".out","r") errFD5 = open(self.testFilePath5+".err","r")
outFD5_lines = outFD5.readlines() errFD5_lines = errFD5.readlines()
outFD5.close() errFD5.close()
for i in range(len(outFD5_lines)): for i in range(len(errFD5_lines)):
outFD5_lines[i] = outFD5_lines[i].strip() errFD5_lines[i] = errFD5_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath5+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath5+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD5_lines[0],"Number of Slither results: 2") self.assertEqual(errFD5_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD5_lines[1],"Number of patches: 5") self.assertEqual(errFD5_lines[1],"INFO:Slither.Format:Number of patches: 5")
self.assertEqual(outFD5_lines.count("Detector: naming-convention (event definition)"), 2) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Detector: naming-convention (event definition)"), 2)
self.assertEqual(outFD5_lines.count("Detector: naming-convention (event calls)"), 3) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Detector: naming-convention (event calls)"), 3)
self.assertEqual(outFD5_lines.count("Old string: event e(uint);"), 2) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Old string: event e(uint);"), 2)
self.assertEqual(outFD5_lines.count("New string: event E(uint);"), 2) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:New string: event E(uint);"), 2)
self.assertEqual(outFD5_lines.count("Location start: 75"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location start: 75"), 1)
self.assertEqual(outFD5_lines.count("Location end: 89"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location end: 89"), 1)
self.assertEqual(outFD5_lines.count("Location start: 148"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location start: 148"), 1)
self.assertEqual(outFD5_lines.count("Location end: 152"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location end: 152"), 1)
self.assertEqual(outFD5_lines.count("Old string: e(i)"), 3) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Old string: e(i)"), 3)
self.assertEqual(outFD5_lines.count("New string: E(i)"), 3) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:New string: E(i)"), 3)
self.assertEqual(outFD5_lines.count("Location start: 148"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location start: 148"), 1)
self.assertEqual(outFD5_lines.count("Location end: 152"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location end: 152"), 1)
self.assertEqual(outFD5_lines.count("Location start: 438"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location start: 438"), 1)
self.assertEqual(outFD5_lines.count("Location end: 442"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location end: 442"), 1)
self.assertEqual(outFD5_lines.count("Location start: 550"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location start: 550"), 1)
self.assertEqual(outFD5_lines.count("Location end: 554"), 1) self.assertEqual(errFD5_lines.count("INFO:Slither.Format:Location end: 554"), 1)
def test_naming_convention_function(self): def test_naming_convention_function(self):
outFD6 = open(self.testFilePath6+".out","r") errFD6 = open(self.testFilePath6+".err","r")
outFD6_lines = outFD6.readlines() errFD6_lines = errFD6.readlines()
outFD6.close() errFD6.close()
for i in range(len(outFD6_lines)): for i in range(len(errFD6_lines)):
outFD6_lines[i] = outFD6_lines[i].strip() errFD6_lines[i] = errFD6_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath6+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath6+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD6_lines[0],"Number of Slither results: 2") self.assertEqual(errFD6_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD6_lines[1],"Number of patches: 4") self.assertEqual(errFD6_lines[1],"INFO:Slither.Format:Number of patches: 4")
self.assertEqual(outFD6_lines.count("Detector: naming-convention (function definition)"), 2) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Detector: naming-convention (function definition)"), 2)
self.assertEqual(outFD6_lines.count("Detector: naming-convention (function calls)"), 2) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Detector: naming-convention (function calls)"), 2)
self.assertEqual(outFD6_lines.count("Old string: function Foo"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Old string: function Foo"), 1)
self.assertEqual(outFD6_lines.count("New string: function foo"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:New string: function foo"), 1)
self.assertEqual(outFD6_lines.count("Location start: 76"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location start: 76"), 1)
self.assertEqual(outFD6_lines.count("Location end: 88"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location end: 88"), 1)
self.assertEqual(outFD6_lines.count("Old string: function Foobar"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Old string: function Foobar"), 1)
self.assertEqual(outFD6_lines.count("New string: function foobar"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:New string: function foobar"), 1)
self.assertEqual(outFD6_lines.count("Location start: 189"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location start: 189"), 1)
self.assertEqual(outFD6_lines.count("Location end: 204"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location end: 204"), 1)
self.assertEqual(outFD6_lines.count("Old string: Foobar(10)"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Old string: Foobar(10)"), 1)
self.assertEqual(outFD6_lines.count("New string: foobar(10)"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:New string: foobar(10)"), 1)
self.assertEqual(outFD6_lines.count("Location start: 136"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location start: 136"), 1)
self.assertEqual(outFD6_lines.count("Location end: 146"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location end: 146"), 1)
self.assertEqual(outFD6_lines.count("Old string: a.Foobar(10)"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Old string: a.Foobar(10)"), 1)
self.assertEqual(outFD6_lines.count("New string: a.foobar(10)"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:New string: a.foobar(10)"), 1)
self.assertEqual(outFD6_lines.count("Location start: 516"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location start: 516"), 1)
self.assertEqual(outFD6_lines.count("Location end: 528"), 1) self.assertEqual(errFD6_lines.count("INFO:Slither.Format:Location end: 528"), 1)
def test_naming_convention_parameter(self): def test_naming_convention_parameter(self):
outFD7 = open(self.testFilePath7+".out","r") errFD7 = open(self.testFilePath7+".err","r")
outFD7_lines = outFD7.readlines() errFD7_lines = errFD7.readlines()
outFD7.close() errFD7.close()
for i in range(len(outFD7_lines)): for i in range(len(errFD7_lines)):
outFD7_lines[i] = outFD7_lines[i].strip() errFD7_lines[i] = errFD7_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath7+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath7+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD7_lines[0],"Number of Slither results: 6") self.assertEqual(errFD7_lines[0],"INFO:Slither.Format:Number of Slither results: 6")
self.assertEqual(outFD7_lines[1],"Number of patches: 12") self.assertEqual(errFD7_lines[1],"INFO:Slither.Format:Number of patches: 12")
self.assertEqual(outFD7_lines.count("Detector: naming-convention (parameter declaration)"), 6) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Detector: naming-convention (parameter declaration)"), 6)
self.assertEqual(outFD7_lines.count("Detector: naming-convention (parameter uses)"), 6) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Detector: naming-convention (parameter uses)"), 6)
self.assertEqual(outFD7_lines.count("Old string: uint Count"), 3) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: uint Count"), 3)
self.assertEqual(outFD7_lines.count("New string: uint _Count"), 3) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: uint _Count"), 3)
self.assertEqual(outFD7_lines.count("Location start: 91"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 91"), 1)
self.assertEqual(outFD7_lines.count("Location end: 101"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 101"), 1)
self.assertEqual(outFD7_lines.count("Location start: 215"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 215"), 1)
self.assertEqual(outFD7_lines.count("Location end: 225"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 225"), 1)
self.assertEqual(outFD7_lines.count("Old string: Count"), 3) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: Count"), 3)
self.assertEqual(outFD7_lines.count("New string: _Count"), 3) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: _Count"), 3)
self.assertEqual(outFD7_lines.count("Location start: 148"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 148"), 1)
self.assertEqual(outFD7_lines.count("Location end: 153"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 153"), 1)
self.assertEqual(outFD7_lines.count("Location start: 308"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 308"), 1)
self.assertEqual(outFD7_lines.count("Location end: 313"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 313"), 1)
self.assertEqual(outFD7_lines.count("Location start: 489"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 489"), 1)
self.assertEqual(outFD7_lines.count("Location end: 499"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 499"), 1)
self.assertEqual(outFD7_lines.count("Location start: 580"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 580"), 1)
self.assertEqual(outFD7_lines.count("Location end: 585"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 585"), 1)
self.assertEqual(outFD7_lines.count("Old string: Count)"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: Count)"), 1)
self.assertEqual(outFD7_lines.count("New string: _Count)"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: _Count)"), 1)
self.assertEqual(outFD7_lines.count("Location start: 506"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 506"), 1)
self.assertEqual(outFD7_lines.count("Location end: 512"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 512"), 1)
self.assertEqual(outFD7_lines.count("Old string: uint Number"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: uint Number"), 1)
self.assertEqual(outFD7_lines.count("New string: uint _Number"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: uint _Number"), 1)
self.assertEqual(outFD7_lines.count("Location start: 227"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 227"), 1)
self.assertEqual(outFD7_lines.count("Location end: 238"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 238"), 1)
self.assertEqual(outFD7_lines.count("Old string: Number"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: Number"), 1)
self.assertEqual(outFD7_lines.count("New string: _Number"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: _Number"), 1)
self.assertEqual(outFD7_lines.count("Location start: 314"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 314"), 1)
self.assertEqual(outFD7_lines.count("Location end: 320"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 320"), 1)
self.assertEqual(outFD7_lines.count("Old string: address _to"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: address _to"), 1)
self.assertEqual(outFD7_lines.count("New string: address _To"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: address _To"), 1)
self.assertEqual(outFD7_lines.count("Location start: 708"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 708"), 1)
self.assertEqual(outFD7_lines.count("Location end: 719"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 719"), 1)
self.assertEqual(outFD7_lines.count("Old string: address _from"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: address _from"), 1)
self.assertEqual(outFD7_lines.count("New string: address _From"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: address _From"), 1)
self.assertEqual(outFD7_lines.count("Location start: 721"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 721"), 1)
self.assertEqual(outFD7_lines.count("Location end: 734"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 734"), 1)
self.assertEqual(outFD7_lines.count("Old string: _to"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: _to"), 1)
self.assertEqual(outFD7_lines.count("New string: _To"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: _To"), 1)
self.assertEqual(outFD7_lines.count("Location start: 811"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location start: 811"), 1)
self.assertEqual(outFD7_lines.count("Location end: 814"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Location end: 814"), 1)
self.assertEqual(outFD7_lines.count("Old string: _from"), 1, "Index variables of writes are not captured by node._expression_vars_read of Slither") self.assertEqual(errFD7_lines.count("INFO:Slither.Format:Old string: _from"), 1, "Index variables of writes are not captured by node._expression_vars_read of Slither")
self.assertEqual(outFD7_lines.count("New string: _From"), 1) self.assertEqual(errFD7_lines.count("INFO:Slither.Format:New string: _From"), 1)
def test_naming_convention_state_variable(self): def test_naming_convention_state_variable(self):
outFD8 = open(self.testFilePath8+".out","r") errFD8 = open(self.testFilePath8+".err","r")
outFD8_lines = outFD8.readlines() errFD8_lines = errFD8.readlines()
outFD8.close() errFD8.close()
for i in range(len(outFD8_lines)): for i in range(len(errFD8_lines)):
outFD8_lines[i] = outFD8_lines[i].strip() errFD8_lines[i] = errFD8_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath8+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath8+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD8_lines[0],"Number of Slither results: 3") self.assertEqual(errFD8_lines[0],"INFO:Slither.Format:Number of Slither results: 3")
self.assertEqual(outFD8_lines[1],"Number of patches: 9") self.assertEqual(errFD8_lines[1],"INFO:Slither.Format:Number of patches: 9")
self.assertEqual(outFD8_lines.count("Detector: naming-convention (state variable declaration)"), 3) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Detector: naming-convention (state variable declaration)"), 3)
self.assertEqual(outFD8_lines.count("Detector: naming-convention (state variable uses)"), 6) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Detector: naming-convention (state variable uses)"), 6)
self.assertEqual(outFD8_lines.count("Old string: number"), 3) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Old string: number"), 3)
self.assertEqual(outFD8_lines.count("New string: NUMBER"), 3) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:New string: NUMBER"), 3)
self.assertEqual(outFD8_lines.count("Location start: 469"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 469"), 1)
self.assertEqual(outFD8_lines.count("Location end: 475"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 475"), 1)
self.assertEqual(outFD8_lines.count("Location start: 716"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 716"), 1)
self.assertEqual(outFD8_lines.count("Location end: 722"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 722"), 1)
self.assertEqual(outFD8_lines.count("Location start: 850"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 850"), 1)
self.assertEqual(outFD8_lines.count("Location end: 856"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 856"), 1)
self.assertEqual(outFD8_lines.count("Old string: Count"), 3) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Old string: Count"), 3)
self.assertEqual(outFD8_lines.count("New string: count"), 3) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:New string: count"), 3)
self.assertEqual(outFD8_lines.count("Location start: 547"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 547"), 1)
self.assertEqual(outFD8_lines.count("Location end: 552"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 552"), 1)
self.assertEqual(outFD8_lines.count("Location start: 725"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 725"), 1)
self.assertEqual(outFD8_lines.count("Location end: 730"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 730"), 1)
self.assertEqual(outFD8_lines.count("Location start: 745"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 745"), 1)
self.assertEqual(outFD8_lines.count("Location end: 750"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 750"), 1)
self.assertEqual(outFD8_lines.count("Old string: Maxnum"), 3) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Old string: Maxnum"), 3)
self.assertEqual(outFD8_lines.count("New string: maxnum"), 3) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:New string: maxnum"), 3)
self.assertEqual(outFD8_lines.count("Location start: 634"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 634"), 1)
self.assertEqual(outFD8_lines.count("Location end: 640"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 640"), 1)
self.assertEqual(outFD8_lines.count("Location start: 733"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 733"), 1)
self.assertEqual(outFD8_lines.count("Location end: 739"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 739"), 1)
self.assertEqual(outFD8_lines.count("Location start: 859"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location start: 859"), 1)
self.assertEqual(outFD8_lines.count("Location end: 865"), 1) self.assertEqual(errFD8_lines.count("INFO:Slither.Format:Location end: 865"), 1)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -37,35 +37,35 @@ class TestPragma(unittest.TestCase):
p2.wait() p2.wait()
def test_pragma(self): def test_pragma(self):
outFD1 = open(self.testFilePath1+".out","r") errFD1 = open(self.testFilePath1+".err","r")
outFD1_lines = outFD1.readlines() errFD1_lines = errFD1.readlines()
for i in range(len(outFD1_lines)): for i in range(len(errFD1_lines)):
outFD1_lines[i] = outFD1_lines[i].strip() errFD1_lines[i] = errFD1_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD1_lines[0],"Number of Slither results: 2") self.assertEqual(errFD1_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD1_lines[1],"Number of patches: 2") self.assertEqual(errFD1_lines[1],"INFO:Slither.Format:Number of patches: 2")
self.assertEqual(outFD1_lines.count("Detector: pragma"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: pragma"), 2)
self.assertEqual(outFD1_lines.count("Old string: pragma solidity ^0.4.23;"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: pragma solidity ^0.4.23;"), 1)
self.assertEqual(outFD1_lines.count("Old string: pragma solidity ^0.4.24;"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: pragma solidity ^0.4.24;"), 1)
self.assertEqual(outFD1_lines.count("New string: pragma solidity 0.4.25;"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: pragma solidity 0.4.25;"), 2)
self.assertEqual(outFD1_lines.count("Location start: 0"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 0"), 2)
self.assertEqual(outFD1_lines.count("Location end: 24"), 2) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 24"), 2)
outFD1.close() errFD1.close()
outFD2 = open(self.testFilePath2+".out","r") errFD2 = open(self.testFilePath2+".err","r")
outFD2_lines = outFD2.readlines() errFD2_lines = errFD2.readlines()
for i in range(len(outFD2_lines)): for i in range(len(errFD2_lines)):
outFD2_lines[i] = outFD2_lines[i].strip() errFD2_lines[i] = errFD2_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD2_lines[0],"Number of Slither results: 2") self.assertEqual(errFD2_lines[0],"INFO:Slither.Format:Number of Slither results: 2")
self.assertEqual(outFD2_lines[1],"Number of patches: 2") self.assertEqual(errFD2_lines[1],"INFO:Slither.Format:Number of patches: 2")
self.assertEqual(outFD2_lines.count("Detector: pragma"), 2) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Detector: pragma"), 2)
self.assertEqual(outFD2_lines.count("Old string: pragma solidity ^0.5.4;"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: pragma solidity ^0.5.4;"), 1)
self.assertEqual(outFD2_lines.count("Old string: pragma solidity ^0.5.2;"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: pragma solidity ^0.5.2;"), 1)
self.assertEqual(outFD2_lines.count("New string: pragma solidity 0.5.3;"), 2) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:New string: pragma solidity 0.5.3;"), 2)
self.assertEqual(outFD2_lines.count("Location start: 0"), 2) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 0"), 2)
self.assertEqual(outFD2_lines.count("Location end: 23"), 2) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 23"), 2)
outFD2.close() errFD2.close()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -54,61 +54,61 @@ class TestSolcVersion(unittest.TestCase):
p4.wait() p4.wait()
def test_solc_version(self): def test_solc_version(self):
outFD1 = open(self.testFilePath1+".out","r") errFD1 = open(self.testFilePath1+".err","r")
outFD1_lines = outFD1.readlines() errFD1_lines = errFD1.readlines()
for i in range(len(outFD1_lines)): for i in range(len(errFD1_lines)):
outFD1_lines[i] = outFD1_lines[i].strip() errFD1_lines[i] = errFD1_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath1+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD1_lines[0],"Number of Slither results: 1") self.assertEqual(errFD1_lines[0],"INFO:Slither.Format:Number of Slither results: 1")
self.assertEqual(outFD1_lines[1],"Number of patches: 1") self.assertEqual(errFD1_lines[1],"INFO:Slither.Format:Number of patches: 1")
self.assertEqual(outFD1_lines.count("Detector: solc-version"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Detector: solc-version"), 1)
self.assertEqual(outFD1_lines.count("Old string: pragma solidity ^0.4.23;"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Old string: pragma solidity ^0.4.23;"), 1)
self.assertEqual(outFD1_lines.count("New string: pragma solidity 0.4.25;"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:New string: pragma solidity 0.4.25;"), 1)
self.assertEqual(outFD1_lines.count("Location start: 63"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location start: 63"), 1)
self.assertEqual(outFD1_lines.count("Location end: 87"), 1) self.assertEqual(errFD1_lines.count("INFO:Slither.Format:Location end: 87"), 1)
outFD1.close() errFD1.close()
outFD2 = open(self.testFilePath2+".out","r") errFD2 = open(self.testFilePath2+".err","r")
outFD2_lines = outFD2.readlines() errFD2_lines = errFD2.readlines()
for i in range(len(outFD2_lines)): for i in range(len(errFD2_lines)):
outFD2_lines[i] = outFD2_lines[i].strip() errFD2_lines[i] = errFD2_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath2+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD2_lines[0],"Number of Slither results: 1") self.assertEqual(errFD2_lines[0],"INFO:Slither.Format:Number of Slither results: 1")
self.assertEqual(outFD2_lines[1],"Number of patches: 1") self.assertEqual(errFD2_lines[1],"INFO:Slither.Format:Number of patches: 1")
self.assertEqual(outFD2_lines.count("Detector: solc-version"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Detector: solc-version"), 1)
self.assertEqual(outFD2_lines.count("Old string: pragma solidity >=0.4.0 <0.6.0;"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Old string: pragma solidity >=0.4.0 <0.6.0;"), 1)
self.assertEqual(outFD2_lines.count("New string: pragma solidity 0.5.3;"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:New string: pragma solidity 0.5.3;"), 1)
self.assertEqual(outFD2_lines.count("Location start: 63"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location start: 63"), 1)
self.assertEqual(outFD2_lines.count("Location end: 94"), 1) self.assertEqual(errFD2_lines.count("INFO:Slither.Format:Location end: 94"), 1)
outFD2.close() errFD2.close()
outFD3 = open(self.testFilePath3+".out","r") errFD3 = open(self.testFilePath3+".err","r")
outFD3_lines = outFD3.readlines() errFD3_lines = errFD3.readlines()
for i in range(len(outFD3_lines)): for i in range(len(errFD3_lines)):
outFD3_lines[i] = outFD3_lines[i].strip() errFD3_lines[i] = errFD3_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath3+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath3+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD3_lines[0],"Number of Slither results: 1") self.assertEqual(errFD3_lines[0],"INFO:Slither.Format:Number of Slither results: 1")
self.assertEqual(outFD3_lines[1],"Number of patches: 1") self.assertEqual(errFD3_lines[1],"INFO:Slither.Format:Number of patches: 1")
self.assertEqual(outFD3_lines.count("Detector: solc-version"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Detector: solc-version"), 1)
self.assertEqual(outFD3_lines.count("Old string: pragma solidity >=0.4.0 <0.4.25;"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Old string: pragma solidity >=0.4.0 <0.4.25;"), 1)
self.assertEqual(outFD3_lines.count("New string: pragma solidity 0.4.25;"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:New string: pragma solidity 0.4.25;"), 1)
self.assertEqual(outFD3_lines.count("Location start: 63"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location start: 63"), 1)
self.assertEqual(outFD3_lines.count("Location end: 95"), 1) self.assertEqual(errFD3_lines.count("INFO:Slither.Format:Location end: 95"), 1)
outFD3.close() errFD3.close()
outFD4 = open(self.testFilePath4+".out","r") errFD4 = open(self.testFilePath4+".err","r")
outFD4_lines = outFD4.readlines() errFD4_lines = errFD4.readlines()
for i in range(len(outFD4_lines)): for i in range(len(errFD4_lines)):
outFD4_lines[i] = outFD4_lines[i].strip() errFD4_lines[i] = errFD4_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath4+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath4+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD4_lines[0],"Number of Slither results: 1") self.assertEqual(errFD4_lines[0],"INFO:Slither.Format:Number of Slither results: 1")
self.assertEqual(outFD4_lines[1],"Number of patches: 1") self.assertEqual(errFD4_lines[1],"INFO:Slither.Format:Number of patches: 1")
self.assertEqual(outFD4_lines.count("Detector: solc-version"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Detector: solc-version"), 1)
self.assertEqual(outFD4_lines.count("Old string: pragma solidity ^0.5.1;"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Old string: pragma solidity ^0.5.1;"), 1)
self.assertEqual(outFD4_lines.count("New string: pragma solidity 0.5.3;"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:New string: pragma solidity 0.5.3;"), 1)
self.assertEqual(outFD4_lines.count("Location start: 63"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location start: 63"), 1)
self.assertEqual(outFD4_lines.count("Location end: 86"), 1) self.assertEqual(errFD4_lines.count("INFO:Slither.Format:Location end: 86"), 1)
outFD4.close() errFD4.close()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -19,19 +19,19 @@ class TestUnusedStateVars(unittest.TestCase):
p.wait() p.wait()
def test_unused_state_vars(self): def test_unused_state_vars(self):
outFD = open(self.testFilePath+".out","r") errFD = open(self.testFilePath+".err","r")
outFD_lines = outFD.readlines() errFD_lines = errFD.readlines()
for i in range(len(outFD_lines)): for i in range(len(errFD_lines)):
outFD_lines[i] = outFD_lines[i].strip() errFD_lines[i] = errFD_lines[i].strip()
self.assertTrue(os.path.isfile(self.testFilePath+".format"),"Patched .format file is not created?!") self.assertTrue(os.path.isfile(self.testFilePath+".format"),"Patched .format file is not created?!")
self.assertEqual(outFD_lines[0].rstrip(),"Number of Slither results: 1") self.assertEqual(errFD_lines[0].rstrip(),"INFO:Slither.Format:Number of Slither results: 1")
self.assertEqual(outFD_lines[1].rstrip(),"Number of patches: 1") self.assertEqual(errFD_lines[1].rstrip(),"INFO:Slither.Format:Number of patches: 1")
self.assertEqual(outFD_lines.count("Detector: unused-state"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Detector: unused-state"), 1)
self.assertEqual(outFD_lines.count("Old string: address unused ;"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Old string: address unused ;"), 1)
self.assertEqual(outFD_lines.count("New string:"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:New string:"), 1)
self.assertEqual(outFD_lines.count("Location start: 44"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location start: 44"), 1)
self.assertEqual(outFD_lines.count("Location end: 63"), 1) self.assertEqual(errFD_lines.count("INFO:Slither.Format:Location end: 63"), 1)
outFD.close() errFD.close()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

Loading…
Cancel
Save