Snapshot for release 2026.10.15.2 (internal 2d4b0af)

This commit is contained in:
Tom Bohar 2026-10-15 20:32:35 -04:00
commit d5e0b50de7
224 changed files with 17914 additions and 1182 deletions

View file

@ -0,0 +1,18 @@
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// Offline tests for the server plugins: the shared model and every server plugin's detection data.
//
// Run: dotnet run -c Release (all tests)
// dotnet run -c Release -- host (tests whose name contains "host")
internal static class Program
{
private static int Main(string[] args)
{
var runner = new Runner();
ServerPackModelTests.Register(runner);
ServerProjectsTests.Register(runner);
return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null);
}
}

View file

@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Tests for the server plugins (Plugins\Shared\ServerPack, built into RynthColdeve, RynthAelrynth, ...):
- the shared model (ServerPackModel.cs, ServerPackInfo.cs): RynthCore's "servermenu" verdict,
the world-name fallback, the override commands and the sections manifest;
- every server plugin's csproj, read as XML: unique ids, plugin names and hosts, and no
server's host claimed by another server's list (RynthCore would load the wrong plugin);
- the launcher's known-server catalog (RynthCore.App\KnownServerCatalog.cs): every entry names
a server plugin whose hosts claim the entry's host, with the same port and emulator.
The plugins are NativeAOT x86 libraries, so the pure sources are compiled in here directly.
The SDK's manifest file (BCL only) supplies RynthCore's host matching.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail; an argument filters by test name)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>RynthServerPack.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackInfo.cs" Link="Plugin\ServerPackInfo.cs" />
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackModel.cs" Link="Plugin\ServerPackModel.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" />
<Compile Include="..\..\..\RynthCore\src\RynthCore.PluginSdk\Manifest\RynthPluginManifest.cs" Link="Sdk\RynthPluginManifest.cs" />
<!-- The launcher's known-server picker, checked against the plugins it names. -->
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\LaunchServerProfile.cs" Link="Launcher\LaunchServerProfile.cs" />
<!-- The RynthAi test tools' check/runner harness (no plugin code in it). -->
<Compile Include="..\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
<Compile Include="..\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,243 @@
using System;
using System.Linq;
using System.Text.Json;
using RynthCore.Plugin.ServerPack;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// The shared server-plugin model (Plugins\Shared\ServerPack\ServerPackModel.cs): RynthCore's
// "servermenu" verdict for the plugin's own server, the world-name fallback before one arrives,
// the override commands the card sends, and the sections manifest RynthCore reads.
internal static class ServerPackModelTests
{
public static void Register(Runner r)
{
r.Add("server pack: RynthCore's push gives this server's verdict, override and reason", EnginePush);
r.Add("server pack: a push without this server, or not a push, changes nothing", ForeignPush);
r.Add("server pack: before any push the world name decides", WorldFallback);
r.Add("server pack: override commands are checked before sending", ForceCommands);
r.Add("server pack: the sections manifest declares the server and a server-only card", SectionsJson);
r.Add("server pack: logout clears the verdict", ClearOnLogout);
r.Add("server pack: the card's botting line and address", InfoText);
r.Add("server pack: the RynthServer.Profile JSON carries the server's settings", ProfileJson);
r.Add("server pack: the profile JSON is plain ASCII and escaped", ProfileJsonAscii);
}
private static void ProfileJson()
{
ServerPackInfo info = new("Coldeve", "Coldeve", new[] { "play.coldeve.ac" }, new[] { "Coldeve" })
{
Port = 9050, Ruleset = "PvP", Status = "Stable", Botting = BottingPolicy.Restricted, BottingNote = "attended only",
AccountLimit = "3 accounts", Facts = new[] { "fact one" }, Commands = new[] { new ServerCommand("/x", "does x") },
Discord = "https://discord.gg/x",
};
string json = ServerPackProfile.BuildJson(info, "RynthColdeve", "0.1.2", true, "Coldeve");
using JsonDocument doc = JsonDocument.Parse(json);
JsonElement root = doc.RootElement;
Check.Eq(root.GetProperty("schema").GetInt32(), ServerPackProfile.Schema, "schema");
Check.Eq(root.GetProperty("id").GetString(), "coldeve", "id (lower-cased)");
Check.Eq(root.GetProperty("plugin").GetString(), "RynthColdeve", "plugin");
Check.Eq(root.GetProperty("version").GetString(), "0.1.2", "version");
Check.True(root.GetProperty("active").GetBoolean(), "active");
Check.Eq(root.GetProperty("world").GetString(), "Coldeve", "world");
Check.Eq(root.GetProperty("hosts")[0].GetString(), "play.coldeve.ac", "hosts");
Check.Eq(root.GetProperty("port").GetInt32(), 9050, "port");
Check.Eq(root.GetProperty("ruleset").GetString(), "PvP", "ruleset");
Check.Eq(root.GetProperty("botting").GetString(), "restricted", "botting");
Check.Eq(root.GetProperty("bottingNote").GetString(), "attended only", "botting note");
Check.Eq(root.GetProperty("facts")[0].GetString(), "fact one", "facts");
Check.Eq(root.GetProperty("commands")[0].GetProperty("what").GetString(), "does x", "commands");
Check.Eq(root.GetProperty("discord").GetString(), "https://discord.gg/x", "links");
// What a reader (RynthOracle, RynthAi's /ra server) makes of it.
var view = RynthCore.Plugin.Shared.ServerProfileView.Parse(json);
Check.True(view != null, "the shared reader parses it");
Check.Eq(view!.Summary(), "PvP, ACE; botting restricted - attended only; accounts: 3 accounts", "the reader's summary");
// No salvage defined: an empty list, which the Crafting tab reads as "none defined".
Check.Eq(root.GetProperty("salvage").GetArrayLength(), 0, "no salvage: empty list");
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList(json).Count, 0, "the reader sees none");
// Salvage defined: each row round-trips through the shared reader.
ServerPackInfo withSalvage = new("x", "X", new[] { "x.example" }, new[] { "X" })
{
Salvage = new[]
{
new ServerSalvage("melee", 52, "+1 tink past the cap", "once", UsesTinkSlot: false),
new ServerSalvage("Armor", 64, "+30 armor level"),
new ServerSalvage("", 64, "no bench: skipped"),
},
};
var salvage = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
ServerPackProfile.BuildJson(withSalvage, "RynthX", "1", true, "X"));
Check.Eq(salvage.Count, 2, "rows without a bench are skipped");
Check.Eq(salvage[0].Bench, "melee", "bench");
Check.Eq(salvage[0].Material, 52, "material id");
Check.Eq(salvage[0].Kind, "once", "kind");
Check.False(salvage[0].UsesTinkSlot, "no tink slot");
Check.Eq(salvage[1].Bench, "armor", "bench lower-cased");
Check.Eq(salvage[1].Kind, "tink", "default kind");
Check.True(salvage[1].UsesTinkSlot, "slot by default");
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList("{\"id\":\"x\"}").Count, 0, "a profile without the list (older plugins)");
// The optional row fields: absent = off / the default, and the writer leaves them out then.
Check.True(salvage.All(v => v.AppliedInt == 0 && !v.Prepared && v.Order == 0 && !v.AfterCap
&& v.StackGroup.Length == 0 && v.StackCap == 0), "optional fields default when absent");
string plain = ServerPackProfile.BuildJson(withSalvage, "RynthX", "1", true, "X");
Check.True(!plain.Contains("\"applied\"") && !plain.Contains("\"prepared\"") && !plain.Contains("\"order\"")
&& !plain.Contains("\"afterCap\"") && !plain.Contains("\"stackGroup\""), "unset fields are not written");
ServerPackInfo withRules = new("x", "X", new[] { "x.example" }, new[] { "X" })
{
Salvage = new[]
{
new ServerSalvage("melee", 52, "post-cap", "once", UsesTinkSlot: false, Order: 995, AfterCap: true),
new ServerSalvage("jewelry", 71, "stack", UsesTinkSlot: false, Order: 50, StackGroup: "jewelry-stack", StackCap: 10),
new ServerSalvage("trinkets", 20, "tier", "once", UsesTinkSlot: false, AppliedInt: 384, Prepared: true, Order: 10),
},
};
var rules = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
ServerPackProfile.BuildJson(withRules, "RynthX", "1", true, "X"));
Check.Eq(rules.Count, 3, "rows with rules");
Check.True(rules[0].AfterCap && rules[0].Order == 995 && !rules[0].Prepared && rules[0].StackGroup.Length == 0, "after cap + order");
Check.Eq(rules[1].StackGroup, "jewelry-stack", "stack group");
Check.Eq(rules[1].StackCap, 10, "stack cap");
Check.True(rules[2].Prepared && rules[2].AppliedInt == 384 && rules[2].Order == 10 && !rules[2].AfterCap, "prepared + applied + order");
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
"{\"salvage\":[{\"bench\":\"jewelry\",\"material\":64,\"stackGroup\":\"g\"},{\"bench\":\"jewelry\",\"material\":71,\"stackGroup\":\"g\",\"stackCap\":0}]}")
.Count(v => v.StackGroup.Length > 0), 0, "a stack group without a positive cap is no group");
var odd = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
"{\"salvage\":[{\"bench\":\"melee\",\"material\":52,\"applied\":\"x\",\"prepared\":1,\"order\":null,\"afterCap\":\"yes\"}]}");
Check.True(odd.Count == 1 && odd[0].AppliedInt == 0 && !odd[0].Prepared && odd[0].Order == 0 && !odd[0].AfterCap,
"fields of the wrong type read as absent");
string idle = ServerPackProfile.BuildJson(info, "RynthColdeve", "0.1.2", false, null);
using JsonDocument idleDoc = JsonDocument.Parse(idle);
Check.False(idleDoc.RootElement.GetProperty("active").GetBoolean(), "not active");
Check.Eq(idleDoc.RootElement.GetProperty("world").GetString(), "", "no world before login");
Check.Eq(ServerPackProfile.BottingName(BottingPolicy.Unknown), "unknown", "unknown botting");
}
private static void ProfileJsonAscii()
{
ServerPackInfo info = new("x", "Caf\u00e9 \"Q\"\n", Array.Empty<string>(), Array.Empty<string>()) { Summary = "a\\b\tc \u2014 d" };
string json = ServerPackProfile.BuildJson(info, "RynthX", "1", false, "");
bool ascii = true;
foreach (char c in json) if (c > 0x7e || c < 0x20) ascii = false;
Check.True(ascii, "only printable ASCII: " + json);
using JsonDocument doc = JsonDocument.Parse(json);
Check.Eq(doc.RootElement.GetProperty("name").GetString(), "Caf\u00e9 \"Q\"", "name round-trips (trimmed)");
Check.Eq(doc.RootElement.GetProperty("summary").GetString(), "a\\b\tc \u2014 d", "summary round-trips");
}
private static ServerPackInfo Coldeve() =>
new("Coldeve", "Coldeve", new[] { "play.coldeve.ac" }, new[] { "Coldeve" }) { Discord = "https://discord.gg/x" };
private const string Push =
"V\tcoldeve\tColdeve\t1\ton\t0\tforced on for this character\n" +
"V\tilt\tInfinite Leaftide\t0\tauto\t0\tnot Infinite Leaftide\n" +
"X\tchar\tChar\n" +
"S\tcoldeve\tColdeve\t1\t/rc server coldeve on\n" +
"I\tColdeve server (RynthColdeve)\t/rc miniremote section char\tWhat is known.\tsection:char\n";
private static void EnginePush()
{
var model = new ServerPackModel(Coldeve());
Check.True(model.ApplyEngine(Push, 1234), "taken");
ServerVerdictView? v = model.Engine;
Check.True(v != null, "this server's verdict");
Check.True(v!.Active, "active");
Check.Eq(v.Force, "on", "override");
Check.False(v.Detected, "forced, not detected");
Check.Eq(v.Reason, "forced on for this character", "reason");
Check.Eq(model.EngineAtMs, 1234L, "when");
Check.True(model.IsActive("SomewhereElse"), "RynthCore's verdict beats the world name");
}
private static void ForeignPush()
{
var model = new ServerPackModel(Coldeve());
Check.False(model.ApplyEngine("X\tchar\tChar\n", 1), "no server lines: not a push");
Check.False(model.ApplyEngine(null, 1), "null");
Check.False(model.ApplyEngine(new string('V', ServerPackModel.MaxPayload + 1), 1), "too long");
Check.True(model.Engine == null, "nothing published");
// A push that lists other servers but not this one yet (RynthCore hasn't read the manifest).
Check.True(model.ApplyEngine("V\tilt\tInfinite Leaftide\t1\tauto\t1\thost matches\n", 2), "a push");
Check.True(model.Engine == null, "no verdict for this server");
ServerPackModel.ParseEngine("V\tCOLDEVE\tColdeve\t0\tweird\t1\n", "coldeve", out bool listed);
Check.True(listed, "listed");
Check.Eq(ServerPackModel.ParseEngine("V\tCOLDEVE\tColdeve\t0\tweird\t1\n", "coldeve", out _)!.Force, "auto",
"id case ignored; an unknown override reads as auto; no reason field is fine");
}
private static void WorldFallback()
{
var model = new ServerPackModel(Coldeve());
Check.True(model.IsActive("Coldeve"), "exact world name");
Check.True(model.IsActive(" coldeve "), "case and spaces");
Check.False(model.IsActive("ColdeveTwo"), "no partial match without '*'");
Check.False(model.IsActive(null), "unknown world");
Check.True(ServerPackModel.WorldMatches("Aeshnidae Live", new[] { "Aelrynth*", "Aeshnidae*" }), "wildcard");
Check.False(ServerPackModel.WorldMatches("LeafDawn", new[] { "Leafdawning" }), "LeafDawn is not Leafdawning");
Check.True(ServerPackModel.WorldMatches("Infinite Leaftide", new[] { "*Leaftide*" }), "both ends");
}
private static void ForceCommands()
{
Check.Eq(ServerPackModel.ForceCommand("coldeve", "On"), "/rc server coldeve on", "on");
Check.Eq(ServerPackModel.ForceCommand("coldeve", "auto"), "/rc server coldeve auto", "auto");
Check.Eq(ServerPackModel.ForceCommand("coldeve", "maybe"), "", "unknown mode");
Check.Eq(ServerPackModel.ForceCommand("cold eve", "on"), "", "an id with a space");
Check.Eq(ServerPackModel.ForceCommand("coldeve; /quit", "on"), "", "no command injection through the id");
Check.False(ServerPackModel.IsSafeId(new string('a', 33)), "too long");
}
private static void SectionsJson()
{
string json = ServerPackModel.BuildSectionsJson(Coldeve(), "RynthColdeve");
using JsonDocument doc = JsonDocument.Parse(json);
JsonElement root = doc.RootElement;
Check.Eq(root.GetProperty("version").GetInt32(), 1, "schema 1");
JsonElement server = root.GetProperty("servers")[0];
Check.Eq(server.GetProperty("id").GetString(), "coldeve", "server id lower-cased");
Check.Eq(server.GetProperty("hosts")[0].GetString(), "play.coldeve.ac", "hosts");
Check.Eq(server.GetProperty("worldNames")[0].GetString(), "Coldeve", "world names");
JsonElement card = root.GetProperty("contributions")[0];
Check.Eq(card.GetProperty("section").GetString(), "server", "in the Server section (not Session Stats)");
JsonElement section = root.GetProperty("sections")[0];
Check.Eq(section.GetProperty("id").GetString(), "server", "the Server section is declared");
Check.Eq(section.GetProperty("label").GetString(), "Server", "its label");
Check.Eq(section.GetProperty("order").GetInt32(), 50, "after Session Stats, before Map");
Check.Eq(card.GetProperty("server").GetString(), "coldeve", "only while Coldeve is active");
Check.Eq(card.GetProperty("surface").GetString(), "section:server-coldeve", "the card's surface");
var quoted = new ServerPackInfo("odd", "Odd \"Name\"\n", new[] { "a\\b" }, Array.Empty<string>());
using JsonDocument odd = JsonDocument.Parse(ServerPackModel.BuildSectionsJson(quoted, "RynthOdd"));
Check.Eq(odd.RootElement.GetProperty("servers")[0].GetProperty("hosts")[0].GetString(), "a\\b", "escaped");
}
private static void ClearOnLogout()
{
var model = new ServerPackModel(Coldeve());
model.ApplyEngine(Push, 5);
model.Clear();
Check.True(model.Engine == null, "verdict cleared");
Check.Eq(model.EngineAtMs, 0L, "time cleared");
Check.False(model.IsActive("Elsewhere"), "back to the world name");
}
private static void InfoText()
{
ServerPackInfo c = Coldeve();
Check.Eq(c.Address, "play.coldeve.ac:9000", "address");
Check.True(c.BottingText.StartsWith("Not published"), "unknown policy says so");
Check.True(c.BottingText.Contains("Discord"), "and points at the Discord");
var lev = new ServerPackInfo("example", "Example", new[] { "play.example.test" }, new[] { "Example" })
{ Botting = BottingPolicy.Forbidden, BottingNote = "no automation" };
Check.Eq(lev.BottingText, "Forbidden - no automation", "forbidden");
Check.Eq(new ServerPackInfo("x", "", Array.Empty<string>(), Array.Empty<string>()).Address, "", "no host, no address");
Check.True(ServerPackModel.LauncherSteps(c)[0].Contains("play.coldeve.ac:9000"), "setup names the address");
}
}

