Snapshot for release 2026.10.20.1 (internal 7116fab)

This commit is contained in:
Tom Bohar 2026-10-20 21:28:18 -04:00
commit bfcd48950d
215 changed files with 16200 additions and 2838 deletions

View file

@ -0,0 +1,119 @@
using System;
using System.IO;
using System.Linq;
using RynthCore.Engine.UI.Sections;
using RynthCore.Plugin.RynthAelrynth;
using RynthCore.Plugin.ServerPack;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// RynthAelrynth's own features (Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth), moved out of
// RynthOracle on 2026-10-20: the /top and /trial reply parser (RynthOracle.Tests' old
// AelrynthReplies), the own-reply hiding, the setting taken over from rynthoracle.json and its page.
internal static class AelrynthTests
{
public static void Register(Runner r)
{
r.Add("aelrynth: the replies of /top, /top me and /trial parse", Replies);
r.Add("aelrynth: replies to RynthAelrynth's own requests are hidden, typed ones show", HideOwnReplies);
r.Add("aelrynth: RynthOracle's reply-hiding choice is taken over once", Migration);
r.Add("aelrynth: its Leaderboards page is an Aelrynth-only view of the Server section", Pages);
}
private static void Replies()
{
var a = new AelrynthBoards();
long now = 2_000_000;
a.RequestTop("", now);
Check.True(a.OnChatLine("Leaderboards - 37 characters, refreshed 4 min ago. /top <board> for the top ten, /top me for yourself.", now, out bool ours) && ours, "overview header");
a.OnChatLine(" kills Creature kills: Buffy, 1,234,567", now, out _);
a.OnChatLine(" pk PK kills: nobody yet", now, out _);
Check.True(a.Overview.Count == 2 && a.Overview[0].Key == "kills" && a.Overview[0].Leader == "Buffy" && a.Overview[0].Value == "1,234,567"
&& a.Overview[1].Leader == "nobody yet", "overview rows");
a.RequestTop("kills", now);
a.OnChatLine("Creature kills - top 10 of 37:", now, out _);
a.OnChatLine(" 1. Buffy 1,234,567 <- you", now, out _);
a.OnChatLine(" 2. Dargoth 987,654", now, out _);
a.OnChatLine(" 3. Sal 500 12 kills per death", now, out _);
Check.True(a.BoardTitle == "Creature kills" && a.BoardRows.Count == 3 && a.BoardRows[0].IsYou && a.BoardRows[1].Value == "987,654"
&& a.BoardRows[2].Extra == "12 kills per death", "board rows: " + string.Join(" | ", a.BoardRows.Select(r => $"{r.Rank} {r.Name} {r.Value} [{r.Extra}] {r.IsYou}")));
a.RequestTop("me", now);
a.OnChatLine("Buffy on the boards:", now, out _);
a.OnChatLine(" Creature kills #1 of 37, 1,234,567", now, out _);
a.OnChatLine(" PK kills -", now, out _);
Check.True(a.Standings.Count == 2 && a.Standings[0].Rank == 1 && a.Standings[1].Rank == 0, "/top me");
Check.False(a.OnChatLine(" 9. Nobody 12", now + 30_000, out _), "an entry long after its header is ignored");
a.RequestTrial("", now);
a.OnChatLine("Trials - a fresh personal copy of a listed dungeon, entered through its portal, is a timed course: ...", now, out _);
a.OnChatLine(" The Citadel Below - Trial (02F0): tier 0 12:34 by Buffy | you: tier 0 12:34 | this week: Buffy 12:34 (tier 0)", now, out _);
a.OnChatLine(" your next attempt here: in 12 min", now, out _);
a.OnChatLine("Trophy: the week's fastest clear of each dungeon, any tier - a trophy and 1,000 experience, Sunday 20:00 (2026-W40). /trial <name> for the top 10 of one dungeon.", now, out _);
Check.True(a.Trials.Count == 1 && a.Trials[0].Landblock == "02F0" && a.TrialLines.Count == 3, $"/trial overview ({a.Trials.Count} dungeons, {a.TrialLines.Count} lines)");
a.RequestTrial("citadel", now);
a.OnChatLine("The Citadel Below - Trial (02F0) - top 10, best per character, any tier:", now, out _);
a.OnChatLine(" 1. 12:34 Buffy (tier 0, 105 kills, 3 Oct)", now, out _);
a.OnChatLine(" you: tier 0 12:34 (105 kills)", now, out _);
Check.True(a.TrialRows.Count == 1 && a.TrialRows[0].Name == "Buffy" && a.TrialRows[0].Value == "12:34" && a.TrialNotes.Count == 1, "/trial dungeon top 10");
Check.False(a.OnChatLine("Bob tells you, \"hello\"", now, out _), "ordinary chat is never taken");
}
private static void HideOwnReplies()
{
var f = new AelrynthFeature();
long now = 3_000_000;
f.Boards.RequestTop("", now);
Check.True(f.OnChatLine("Leaderboards - 3 characters, refreshed just now. /top <board> ...", 0, now), "a reply to RynthAelrynth's /top is hidden");
Check.True(f.OnChatLine(" kills Creature kills: Buffy, 12", 0, now), "and its rows");
Check.False(f.OnChatLine("Leaderboards - 3 characters, refreshed just now. /top <board> ...", 0, now + 60_000), "a typed /top's reply shows");
Check.False(f.OnChatLine(" kills Creature kills: Ann, 14", 0, now + 60_000), "and its rows");
Check.True(f.Boards.Overview.Count == 1 && f.Boards.Overview[0].Leader == "Ann", "read either way");
f.HideOwnReplies = false;
f.Boards.RequestTrial("", now);
Check.False(f.OnChatLine("Trials - a fresh personal copy of a listed dungeon ...", 0, now), "with hiding off, own replies show too");
Check.False(f.OnChatLine("Bob says, \"hi\"", 0, now), "ordinary chat shows");
f.Reset();
Check.True(f.Boards.Overview.Count == 0 && f.Boards.Trials.Count == 0, "login/logout clears the boards");
}
private static void Migration()
{
string dir = ServerPackHooksTests.TempDir();
try
{
string oracle = Path.Combine(dir, "rynthoracle.json"), mine = Path.Combine(dir, "rynthaelrynth.json");
File.WriteAllText(oracle, "{ \"hideOwnQuestReplies\": false }");
var s = new ServerPackSettings(mine);
s.Load();
Check.True(AelrynthFeature.Migrate(s, oracle), "taken over the first time");
var f = new AelrynthFeature();
f.LoadSettings(s);
Check.False(f.HideOwnReplies, "the player's choice (shown) came over");
Check.False(AelrynthFeature.Migrate(s, oracle), "never twice");
var fresh = new ServerPackSettings(Path.Combine(dir, "fresh.json"));
fresh.Load();
AelrynthFeature.Migrate(fresh, Path.Combine(dir, "none.json"));
var g = new AelrynthFeature();
g.LoadSettings(fresh);
Check.True(g.HideOwnReplies, "default: hidden");
}
finally { try { Directory.Delete(dir, true); } catch { } }
}
private static void Pages()
{
var pages = ServerPackPages.Validate(AelrynthFeature.PageList.Select(p => new ServerPage(p.Id, p.Label, p.Tooltip, () => { })));
Check.Eq(pages.Count, 1, "one page");
ServerPackInfo info = new("aelrynth", "Aelrynth", new[] { "aelrynth.com" }, new[] { "Aelrynth*", "Aeshnidae*" });
SectionManifest m = SectionManifestParser.Parse("RynthAelrynth", ServerPackModel.BuildSectionsJson(info, "RynthAelrynth", pages), out string error);
Check.Eq(error, "", "RynthCore parses the manifest");
SectionContribution view = m.Contributions.Single(c => c.Primary);
Check.True(view.Server == "aelrynth" && view.Label == "Leaderboards" && view.Surface == "section:server-aelrynth.boards",
"Leaderboards, only while Aelrynth is active");
}
}

