Skip to content

Commit 1b37969

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

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
@@ -207,9 +207,27 @@ def run(scenario_file: str, debug: bool, additional_args: tuple[str]):
207207
# Create in-memory buffer to store python archive instead of writing to disk
208208
archive_buffer = io.BytesIO()
209209

210+
# No need to copy the entire scenarios/ directory into the archive
211+
def filter(path):
212+
if any(
213+
needle in str(path) for needle in [
214+
".pyc",
215+
".csv",
216+
".DS_Store"
217+
]
218+
):
219+
return False
220+
return any(
221+
needle in str(path) for needle in [
222+
"commander.py",
223+
"test_framework",
224+
scenario_name
225+
]
226+
)
227+
210228
# Compile python archive
211229
zipapp.create_archive(
212-
source=scenario_dir, target=archive_buffer, main=f"{scenario_name}:main", compressed=True
230+
source=scenario_dir, target=archive_buffer, main=f"{scenario_name}:main", compressed=True, filter=filter
213231
)
214232

215233
# 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)