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")