View file

@ -0,0 +1,216 @@
using System;
using System.IO;
using System.Linq;
using RynthCore.Engine.UI.Sections;
using RynthCore.Plugin.RynthConquest;
using RynthCore.Plugin.RynthOracle.Data;
using RynthCore.Plugin.ServerPack;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// RynthConquest's own features (Plugins\RynthCore.Plugin.RynthConquest\Conquest), moved out of
// RynthOracle on 2026-10-20: the reply parser (RynthOracle.Tests' old ConquestReplies), the
// own-reply hiding, the login /augs, the auto-deposit, the settings taken over from rynthoracle.json,
// the Void DoT rule it publishes, the custom quest list and its pages.
internal static class ConquestTests
{
public static void Register(Runner r)
{
r.Add("conquest: the replies of /b, /augs, /enl augs, /bonus, /fship list and /top parse", Replies);
r.Add("conquest: replies to RynthConquest's own requests are hidden, typed ones show", HideOwnReplies);
r.Add("conquest: /augs once after login, then never again", LoginAugs);
r.Add("conquest: the auto-deposit is off unless turned on, then once per ten-minute mark", AutoDeposit);
r.Add("conquest: RynthOracle's settings are taken over once (defaults kept without them)", Migration);
r.Add("conquest: the Void DoT rule for RynthOracle's timers", VoidRule);
r.Add("conquest: the custom quest worklist and its status", CustomQuests);
r.Add("conquest: its pages are Conquest-only views of the Server section", Pages);
}
private static void Replies()
{
var d = new ConquestData();
long now = 1_000_000;
d.RequestBank(now);
Check.True(d.OnChatLine("[BANK] Your balances:", now, out bool ours) && ours, "bank heading (ours)");
d.OnChatLine("[BANK] Pyreals: 1,039,678,533", now, out _);
d.OnChatLine("[BANK] Event Tokens [Dragon Coins] (x): 12", now, out _);
Check.True(d.Bank.Any(b => b.Name == "Pyreals" && b.Value.Contains("4,158 MMDs")), "pyreals with MMDs");
Check.True(d.Bank.Any(b => b.Name == "Dragon Coins (x)"), "event token name");
Check.False(d.OnChatLine("Bob says, \"[BANK] Pyreals: 999\"", now, out _), "a pasted balance is ignored");
d.OnChatLine("[BANK] Pyreals: 5", now + 60_000, out bool late);
Check.False(late, "a reply long after the request isn't ours (shows in chat)");
d.RequestAugs(now);
d.OnChatLine("Creature: 25", now, out _);
d.OnChatLine("Duration: 3", now, out _);
ConquestAug creature = d.Augs.First(a => a.Name == "Creature");
Check.True(creature.Count == 25 && creature.NextLuminanceCost() == 6_229_500, $"Creature 25 next costs 6,229,500 ({creature.NextLuminanceCost()})");
Check.True(d.DurationAugs == 3 && Math.Abs(d.VoidDurationMultiplier(5) - 2.15) < 1e-9, "void duration x(1 + 5*0.2 + 3*0.05)");
d.RequestEnl(now);
d.OnChatLine("Enlightenment Augmentations:", now, out _);
d.OnChatLine("Skill Credits: 2 (10 max)", now, out _);
d.OnChatLine("Damage: 5 (25 max)", now, out _);
Check.True(d.EnlAugs.Count == 2 && d.EnlAugs[0].Name == "Damage", "enlightenment augs in display order");
d.RequestBonus(now);
d.OnChatLine("=== XP Bonuses ===", now, out _);
d.OnChatLine("Quest Bonus: 14.18% (1,418 quests)", now, out _);
d.OnChatLine("Total Bonus (Kills): 0.16%", now, out _);
Check.True(d.Bonuses.First(b => b.Name == "Quest").Value == "14.18% (1,418 quests)" && d.Bonuses.First(b => b.Name == "Total (Kills)").Value == "0.16%", "bonuses");
d.RequestFships(now);
d.OnChatLine("Fellowships looking for members:", now, out _);
d.OnChatLine("- Heroes (Leader: Bob) [3/14] @ Bur", now, out _);
d.OnChatLine("- Quiet (Leader: Ann) [1/14]", now, out _);
Check.True(d.Fellowships.Count == 2 && d.Fellowships[0].Location == "Bur" && d.Fellowships[1].MemberCount == 1, "fellowship list");
ConquestBoard lvl = d.Boards.First(b => b.Key == "level");
d.RequestBoard(lvl, now);
d.OnChatLine("Top 2 Players by Level:", now, out _);
d.OnChatLine("1: 300 - Alpha", now, out _);
d.OnChatLine("2: 299 - Beta", now, out _);
d.OnChatLine("57: 250 - Me (You)", now, out _);
Check.True(lvl.Rows.Count == 2 && lvl.You != null && lvl.You.Rank == 57 && lvl.You.Name == "Me", "Conquest /top board");
Check.Eq(ConquestData.WithdrawCommand(ConquestData.Withdrawable[ConquestData.DefaultWithdraw], "10"), "/bank withdraw n 10", "withdraw MMDs");
Check.Null(ConquestData.WithdrawCommand(ConquestData.Withdrawable[0], "-3"), "withdraw refuses a bad amount");
Check.Eq(ConquestData.TransferCommand(ConquestData.Transferable[2], "4", "Some One"), "/bank transfer p 1000000 \"Some One\"", "transfer MMD notes as pyreals");
Check.Null(ConquestData.TransferCommand(ConquestData.Transferable[2], "1001", "X"), "transfer cap");
}
private static void HideOwnReplies()
{
var f = new ConquestFeature();
f.Login(0);
long now = 100_000;
f.Data.RequestBank(now);
Check.True(f.OnChatLine("[BANK] Pyreals: 1,000", now), "a reply to RynthConquest's /b is hidden");
Check.False(f.OnChatLine("[BANK] Pyreals: 1,000", now + 60_000), "the same reply long after (typed /b) shows");
Check.False(f.OnChatLine("Bob says, \"hello\"", now), "ordinary chat shows");
f.HideOwnReplies = false;
f.Data.RequestBank(now);
Check.False(f.OnChatLine("[BANK] Pyreals: 1,000", now), "with hiding off, own replies show too");
f.HideOwnReplies = true;
// /myquests: only RynthConquest's own request's reply is hidden; the flags are read either way.
Check.True(f.Flags.Request(_ => true, now), "own /myquests sent");
Check.True(f.OnChatLine("assaultonaimaru - 1 solves (1719432000)\"x\" -1 0", now), "its reply is hidden");
f.Flags.Tick(now + 2000);
Check.True(f.Flags.TryGet("assaultonaimaru", out _), "and read");
Check.False(f.OnChatLine("ghostdencompleted - 1 solves (1719432000)\"x\" -1 0", now + 3000), "a reply nobody here asked for shows");
Check.True(f.Data.AutoDeposit(now).Length > 0 && f.OnChatLine("Deposited 12 items.", now), "the auto-deposit's reply is hidden");
}
private static void LoginAugs()
{
var f = new ConquestFeature();
f.Login(1000);
Check.Null(f.LoginAugsDue(1000 + ConquestFeature.AugsReadDelayMs), "not before the delay");
Check.Eq(f.LoginAugsDue(1001 + ConquestFeature.AugsReadDelayMs), "/augs", "/augs after it");
Check.Null(f.LoginAugsDue(5_000_000), "only once");
f.Login(9_000_000);
Check.Eq(f.LoginAugsDue(9_000_001 + ConquestFeature.AugsReadDelayMs), "/augs", "again for the next login");
}
private static void AutoDeposit()
{
var f = new ConquestFeature();
f.Login(0);
var at = new DateTime(2026, 10, 20, 14, 0, 5, DateTimeKind.Local);
Check.False(f.AutoDeposit, "off by default (as it was in RynthOracle)");
Check.Null(f.AutoDepositDue(at, 0), "off: no deposit at :00");
f.AutoDeposit = true;
Check.Eq(f.AutoDepositDue(at, 0), "/bank deposit", "on: /bank deposit at :00");
Check.Null(f.AutoDepositDue(at.AddSeconds(30), 0), "once per mark");
Check.Null(f.AutoDepositDue(at.AddMinutes(5), 0), "not at :05");
Check.Eq(f.AutoDepositDue(at.AddMinutes(10), 0), "/bank deposit", "again at :10");
long block = -1;
Check.True(ConquestFeature.DepositDue(new DateTime(2026, 1, 1, 0, 20, 0), ref block), "the schedule: :20");
Check.False(ConquestFeature.DepositDue(new DateTime(2026, 1, 1, 0, 21, 0), ref block), "the schedule: not :21");
}
private static void Migration()
{
string dir = ServerPackHooksTests.TempDir();
try
{
string oracle = Path.Combine(dir, "rynthoracle.json"), mine = Path.Combine(dir, "rynthconquest.json");
File.WriteAllText(oracle, "{ \"hideOwnQuestReplies\": false, \"conquestAutoDeposit\": true, \"tabName\": \"Conquest\" }");
var s = new ServerPackSettings(mine);
s.Load();
Check.True(ConquestFeature.Migrate(s, oracle), "taken over the first time");
var f = new ConquestFeature();
f.LoadSettings(s);
Check.True(f.AutoDeposit, "auto-deposit came over (on)");
Check.False(f.HideOwnReplies, "hiding came over (off)");
// Turned off here later: a newer rynthoracle.json never turns it back on.
f.AutoDeposit = false;
f.SaveSettings(s);
var again = new ServerPackSettings(mine);
again.Load();
Check.False(ConquestFeature.Migrate(again, oracle), "never taken over twice");
var g = new ConquestFeature();
g.LoadSettings(again);
Check.False(g.AutoDeposit, "the player's choice here stands");
// A new player (no RynthOracle settings): the defaults.
string fresh = Path.Combine(dir, "fresh.json");
var n = new ServerPackSettings(fresh);
n.Load();
Check.True(ConquestFeature.Migrate(n, Path.Combine(dir, "missing.json")), "runs (nothing to take)");
var h = new ConquestFeature();
h.LoadSettings(n);
Check.True(!h.AutoDeposit && h.HideOwnReplies, "defaults: auto-deposit off, own replies hidden");
Check.True(new ServerPackSettings(fresh) is var reread && Reload(reread) && reread.GetBool(ConquestFeature.MigrationMarker, false),
"the marker is saved");
}
finally { try { Directory.Delete(dir, true); } catch { } }
}
private static bool Reload(ServerPackSettings s) { s.Load(); return true; }
private static void VoidRule()
{
var f = new ConquestFeature();
f.Login(0);
Check.Eq(f.VoidScale, 1.0, "no augs, no Archmage's Endurance: x1");
f.ArchmagesEndurance = 5;
f.Data.RequestAugs(0);
f.Data.OnChatLine("Duration: 3", 0, out _);
Check.Near(f.VoidScale, 2.15, 1e-9, "x(1 + 5*0.2 + 3*0.05)");
Check.Eq(ConquestFeature.VoidScaleKey, "voidDotDurationScale", "the profile value RynthOracle reads");
}
private static void CustomQuests()
{
Check.Eq(CustomQuestList.All.Count, 6, "six custom quests (customquests.csv, embedded)");
Check.True(CustomQuestList.All.All(q => q.Server == "Conquest" && q.Flag.Length > 0 && q.Flag == q.Flag.ToLowerInvariant()), "Conquest rows, flags in lower case");
var flags = new QuestFlagStore();
CustomQuest darsh = CustomQuestList.All.First(q => q.Flag == "assaultonaimaru");
DateTime now = DateTime.UtcNow;
Check.False(darsh.IsComplete(flags, now), "not done without the flag");
Check.Eq(darsh.Status(flags, now), "ready", "ready without the flag");
long done = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - 60;
flags.OnChatLine($"assaultonaimaru - 1 solves ({done})\"x\" -1 3600", 0);
flags.Tick(5000);
Check.True(darsh.IsComplete(flags, now), "a repeatable on cooldown counts as done");
Check.True(darsh.Status(flags, now) is not ("ready" or "completed") && darsh.Status(flags, now).Contains('m'), "its status is the time left: " + darsh.Status(flags, now));
}
private static void Pages()
{
var pages = ServerPackPages.Validate(ConquestFeature.PageList.Select(p => new ServerPage(p.Id, p.Label, p.Tooltip, () => { })));
Check.Eq(pages.Count, ConquestFeature.PageList.Length, "every page is valid");
Check.True(pages.Select(p => p.Label).SequenceEqual(new[] { "Conquest", "Leaderboards" }), "the Conquest and Leaderboards pages");
ServerPackInfo info = new("conquest", "Conquest", new[] { "acconquest.ddns.net" }, new[] { "Conquest", "ConquestAC" });
SectionManifest m = SectionManifestParser.Parse("RynthConquest", ServerPackModel.BuildSectionsJson(info, "RynthConquest", pages), out string error);
Check.Eq(error, "", "RynthCore parses the manifest");
SectionContribution[] views = m.Contributions.Where(c => c.Primary).ToArray();
Check.Eq(views.Length, 2, "two pages in the Mini Remote");
Check.True(views.All(c => c.Server == "conquest"), "shown only while Conquest is active");
Check.True(views.Select(c => c.Surface).SequenceEqual(new[] { "section:server-conquest.main", "section:server-conquest.boards" }), "their surfaces");
}
}

