mirror of
https://github.com/2dust/v2rayN.git
synced 2026-09-22 22:38:10 +03:00
`FmtHandlerTests` round-tripped VMess, VLESS, Shadowsocks and SOCKS. `FmtHandler.GetShareUri` dispatches ten protocols, so Trojan, Hysteria2, TUIC, Anytls, WireGuard and Naive were exported and re-imported untested, and `WireguardFmt` was covered in the `Resolve` direction only. Each new test exports a profile, imports the result and asserts the fields that protocol carries in its URI: the flow for Trojan, the uuid/password pair and the congestion control for TUIC, the obfuscation password and the port range for Hysteria2, the peer keys, reserved bytes, interface address and MTU for WireGuard, and the credentials plus the insecure concurrency for Naive. `ShareUriSuite_ShouldCoverAndRoundTripEveryExportableProtocol` compares the profile-factory map against `Global.ProtocolShares` and round-trips every entry, so a newly exportable protocol cannot be added without a case here. Three things a round trip alone cannot prove are asserted on the wire form instead. The allow-insecure flag is spelled per protocol since #9888 - `allowInsecure` and `insecure` for Trojan, `allow_insecure` for TUIC, `insecure` for Anytls and Hysteria2 - so an exporter and an importer that agreed on the wrong name would otherwise round-trip cleanly. The WireGuard test pins the percent-encoding of the base64 keys and the brackets around the IPv6 literal. Hysteria2 keeps `CertSha` unset on purpose: the importer turns `AllowInsecure` on by itself when a `pinSHA256` is present, which would mask an exporter that stopped emitting `insecure=1`. Fixtures are deterministic and no longer plain ASCII: a fixed uuid for TUIC, real 32-byte base64 keys and an IPv6 address for WireGuard, and reserved and non-Latin characters in passwords and remarks. `ExportThenImport` derives the expected scheme, because `NaiveFmt` emits `naive+https://` or `naive+quic://` and never the `naive://` prefix that `Global.ProtocolShares` records for that type - that entry is only read when importing.