|
1 | 1 | """ |
2 | 2 | Test auto library linking functionality |
3 | 3 | """ |
| 4 | + |
4 | 5 | import json |
5 | 6 | import os |
6 | | -from pathlib import Path |
7 | 7 | import shutil |
| 8 | +from pathlib import Path |
8 | 9 |
|
9 | 10 | from crytic_compile.crytic_compile import CryticCompile |
10 | 11 | from crytic_compile.utils.libraries import get_deployment_order |
@@ -40,12 +41,12 @@ def test_deployment_order(): |
40 | 41 | deployment_order, libraries_needed = get_deployment_order(dependencies, target_contracts) |
41 | 42 |
|
42 | 43 | # Check that deployment order only contains libraries, not target contracts |
43 | | - assert ( |
44 | | - "TestComplexDependencies" not in deployment_order |
45 | | - ), "Target contracts should not be in deployment order" |
46 | | - assert ( |
47 | | - "SimpleMathContract" not in deployment_order |
48 | | - ), "Target contracts should not be in deployment order" |
| 44 | + assert "TestComplexDependencies" not in deployment_order, ( |
| 45 | + "Target contracts should not be in deployment order" |
| 46 | + ) |
| 47 | + assert "SimpleMathContract" not in deployment_order, ( |
| 48 | + "Target contracts should not be in deployment order" |
| 49 | + ) |
49 | 50 |
|
50 | 51 | # MathLib should come first (no dependencies) |
51 | 52 | assert deployment_order.index("MathLib") < deployment_order.index("AdvancedMath") |
@@ -80,9 +81,9 @@ def test_no_autolink_without_flag(): |
80 | 81 | cc = CryticCompile(Path(TEST_DIR / "library_dependency_test.sol").as_posix()) |
81 | 82 |
|
82 | 83 | # Check that autolink did not generate library addresses |
83 | | - assert ( |
84 | | - cc.libraries is None or len(cc.libraries) == 0 |
85 | | - ), "Autolink should not generate library addresses without flag" |
| 84 | + assert cc.libraries is None or len(cc.libraries) == 0, ( |
| 85 | + "Autolink should not generate library addresses without flag" |
| 86 | + ) |
86 | 87 |
|
87 | 88 | # Export and check that no autolink file is created |
88 | 89 | export_files = cc.export(export_format="solc", export_dir="test_no_autolink_output") |
@@ -128,15 +129,15 @@ def test_autolink_functionality(): |
128 | 129 |
|
129 | 130 | assert autolink_file is not None, "Autolink file should be created" |
130 | 131 |
|
131 | | - with open(autolink_file, "r", encoding="utf8") as f: |
| 132 | + with open(autolink_file, encoding="utf8") as f: |
132 | 133 | autolink_data = json.load(f) |
133 | 134 |
|
134 | 135 | # Check autolink file structure |
135 | 136 | assert "deployment_order" in autolink_data, "Autolink file should contain deployment_order" |
136 | 137 | assert "library_addresses" in autolink_data, "Autolink file should contain library_addresses" |
137 | | - assert ( |
138 | | - len(autolink_data["library_addresses"]) > 0 |
139 | | - ), "Should have library addresses in autolink file" |
| 138 | + assert len(autolink_data["library_addresses"]) > 0, ( |
| 139 | + "Should have library addresses in autolink file" |
| 140 | + ) |
140 | 141 |
|
141 | 142 | # Check deployment order contains expected contracts |
142 | 143 | deployment_order = autolink_data["deployment_order"] |
|
0 commit comments