View file

@ -13,6 +13,10 @@ internal static class Program
var runner = new Runner();
ServerPackModelTests.Register(runner);
ServerProjectsTests.Register(runner);
ServerPackHooksTests.Register(runner);
ConquestTests.Register(runner);
AelrynthTests.Register(runner);
VaultTests.Register(runner);
return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null);
}
}

View file

@ -23,6 +23,26 @@
<ItemGroup>
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackInfo.cs" Link="Plugin\ServerPackInfo.cs" />
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackModel.cs" Link="Plugin\ServerPackModel.cs" />
<!-- The hooks for a server's own features: pages, the settings file, the own-reply window. -->
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackPages.cs" Link="Plugin\ServerPackPages.cs" />
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackSettings.cs" Link="Plugin\ServerPackSettings.cs" />
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerChatRequest.cs" Link="Plugin\ServerChatRequest.cs" />
<!-- RynthConquest's own features (pure parts) and the RynthOracle sources it links. -->
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthConquest\Conquest\ConquestData.cs" Link="Conquest\ConquestData.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthConquest\Conquest\ConquestFeature.cs" Link="Conquest\ConquestFeature.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthConquest\Conquest\CustomQuests.cs" Link="Conquest\CustomQuests.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Data\QuestFlags.cs" Link="Oracle\QuestFlags.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Data\TimeText.cs" Link="Oracle\TimeText.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Data\Csv.cs" Link="Oracle\Csv.cs" />
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthConquest\Resources\customquests.csv" LogicalName="RynthConquest.customquests.csv" />
<!-- RynthAelrynth's own features (pure parts). -->
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthBoards.cs" Link="Aelrynth\AelrynthBoards.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthFeature.cs" Link="Aelrynth\AelrynthFeature.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\VaultFeed.cs" Link="Aelrynth\VaultFeed.cs" />
<Compile Include="..\..\Plugins\Shared\ChatSource.cs" Link="Shared\ChatSource.cs" />
<Compile Include="..\..\Plugins\Shared\StorageFeed.cs" Link="Shared\StorageFeed.cs" />
<!-- RynthCore's own sections-manifest parser (pure), so the manifest is checked the way the engine reads it. -->
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\Sections\SectionManifest.cs" Link="Engine\SectionManifest.cs" />
<!-- "RynthServer.Profile": the profile JSON, and the shared reader's parser that consumes it. -->
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackProfile.cs" Link="Plugin\ServerPackProfile.cs" />
<Compile Include="..\..\Plugins\Shared\EngineServerState.cs" Link="Shared\EngineServerState.cs" />