View file

@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using RynthCore.PluginSdk.Manifest;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// Every server plugin's csproj (Plugins\RynthCore.Plugin.Rynth*\ with RynthPluginServerId), read as
// XML: the detection data RynthCore's loader and sections use must be unique and must not overlap,
// or a client would load (or show) the wrong server's plugin.
internal static class ServerProjectsTests
{
public static void Register(Runner r)
{
r.Add("server projects: every listed server has a plugin", AllServersPresent);
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);
}
private sealed record Project(string Dir, string PluginName, string Id, string Name, string[] Hosts, string[] Worlds, bool Shared);
/// <summary>The servers in the request (the server list's busiest, plus Aelrynth) and their plugins.</summary>
private static readonly string[] Expected =
{
"coldeve", "ilt", "frostace", "reefcull", "conquest", "dreamweave", "portalstorm", "sundering",
"achard", "leafdawn", "derptide", "frostcull", "thistlecrown", "eversong", "leafdawning", "aelrynth",
};
private static string PluginsDir()
{
string? dir = AppContext.BaseDirectory;
while (dir != null && !Directory.Exists(Path.Combine(dir, "Plugins", "Shared", "ServerPack")))
dir = Path.GetDirectoryName(dir);
if (dir == null) throw new DirectoryNotFoundException("RynthSuite\\Plugins not found above " + AppContext.BaseDirectory);
return Path.Combine(dir, "Plugins");
}
private static List<Project> Load()
{
var list = new List<Project>();
foreach (string dir in Directory.GetDirectories(PluginsDir(), "RynthCore.Plugin.Rynth*"))
{
string csproj = Path.Combine(dir, Path.GetFileName(dir) + ".csproj");
if (!File.Exists(csproj)) continue;
XDocument doc = XDocument.Load(csproj);
string Prop(string name) => doc.Descendants(name).FirstOrDefault()?.Value.Trim() ?? "";
string id = Prop("RynthPluginServerId");
if (id.Length == 0) continue;
string[] Split(string v) => v.Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
bool shared = doc.Descendants("Import").Any(i => (i.Attribute("Project")?.Value ?? "").EndsWith("ServerPlugin.props"));
string asm = Prop("AssemblyName");
list.Add(new Project(dir, asm.Replace("RynthCore.Plugin.", ""), id, Prop("RynthPluginServerName"),
Split(Prop("RynthPluginServerHosts")), Split(Prop("RynthPluginServerWorldNames")), shared));
}
return list;
}
private static void AllServersPresent()
{
List<Project> projects = Load();
foreach (string id in Expected)
Check.True(projects.Any(p => p.Id == id), "a server plugin for " + id);
Check.Eq(projects.Count, Expected.Length, "no unexpected server plugins");
}
private static void Unique()
{
List<Project> projects = Load();
Check.Eq(projects.Select(p => p.Id).Distinct().Count(), projects.Count, "ids unique");
Check.Eq(projects.Select(p => p.PluginName.ToLowerInvariant()).Distinct().Count(), projects.Count, "plugin names unique");
var hosts = projects.SelectMany(p => p.Hosts).Select(h => h.ToLowerInvariant()).ToList();
Check.Eq(hosts.Distinct().Count(), hosts.Count, "hosts unique");
foreach (Project p in projects)
{
Check.True(p.Hosts.Length > 0, p.PluginName + " lists a host (the loader picks plugins by host)");
Check.True(p.Worlds.Length > 0, p.PluginName + " lists a world name");
Check.True(p.Name.Length > 0, p.PluginName + " has a display name");
}
}
private static void NoHostOverlap()
{
List<Project> projects = Load();
foreach (Project owner in projects)
foreach (string host in owner.Hosts.Where(h => !h.Contains('*')))
foreach (Project other in projects.Where(o => o != owner))
{
var server = new RynthPluginServer { Id = other.Id, Hosts = other.Hosts.ToList() };
Check.False(server.MatchesHost(host, out string hit),
$"{owner.PluginName}'s host {host} is not claimed by {other.PluginName} ({hit})");
}
}
private static void Layout()
{
foreach (Project p in Load().Where(p => p.Id != "ilt"))
{
Check.True(p.Shared, p.PluginName + " imports Shared\\ServerPack\\ServerPlugin.props");
Check.True(File.Exists(Path.Combine(p.Dir, "ServerData.cs")), p.PluginName + " has ServerData.cs");
}
}
}