diff --git a/utils/slither_format/format_pragma.py b/utils/slither_format/format_pragma.py index f3f06a667..193b64fe6 100644 --- a/utils/slither_format/format_pragma.py +++ b/utils/slither_format/format_pragma.py @@ -17,10 +17,10 @@ class FormatPragma: def format(slither, patches, elements): versions_used = [] for element in elements: - versions_used.append(element['expression']) + versions_used.append(''.join(element['directive'][1:])) solc_version_replace = FormatPragma.analyse_versions(versions_used) for element in elements: - FormatPragma.create_patch(slither, patches, element['source_mapping']['filename'], solc_version_replace, element['source_mapping']['start'], element['source_mapping']['start'] + element['source_mapping']['length']) + FormatPragma.create_patch(slither, patches, element['source_mapping']['filename_absolute'], solc_version_replace, element['source_mapping']['start'], element['source_mapping']['start'] + element['source_mapping']['length']) @staticmethod def analyse_versions(used_solc_versions): diff --git a/utils/slither_format/tests/test_pragma.py b/utils/slither_format/tests/test_pragma.py index 38818124e..1d1e7c1c3 100644 --- a/utils/slither_format/tests/test_pragma.py +++ b/utils/slither_format/tests/test_pragma.py @@ -50,8 +50,6 @@ class TestPragma(unittest.TestCase): self.assertEqual(outFD1_lines.count("New string: pragma solidity 0.4.25;"), 2) self.assertEqual(outFD1_lines.count("Location start: 0"), 2) self.assertEqual(outFD1_lines.count("Location end: 24"), 2) - self.assertEqual(outFD1_lines.count("Patch file: ./slither_format/tests/test_data/pragma.0.4.24.sol"), 1) - self.assertEqual(outFD1_lines.count("Patch file: ./slither_format/tests/test_data/pragma.0.4.23.sol"), 1) outFD1.close() outFD2 = open(self.testFilePath2+".out","r") @@ -67,8 +65,6 @@ class TestPragma(unittest.TestCase): self.assertEqual(outFD2_lines.count("New string: pragma solidity 0.5.3;"), 2) self.assertEqual(outFD2_lines.count("Location start: 0"), 2) self.assertEqual(outFD2_lines.count("Location end: 23"), 2) - self.assertEqual(outFD2_lines.count("Patch file: ./slither_format/tests/test_data/pragma.0.5.4.sol"), 1) - self.assertEqual(outFD2_lines.count("Patch file: ./slither_format/tests/test_data/pragma.0.5.2.sol"), 1) outFD2.close() if __name__ == '__main__':