Fixes optimizer issue (#1597)

* Init config dir

* Fix solc optimizer
pull/1608/head
Nikhil Parasaram 3 years ago committed by GitHub
parent 8f1b8cdc3b
commit c88a5eda57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      mythril/ethereum/util.py
  2. 10
      tests/integration_tests/test_solc_settings.py
  3. 55
      tests/testdata/json_test_dir/dir_a/input_file.sol
  4. 4
      tests/testdata/json_test_dir/test_file_disable.json

@ -47,9 +47,11 @@ def get_solc_json(file, solc_binary="solc", solc_settings_json=None):
if solc_settings_json:
with open(solc_settings_json) as f:
settings = json.load(f)
if "optimizer" not in settings:
settings.update({"optimizer": {"enabled": False}})
settings.update(
{
"optimizer": {"enabled": False},
"outputSelection": {
"*": {
"": ["ast"],

@ -18,6 +18,16 @@ def test_positive_solc_settings():
assert "The analysis was completed successfully" in output
def test_neg_optimizer_solc_settings():
file_dir = str(TESTDATA / "json_test_dir" / "dir_a")
json_file_path = str(TESTDATA / "json_test_dir" / "test_file_disable.json")
file_path = file_dir + "/input_file.sol"
command = f"cd {file_dir} && python3 {MYTH} analyze {file_path} --solc-json {json_file_path} --solv 0.8.0"
output = check_output(command, shell=True, stderr=STDOUT).decode("UTF-8")
assert "Stack too deep when compiling inline assembly" in output
def test_negative_solc_settings():
file_path = str(TESTDATA / "json_test_dir" / "dir_a" / "input_file.sol")

@ -1,7 +1,60 @@
import "@openzeppelin/contracts/token/PRC20/PRC20.sol";
contract Nothing is PRC20{
function nothing() public pure{
string x_0 = "";
bytes3 x_1 = "A";
bytes5 x_2 = "E";
bytes5 x_3 = "";
bytes3 x_4 = "I";
bytes3 x_5 = "U";
bytes3 x_6 = "O";
bytes3 x_7 = "0";
bytes3 x_8 = "U";
bytes3 x_9 = "U";
function stringCompare(string memory a, string memory b) internal pure returns (bool) {
if(bytes(a).length != bytes(b).length) {
return false;
} else {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
function nothing(string memory g_0, bytes3 g_1, bytes5 g_2, bytes5 g_3, bytes3 g_4, bytes3 g_5, bytes3 g_6, bytes3 g_7, bytes3 g_8, bytes3 g_9, bytes3 g_10, bytes3 g_11) public view returns (bool){
if (!stringCompare(g_0, x_0)) return false;
if (g_1 != x_1) return false;
if (g_2 != x_2) return false;
if (g_3 != x_3) return false;
if (g_4 != x_4) return false;
if (g_5 != x_5) return false;
if (g_6 != x_6) return false;
if (g_7 != x_7) return false;
if (g_8 != x_8) return false;
if (g_9 != x_9) return false;
if (g_10 != x_9) return false;
if (g_11 != x_9) return false;
return true;
}
}

@ -0,0 +1,4 @@
{
"remappings": [ "@openzeppelin/contracts/token/PRC20/=../" ]
}
Loading…
Cancel
Save