From 8fbe2e2748ea3ada8f4b0a94d9321e8418656704 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Fri, 11 Mar 2022 14:28:01 +0000 Subject: [PATCH] Fix NPM code block issue (#1602) * Init config dir * Fix solc optimizer * Fix NPM code block issue * Extend tests --- mythril/ethereum/util.py | 2 +- tests/util_tests.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mythril/ethereum/util.py b/mythril/ethereum/util.py index 08d6927f..51907b89 100644 --- a/mythril/ethereum/util.py +++ b/mythril/ethereum/util.py @@ -141,7 +141,7 @@ def extract_version(file: str) -> Optional[str]: for line in file.split("\n"): if "pragma solidity" not in line: continue - version_line = line + version_line = line.rstrip() break if version_line is None: return None diff --git a/tests/util_tests.py b/tests/util_tests.py index 6fa5a1d9..6928c8f7 100644 --- a/tests/util_tests.py +++ b/tests/util_tests.py @@ -7,8 +7,17 @@ test_data = ( ("pragma solidity 0.5.0\n", ["0.5.0"]), ("pragma solidity ^0.4.26\n", ["0.4.26"]), ("pragma solidity ^0.6.3;\n", [f"0.6.{x}" for x in range(3, 13)]), + ("pragma solidity ^0.6.3 ;\n", [f"0.6.{x}" for x in range(3, 13)]), ( - """pragma solidity >=0.4.0 <0.6.0; + "pragma solidity ^0.6.3; \n", + [f"0.6.{x}" for x in range(3, 13)], + ), + ( + "pragma solidity ^0.6.3 ; \n", + [f"0.6.{x}" for x in range(3, 13)], + ), + ( + """pragma solidity >=0.4.0 <0.6.0 ; contract SimpleStorage { uint storedData; function set(uint x) public {