From a94f373c4b638d4635895c8cd38945a15534df7f Mon Sep 17 00:00:00 2001 From: hladu357 Date: Sat, 8 Jun 2024 18:22:26 +0200 Subject: [PATCH] test generator fix --- tests/test-trie.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test-trie.py b/tests/test-trie.py index c52470d..590d256 100644 --- a/tests/test-trie.py +++ b/tests/test-trie.py @@ -14,6 +14,7 @@ def generate_random_test_cases(rules, n): rule_network = rule[0] rule_next_hop = rule[1] + network = rule_network for _ in range(n): next_hop = rule_next_hop address = rule_network.network_address + random.randint(0, rule_network.num_addresses - 1) @@ -23,9 +24,10 @@ def generate_random_test_cases(rules, n): continue oth_network = oth_rule[0] oth_next_hop = oth_rule[1] - if address in oth_network and oth_network.subnet_of( rule_network ): + if address in oth_network and oth_network.subnet_of( network ): print(f"address {address} is closer to {oth_network} {rule_next_hop} than {rule_network} {oth_next_hop}") next_hop = oth_next_hop + network = oth_network f.write(f"{address} {next_hop}\n") print(f"Generated test case: {address} {next_hop}") print("tests for rule ", rule_network, " with next hop ", rule_next_hop, " generated")