Handle CRLF line endings (#1637)

* Handle CRLF line endings

* Add new line at the end of file
pull/1639/head
Nikhil Parasaram 3 years ago committed by GitHub
parent c65340a328
commit ca0edd6208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      mythril/solidity/soliditycontract.py
  2. 16
      tests/integration_tests/test_src_mapping.py
  3. 10
      tests/testdata/input_contracts/destruct_crlf.sol

@ -164,10 +164,12 @@ class SolidityContract(EVMContract):
full_contract_src_maps = SolidityContract.get_full_contract_src_maps(
source["ast"]
)
with open(source["ast"]["absolutePath"]) as f:
with open(source["ast"]["absolutePath"], "rb") as f:
code = f.read()
indices[source["id"]] = SolidityFile(
source["ast"]["absolutePath"], code, full_contract_src_maps
source["ast"]["absolutePath"],
code.decode("utf-8"),
full_contract_src_maps,
)
return indices

@ -0,0 +1,16 @@
import pytest
import json
import sys
from subprocess import check_output, STDOUT
from tests import PROJECT_DIR, TESTDATA
MYTH = str(PROJECT_DIR / "myth")
def test_positive_solc_settings():
file_path = str(TESTDATA / "input_contracts" / "destruct_crlf.sol")
command = f"python3 {MYTH} analyze {file_path} --solv 0.5.0"
output = check_output(command, shell=True, stderr=STDOUT).decode("UTF-8")
assert "selfdestruct(addr)" in output

@ -0,0 +1,10 @@
pragma solidity ^0.5.0;
contract Suicide {
function kill(address payable addr) public {
selfdestruct(addr);
}
}
Loading…
Cancel
Save