Files
SVSimServer/SVSim.UnitTests/Controllers/ArenaTwoPickBattleControllerTests.cs
gamer147 5525dbee24 fix(battle-node): node_server_url matches prod wire format (no scheme, with path)
Prod do_matching captures (data_dumps/captures/traffic_prod_tk2_*) send
the node URL as host:port/socket.io/ with no scheme prefix —
e.g. "node06.shadowverse.jp:13560/socket.io/". BestHTTP's SocketManager
expects this exact shape; the leading ws:// we were sending plus the
missing /socket.io/ path was preventing the client from completing the
post-do_matching connect (eventually times out with "connection timed
out").

Update BattleNodeOptions default, Program.cs override, and both
controller and bridge tests to use "localhost:5148/socket.io/".

Discovered during v1 smoke walkthrough.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 01:06:40 -04:00

40 lines
1.8 KiB
C#

using System.Net;
using System.Net.Http.Json;
using System.Text.Json;
using SVSim.UnitTests.Infrastructure;
namespace SVSim.UnitTests.Controllers;
public class ArenaTwoPickBattleControllerTests
{
[Test]
public async Task DoMatching_AuthenticatedViewer_Returns3004WithBattleIdAndNodeUrl()
{
using var factory = new SVSimTestFactory();
var viewerId = await factory.SeedViewerAsync();
using var client = factory.CreateAuthenticatedClient(viewerId);
var req = new {
deck_no = 1L, need_init = 1, log = 1, excluded_field_id_list = new long[] { }, use_stage_select = 1, is_default_skin = 0,
viewer_id = "0", steam_id = 0, steam_session_ticket = "",
};
var resp = await client.PostAsync("/arena_two_pick_battle/do_matching", JsonContent.Create(req));
Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK));
var body = await resp.Content.ReadAsStringAsync();
using var doc = JsonDocument.Parse(body);
var root = doc.RootElement;
Assert.That(root.GetProperty("matching_state").GetInt32(), Is.EqualTo(3004));
var battleId = root.GetProperty("battle_id").GetString();
Assert.That(battleId, Is.Not.Null.And.Not.Empty);
var nodeUrl = root.GetProperty("node_server_url").GetString();
// Matches prod wire format: host:port/socket.io/, no scheme prefix.
Assert.That(nodeUrl, Does.Contain("/socket.io/"));
Assert.That(nodeUrl, Does.Not.StartWith("ws://"));
Assert.That(nodeUrl, Does.Not.StartWith("http://"));
// Required when matching_state ∈ {3004,3007,3011} per
// DoMatchingBase.SettingCardMasterId; client throws KeyNotFoundException without it.
Assert.That(root.GetProperty("card_master_id").GetInt32(), Is.EqualTo(1));
}
}