using Shouldly; using ZB.MOM.NatsNet.Server; namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog; public sealed partial class LeafNodeHandlerTests { [Fact] // T:1984 public void LeafNodeCompressionAuto_ShouldSucceed() { var options = new ServerOptions(); var errors = new List(); var warnings = new List(); var parseError = ServerOptions.ParseLeafNodes( new Dictionary { ["remotes"] = new List { new Dictionary { ["url"] = "nats://127.0.0.1:7422", ["compression"] = new Dictionary { ["mode"] = CompressionModes.S2Auto, ["rtt_thresholds"] = new List { "10ms", "20ms", "30ms" }, }, }, }, }, options, errors, warnings); parseError.ShouldBeNull(); errors.ShouldBeEmpty(); options.LeafNode.Remotes.Count.ShouldBe(1); options.LeafNode.Remotes[0].Compression.Mode.ShouldBe(CompressionModes.S2Auto); options.LeafNode.Remotes[0].Compression.RttThresholds.Count.ShouldBe(3); options.LeafNode.Remotes[0].Compression.RttThresholds[0].ShouldBe(TimeSpan.FromMilliseconds(10)); options.LeafNode.Remotes[0].Compression.RttThresholds[1].ShouldBe(TimeSpan.FromMilliseconds(20)); options.LeafNode.Remotes[0].Compression.RttThresholds[2].ShouldBe(TimeSpan.FromMilliseconds(30)); } [Fact] // T:2001 public void LeafNodeConnectionSucceedsEvenWithDelayedFirstINFO_ShouldSucceed() { var errors = new List(); var warnings = new List(); var remotes = ServerOptions.ParseRemoteLeafNodes( new List { new Dictionary { ["url"] = "nats://127.0.0.1:7422", ["first_info_timeout"] = "3s", }, new Dictionary { ["url"] = "ws://127.0.0.1:7423", ["first_info_timeout"] = "3s", }, }, errors, warnings); errors.ShouldBeEmpty(); remotes.Count.ShouldBe(2); remotes[0].FirstInfoTimeout.ShouldBe(TimeSpan.FromSeconds(3)); remotes[1].FirstInfoTimeout.ShouldBe(TimeSpan.FromSeconds(3)); remotes[1].Urls[0].Scheme.ShouldBe("ws"); } }