pull/2281/head
Simone 9 months ago
parent a8cb6bed86
commit 591c4c0953
  1. 23
      tests/e2e/solc_parsing/test_ast_parsing.py
  2. BIN
      tests/e2e/solc_parsing/test_data/compile/solidity-0.8.24.sol-0.8.24-compact.zip
  3. 6
      tests/e2e/solc_parsing/test_data/expected/solidity-0.8.24.sol-0.8.24-compact.json
  4. 26
      tests/e2e/solc_parsing/test_data/solidity-0.8.24.sol

@ -21,12 +21,18 @@ TEST_ROOT = os.path.join(E2E_ROOT, "solc_parsing", "test_data")
# pylint: disable=too-few-public-methods
class Test:
def __init__(self, test_file: str, solc_versions: List[str], disable_legacy: bool = False):
def __init__(
self,
test_file: str,
solc_versions: List[str],
disable_legacy: bool = False,
solc_args: str = None,
):
self.solc_versions = solc_versions
self.test_file = test_file
self.disable_legacy = disable_legacy
versions_with_flavors: List[Tuple[str, str]] = []
versions_with_flavors: List[Tuple[str, str, str]] = []
flavors = ["compact"]
if not self.disable_legacy:
flavors += ["legacy"]
@ -42,7 +48,7 @@ class Test:
) < parse_version("0.4.12")
if legacy_unavailable or compact_unavailable:
continue
versions_with_flavors.append((version, flavor))
versions_with_flavors.append((version, flavor, solc_args))
self.versions_with_flavors = versions_with_flavors
@ -462,6 +468,7 @@ ALL_TESTS = [
Test("aliasing/main.sol", ["0.8.19"]),
Test("type-aliases.sol", ["0.8.19"]),
Test("enum-max-min.sol", ["0.8.19"]),
Test("solidity-0.8.24.sol", ["0.8.24"], solc_args="--evm-version cancun"),
]
# create the output folder if needed
try:
@ -473,7 +480,7 @@ except OSError:
def pytest_generate_tests(metafunc):
test_cases = []
for test_item in ALL_TESTS:
for version, flavor in test_item.versions_with_flavors:
for version, flavor, _ in test_item.versions_with_flavors:
test_cases.append((test_item.test_file, version, flavor))
metafunc.parametrize("test_file, version, flavor", test_cases)
@ -537,7 +544,7 @@ def _generate_test(test_item: Test, skip_existing=False):
flavors = ["compact"]
if not test_item.disable_legacy:
flavors += ["legacy"]
for version, flavor in test_item.versions_with_flavors:
for version, flavor, _ in test_item.versions_with_flavors:
test_file = os.path.join(
TEST_ROOT, "compile", f"{test_item.test_file}-{version}-{flavor}.zip"
)
@ -582,7 +589,7 @@ def set_solc(version: str):
def _generate_compile(test_item: Test, skip_existing=False):
for version, flavor in test_item.versions_with_flavors:
for version, flavor, solc_args in test_item.versions_with_flavors:
test_file = os.path.join(TEST_ROOT, test_item.test_file)
expected_file = os.path.join(
TEST_ROOT, "compile", f"{test_item.test_file}-{version}-{flavor}.zip"
@ -594,7 +601,9 @@ def _generate_compile(test_item: Test, skip_existing=False):
set_solc(version)
print(f"Compiled to {expected_file}")
cc = CryticCompile(test_file, solc_force_legacy_json=flavor == "legacy")
cc = CryticCompile(
test_file, solc_force_legacy_json=flavor == "legacy", solc_args=solc_args
)
# pylint: disable=no-member
Path(expected_file).parents[0].mkdir(parents=True, exist_ok=True)

@ -0,0 +1,6 @@
{
"A": {
"a()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->12;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n1->2;\n2[label=\"Node Type: NEW VARIABLE 2\n\"];\n2->3;\n3[label=\"Node Type: INLINE ASM 3\n\"];\n3->4;\n4[label=\"Node Type: NEW VARIABLE 4\n\"];\n4->5;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n5->6;\n6[label=\"Node Type: NEW VARIABLE 6\n\"];\n6->7;\n7[label=\"Node Type: EXPRESSION 7\n\"];\n7->8;\n8[label=\"Node Type: NEW VARIABLE 8\n\"];\n8->9;\n9[label=\"Node Type: EXPRESSION 9\n\"];\n9->10;\n10[label=\"Node Type: EXPRESSION 10\n\"];\n10->11;\n11[label=\"Node Type: END INLINE ASM 11\n\"];\n12[label=\"Node Type: EXPRESSION 12\n\"];\n12->1;\n}\n",
"NonReentrant()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: INLINE ASM 1\n\"];\n1->2;\n2[label=\"Node Type: IF 2\n\"];\n2->4[label=\"True\"];\n2->3[label=\"False\"];\n3[label=\"Node Type: END_IF 3\n\"];\n3->5;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->3;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n5->6;\n6[label=\"Node Type: END INLINE ASM 6\n\"];\n6->7;\n7[label=\"Node Type: _ 7\n\"];\n7->8;\n8[label=\"Node Type: INLINE ASM 8\n\"];\n8->9;\n9[label=\"Node Type: EXPRESSION 9\n\"];\n9->10;\n10[label=\"Node Type: END INLINE ASM 10\n\"];\n}\n"
}
}

@ -0,0 +1,26 @@
contract A {
modifier NonReentrant {
assembly {
if tload(0) { revert(0, 0) }
tstore(0, 1)
}
_;
assembly {
tstore(0, 0)
}
}
function a() NonReentrant public {
bytes32 _blobhash = blobhash(2);
uint _blobbasefee = block.blobbasefee;
assembly {
let __blobbasefee := blobbasefee()
let _basefee := basefee()
let __blobhash := blobhash(3)
mcopy(0, 0x40, 0x20)
}
}
}
Loading…
Cancel
Save