Files
opengenesislinkserver/tools/ci/FirestormBridgeHttpRegression/Program.cs
T
OpenGenesis (MPL 2.0) edc4095b94 fix(yengine): normalize Firestorm http_request LSLString event args (#222)
* fix(yengine): normalize LSLString HTTP-request event parameters before compiled handler

* test(yengine): reproduce and guard Firestorm HTTP event boxed string compatibility

* test(yengine): reproduce and guard Firestorm HTTP event boxed string compatibility

* ci(yengine): run Firestorm HTTP callback string compatibility regression
2026-10-15 00:34:56 +02:00

66 lines
2.8 KiB
C#

using System;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Yengine;
internal static class Program
{
private static int checks;
private static void Check(bool test, string description)
{
++checks;
if (!test)
throw new Exception("Firestorm Bridge http_request: " + description);
}
private static int Main()
{
object[] native = { "a1", "URL_REQUEST_GRANTED", "https://example.invalid/" };
object[] noChange = XMRInstance.NormalizeHttpRequestArgs(native);
Check(ReferenceEquals(native, noChange),
"Native CLR-string event must keep its arguments");
object[] legacy =
{
new LSL_Types.LSLString("b2"),
new LSL_Types.LSLString("URL_REQUEST_GRANTED"),
new LSL_Types.LSLString("https://example.invalid/bridge")
};
object[] converted = XMRInstance.NormalizeHttpRequestArgs(legacy);
Check(!ReferenceEquals(legacy, converted),
"Mixed or LSL-wrapped event requires a new argument array");
Check(converted[0] is string && (string)converted[0] == "b2",
"Legacy key must become native string");
Check(converted[1] is string && (string)converted[1] == "URL_REQUEST_GRANTED",
"Legacy method must become native string");
Check(converted[2] is string &&
(string)converted[2] == "https://example.invalid/bridge",
"Legacy body must become native string");
Check(legacy[0] is LSL_Types.LSLString,
"Original arguments must not be mutated");
object[] mixed = { "c3", new LSL_Types.LSLString("POST"), "hello" };
object[] mixedConverted = XMRInstance.NormalizeHttpRequestArgs(mixed);
Check(ReferenceEquals(mixedConverted[0], mixed[0]) &&
(string)mixedConverted[1] == "POST" &&
ReferenceEquals(mixedConverted[2], mixed[2]),
"Mixed legacy and CLR-string payloads must be preserved exactly");
object[] wrongCount = { new LSL_Types.LSLString("id") };
Check(ReferenceEquals(XMRInstance.NormalizeHttpRequestArgs(wrongCount),
wrongCount),
"Do not silently rewrite malformed argument count");
Check(XMRInstance.NormalizeHttpRequestArgs(null) == null,
"Null argument array does not throw");
Check(TypeCast.EHArgUnwrapString(
new LSL_Types.LSLString("expected")) == "expected",
"Compiled handler converter supports boxed LSLString");
Check(TypeCast.EHArgUnwrapString("expected") == "expected",
"Compiled handler converter supports CLR string");
Console.WriteLine("Firestorm Bridge http_request parameter regression: PASS (" +
checks + " checks)");
return 0;
}
}