diff --git a/tests/stream_netns/nat_scenario.py b/tests/stream_netns/nat_scenario.py index 54470b2bc..20b12d39b 100644 --- a/tests/stream_netns/nat_scenario.py +++ b/tests/stream_netns/nat_scenario.py @@ -46,6 +46,10 @@ def check_profiles(scenario): # Отсутствие второго наблюдателя не превращается в STRICT/DIRECT. first, second = public[:2] connect(first, second) + accepted = profile(agents[second.name].rpc("stats"), transport) + if (accepted["mapping"], accepted["inbound"], accepted["source"]) != ("UNCHANGED", "OPEN", "ETCP"): + raise RuntimeError(f"NAT accepted public {transport} connection did not confirm DIRECT/OPEN: {accepted}") + print(f"NAT accepted public {transport}: {second.name} DIRECT/OPEN without helper", flush=True) if not scenario.args.tcp_only: incomplete = measure(first, second, "udp") if (incomplete["mapping"], incomplete["inbound"], incomplete["reason"]) != ("UNKNOWN", "UNKNOWN", "no_helper"): @@ -116,7 +120,8 @@ def check_profiles(scenario): profile(statistics[owner.name], "tcp")["source"] == "ETCP" and bool(profile(statistics[owner.name], "tcp")["external"]), 10) actual = profile(data[owner.name], "tcp") - expected = ("UNKNOWN" if owner.nat else "UNCHANGED", "UNKNOWN") + # second принимает первый TCP от first; остальные проверяемые сокеты здесь исходящие. + expected = ("UNKNOWN" if owner.nat else "UNCHANGED", "OPEN" if owner.name == second.name else "UNKNOWN") ip = next(item for item in NATS if item.name == owner.nat).ip if owner.nat else owner.ip if (actual["mapping"], actual["inbound"], actual["external"]) != (*expected, f"{ip}:0"): raise RuntimeError(f"{owner.name}/tcp: expected {expected}, IP={ip}:0, detector returned {actual}") @@ -136,7 +141,8 @@ def check_profiles(scenario): if again["inbound"] == "UNKNOWN" and again["reason"] != "contact_history": raise RuntimeError(f"{first.name}: UNKNOWN without contact-history explanation: {again}") - result = {"nodes_checked": len(verified), "protocols": protocols, "no_helper_checked": not scenario.args.tcp_only, + result = {"nodes_checked": len(verified), "protocols": protocols, "accepted_connection_checked": True, + "no_helper_checked": not scenario.args.tcp_only, "warm_recheck_checked": bool(first_profile), "verified": verified} (scenario.network.directory / "nat-result.json").write_text(json.dumps(result, indent=2) + "\n") return result