mirror of https://github.com/ConsenSys/mythril
blockchainethereumsmart-contractssoliditysecurityprogram-analysissecurity-analysissymbolic-execution
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
3 years ago
|
import pytest
|
||
|
|
||
|
from mythril.ethereum.util import extract_version
|
||
|
|
||
|
|
||
|
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.4.0 <0.6.0;
|
||
|
contract SimpleStorage {
|
||
|
uint storedData;
|
||
|
function set(uint x) public {
|
||
|
storedData = x;
|
||
|
}
|
||
|
function get() public view returns (uint) {
|
||
|
return storedData;
|
||
|
}
|
||
|
}""",
|
||
|
[f"0.4.{x}" for x in range(11, 27)] + [f"0.5.{x}" for x in range(0, 18)],
|
||
|
),
|
||
|
(
|
||
|
"""
|
||
|
pragma solidity >=0.4.0 <0.6.0
|
||
|
;contract SimpleStorage {
|
||
|
uint storedData;
|
||
|
function set(uint x) public {
|
||
|
storedData = x;
|
||
|
}
|
||
|
function get() public view returns (uint) {
|
||
|
return storedData;
|
||
|
}
|
||
|
}""",
|
||
|
[f"0.4.{x}" for x in range(11, 27)] + [f"0.5.{x}" for x in range(0, 18)],
|
||
|
),
|
||
|
(
|
||
|
"""
|
||
|
pragma solidity >=0.4.0 <0.6.0
|
||
|
;contract SimpleStorage {
|
||
|
uint storedData;
|
||
|
function set(uint x) public {
|
||
|
storedData = x;
|
||
|
}
|
||
|
function get() public view returns (uint) {
|
||
|
return storedData;
|
||
|
}
|
||
|
}""",
|
||
|
[f"0.4.{x}" for x in range(11, 27)] + [f"0.5.{x}" for x in range(0, 18)],
|
||
|
),
|
||
|
)
|
||
|
|
||
|
|
||
|
@pytest.mark.parametrize("input_,output", test_data)
|
||
|
def test_sar(input_, output):
|
||
|
assert extract_version(input_) in output
|