forked from ConsenSysDiligence/mythril
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_tests.py
65 lines (60 loc) · 1.92 KB
/
util_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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.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.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