test(batch19): port accounts core mapped tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Shouldly;
|
||||
using ZB.MOM.NatsNet.Server;
|
||||
using ZB.MOM.NatsNet.Server.Internal;
|
||||
|
||||
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||
|
||||
@@ -71,4 +72,54 @@ public sealed partial class LeafNodeHandlerTests
|
||||
remotes[1].FirstInfoTimeout.ShouldBe(TimeSpan.FromSeconds(3));
|
||||
remotes[1].Urls[0].Scheme.ShouldBe("ws");
|
||||
}
|
||||
|
||||
[Fact] // T:1935
|
||||
public void LeafNodeNoDuplicateWithinCluster_ShouldSucceed()
|
||||
{
|
||||
var account = Account.NewAccount("$G");
|
||||
var leaf1 = new ClientConnection(ClientKind.Leaf);
|
||||
var leaf2 = new ClientConnection(ClientKind.Leaf);
|
||||
|
||||
((INatsAccount)account).AddClient(leaf1);
|
||||
((INatsAccount)account).AddClient(leaf2);
|
||||
|
||||
account.RegisterLeafNodeCluster("xyz");
|
||||
account.RegisterLeafNodeCluster("xyz");
|
||||
|
||||
account.NumLocalLeafNodes().ShouldBe(2);
|
||||
account.HasLeafNodeCluster("xyz").ShouldBeTrue();
|
||||
account.IsLeafNodeClusterIsolated("xyz").ShouldBeTrue();
|
||||
|
||||
account.RegisterLeafNodeCluster("abc");
|
||||
account.IsLeafNodeClusterIsolated("xyz").ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact] // T:1952
|
||||
public void LeafNodeStreamImport_ShouldSucceed()
|
||||
{
|
||||
var exporter = Account.NewAccount("B");
|
||||
var importer = Account.NewAccount("C");
|
||||
|
||||
exporter.AddStreamExport(">", null).ShouldBeNull();
|
||||
importer.AddStreamImport(exporter, ">", string.Empty).ShouldBeNull();
|
||||
|
||||
importer.Imports.Streams.ShouldNotBeNull();
|
||||
importer.Imports.Streams!.Count.ShouldBe(1);
|
||||
importer.Imports.Streams[0].From.ShouldBe(">");
|
||||
importer.Imports.Streams[0].To.ShouldBe(">");
|
||||
exporter.CheckStreamExportApproved(importer, "a", null).ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact] // T:1955
|
||||
public void LeafNodeUnsubOnRouteDisconnect_ShouldSucceed()
|
||||
{
|
||||
var account = Account.NewAccount("$G");
|
||||
var leaf = new ClientConnection(ClientKind.Leaf);
|
||||
|
||||
((INatsAccount)account).AddClient(leaf);
|
||||
account.NumLocalLeafNodes().ShouldBe(1);
|
||||
|
||||
((INatsAccount)account).RemoveClient(leaf);
|
||||
account.NumLocalLeafNodes().ShouldBe(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user