View file

@ -0,0 +1,210 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using RynthCore.Engine.UI.Sections;
using RynthCore.Plugin.ServerPack;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// The shared hooks a server plugin's own features use (2026-10-20, when RynthOracle's and
// RynthInventory's Conquest and Aelrynth features moved into RynthConquest and RynthAelrynth):
// pages beside the server card, the plugin's own settings file (with a one-time migration), live
// numbers in the "RynthServer.Profile" JSON, and the own-reply window.
internal static class ServerPackHooksTests
{
public static void Register(Runner r)
{
r.Add("hooks: page ids, surfaces and the surface a page is drawn under", PageNames);
r.Add("hooks: bad, duplicate and surplus pages are left out", PageValidation);
r.Add("hooks: pages are server-only primary views of the Server section, accepted by RynthCore's parser", PagesInManifest);
r.Add("hooks: settings round-trip and keep values the plugin doesn't know", SettingsRoundTrip);
r.Add("hooks: settings migration runs once, and a broken file means defaults", SettingsMigration);
r.Add("hooks: profile values are published, validated and read back", ProfileValues);
r.Add("hooks: the own-reply window opens, stretches and closes", ReplyWindow);
}
internal static string TempDir()
{
string dir = Path.Combine(Path.GetTempPath(), "RynthServerPack.Tests", Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(dir);
return dir;
}
private static void PageNames()
{
Check.True(ServerPackPages.IsValidId("bank") && ServerPackPages.IsValidId("top-10"), "plain ids");
Check.False(ServerPackPages.IsValidId("") || ServerPackPages.IsValidId("Bank") || ServerPackPages.IsValidId("a.b")
|| ServerPackPages.IsValidId(new string('a', 17)), "empty, capitals, dots and long ids are refused");
Check.Eq(ServerPackPages.SurfaceFor("conquest", "bank"), "section:server-conquest.bank", "surface");
Check.Eq(ServerPackPages.PageIdOf("section:server-conquest.bank", "conquest"), "bank", "page from its surface");
Check.Eq(ServerPackPages.PageIdOf("section:server-conquest.bank:popout", "conquest"), "bank", "popped out");
Check.Null(ServerPackPages.PageIdOf("section:server-conquest", "conquest"), "the card is not a page");
Check.Null(ServerPackPages.PageIdOf("section:server-aelrynth.top", "conquest"), "another server's page");
Check.Null(ServerPackPages.PageIdOf("section:server-conquest.Bad!", "conquest"), "a malformed page id");
Check.Null(ServerPackPages.PageIdOf(null, "conquest"), "null");
string longest = ServerPackPages.SurfaceFor(new string('a', 32), new string('b', ServerPackPages.MaxIdLength));
Check.True(longest.Length <= SectionManifestParser.MaxSurfaceLength, "the longest surface fits RynthCore's cap: " + longest.Length);
}
private static void PageValidation()
{
Action draw = () => { };
var notes = new List<string>();
var pages = new List<ServerPage>
{
new("one", "One", "", draw), new("one", "Again", "", draw), new("Two", "Two", "", draw),
new("three", " ", "", draw), new("four", "Four", "tip", null!),
};
for (int i = 0; i < 8; i++) pages.Add(new ServerPage("p" + i, "Page " + i, "", draw));
List<ServerPage> kept = ServerPackPages.Validate(pages, notes.Add);
Check.Eq(kept.Count, ServerPackPages.MaxPages, "capped");
Check.Eq(kept[0].Id, "one", "first kept");
Check.Eq(kept.Count(p => p.Id == "one"), 1, "a duplicate id is dropped");
Check.False(kept.Any(p => p.Id is "Two" or "three" or "four"), "bad id, no label, nothing to draw");
Check.True(notes.Count == pages.Count - kept.Count, "every dropped page is reported: " + string.Join(" | ", notes));
Check.Eq(ServerPackPages.Validate(null).Count, 0, "no pages");
string label = new string('x', 60);
Check.Eq(ServerPackPages.Validate(new[] { new ServerPage("x", label, "", draw) })[0].Label.Length, ServerPackPages.MaxLabelLength, "label capped");
}
private static void PagesInManifest()
{
ServerPackInfo info = new("conquest", "Conquest", new[] { "acconquest.ddns.net" }, new[] { "Conquest" });
var pages = ServerPackPages.Validate(new[]
{
new ServerPage("main", "Conquest", "Bank, augs and more", () => { }),
new ServerPage("boards", "Leaderboards", "", () => { }),
});
string json = ServerPackModel.BuildSectionsJson(info, "RynthConquest", pages);
SectionManifest m = SectionManifestParser.Parse("RynthConquest", json, out string error);
Check.Eq(error, "", "RynthCore parses it");
Check.Eq(m.Contributions.Length, 3, "the card and two pages");
SectionContribution card = m.Contributions.Single(c => !c.Primary);
Check.Eq(card.Surface, "section:server-conquest", "the card keeps its surface");
SectionContribution[] views = m.Contributions.Where(c => c.Primary).ToArray();
Check.True(views.All(c => c.Section == ServerPackModel.SectionId && c.Server == "conquest" && c.IsSurface),
"pages: primary views of the Server section, only on Conquest");
Check.Eq(views[0].Surface, "section:server-conquest.main", "page surface");
Check.Eq(views[0].Label, "Conquest", "page label");
Check.Eq(views[0].Tooltip, "Bank, augs and more", "page tooltip");
Check.Eq(views[1].Tooltip, "Leaderboards (RynthConquest)", "a default tooltip");
Check.True(views[0].Order < views[1].Order, "pages keep their order");
Check.True(views[0].Width > 0 && views[0].Height > 0, "pages say their size");
// Without pages the manifest is byte for byte what it was.
Check.Eq(ServerPackModel.BuildSectionsJson(info, "RynthConquest", null), ServerPackModel.BuildSectionsJson(info, "RynthConquest"),
"no pages: the old manifest");
Check.Eq(SectionManifestParser.Parse("x", ServerPackModel.BuildSectionsJson(info, "RynthConquest"), out _).Contributions.Length, 1,
"no pages: only the card");
}
private static void SettingsRoundTrip()
{
string dir = TempDir();
try
{
string path = Path.Combine(dir, "rynthtest.json");
File.WriteAllText(path, "{ \"future\": {\"a\":[1,2]}, \"flag\": false, \"name\": \"x\" }");
var s = new ServerPackSettings(path);
s.Load();
Check.Eq(s.LastError, "", "read");
Check.False(s.GetBool("flag", true), "a stored false");
Check.True(s.GetBool("missing", true), "a missing value falls back");
Check.True(s.GetBool("name", true), "a value of another type falls back");
Check.Eq(s.GetString("name", "?"), "x", "text");
Check.True(s.SetBool("flag", true), "a change says so");
Check.False(s.SetBool("flag", true), "the same value is no change");
s.SetString("quote", "a \"b\" \\ c");
Check.True(s.Save(), "saved");
var again = new ServerPackSettings(path);
again.Load();
Check.True(again.GetBool("flag", false), "the change was kept");
Check.Eq(again.GetString("quote", ""), "a \"b\" \\ c", "text escaped and read back");
using JsonDocument doc = JsonDocument.Parse(File.ReadAllText(path));
Check.Eq(doc.RootElement.GetProperty("future").GetProperty("a").GetArrayLength(), 2, "an unknown value is written back as it was");
Check.False(File.Exists(path + ".tmp"), "no temporary file left");
Check.True(ServerPackSettings.DefaultPath("RynthConquest").EndsWith(Path.Combine("RynthCore", "rynthconquest.json"), StringComparison.Ordinal),
"%APPDATA%\\RynthCore\\<plugin>.json");
}
finally { try { Directory.Delete(dir, true); } catch { } }
}
private static void SettingsMigration()
{
string dir = TempDir();
try
{
string old = Path.Combine(dir, "old.json"), mine = Path.Combine(dir, "mine.json");
File.WriteAllText(old, "{ \"moved\": true, \"text\": \"t\" }");
Check.Eq(ServerPackSettings.ReadBoolFrom(old, "moved"), (bool?)true, "the old home's value");
Check.Null(ServerPackSettings.ReadBoolFrom(old, "text"), "not a true/false value");
Check.Null(ServerPackSettings.ReadBoolFrom(old, "absent"), "missing value");
Check.Null(ServerPackSettings.ReadBoolFrom(Path.Combine(dir, "nope.json"), "moved"), "missing file");
var s = new ServerPackSettings(mine);
s.Load();
int runs = 0;
Action<ServerPackSettings> migrate = t => { runs++; if (ServerPackSettings.ReadBoolFrom(old, "moved") is bool b) t.SetBool("moved", b); };
Check.True(s.MigrateOnce("migratedFromOld", migrate), "runs the first time");
Check.True(s.GetBool("moved", false), "imported");
File.WriteAllText(old, "{ \"moved\": false }");
var later = new ServerPackSettings(mine);
later.Load();
Check.False(later.MigrateOnce("migratedFromOld", migrate), "never again (the marker was saved)");
Check.True(later.GetBool("moved", false), "later changes to the old home don't come over");
Check.Eq(runs, 1, "ran once");
File.WriteAllText(mine, "{ not json");
var broken = new ServerPackSettings(mine);
broken.Load();
Check.True(broken.LastError.Length > 0 && broken.GetBool("moved", true), "a broken file reads as defaults");
}
finally { try { Directory.Delete(dir, true); } catch { } }
}
private static void ProfileValues()
{
var v = new ServerProfileValues();
int r0 = v.Revision;
Check.True(v.Set("voidDotDurationScale", 1.35), "set");
Check.True(v.Revision > r0, "a change bumps the revision");
int r1 = v.Revision;
Check.True(v.Set("voidDotDurationScale", 1.35) && v.Revision == r1, "the same value is no change");
Check.False(v.Set("bad key", 1) || v.Set("", 1) || v.Set("x", double.NaN) || v.Set("y", double.PositiveInfinity), "bad keys and numbers");
ServerPackInfo info = new("conquest", "Conquest", new[] { "h" }, new[] { "Conquest" });
string json = ServerPackProfile.BuildJson(info, "RynthConquest", "0.2.0", true, "Conquest", v.Snapshot(out int rev));
Check.Eq(rev, v.Revision, "the snapshot's revision");
Check.Near(RynthCore.Plugin.Shared.ServerProfileView.Value(json, "voidDotDurationScale", 1), 1.35, 1e-12, "a reader gets the value");
Check.Eq(RynthCore.Plugin.Shared.ServerProfileView.Value(json, "other", 7), 7.0, "a missing value falls back");
Check.Eq(RynthCore.Plugin.Shared.ServerProfileView.Value("", "voidDotDurationScale", 1), 1.0, "no profile falls back");
Check.Eq(RynthCore.Plugin.Shared.ServerProfileView.Value("{\"values\":{\"k\":\"2\"}}", "k", 1), 1.0, "text is not a number");
Check.Eq(RynthCore.Plugin.Shared.ServerProfileView.Value("{broken", "k", 3), 3.0, "broken JSON falls back");
using (JsonDocument doc = JsonDocument.Parse(ServerPackProfile.BuildJson(info, "RynthConquest", "0.2.0", true, "Conquest")))
Check.Eq(doc.RootElement.GetProperty("values").EnumerateObject().Count(), 0, "no values: an empty object");
Check.True(v.Remove("voidDotDurationScale") && !v.Remove("voidDotDurationScale"), "remove");
v.Set("a", 1);
int r2 = v.Revision;
v.Clear();
Check.True(v.Revision > r2 && v.Snapshot(out _).Length == 0, "clear (logout)");
}
private static void ReplyWindow()
{
var req = new ServerChatRequest();
Check.False(req.Awaiting(0), "nothing asked");
req.Sent(1000);
Check.True(req.Awaiting(1000 + ServerChatRequest.WindowMs - 1), "inside the window");
Check.False(req.Awaiting(1000 + ServerChatRequest.WindowMs), "the window closes");
req.Sent(1000);
req.Extend(5500);
Check.True(req.Awaiting(7000), "a reply line stretches it");
req.Clear();
Check.False(req.Awaiting(1001), "cleared");
}
}

View file

@ -19,6 +19,36 @@ internal static class ServerProjectsTests
r.Add("server projects: ids, plugin names and hosts are unique", Unique);
r.Add("server projects: no server's host is claimed by another server's list", NoHostOverlap);
r.Add("server projects: each new server plugin has ServerData.cs and imports the shared props", Layout);
r.Add("server projects: RynthOracle and RynthInventory send no server's own commands (they live in its plugin)", SharedPluginsServerFree);
}
/// <summary>
/// Since 2026-10-20 a server's own features live in its server plugin (RynthConquest, RynthAelrynth):
/// the shared plugins' sources hold none of those servers' commands or chat markers, and use the
/// server tags only to pick a quest pack (data, RynthOracle's ServerIdentity.cs).
/// </summary>
private static void SharedPluginsServerFree()
{
string[] commands = { "\"/bank", "\"/b\"", "\"/augs", "\"/enl augs", "\"/bonus", "\"/fship list", "\"/top", "\"/trial", "\"/mule-data", "\"~ael1" };
foreach (string plugin in new[] { "RynthCore.Plugin.RynthOracle", "RynthCore.Plugin.RynthInventory" })
{
string dir = Path.Combine(PluginsDir(), plugin);
var files = Directory.GetFiles(dir, "*.cs", SearchOption.AllDirectories)
.Where(f => !f.Contains(Path.DirectorySeparatorChar + "obj" + Path.DirectorySeparatorChar)
&& !f.Contains(Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar))
.ToList();
Check.True(files.Count > 10, plugin + ": its sources were found (" + files.Count + ")");
foreach (string file in files)
{
string text = File.ReadAllText(file);
string name = plugin + "/" + Path.GetRelativePath(dir, file);
foreach (string c in commands)
Check.False(text.Contains(c, StringComparison.Ordinal), $"{name} sends no server command {c.TrimStart('"')}");
if (!file.EndsWith("ServerIdentity.cs", StringComparison.Ordinal))
Check.False(text.Contains("ServerTags.Conquest", StringComparison.Ordinal) || text.Contains("ServerTags.Aelrynth", StringComparison.Ordinal),
$"{name} has no Conquest or Aelrynth feature");
}
}
}
private sealed record Project(string Dir, string PluginName, string Id, string Name, string[] Hosts, string[] Worlds, bool Shared);

View file

@ -0,0 +1,229 @@
using System.Collections.Generic;
using RynthCore.Plugin.RynthAelrynth;
using RynthCore.Plugin.Shared;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// The Aelrynth account vault: /mule-data answers, one "~ael1" line a page (Aeshnidae.Mule MuleData.cs).
// Moved with the feed from RynthInventory.Tests on 2026-10-20: RynthAelrynth reads the vault now and
// hands it to RynthInventory through the storage feed (Plugins/Shared/StorageFeed.cs).
internal static class VaultTests
{
public static void Register(Runner r)
{
r.Add("vault: pages are asked one after the other and filed as one record", Pages);
r.Add("vault: other plugins' lines and players' imitations are left alone", Imitations);
r.Add("vault: a server without the command is asked once", Unsupported);
r.Add("vault: loading, changed and silent vaults are never filed half or empty", Retries);
r.Add("vault: RynthAelrynth asks after login, every ten minutes and on /rserver vault", Schedule);
r.Add("vault: the record reaches RynthInventory's format intact (plain ASCII)", HandOff);
}
private const string A = "{\"o\":2147483649,\"w\":100,\"n\":\"Acid Assagai\",\"i\":100667000,\"u\":100667001,\"v\":100667002,\"s\":3,\"m\":100,\"y\":1,\"e\":1}";
private const string B = "{\"o\":2147483650,\"w\":101,\"n\":\"Pyreal\",\"i\":100667003,\"y\":8192}";
private static string VaultPage(int page, int pages, int count, string items, bool ready = true, string why = "") =>
ready
? "~ael1 {\"t\":\"mule\",\"ready\":true,\"page\":" + page + ",\"pages\":" + pages + ",\"count\":" + count + ",\"max\":1000,\"items\":[" + items + "]}"
: "~ael1 {\"t\":\"mule\",\"ready\":false,\"why\":\"" + why + "\"}";
private static (VaultFeed Feed, List<string> Sent) NewVault()
{
var sent = new List<string>();
return (new VaultFeed(t => { sent.Add(t); return true; }), sent);
}
private static void Pages()
{
(VaultFeed v, List<string> sent) = NewVault();
Check.True(v.Ask(1000), "ask starts");
Check.Eq(sent.Count == 1 ? sent[0] : "?", "/mule-data", "page 1 asked first");
Check.True(v.ShouldEat(VaultPage(1, 2, 2, A)), "page 1 is eaten");
v.Tick(1100, "Tom");
Check.Eq(sent.Count == 2 ? sent[1] : "?", "/mule-data 2", "page 2 asked when page 1 came");
Check.Null(v.Record, "nothing filed before the last page");
Check.True(v.ShouldEat(VaultPage(2, 2, 2, B)), "page 2 is eaten");
v.Tick(1200, "Tom");
StorageFeedRecord? r = v.Record;
Check.True(r != null && v.TakeChanged() && !v.TakeChanged(), "filed once");
Check.Eq(r?.Items.Count ?? -1, 2, "both pages' items");
Check.Eq(r?.Id ?? 0, VaultFeed.VaultId("tom"), "id follows the account, case-blind");
Check.True(StorageFeed.IsStandInId(r?.Id ?? 0), "id is a stand-in, far from real objects");
Check.Eq(r?.Label ?? "", "Account vault", "label");
Check.Eq(r?.Name ?? "", "Aelrynth vault", "name");
StorageFeedItem a = r!.Items[0];
Check.Eq(a.Name, "Acid Assagai", "name"); Check.Eq(a.Icon, 100667000u, "icon"); Check.Eq(a.Underlay, 100667001u, "underlay");
Check.Eq(a.Overlay, 100667002u, "overlay"); Check.Eq(a.Stack, 3, "stack"); Check.Eq(a.MaxStack, 100, "max stack");
Check.Eq(a.ItemType, 1u, "item type");
Check.Eq(r.Items[1].Stack, 1, "no stack field is a stack of 1");
Check.Eq(v.Status, VaultFeed.State.Idle, "idle again");
Check.Eq(VaultFeed.VaultId("Tom"), 0xFF000000u | (FnvOf("tom") & 0x00FFFFFFu), "the id RynthInventory used before the move (no second vault)");
}
private static uint FnvOf(string s)
{
uint h = 2166136261u;
foreach (char c in s) { h ^= c; h *= 16777619u; }
return h;
}
private static void Imitations()
{
{
(VaultFeed v, _) = NewVault();
v.Ask(0);
Check.False(v.ShouldEat("~ael1 {\"t\":\"inspect\",\"ok\":true}"), "the Companion's line stays visible");
Check.False(v.ShouldEat("Welcome to Aelrynth"), "ordinary chat stays visible");
Check.False(v.ShouldEat(null), "null is fine");
}
{
(VaultFeed v, _) = NewVault();
v.Ask(0);
Check.False(v.ShouldEat("Bob says, \"" + VaultPage(1, 1, 1, A) + "\"", 2), "spoken data line is not ours");
Check.False(v.ShouldEat("Bob " + VaultPage(1, 1, 1, A), 12), "an emoted data line is not ours");
Check.False(v.ShouldEat("Bob " + VaultPage(1, 1, 1, A)), "a data line not at the start is not ours, type unknown");
Check.False(v.ShouldEat(VaultPage(1, 1, 1, A), 3), "a data line in a tell is not ours");
Check.False(v.ShouldEat("Bob tells you, \"Unknown command: mule-data\"", 3), "a told unknown-command line is not ours");
Check.False(v.ShouldEat("Unknown command: mule-data", 2), "unknown-command in speech is not ours");
Check.False(v.ShouldEat("Unknown command: mule-data-ish"), "another command's refusal is not ours");
Check.True(v.ShouldEat("Unknown command: mule-data", 15), "ACE's real reply (Help) is ours");
}
{
(VaultFeed v, _) = NewVault();
v.Ask(0);
Check.True(v.ShouldEat(" " + VaultPage(1, 1, 1, A), 0), "the server's line (Broadcast), leading space allowed");
}
{
(VaultFeed v, _) = NewVault();
Check.True(v.ShouldEat(VaultPage(1, 1, 1, A)), "a line typed by hand while we are not asking is eaten");
v.Tick(0, "tom");
Check.Null(v.Record, "but ignored when we did not ask");
}
}
private static void Unsupported()
{
{
(VaultFeed v, List<string> sent) = NewVault();
v.Ask(0);
Check.True(v.ShouldEat("Unknown command: /mule-data"), "the unknown-command reply is eaten while we wait");
v.Tick(100, "tom");
Check.Eq(v.Status, VaultFeed.State.Unsupported, "unsupported");
Check.False(v.Ask(200), "not asked again");
Check.Eq(sent.Count, 1, "one probe, no more");
Check.True(v.Ask(300, force: true), "/rserver vault asks anyway");
}
{
(VaultFeed v, _) = NewVault();
Check.False(v.ShouldEat("Unknown command: /mule-data"), "an unknown-command line we did not provoke is left alone");
}
}
private static void Retries()
{
// A vault the server is still loading is asked again, and never recorded as empty.
{
(VaultFeed v, List<string> sent) = NewVault();
v.Ask(0);
v.ShouldEat(VaultPage(1, 1, 0, "", ready: false, why: "loading"));
v.Tick(10, "tom");
Check.Eq(v.Status, VaultFeed.State.Waiting, "waiting");
v.Tick(2000, "tom");
Check.Eq(sent.Count, 1, "not before the retry delay");
v.Tick(3500, "tom");
Check.Eq(sent.Count, 2, "asked again after it");
Check.Null(v.Record, "never recorded");
for (int i = 0; i < 10; i++)
{
v.ShouldEat(VaultPage(1, 1, 0, "", ready: false, why: "loading"));
v.Tick(4000 + i * 4000, "tom");
}
Check.True(v.Status != VaultFeed.State.Asking || sent.Count < 12, "it gives up after a few tries");
Check.Null(v.Record, "still never recorded");
}
// A vault that changed between pages is read again, not filed half and half.
{
(VaultFeed v, _) = NewVault();
v.Ask(0);
v.ShouldEat(VaultPage(1, 2, 3, A));
v.Tick(10, "tom");
v.ShouldEat(VaultPage(2, 2, 3, B)); // 2 read, the server says 3
v.Tick(20, "tom");
Check.Null(v.Record, "a mismatched read is not filed");
Check.Eq(v.Status, VaultFeed.State.Waiting, "and is retried");
}
// Silence is an idle feed, not a stuck one.
{
(VaultFeed v, _) = NewVault();
v.Ask(0);
v.Tick(20_000, "tom");
Check.Eq(v.Status, VaultFeed.State.Idle, "no answer in time");
Check.True(v.Ask(21_000), "can ask again");
}
// Garbage inside a mule line does not throw.
{
(VaultFeed v, _) = NewVault();
v.Ask(0);
v.ShouldEat("~ael1 {\"t\":\"mule\",\"ready\":tru");
v.Tick(5, "tom");
Check.True(v.Record == null && v.Status == VaultFeed.State.Idle, "bad JSON drops the read");
}
}
private static void Schedule()
{
var sent = new List<string>();
var f = new AelrynthFeature { SendCommand = t => { sent.Add(t); return true; } };
f.Reset();
long login = 50_000;
Check.Null(f.VaultTick(login, "tom"), "nothing at login");
Check.Eq(sent.Count, 0, "not asked at once");
f.VaultTick(login + VaultFeed.FirstAskMs - 1, "tom");
Check.Eq(sent.Count, 0, "not before the first delay");
f.VaultTick(login + VaultFeed.FirstAskMs, "tom");
Check.Eq(sent.Count == 1 ? sent[0] : "?", "/mule-data", "asked after the first delay");
Check.True(f.OnChatLine(VaultPage(1, 1, 1, A), 0, login + VaultFeed.FirstAskMs + 10), "its reply is always hidden");
StorageFeedRecord? read = f.VaultTick(login + VaultFeed.FirstAskMs + 20, "tom");
Check.True(read != null && read.Items.Count == 1, "the finished read is handed back once");
Check.Null(f.VaultTick(login + VaultFeed.FirstAskMs + 30, "tom"), "and only once");
f.VaultTick(login + VaultFeed.FirstAskMs + VaultFeed.RefreshMs, "tom");
Check.Eq(sent.Count, 2, "read again ten minutes later");
f.OnChatLine(VaultPage(1, 1, 1, A), 0, login + VaultFeed.FirstAskMs + VaultFeed.RefreshMs + 1);
f.VaultTick(login + VaultFeed.FirstAskMs + VaultFeed.RefreshMs + 2, "tom");
Check.True(f.VaultAskNow(login + 700_000) && sent.Count == 3, "/rserver vault reads it now");
// A server without the command: one probe per login, then quiet.
var g = new AelrynthFeature { SendCommand = t => { sent.Add(t); return true; } };
g.Reset();
int before = sent.Count;
g.VaultTick(0, "tom");
g.VaultTick(VaultFeed.FirstAskMs, "tom");
g.OnChatLine("Unknown command: mule-data", 0, VaultFeed.FirstAskMs + 1);
g.VaultTick(VaultFeed.FirstAskMs + 2, "tom");
g.VaultTick(VaultFeed.FirstAskMs + 3 * VaultFeed.RefreshMs, "tom");
Check.Eq(sent.Count - before, 1, "no vault on the server: asked once, then never on a timer");
g.Reset();
Check.Eq(g.Vault.Status, VaultFeed.State.Idle, "the next login asks again");
}
private static void HandOff()
{
var items = new List<StorageFeedItem>
{
new(2147483649u, 100, "Acid \"Assagai\" \\ é", 100667000, 100667001, 100667002, 3, 100, 1),
new(2147483650u, 101, "Pyreal", 100667003, 0, 0, 1, 0, 8192),
};
var rec = new StorageFeedRecord(VaultFeed.VaultId("tom"), VaultFeed.VaultName, VaultFeed.Label, items);
string json = StorageFeed.ToJson(rec);
bool ascii = true;
foreach (char c in json) if (c > 0x7e || c < 0x20) ascii = false;
Check.True(ascii, "plain ASCII (the broker carries ANSI)");
StorageFeedRecord? back = StorageFeed.Parse(json, out string error);
Check.Eq(error, "", "parsed");
Check.True(back != null && back.Id == rec.Id && back.Name == rec.Name && back.Label == rec.Label && back.Items.Count == 2, "the record");
Check.Eq(back!.Items[0], items[0], "an item, name escapes included");
Check.Eq(back.Items[1], items[1], "another");
Check.Eq(StorageFeed.TargetPlugin + "/" + StorageFeed.Action, "RynthInventory/storage", "sent to RynthInventory's \"storage\" command");
}
}