test(batch27): port wave-a cross-module jetstream tests

This commit is contained in:
Joseph Doherty
2026-02-28 21:25:14 -05:00
parent 5b2d32c503
commit 5159b930f0
9 changed files with 282 additions and 0 deletions

View File

@@ -445,6 +445,68 @@ public sealed class AccountTests
exporter.CheckServiceExportApproved(importer, "foo", null).ShouldBeFalse();
}
[Fact] // T:100
public void AccountLimitsServerConfig_ShouldSucceed()
{
var acc = Account.NewAccount("A");
acc.MaxConnections = 1;
var c1 = new ClientConnection(ClientKind.Client) { Cid = 1001 };
c1.RegisterWithAccount(acc);
Should.Throw<TooManyAccountConnectionsException>(() =>
new ClientConnection(ClientKind.Client) { Cid = 1002 }.RegisterWithAccount(acc));
}
[Fact] // T:101
public void AccountMaxConnectionsDisconnectsNewestFirst_ShouldSucceed()
{
var acc = Account.NewAccount("A");
acc.MaxConnections = 2;
var c1 = new ClientConnection(ClientKind.Client) { Cid = 1011 };
var c2 = new ClientConnection(ClientKind.Client) { Cid = 1012 };
c1.RegisterWithAccount(acc);
c2.RegisterWithAccount(acc);
var toDisconnect = acc.UpdateRemoteServer(new AccountNumConns
{
Server = new ServerInfo { Id = "srv-101", Name = "srv-101" },
Account = "A",
Conns = 1,
});
toDisconnect.Count.ShouldBe(1);
toDisconnect[0].Cid.ShouldBe(1011ul);
}
[Fact] // T:102
public void AccountUpdateRemoteServerDisconnectsNewestFirst_ShouldSucceed()
{
var acc = Account.NewAccount("A");
acc.MaxConnections = 2;
new ClientConnection(ClientKind.Client) { Cid = 1021 }.RegisterWithAccount(acc);
new ClientConnection(ClientKind.Client) { Cid = 1022 }.RegisterWithAccount(acc);
var first = acc.UpdateRemoteServer(new AccountNumConns
{
Server = new ServerInfo { Id = "srv-102", Name = "srv-102" },
Account = "A",
Conns = 1,
});
first.Count.ShouldBe(1);
first[0].Cid.ShouldBe(1021ul);
var second = acc.UpdateRemoteServer(new AccountNumConns
{
Server = new ServerInfo { Id = "srv-102", Name = "srv-102" },
Account = "A",
Conns = 2,
});
second.Count.ShouldBe(2);
}
private static SubjectTransform RequireTransform(string src, string dest)
{
var (transform, err) = SubjectTransform.New(src, dest);