aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 5e889b08193b959b06f9571204c0902e7ccbceb9
parent 57d7278c56f6fa6de69fe021b7faeaa67c5330c3
Author: anon <anon@example.com>
Date:   Mon,  2 Nov 2026 23:07:59 +0000

Close browser launch and control reload test databases

Diffstat:
MTODO.md | 6++++++
Mserver/browser_launch_test.go | 25+++++++++++++++++++++++++
Mserver/control_data_test.go | 4++++
3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -3529,6 +3529,12 @@ with payloads and known client/server provenance. write during a failed run. Shared browser-stream cleanup now waits for its world sessions to retire after closing their streams, while ignoring synthetic non-browser clients. The broader fixture-handle audit remains open. + A focused browser-launch/control reload audit now fixes nine further unclosed + database instances. Before cleanup, the first launch case retains five SQLite + descriptors and two connection-opener goroutines. After cleanup, six affected + test scopes repeated three times return both counts to zero after every scope. + Cleanup is registered before fallible browser operations. This bounded fix does + not establish full-suite resource bounds; see `local/fixture-cleanup-focused/`. - [ ] [P3] Reproduce stale shop interaction state after a live control-panel inventory edit. In the restoration smoke run, a nearby original terminal reported "Too far away" after the edit, while a fresh page could use it. diff --git a/server/browser_launch_test.go b/server/browser_launch_test.go @@ -16,10 +16,20 @@ func TestBrowserLaunchCreatesPersistentVisitor(t *testing.T) { t.Fatal(err) } world := &server{baseURL: "/", worldPort: 7501, characters: make(map[uint32]*character), clients: make(map[uint32]*worldClient)} + t.Cleanup(func() { + if world.db != nil { + world.db.Close() + } + }) response := httptest.NewRecorder() world.browserLaunch(response, httptest.NewRequest("POST", "/browser-launch", nil)) loaded := &server{characters: make(map[uint32]*character)} + t.Cleanup(func() { + if loaded.db != nil { + loaded.db.Close() + } + }) err := loaded.loadUsers() if response.Code != http.StatusOK || response.Body.String() != "Clientr.exe localtest localtest 1 2130706433 7501 0 0" { @@ -68,9 +78,19 @@ func TestBrowserLaunchResumesOwnedCharacterAfterRestart(t *testing.T) { t.Fatal(err) } world := &server{worldPort: 7501, characters: make(map[uint32]*character)} + t.Cleanup(func() { + if world.db != nil { + world.db.Close() + } + }) first := httptest.NewRecorder() world.browserLaunch(first, httptest.NewRequest("POST", "/browser-launch", nil)) loaded := &server{worldPort: 7501, characters: make(map[uint32]*character), clients: map[uint32]*worldClient{1: {}}} + t.Cleanup(func() { + if loaded.db != nil { + loaded.db.Close() + } + }) if err := loaded.loadUsers(); err != nil { t.Fatal(err) } @@ -91,6 +111,11 @@ func TestBrowserLaunchSeparatesVisitorsAndReplacesUnknownCookie(t *testing.T) { t.Fatal(err) } world := &server{worldPort: 7501, characters: make(map[uint32]*character)} + t.Cleanup(func() { + if world.db != nil { + world.db.Close() + } + }) first := httptest.NewRecorder() world.browserLaunch(first, httptest.NewRequest("POST", "/browser-launch", nil)) request := httptest.NewRequest("POST", "https://example.test/browser-launch", nil) diff --git a/server/control_data_test.go b/server/control_data_test.go @@ -87,6 +87,7 @@ func TestControlItemsShareOneRegistryAndShowOwnersAndBackpackContents(t *testing placed := postControlForm(world, "/control/users/1", url.Values{"data": {"inventory:\n slots: {inventory_slot_1: 1, inventory_slot_2: 2}\n"}}) filled := postControlForm(world, "/control/items/2", url.Values{"data": {"type: 51017\ntemplate: 99228\nquality: 1\ncount: 1\nslots: {slot_1: 3}\n"}}) restarted := newServer() + t.Cleanup(func() { restarted.db.Close() }) page := httptest.NewRecorder() restarted.httpHandler().ServeHTTP(page, httptest.NewRequest("GET", "/control/items?q=Explorer", nil)) details := httptest.NewRecorder() @@ -128,8 +129,10 @@ func TestControlItemCanBeUnassignedAndTransferredWithoutChangingID(t *testing.T) cleared := postControlForm(world, "/control/users/1", url.Values{"data": {"inventory:\n slots: {inventory_slot_1: null}\n"}}) unassigned := newServer() + t.Cleanup(func() { unassigned.db.Close() }) transferred := postControlForm(world, "/control/users/2", url.Values{"data": {"inventory:\n slots: {inventory_slot_30: 1}\n"}}) restarted := newServer() + t.Cleanup(func() { restarted.db.Close() }) postControlForm(restarted, "/control/items", url.Values{"template": {"121567"}}) if cleared.Code != http.StatusSeeOther || transferred.Code != http.StatusSeeOther || len(unassigned.items) != 1 || len(unassigned.characters[1].inventory.Items) != 0 { @@ -231,6 +234,7 @@ func TestControlNestedSkillsAndImprovementPointsPersistAndReachClient(t *testing response := postControlForm(world, "/control/users/1", url.Values{"data": {contents}}) restarted := newServer() + t.Cleanup(func() { restarted.db.Close() }) packet := fullCharacterPacket(restarted.characters[1]) values := make(map[uint32]uint32) count := binary.BigEndian.Uint32(packet[64:68])/1009 - 1