Skip to content

Commit 7df8fb6

Browse files
committed
test: move test scenarios to resources/scenarios
also filter out unused files from the archive sent to the commander
1 parent 1b92b8e commit 7df8fb6

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

test/data/scenario_buggy_failure.py renamed to resources/scenarios/test_buggy_failure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ def run_test(self):
2020
raise Exception("Failed execution!")
2121

2222

23-
if __name__ == "__main__":
23+
def main():
2424
Failure().main()

test/data/scenario_connect_dag.py renamed to resources/scenarios/test_connect_dag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,5 @@ def assert_connection(self, connector, connectee_index, connection_type: Connect
117117
raise ValueError("ConnectionType must be of type DNS or IP")
118118

119119

120-
if __name__ == "__main__":
120+
def main():
121121
ConnectDag().main()

test/data/scenario_p2p_interface.py renamed to resources/scenarios/test_p2p_interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ def run_test(self):
5252
p2p_block_store.wait_until(lambda: p2p_block_store.blocks[best_block] == 1)
5353

5454

55-
if __name__ == "__main__":
55+
def main():
5656
GetdataTest().main()

src/warnet/control.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,27 @@ def run(scenario_file: str, additional_args: tuple[str]):
198198
# Create in-memory buffer to store python archive instead of writing to disk
199199
archive_buffer = io.BytesIO()
200200

201+
# No need to copy the entire scenarios/ directory into the archive
202+
def filter(path):
203+
if any(
204+
needle in str(path) for needle in [
205+
".pyc",
206+
".csv",
207+
".DS_Store"
208+
]
209+
):
210+
return False
211+
return any(
212+
needle in str(path) for needle in [
213+
"commander.py",
214+
"test_framework",
215+
scenario_name
216+
]
217+
)
218+
201219
# Compile python archive
202220
zipapp.create_archive(
203-
source=scenario_dir, target=archive_buffer, main=f"{scenario_name}:main", compressed=True
221+
source=scenario_dir, target=archive_buffer, main=f"{scenario_name}:main", compressed=True, filter=filter
204222
)
205223

206224
# Encode the binary data as Base64

test/dag_connection_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def setup_network(self):
2626

2727
def run_connect_dag_scenario(self):
2828
self.log.info("Running connect_dag scenario")
29-
self.warnet("run test/data/scenario_connect_dag.py")
29+
self.warnet("run resources/scenarios/test_connect_dag.py")
3030
self.wait_for_all_scenarios()
3131

3232

test/scenarios_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def run_and_check_miner_scenario_from_file(self):
8282
self.stop_scenario()
8383

8484
def run_and_check_scenario_from_file(self):
85-
scenario_file = "test/data/scenario_p2p_interface.py"
85+
scenario_file = "resources/scenarios/test_p2p_interface.py"
8686
self.log.info(f"Running scenario from: {scenario_file}")
8787
self.warnet(f"run {scenario_file}")
8888
self.wait_for_predicate(self.check_scenario_clean_exit)
@@ -94,7 +94,7 @@ def check_regtest_recon(self):
9494
self.wait_for_predicate(self.check_scenario_clean_exit)
9595

9696
def check_active_count(self):
97-
scenario_file = "test/data/scenario_buggy_failure.py"
97+
scenario_file = "resources/scenarios/test_buggy_failure.py"
9898
self.log.info(f"Running scenario from: {scenario_file}")
9999
self.warnet(f"run {scenario_file}")
100100

0 commit comments

Comments
 (0)