commit d483412ec67b3ba38ba5c9c37a4bfc0d20ae80eb parent 5ed829244cc8d02f72a7b4028f4e27c936defc53 Author: anon <anon@example.com> Date: Fri, 30 Oct 2026 16:01:51 +0000 Close databases owned by shared combat test fixtures Diffstat:
53 files changed, 193 insertions(+), 152 deletions(-)
diff --git a/DEVELOPERS.md b/DEVELOPERS.md @@ -46,7 +46,7 @@ and `build.json`. A fresh clone can run `go run ./server` immediately. No Emscripten, Python, Make, C compiler, or original Windows client is needed on the server build machine. Rebuild the Go binary after updating resources. -Requires Go 1.24 or newer. The server listens on all network interfaces. Default +Requires Go 1.26 or newer. The server listens on all network interfaces. Default ports are login 7500, world 7501, chat 7502, HTTP 8080 and HTTPS 8443. Chat uses the port immediately after the world port. From another machine, open `https://<server-address>:8443/` or `/control`. On first startup, Go @@ -423,12 +423,14 @@ On Linux, from a graphical desktop session: ```sh SDL_VIDEODRIVER=x11 make test -go test ./server +go test ./server/... -timeout=1h ``` `make test` includes graphics/window tests and needs a working display. Windows comparison wrappers live in `tools/client/test_portable_*.py`; they use the local LLVM-MinGW compiler and WSL. Normal Linux tests do not require those wrappers. +The full server suite includes many persistence and catalog cases and can exceed +Go's default ten-minute timeout. See [tools/README.md](tools/README.md) for the smoke-test fixtures and tools. For client smoke tests, confirm world loading has completed, open/close diff --git a/TODO.md b/TODO.md @@ -3052,6 +3052,13 @@ with payloads and known client/server provenance. The later connected capacity run also hits the full suite ten-minute timeout while entering a mission-return test, with earlier connection openers retained in its dump. Evidence: `local/todo-progression-play/capacity-go-full.log`. + The shared combat fixture now receives its test context and closes a lazily + opened database at scope exit, including its pursuit/regeneration/threat + helpers. A nested equipment fixture reproduces one retained connection before + the fix and zero afterward; six focused race checks pass. Descriptor samples + still identify deleted databases from separate browser/chat/control/reload + fixtures, so the broad audit remains open. Evidence: + `local/todo-progression-play/fixture-cleanup-*.log` and `fixture-resource-*.json`. The ordinary two-client progression fixture also exposed late disconnect writes: closing browser streams does not wait for `serveWorldClient` to save active nano durations. Two stopped runs logged `Saving nano durations: sql: @@ -3516,6 +3523,10 @@ and server restarts. Turn every reproduced bug into a focused regression test. ## Checks that apply to each milestone +- [ ] [P2] Update developer persistence and backup documentation to the current + SQLite store. `DEVELOPERS.md` still describes `player.yaml`, `position.yaml`, + `inventory.yaml` and chat files as durable storage. Distinguish the control + panel's YAML editing format from the actual database files and checkpoints. - [x] Repair the browser-profile worker test fixture. Its VM context supplies `URL`/`location` and checks build/upload URLs relative to the worker location. `node client/tests/browser_profile.mjs` now exercises all existing assertions. diff --git a/server/backyard_test.go b/server/backyard_test.go @@ -24,7 +24,7 @@ var backyardFixtures = []struct { func newBackyardTestWorld(t *testing.T) *server { t.Helper() t.Chdir(t.TempDir()) - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) delete(world.characters, 1000000) world.nextCharacter = 1 var err error diff --git a/server/character_info_test.go b/server/character_info_test.go @@ -214,7 +214,7 @@ func TestCharacterInfoNPCUsesNativeDefaultsWithoutChangingRecovery(t *testing.T) func TestCharacterInfoNPCRejectsTargetsWithoutASimpleCharacter(t *testing.T) { for _, scenario := range []string{"unseen", "other zone", "removed", "corpse", "foreign owner", "loading", "not ready", "replaced"} { t.Run(scenario, func(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) npc, client := world.characters[1000000], world.clients[1] request := teamRequest(1, 105, 1000000, 0) switch scenario { diff --git a/server/combat_interest_test.go b/server/combat_interest_test.go @@ -29,7 +29,7 @@ func (conn *combatInterestConn) Close() error { } func TestCombatLateLoginReceivesTargetsAfterParticipantSpawns(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.advanceCombat(world.characters[1].nextAttack) world.characters[2] = &character{id: 2, name: "Observer", playfield: 950, health: 100} @@ -60,7 +60,7 @@ func TestCombatLateLoginReceivesTargetsAfterParticipantSpawns(t *testing.T) { } func TestCombatNPCInterestReplaysTargetsOnceAfterSpawning(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.advanceCombat(world.characters[1].nextAttack) world.characters[2] = &character{id: 2, playfield: 950, health: 100} @@ -87,7 +87,7 @@ func TestCombatNPCInterestReplaysTargetsOnceAfterSpawning(t *testing.T) { } func TestCombatInterestWaitsForBothNPCParticipants(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) world.clients[1].npcs = make(map[uint32]bool) world.characters[1000000].fighting = 1000001 world.fighting[1000000] = world.characters[1000000] @@ -105,7 +105,7 @@ func TestCombatInterestWaitsForBothNPCParticipants(t *testing.T) { } func TestCombatSessionReplacementCancelsBeforeInitialization(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.clients[1].conn = &combatInterestConn{} world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.advanceCombat(world.characters[1].nextAttack) diff --git a/server/combat_lifecycle_test.go b/server/combat_lifecycle_test.go @@ -10,7 +10,7 @@ import ( ) func TestCombatReplacedSessionCannotMoveRestOrFinishLoading(t *testing.T) { - world, currentOutput := newCombatWorld() + world, currentOutput := newCombatWorld(t) world.clients[1].loading = true oldOutput := &combatTestConn{} old := &worldClient{id: 1, conn: oldOutput, ready: true} @@ -36,7 +36,7 @@ func TestCombatReplacedSessionCannotMoveRestOrFinishLoading(t *testing.T) { } func TestCombatRepeatedWorldCookieCannotReinitializeTheActor(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) delete(world.clients, 1) cookie := systemPacket(0x1b, []byte{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}) conn := &combatInterestConn{input: bytes.NewReader(append(cookie, cookie...))} @@ -59,7 +59,7 @@ func TestCombatRepeatedWorldCookieCannotReinitializeTheActor(t *testing.T) { func TestCombatProfileEditStopsBothActorsInTheirOriginalPlayfield(t *testing.T) { t.Chdir(t.TempDir()) - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.advanceCombat(world.characters[1].nextAttack) observer := &combatTestConn{} @@ -86,7 +86,7 @@ func TestCombatProfileEditStopsBothActorsInTheirOriginalPlayfield(t *testing.T) func TestCombatFailedProfileEditPreservesBothActorsAndResources(t *testing.T) { t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.advanceCombat(world.characters[1].nextAttack) before := *world.characters[1] @@ -106,7 +106,7 @@ func TestCombatFailedProfileEditPreservesBothActorsAndResources(t *testing.T) { } func TestRegenerationSchedulerJitterDoesNotAccumulate(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) for second := 2; second <= 58; second += 2 { jitter := time.Millisecond @@ -122,7 +122,7 @@ func TestRegenerationSchedulerJitterDoesNotAccumulate(t *testing.T) { } func TestCombatSlowLiveRecipientDoesNotBlockWorldTick(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) delete(world.clients, 1) peer := connectZoningClient(t, world, true) if _, err := peer.Write(targetPacket(attackPacket(1, 1000000))); err != nil { diff --git a/server/combat_range_test.go b/server/combat_range_test.go @@ -14,7 +14,7 @@ func TestCombatMeleeUsesActorExtentsAtThreeDimensionalBoundary(t *testing.T) { {"outside diagonal", [3]float32{6, 3.125, 6}, false}, } { t.Run(scenario.name, func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) npc := world.characters[1000000] npc.monsterData, npc.position = 17655, scenario.position @@ -32,7 +32,7 @@ func TestCombatMeleeUsesActorExtentsAtThreeDimensionalBoundary(t *testing.T) { func TestCombatLeetRangeIncludesItsOwnExtentTwice(t *testing.T) { for _, distance := range []float32{10, 10.125} { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player, npc := world.characters[1], world.characters[1000000] npc.monsterData = 17655 world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) diff --git a/server/combat_stats_test.go b/server/combat_stats_test.go @@ -37,7 +37,7 @@ func TestCombatPlayerHealthMatchesBreedAndSoldierTitle(t *testing.T) { func TestCombatProfileEditClampsHealthToNewMaximum(t *testing.T) { t.Chdir(t.TempDir()) - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1].health = 59 destination := world.characters[1].userData() destination.Level = 1 diff --git a/server/combat_stress_test.go b/server/combat_stress_test.go @@ -32,7 +32,7 @@ func (conn *stalledCombatConn) Write(packet []byte) (int, error) { } func TestCombatSharedNPCKillingBlowIsResolvedOnce(t *testing.T) { - world, first := newCombatWorld() + world, first := newCombatWorld(t) second := &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950, health: 100} world.clients[2] = &worldClient{id: 2, conn: second, target: true, ready: true, npcs: map[uint32]bool{1000000: true}} @@ -71,7 +71,7 @@ func TestCombatSharedNPCKillingBlowIsResolvedOnce(t *testing.T) { } func TestCombatSwitchingTargetsLeavesExistingRetaliation(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1000001] = &character{id: 1000001, npc: true, appearance: 229, playfield: 950, position: [3]float32{2, 0, 0}, health: 100} world.clients[1].npcs[1000001] = true if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { @@ -92,7 +92,7 @@ func TestCombatSwitchingTargetsLeavesExistingRetaliation(t *testing.T) { } func TestCombatRepeatedStartStopDoesNotLeaveScheduledSwings(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) for range 100 { if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { @@ -112,7 +112,7 @@ func TestCombatRepeatedStartStopDoesNotLeaveScheduledSwings(t *testing.T) { func TestCombatChangingTargetsCannotBypassRecharge(t *testing.T) { for _, action := range []string{"switch target", "stop and restart"} { t.Run(action, func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1000001] = &character{id: 1000001, npc: true, appearance: 229, playfield: 950, position: [3]float32{2, 0, 0}, health: 100} world.clients[1].npcs[1000001] = true if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { @@ -140,7 +140,7 @@ func TestCombatChangingTargetsCannotBypassRecharge(t *testing.T) { } func TestCombatFailedObserverDoesNotSuppressOtherObservers(t *testing.T) { - world, healthy := newCombatWorld() + world, healthy := newCombatWorld(t) failed := &failingCombatConn{} world.characters[2] = &character{id: 2, playfield: 950, health: 100} world.clients[2] = &worldClient{id: 2, conn: failed, target: true, ready: true, npcs: map[uint32]bool{1000000: true}} @@ -156,7 +156,7 @@ func TestCombatFailedObserverDoesNotSuppressOtherObservers(t *testing.T) { } func TestCombatLateObserverReceivesInjuredNPCBeforeFight(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { t.Fatal(err) } @@ -178,7 +178,7 @@ func TestCombatLateObserverReceivesInjuredNPCBeforeFight(t *testing.T) { } func TestCombatStalledObserverCannotFreezeWorldUpdates(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) peer, connection := net.Pipe() if err := peer.SetReadDeadline(time.Now().Add(8 * time.Second)); err != nil { t.Fatal(err) @@ -214,7 +214,7 @@ func TestCombatStalledObserverCannotFreezeWorldUpdates(t *testing.T) { } func TestCombatConcurrentDisconnectAndTicksReleaseBothSides(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) delete(world.clients, 1) client := connectZoningClient(t, world, false) if _, err := client.Write(attackPacket(1, 1000000)); err != nil { diff --git a/server/combat_test.go b/server/combat_test.go @@ -28,9 +28,10 @@ func landedCombatRoll(limit uint32) uint32 { return limit - 1 } -func newCombatWorld() (*server, *combatTestConn) { +func newCombatWorld(t *testing.T) (*server, *combatTestConn) { + t.Helper() conn := &combatTestConn{} - return &server{ + world := &server{ characters: map[uint32]*character{ 1: {id: 1, playfield: 950, health: 100, stats: testCharacterStats()}, 1000000: {id: 1000000, playfield: 950, position: [3]float32{1, 0, 0}, appearance: 229, npc: true, health: 100, stats: testCharacterStats()}, @@ -40,11 +41,19 @@ func newCombatWorld() (*server, *combatTestConn) { }, fighting: make(map[uint32]*character), combatRoll: landedCombatRoll, - }, conn + } + + // Close a database opened lazily by persistent actions. + t.Cleanup(func() { + if world.db != nil { + world.db.Close() + } + }) + return world, conn } func TestCombatTimesSwingsAndRetaliation(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player, npc := world.characters[1], world.characters[1000000] if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { @@ -68,7 +77,7 @@ func TestCombatTimesSwingsAndRetaliation(t *testing.T) { } func TestCombatStartingAttackStandsTheAttacker(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1].sitting = true err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) @@ -79,7 +88,7 @@ func TestCombatStartingAttackStandsTheAttacker(t *testing.T) { } func TestCombatRepeatedRequestsDoNotResetClockOrCatchUpTicks(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) request := attackPacket(1, 1000000)[20:] world.handleCombat(world.clients[1], request) first := world.characters[1].nextAttack @@ -98,7 +107,7 @@ func TestCombatRepeatedRequestsDoNotResetClockOrCatchUpTicks(t *testing.T) { func TestCombatRejectsInvalidTargetsAndSessions(t *testing.T) { for _, scenario := range []string{"player", "human NPC", "dead", "other zone", "unknown", "hidden", "far", "loading", "replaced"} { t.Run(scenario, func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) npc, client := world.characters[1000000], world.clients[1] switch scenario { case "player": @@ -131,7 +140,7 @@ func TestCombatRejectsInvalidTargetsAndSessions(t *testing.T) { } func TestCombatStopLeavesRetaliatingNPCActive(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) first := world.characters[1].nextAttack world.advanceCombat(first) @@ -148,7 +157,7 @@ func TestCombatStopLeavesRetaliatingNPCActive(t *testing.T) { } func TestCombatRangeUsesPredictedPlayerPosition(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) first := world.characters[1].nextAttack world.characters[1].rotation = [4]float32{0, 0, 0, 1} @@ -166,7 +175,7 @@ func TestCombatRangeUsesPredictedPlayerPosition(t *testing.T) { } func TestCombatKillingHitClampsHealthAndCancelsEveryAttacker(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) world.characters[1000000].health = 3 world.characters[1000000].motion = &npcMotion{roaming: true, moving: true} world.characters[2] = &character{id: 2, playfield: 950, health: 100, fighting: 1000000} @@ -189,7 +198,7 @@ func TestCombatKillingHitClampsHealthAndCancelsEveryAttacker(t *testing.T) { } func TestCombatPacketsOnlyReachObserversWhoKnowTheNPC(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) near, hidden, elsewhere := &combatTestConn{}, &combatTestConn{}, &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950, health: 100} world.characters[3] = &character{id: 3, playfield: 950, health: 100} @@ -256,7 +265,7 @@ func TestCombatAcceptsNativeWorldMessagesAndCancelsOnDisconnect(t *testing.T) { func TestCombatPlayerDeathStopsMovementAndFurtherAttacks(t *testing.T) { t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) if err := world.saveUser_locked(world.characters[1]); err != nil { t.Fatal(err) } @@ -283,7 +292,7 @@ func TestCombatPlayerDeathStopsMovementAndFurtherAttacks(t *testing.T) { } func TestCombatLateObserverSeesDeadNPC(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1000000].health = 3 world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.advanceCombat(world.characters[1].nextAttack) @@ -300,7 +309,7 @@ func TestCombatLateObserverSeesDeadNPC(t *testing.T) { func TestCombatZoningCancelsOpponentsAndPreservesHealth(t *testing.T) { t.Chdir(t.TempDir()) - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1].appearance = 0x315 world.characters[1].level = 1 world.characters[1].health = 37 @@ -322,7 +331,7 @@ func TestCombatZoningCancelsOpponentsAndPreservesHealth(t *testing.T) { func TestCombatMalformedPacketsAreRejected(t *testing.T) { for _, packet := range [][]byte{attackPacket(1, 1000000)[:44], stopFightPacket(1)[:39], n3Packet(0x76793f0d, 50000, 1, []byte{0, 0, 0})[:39]} { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) err := world.handleCombat(world.clients[1], packet[20:]) @@ -345,7 +354,7 @@ func TestCombatAggDefControlsNativeFistTimings(t *testing.T) { {"full defense", -100, 2980 * time.Millisecond, 2970 * time.Millisecond}, } { t.Run(scenario.name, func(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) request := n3Packet(0x76793f0d, 50000, 1, binary.BigEndian.AppendUint32(nil, uint32(scenario.value))) if err := world.handleCombat(world.clients[1], request[20:]); err != nil { @@ -374,7 +383,7 @@ func TestCombatAggDefControlsNativeFistTimings(t *testing.T) { func TestCombatAggDefRejectsInvalidValuesAndReplacedSessions(t *testing.T) { for _, value := range []int32{-101, 101, -2147483648, 2147483647, 75} { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) client := world.clients[1] if value == 75 { world.clients[1] = &worldClient{id: 1} @@ -415,7 +424,7 @@ func TestCombatAggDefUsesNativeWorldRequest(t *testing.T) { } func TestCombatDeadPlayerCannotCrossZoneTriggers(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1].health = 0 world.characters[1].rotation = [4]float32{0, 0, 0, 1} world.characters[1].movement.forward = 1 diff --git a/server/combat_visibility_test.go b/server/combat_visibility_test.go @@ -26,7 +26,7 @@ func TestCombatVisibilityRejectsBothWallDirectionsAndAllowsClearRetry(t *testing for _, kind := range []string{"unarmed", "ranged"} { for _, reverse := range []bool{false, true} { t.Run(kind+map[bool]string{false: "/front", true: "/back"}[reverse], func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) if kind == "ranged" { world, _ = newRangedWorld(t) } @@ -137,7 +137,7 @@ func TestCombatVisibilitySpecialsRejectWithoutLocksOrClockChanges(t *testing.T) } func TestCombatVisibilityUsesNativeEyeHeightAboveLowScenery(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) addCombatWall(world) wall := world.geometry.surfaces[950<<16].primary wall.vertices[2][1], wall.groups[0].bounds[4] = 1, 1 diff --git a/server/corpse_credits_test.go b/server/corpse_credits_test.go @@ -9,7 +9,7 @@ import ( func newCorpseCreditWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.newCharacter() player.position = [3]float32{} if err := world.saveUser_locked(player); err != nil { diff --git a/server/critical_hit_test.go b/server/critical_hit_test.go @@ -130,7 +130,7 @@ func TestCriticalFistsAndNPCWeaponUseTheirOwnCatalogBonus(t *testing.T) { {"player fists", false, false, 8}, {"Leet Bite", true, true, 12}, {"prototype NPC", true, false, 5}, } { t.Run(scenario.name, func(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) attacker, target := world.characters[1], world.characters[1000000] if scenario.npc { attacker, target = target, attacker diff --git a/server/equipment_test.go b/server/equipment_test.go @@ -14,7 +14,7 @@ import ( func newEquipmentWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.characters[1] player.name, player.level, player.appearance = "Axe Owner", 1, 277 player.rotation[3] = 1 @@ -28,6 +28,21 @@ func newEquipmentWorld(t *testing.T) (*server, *combatTestConn) { return world, conn } +func TestEquipmentFixtureClosesDatabase(t *testing.T) { + var world *server + + if !t.Run("fixture", func(t *testing.T) { + world, _ = newEquipmentWorld(t) + }) { + return + } + defer world.db.Close() + + if connections := world.db.Stats().OpenConnections; connections != 0 { + t.Fatalf("fixture retained %d database connections", connections) + } +} + func TestEquipmentDelayedNativeMoveAndRestart(t *testing.T) { world, conn := newEquipmentWorld(t) observer := &combatTestConn{} diff --git a/server/flying_vehicle_test.go b/server/flying_vehicle_test.go @@ -14,7 +14,7 @@ import ( func newFlyingVehicleWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.newCharacter() player.stats = testCharacterStats() player.playfield, player.position = 800, [3]float32{600, 67, 700} diff --git a/server/grid_test.go b/server/grid_test.go @@ -8,7 +8,7 @@ import ( func newGridWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.newCharacter() player.stats = testCharacterStats() player.playfield = 800 diff --git a/server/insurance_test.go b/server/insurance_test.go @@ -74,7 +74,7 @@ func TestInsuranceNativeUseSurvivesRestartAndReturnsAfterDeath(t *testing.T) { func TestInsuranceRejectsInvalidUseWithoutSaving(t *testing.T) { for _, scenario := range []string{"Clan", "Neutral", "wrong zone", "too far", "dead", "loading", "unready", "replaced", "wrong owner", "wrong user", "wrong object", "wrong type", "reply", "wrong action", "11.0"} { t.Run(scenario, func(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) client, player := world.clients[1], world.characters[1] player.playfield = 705 player.position = [3]float32{918, 20.7, 578} @@ -135,7 +135,7 @@ func TestInsuranceRejectsInvalidUseWithoutSaving(t *testing.T) { func TestInsuranceRepeatedUsesShareTheGenericCommandSequence(t *testing.T) { t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) client, player := world.clients[1], world.characters[1] player.playfield = 705 player.position = [3]float32{918, 20.7, 578} @@ -163,7 +163,7 @@ func TestInsuranceRepeatedUsesShareTheGenericCommandSequence(t *testing.T) { func TestInsuranceSaveFailureDoesNotAcknowledgeOrChangeThePoint(t *testing.T) { t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.characters[1] player.playfield = 705 player.position = [3]float32{918, 20.7, 578} diff --git a/server/inventory_test.go b/server/inventory_test.go @@ -185,7 +185,7 @@ func TestInventoryRejectsForeignOccupiedAndStaleRequests(t *testing.T) { for _, scenario := range []string{"foreign move", "foreign target", "foreign delete", "wrong template", "occupied", "outside", "empty", "replaced", "loading", "repeat move", "repeat delete"} { t.Run(scenario, func(t *testing.T) { t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) world.characters[1].inventory = playerInventory{LastID: 2, Items: []ownedItem{ {ID: 1, Type: 51018, Template: 121567, Quality: 1, Slot: 64, Count: 1}, {ID: 2, Type: 51018, Template: 121567, Quality: 1, Slot: 65, Count: 1}, @@ -235,7 +235,7 @@ func TestInventoryRejectsForeignOccupiedAndStaleRequests(t *testing.T) { func TestInventoryFullGrantAndFailedSavePreserveItems(t *testing.T) { t.Chdir(t.TempDir()) - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) for range 30 { if granted, err := world.grantItem_locked(world.characters[1], 121567); err != nil || !granted { t.Fatalf("grant: %v %v", granted, err) diff --git a/server/loot_rights_test.go b/server/loot_rights_test.go @@ -10,7 +10,7 @@ import ( func newLootRightsWorld(t *testing.T) *server { t.Helper() - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) for range 3 { player := world.newCharacter() player.position = [3]float32{} diff --git a/server/map_purchases_test.go b/server/map_purchases_test.go @@ -32,7 +32,7 @@ func newMapPurchaseWorld(t *testing.T) (*server, *combatTestConn) { func TestMapTerminalsExposeOnlyTheSupportedReaderUpgradeSubset(t *testing.T) { for _, identity := range []uint32{3223848092, 3221750941, 3223913630, 3221685407, 3225552032, 3222602913, 3222537378, 3221226659} { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player, client := world.characters[1], world.clients[1] machine, exists := gamedata.ShopMachines[identity] if !exists { diff --git a/server/mouse_movement_test.go b/server/mouse_movement_test.go @@ -72,7 +72,7 @@ func TestMouseMovementRelaysFacingAndCheckpointsWithoutPerPacketWrites(t *testin func TestMouseMovementRejectsInvalidInputWithoutChangingPose(t *testing.T) { for _, scenario := range []string{"short", "long", "foreign owner", "wrong type", "wrong pass-on", "wrong action", "correction", "zero rotation", "NaN extra", "infinite extra", "replaced", "loading", "unready", "dead", "unsupported client"} { t.Run(scenario, func(t *testing.T) { - world, output := newCombatWorld() + world, output := newCombatWorld(t) player, client := world.characters[1], world.clients[1] player.position, player.rotation = [3]float32{60, 14, 54}, [4]float32{0, 0, 0, 1} request := mouseMovementRequest() diff --git a/server/nano_casting_test.go b/server/nano_casting_test.go @@ -12,7 +12,7 @@ import ( func newNanoCastingWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.characters[1] player.name = "Nano Caster" player.profession, player.nano = 8, 30 diff --git a/server/nano_kit_test.go b/server/nano_kit_test.go @@ -11,7 +11,7 @@ import ( func newNanoKitWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.characters[1] player.name, player.level, player.appearance = "Nano Kit Owner", 1, 277 player.rotation[3], player.stats = 1, testCharacterStats() diff --git a/server/nano_learning_test.go b/server/nano_learning_test.go @@ -11,7 +11,7 @@ import ( func newNanoLearningWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.newCharacter() player.stats = testCharacterStats() player.profession = 12 diff --git a/server/npc_pursuit_test.go b/server/npc_pursuit_test.go @@ -9,8 +9,9 @@ import ( "time" ) -func newNPCPursuitWorld() (*server, *combatTestConn, time.Time) { - world, conn := newCombatWorld() +func newNPCPursuitWorld(t *testing.T) (*server, *combatTestConn, time.Time) { + t.Helper() + world, conn := newCombatWorld(t) start := time.Now() world.characters[1].position = [3]float32{21, 0, 0} npc := world.characters[1000000] @@ -26,7 +27,7 @@ func newNPCPursuitWorld() (*server, *combatTestConn, time.Time) { } func TestNPCPursuitRetainsAttackDeadlineAndOnlyHitsInsideRange(t *testing.T) { - world, _, start := newNPCPursuitWorld() + world, _, start := newNPCPursuitWorld(t) deadline := world.characters[1000000].nextAttack for tick := 1; tick <= 8; tick++ { @@ -49,7 +50,7 @@ func TestNPCPursuitRetainsAttackDeadlineAndOnlyHitsInsideRange(t *testing.T) { } func TestNPCPursuitPublishesNativeWaypointRouteToBothObservers(t *testing.T) { - world, first, start := newNPCPursuitWorld() + world, first, start := newNPCPursuitWorld(t) second := &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950} world.clients[2] = &worldClient{id: 2, conn: second, target: true, ready: true, npcs: map[uint32]bool{1000000: true}} @@ -62,7 +63,7 @@ func TestNPCPursuitPublishesNativeWaypointRouteToBothObservers(t *testing.T) { } func TestNPCPursuitChangesDirectionForMovingTargetWithoutRestartingAttack(t *testing.T) { - world, conn, start := newNPCPursuitWorld() + world, conn, start := newNPCPursuitWorld(t) deadline := world.characters[1000000].nextAttack world.advanceNPCs(start.Add(250 * time.Millisecond)) world.characters[1].position = [3]float32{2.125, 0, 20} @@ -77,7 +78,7 @@ func TestNPCPursuitChangesDirectionForMovingTargetWithoutRestartingAttack(t *tes func TestNPCPursuitReturnsHomeAfterTargetLossWithoutHealingOrTeleporting(t *testing.T) { for _, scenario := range []string{"disconnect", "loading", "death", "zone"} { t.Run(scenario, func(t *testing.T) { - world, conn, start := newNPCPursuitWorld() + world, conn, start := newNPCPursuitWorld(t) world.advanceNPCs(start.Add(250 * time.Millisecond)) world.advanceNPCs(start.Add(500 * time.Millisecond)) world.characters[1000000].health = 50 @@ -108,7 +109,7 @@ func TestNPCPursuitReturnsHomeAfterTargetLossWithoutHealingOrTeleporting(t *test } func TestNPCPursuitCanBeEngagedAgainDuringReturn(t *testing.T) { - world, conn, start := newNPCPursuitWorld() + world, conn, start := newNPCPursuitWorld(t) world.advanceNPCs(start.Add(250 * time.Millisecond)) world.advanceNPCs(start.Add(500 * time.Millisecond)) world.clients[1].loading = true @@ -129,7 +130,7 @@ func TestNPCPursuitCanBeEngagedAgainDuringReturn(t *testing.T) { func TestNPCPursuitDeathClearsRouteAndNeverReturnsCorpse(t *testing.T) { for _, scenario := range []string{"pursuing", "returning"} { t.Run(scenario, func(t *testing.T) { - world, conn, start := newNPCPursuitWorld() + world, conn, start := newNPCPursuitWorld(t) world.advanceNPCs(start.Add(250 * time.Millisecond)) world.advanceNPCs(start.Add(500 * time.Millisecond)) if scenario == "returning" { @@ -155,7 +156,7 @@ func TestNPCPursuitDeathClearsRouteAndNeverReturnsCorpse(t *testing.T) { } func TestNPCPursuitJoiningObserverGetsSpawnBeforeRouteAndAttack(t *testing.T) { - world, _, start := newNPCPursuitWorld() + world, _, start := newNPCPursuitWorld(t) world.advanceNPCs(start.Add(250 * time.Millisecond)) observer := &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950} @@ -171,7 +172,7 @@ func TestNPCPursuitJoiningObserverGetsSpawnBeforeRouteAndAttack(t *testing.T) { func TestNPCPursuitExcludesUnadmittedProfiles(t *testing.T) { for _, scenario := range []string{"species", "profile"} { t.Run(scenario, func(t *testing.T) { - world, _, start := newNPCPursuitWorld() + world, _, start := newNPCPursuitWorld(t) switch scenario { case "species": world.characters[1000000].monsterData = 17657 diff --git a/server/npc_regeneration_test.go b/server/npc_regeneration_test.go @@ -8,8 +8,9 @@ import ( "time" ) -func newNPCRegenerationWorld() (*server, *combatTestConn, time.Time) { - world, conn := newCombatWorld() +func newNPCRegenerationWorld(t *testing.T) (*server, *combatTestConn, time.Time) { + t.Helper() + world, conn := newCombatWorld(t) world.characters[1000000].monsterData = 17655 world.characters[1000000].level = 1 world.characters[1000000].combatProfile = gamedata.NPCCombatProfiles[17655][1] @@ -21,7 +22,7 @@ func newNPCRegenerationWorld() (*server, *combatTestConn, time.Time) { } func TestNPCRegenerationUsesOneIdleCheckDespiteJitterAndBacklogs(t *testing.T) { - world, _, start := newNPCRegenerationWorld() + world, _, start := newNPCRegenerationWorld(t) world.advanceRegeneration(start) world.advanceRegeneration(start.Add(2*time.Second - time.Nanosecond)) @@ -44,7 +45,7 @@ func TestNPCRegenerationUsesNativeDefaultsWithoutASpeciesOrLevelGate(t *testing. monster uint32 level uint16 }{{30365, 1}, {17655, 7}, {30365, 300}} { - world, _, start := newNPCRegenerationWorld() + world, _, start := newNPCRegenerationWorld(t) npc := world.characters[1000000] npc.monsterData, npc.level, npc.combatProfile = scenario.monster, scenario.level, nil @@ -91,7 +92,7 @@ func TestNPCRegenerationUsesPeriodicWorldCheckpoint(t *testing.T) { } func TestNPCRegenerationCombatUsesNativeDeltaAndCounter(t *testing.T) { - world, conn, start := newNPCRegenerationWorld() + world, conn, start := newNPCRegenerationWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.characters[1000000].fighting = 1 world.fighting[1000000] = world.characters[1000000] @@ -112,7 +113,7 @@ func TestNPCRegenerationCombatUsesNativeDeltaAndCounter(t *testing.T) { } func TestNPCRegenerationDisengagementDoesNotHealTwiceOrResetPhase(t *testing.T) { - world, conn, start := newNPCRegenerationWorld() + world, conn, start := newNPCRegenerationWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) world.characters[1000000].fighting = 1 world.fighting[1000000] = world.characters[1000000] @@ -135,7 +136,7 @@ func TestNPCRegenerationDisengagementDoesNotHealTwiceOrResetPhase(t *testing.T) } func TestNPCRegenerationSendsQuietHealthOnlyToReadyObserversWithInterest(t *testing.T) { - world, first, start := newNPCRegenerationWorld() + world, first, start := newNPCRegenerationWorld(t) observers := make([]*combatTestConn, 5) for i := range observers { id := uint32(i + 2) @@ -165,7 +166,7 @@ func TestNPCRegenerationSendsQuietHealthOnlyToReadyObserversWithInterest(t *test } func TestNPCRegenerationDefersCorrectionForIncomingWeaponQueue(t *testing.T) { - world, conn, start := newNPCRegenerationWorld() + world, conn, start := newNPCRegenerationWorld(t) world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]) conn.packets = nil @@ -181,7 +182,7 @@ func TestNPCRegenerationClampsNativeIdleGainBoundaries(t *testing.T) { for _, scenario := range []struct{ maximum, initial, want uint32 }{ {100, 99, 100}, {120, 100, 101}, {121, 100, 101}, {239, 100, 101}, {240, 100, 102}, {480, 478, 480}, } { - world, _, start := newNPCRegenerationWorld() + world, _, start := newNPCRegenerationWorld(t) world.characters[1000000].combatProfile = &gamedata.NPCCombatProfile{Health: scenario.maximum} world.characters[1000000].health = scenario.initial @@ -197,7 +198,7 @@ func TestNPCRegenerationClampsNativeIdleGainBoundaries(t *testing.T) { func TestNPCRegenerationSkipsDeadAndPlayerCharacters(t *testing.T) { for _, scenario := range []string{"dead", "player"} { t.Run(scenario, func(t *testing.T) { - world, conn, start := newNPCRegenerationWorld() + world, conn, start := newNPCRegenerationWorld(t) switch scenario { case "dead": world.characters[1000000].health = 0 @@ -217,7 +218,7 @@ func TestNPCRegenerationSkipsDeadAndPlayerCharacters(t *testing.T) { } func TestNPCRegenerationContinuesWithoutObservers(t *testing.T) { - world, conn, start := newNPCRegenerationWorld() + world, conn, start := newNPCRegenerationWorld(t) delete(world.clients, 1) world.advanceRegeneration(start) @@ -229,7 +230,7 @@ func TestNPCRegenerationContinuesWithoutObservers(t *testing.T) { } func TestNPCRegenerationRespawnStartsWithFreshResourcesAndClock(t *testing.T) { - world, _, start := newNPCRegenerationWorld() + world, _, start := newNPCRegenerationWorld(t) delete(world.clients, 1) world.advanceRegeneration(start) world.advanceRegeneration(start.Add(2 * time.Second)) diff --git a/server/npc_shared_pursuit_test.go b/server/npc_shared_pursuit_test.go @@ -15,7 +15,7 @@ func TestAdmittedNPCProfilesSharePursuitAndReturn(t *testing.T) { {17687, 1}, {17687, 2}, {30252, 1}, {30252, 2}, {30252, 3}, {30252, 4}, {17660, 1}, {17660, 2}, {17660, 3}, {17660, 4}} { for _, roaming := range []bool{false, true} { t.Run(fmt.Sprintf("%d/%d/roaming=%t", profile.monster, profile.level, roaming), func(t *testing.T) { - world, _, start := newNPCPursuitWorld() + world, _, start := newNPCPursuitWorld(t) npc := world.characters[1000000] npc.monsterData, npc.level = profile.monster, profile.level npc.combatProfile = gamedata.NPCCombatProfiles[profile.monster][profile.level] @@ -59,7 +59,7 @@ func newFixedBossPursuitWorld(t *testing.T) (*server, *combatTestConn) { } func TestFixedNPCPursuitUsesRemainingThreatAfterTargetLoss(t *testing.T) { - world, _, start := newNPCPursuitWorld() + world, _, start := newNPCPursuitWorld(t) npc := world.characters[1000000] npc.motion.roaming = false npc.threat = map[uint32]int64{1: 20, 2: 10} diff --git a/server/npc_threat_test.go b/server/npc_threat_test.go @@ -6,15 +6,16 @@ import ( "time" ) -func newThreatWorld() (*server, *combatTestConn) { - world, conn := newCombatWorld() +func newThreatWorld(t *testing.T) (*server, *combatTestConn) { + t.Helper() + world, conn := newCombatWorld(t) world.characters[2] = &character{id: 2, playfield: 950, health: 100, stats: testCharacterStats()} world.clients[2] = &worldClient{id: 2, conn: &combatTestConn{}, ready: true, npcs: map[uint32]bool{1000000: true}} return world, conn } func TestNPCSwitchesToHigherDamageWithoutResettingItsAttackClock(t *testing.T) { - world, conn := newThreatWorld() + world, conn := newThreatWorld(t) npc := world.characters[1000000] world.handleCombat(world.clients[1], attackPacket(1, npc.id)[20:]) first := world.characters[1].nextAttack @@ -43,7 +44,7 @@ func TestNPCSwitchesToHigherDamageWithoutResettingItsAttackClock(t *testing.T) { } func TestNPCThreatIsIndividualEvenWhenDamageCreditBelongsToATeam(t *testing.T) { - world, _ := newThreatWorld() + world, _ := newThreatWorld(t) npc := world.characters[1000000] team := &playerTeam{id: 7} world.characters[1].team, world.characters[2].team = team, team @@ -65,7 +66,7 @@ func TestNPCThreatIsIndividualEvenWhenDamageCreditBelongsToATeam(t *testing.T) { func TestNPCChoosesAnEligibleParticipantWhenItsTargetBecomesUnavailable(t *testing.T) { for _, scenario := range []string{"offline", "dead", "other zone", "loading", "not ready", "no interest", "missing actor"} { t.Run(scenario, func(t *testing.T) { - world, _ := newThreatWorld() + world, _ := newThreatWorld(t) npc := world.characters[1000000] world.handleCombat(world.clients[1], attackPacket(1, npc.id)[20:]) world.advanceCombat(world.characters[1].nextAttack) @@ -102,7 +103,7 @@ func TestNPCChoosesAnEligibleParticipantWhenItsTargetBecomesUnavailable(t *testi func TestNPCRemovesZonedPlayersFromThreatButKeepsTheirDamageCredit(t *testing.T) { t.Chdir(t.TempDir()) - world, _ := newThreatWorld() + world, _ := newThreatWorld(t) npc := world.characters[1000000] world.handleCombat(world.clients[1], attackPacket(1, npc.id)[20:]) world.advanceCombat(world.characters[1].nextAttack) @@ -121,7 +122,7 @@ func TestNPCRemovesZonedPlayersFromThreatButKeepsTheirDamageCredit(t *testing.T) } func TestNPCDisconnectRemovesThreatAndRetargetsTheRemainingConnection(t *testing.T) { - world, _ := newThreatWorld() + world, _ := newThreatWorld(t) delete(world.clients, 1) peer := connectZoningClient(t, world, false) world.mutex.Lock() diff --git a/server/player_follow_test.go b/server/player_follow_test.go @@ -76,7 +76,7 @@ func playerFollowRequest(target uint32) []byte { func TestPlayerFollowRejectsUntrustedTargetsAndRoutes(t *testing.T) { for _, scenario := range []string{"short", "long", "foreign owner", "subject type", "target type", "pass-on", "scalar", "control", "correction", "waypoints", "missing target", "dead target", "other zone", "unseen NPC", "offline player", "loading player", "loading owner", "unready owner", "dead owner", "sitting owner", "replaced owner", "unsupported client"} { t.Run(scenario, func(t *testing.T) { - world, output := newCombatWorld() + world, output := newCombatWorld(t) player, client := world.characters[1], world.clients[1] target := world.characters[1000000] request := playerFollowRequest(target.id) @@ -138,7 +138,7 @@ func TestPlayerFollowRejectsUntrustedTargetsAndRoutes(t *testing.T) { } func TestPlayerFollowAcceleratesAndArrivesWithoutNativeMovementSnapshots(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player, client := world.characters[1], world.clients[1] world.characters[1000000].position = [3]float32{30, 0, 0} if err := world.handlePlayerFollow(client, playerFollowRequest(1000000)); err != nil { @@ -166,7 +166,7 @@ func TestPlayerFollowAcceleratesAndArrivesWithoutNativeMovementSnapshots(t *test } func TestPlayerFollowChainsUseOneTargetSnapshot(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[2] = &character{id: 2, playfield: 950, health: 100, position: [3]float32{10, 0, 0}} world.clients[2] = &worldClient{id: 2, ready: true, target: true, conn: &combatTestConn{}} if err := world.handlePlayerFollow(world.clients[1], playerFollowRequest(2)); err != nil { @@ -190,7 +190,7 @@ func TestPlayerFollowChainsUseOneTargetSnapshot(t *testing.T) { func TestPlayerFollowTargetLossClearsNativeController(t *testing.T) { for _, scenario := range []string{"despawn", "death", "zone", "interest", "owner death", "owner loading"} { t.Run(scenario, func(t *testing.T) { - world, output := newCombatWorld() + world, output := newCombatWorld(t) client := world.clients[1] world.characters[client.id].movement = heldPlayerMovement(world.characters[client.id], 1, time.Now()) if err := world.handlePlayerFollow(client, playerFollowRequest(1000000)); err != nil { @@ -301,7 +301,7 @@ func TestPlayerFollowMouseRotationPreservesControllerAndManualMovementCancels(t } func TestPlayerFollowRootSuspendsAndResumesController(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player, client := world.characters[1], world.clients[1] world.characters[1000000].position = [3]float32{30, 0, 0} if err := world.handlePlayerFollow(client, playerFollowRequest(1000000)); err != nil { @@ -411,7 +411,7 @@ func TestPlayerFollowArrivalToleranceAndCrossing(t *testing.T) { {"outside tolerance", 4.25, 0, .03}, {"crossed goal", 10, 7, 0}, } { t.Run(scenario.name, func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] world.characters[1000000].position = [3]float32{scenario.target, 0, 0} if err := world.handlePlayerFollow(world.clients[1], playerFollowRequest(1000000)); err != nil { @@ -451,7 +451,7 @@ func TestPlayerFollowMotionInterruptsCastAndRefundsReservation(t *testing.T) { } func TestPlayerFollowRetargetingPreservesVelocity(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1000000].position = [3]float32{30, 0, 0} client := world.clients[1] if err := world.handlePlayerFollow(client, playerFollowRequest(1000000)); err != nil { @@ -470,7 +470,7 @@ func TestPlayerFollowRetargetingPreservesVelocity(t *testing.T) { } func TestPlayerFollowSnapshotIncludesVelocityBeforeLateReplay(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] player.name, player.appearance = "Follower", 0x315 world.characters[1000000].position = [3]float32{30, 0, 0} @@ -489,7 +489,7 @@ func TestPlayerFollowSnapshotIncludesVelocityBeforeLateReplay(t *testing.T) { } func TestPlayerFollowChecksTradeRangeAfterBothTradersMove(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) world.characters[1000000].position = [3]float32{0, 0, 30} world.characters[2] = &character{id: 2, playfield: 950, health: 100, position: [3]float32{4.99999, 0, 0}} world.characters[1000001] = &character{id: 1000001, npc: true, playfield: 950, health: 100, position: [3]float32{4.99999, 0, 30}} @@ -517,7 +517,7 @@ func TestPlayerFollowChecksTradeRangeAfterBothTradersMove(t *testing.T) { } func TestPlayerFollowRunningStartUsesNativeRestThenForwardParameters(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] player.running = true player.stats.Speed.RunSpeed = 10 diff --git a/server/player_frozen_test.go b/server/player_frozen_test.go @@ -11,7 +11,7 @@ import ( func TestPlayerRestrictedStandFreezesHelperWithoutClearingRest(t *testing.T) { for _, running := range []bool{false, true} { t.Run(fmt.Sprint(running), func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] player.sitting, player.running = true, running player.movement.prepare(player, time.Now().Add(time.Second)) @@ -114,7 +114,7 @@ func TestPlayerRestrictionExpiryUsesFrozenAdmissionAndWaterState(t *testing.T) { func TestPlayerFullStopPreservesModeAndIndependentMotion(t *testing.T) { for _, mode := range []byte{1, 3, 7, 8} { t.Run(fmt.Sprint(mode), func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] player.running = true player.movement.prepare(player, time.Now()) diff --git a/server/player_posture_test.go b/server/player_posture_test.go @@ -25,7 +25,7 @@ func TestPlayerSitUsesComponentAdmissionBeforeChangingRest(t *testing.T) { {"seated", [10]byte{8, 1, 0, 1, 0, 5, 4, 1, 0, 1}, true}, } { t.Run(scenario.name, func(t *testing.T) { - world, owner := newCombatWorld() + world, owner := newCombatWorld(t) player := world.characters[1] player.running, player.sitting = scenario.components[0] == 3, scenario.components[0] == 8 player.movement.prepare(player, time.Now().Add(time.Second)) @@ -58,7 +58,7 @@ func TestPlayerSitUsesComponentAdmissionBeforeChangingRest(t *testing.T) { func TestPlayerSitHaltPreservesGravityAndIndependentControls(t *testing.T) { for _, speed := range []float32{0, 5} { t.Run(fmt.Sprint(speed), func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] player.rotation = [4]float32{0, 0, 0, 1} player.followTarget = 1000000 @@ -127,7 +127,7 @@ func TestPlayerStandPreservesMotionAndRequiresMovementPermission(t *testing.T) { for _, restricted := range []bool{false, true} { for _, running := range []bool{false, true} { t.Run(fmt.Sprintf("restricted%t/running%t", restricted, running), func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] player.sitting, player.running = true, running player.movement.prepare(player, time.Now().Add(time.Second)) @@ -159,7 +159,7 @@ func TestPlayerStandPreservesMotionAndRequiresMovementPermission(t *testing.T) { } func TestPlayerRejectedSitKeepsStandingRecovery(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) player := world.characters[1] player.movement.prepare(player, time.Now().Add(time.Second)) player.movement.components[1], player.movement.components[2], player.movement.forward = 3, 1, 1 diff --git a/server/player_water_posture_test.go b/server/player_water_posture_test.go @@ -214,7 +214,7 @@ func TestPlayerWaterPostureFollowRejectsNonSteeringModes(t *testing.T) { for _, mode := range []byte{1, 8, 9} { for _, sitting := range []bool{false, true} { t.Run(fmt.Sprintf("mode%d/sitting%t", mode, sitting), func(t *testing.T) { - world, output := newCombatWorld() + world, output := newCombatWorld(t) player, client := world.characters[1], world.clients[1] player.sitting = sitting player.movement.prepare(player, time.Now().Add(time.Second)) diff --git a/server/profession_resources_test.go b/server/profession_resources_test.go @@ -52,7 +52,7 @@ func TestProfessionEditClampsResourcesAndPersistsCoefficients(t *testing.T) { } { t.Run(fmt.Sprintf("%dto%d", scenario.from, scenario.to), func(t *testing.T) { t.Chdir(t.TempDir()) - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.newCharacter() player.stats = testCharacterStats() player.level, player.profession = 190, scenario.from diff --git a/server/ranged_test.go b/server/ranged_test.go @@ -12,7 +12,7 @@ import ( func newRangedWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) world.nextNPC = 1000001 t.Cleanup(func() { world.db.Close() }) player := world.characters[1] diff --git a/server/reclaim_test.go b/server/reclaim_test.go @@ -29,7 +29,7 @@ func reclaimTakeRequest(slot uint32) []byte { func newReclaimWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.characters[1] player.name, player.level, player.appearance = "Reclaimer", 10, 0x515 player.playfield, player.position, player.rotation = 705, [3]float32{918, 20.7, 578}, [4]float32{0, 0, 0, 1} diff --git a/server/regeneration_delta_test.go b/server/regeneration_delta_test.go @@ -32,7 +32,7 @@ func TestRegenerationUsesSignedDeltasAndNativeFullResourceGates(t *testing.T) { definition.Sections[0].Functions = &functions gamedata.ItemTemplates[191531] = &definition t.Cleanup(func() { gamedata.ItemTemplates[191531] = original }) - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) player := world.characters[1] player.inventory.Items = []ownedItem{{Type: 51022, Template: 191531, Quality: 1, Slot: 45}} player.health, player.nano = scenario.health, scenario.nano @@ -85,7 +85,7 @@ func TestRegenerationAddsAuthoredEquipmentAndNanoDeltas(t *testing.T) { {"attacking", false, true, 3422, 25, 5, 59}, } { t.Run(source.name+"/"+posture.name, func(t *testing.T) { - world, conn, start := newRegenerationWorld() + world, conn, start := newRegenerationWorld(t) player := world.characters[1] player.level, player.stats.Body.BodyDevelopment = 50, 198 player.inventory.Items, player.activeNanos = source.items, source.nanos @@ -114,7 +114,7 @@ func TestRegenerationAddsAuthoredEquipmentAndNanoDeltas(t *testing.T) { func TestRegenerationDeltasClampWithoutRevivingOrChangingSkippedActors(t *testing.T) { for _, scenario := range []string{"below cap", "at cap", "dead", "loading", "offline", "not ready"} { t.Run(scenario, func(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) player := world.characters[1] player.inventory.Items = []ownedItem{{Type: 51022, Template: 191531, Quality: 1, Slot: 45}} player.health, player.nano = 36, 34 diff --git a/server/regeneration_test.go b/server/regeneration_test.go @@ -7,8 +7,9 @@ import ( "time" ) -func newRegenerationWorld() (*server, *combatTestConn, time.Time) { - world, conn := newCombatWorld() +func newRegenerationWorld(t *testing.T) (*server, *combatTestConn, time.Time) { + t.Helper() + world, conn := newCombatWorld(t) world.characters[1].appearance = 1 << 4 world.characters[1].level = 1 world.characters[1].health = 20 @@ -18,7 +19,7 @@ func newRegenerationWorld() (*server, *combatTestConn, time.Time) { } func TestRegenerationStandingUsesNativeCounterAndNanoInterval(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) for second := 2; second <= 56; second += 2 { world.advanceRegeneration(start.Add(time.Duration(second) * time.Second)) @@ -35,7 +36,7 @@ func TestRegenerationStandingUsesNativeCounterAndNanoInterval(t *testing.T) { } func TestRegenerationSittingHalvesHealthInterval(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) world.characters[1].sitting = true for second := 2; second <= 14; second += 2 { @@ -48,7 +49,7 @@ func TestRegenerationSittingHalvesHealthInterval(t *testing.T) { } func TestRegenerationCombatUsesLongerIntervalsWithoutAbsoluteHealth(t *testing.T) { - world, conn, start := newRegenerationWorld() + world, conn, start := newRegenerationWorld(t) if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { t.Fatal(err) } @@ -73,7 +74,7 @@ func TestRegenerationCombatUsesLongerIntervalsWithoutAbsoluteHealth(t *testing.T } func TestRegenerationDoesNotCorrectHealthWhileOnlyTheEnemyAttacks(t *testing.T) { - world, conn, start := newRegenerationWorld() + world, conn, start := newRegenerationWorld(t) world.characters[1000000].fighting = 1 world.fighting[1000000] = world.characters[1000000] @@ -85,7 +86,7 @@ func TestRegenerationDoesNotCorrectHealthWhileOnlyTheEnemyAttacks(t *testing.T) } func TestRegenerationCorrectsAbsoluteIdleResourcesForOwnerAndObserver(t *testing.T) { - world, conn, start := newRegenerationWorld() + world, conn, start := newRegenerationWorld(t) observer := &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950} world.clients[2] = &worldClient{id: 2, conn: observer, target: true, ready: true} @@ -104,7 +105,7 @@ func TestRegenerationCorrectsAbsoluteIdleResourcesForOwnerAndObserver(t *testing } func TestRegenerationClampsHealthAndNanoToNativeMaximums(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) world.characters[1].health = 36 world.characters[1].nano = 34 world.clients[1].regenerationSeconds = 810 @@ -119,7 +120,7 @@ func TestRegenerationClampsHealthAndNanoToNativeMaximums(t *testing.T) { func TestRegenerationSkipsDeadLoadingOfflineAndNPCCharacters(t *testing.T) { for _, scenario := range []string{"dead", "loading", "not ready", "offline", "NPC"} { t.Run(scenario, func(t *testing.T) { - world, conn, start := newRegenerationWorld() + world, conn, start := newRegenerationWorld(t) world.clients[1].regenerationSeconds = 810 switch scenario { case "dead": @@ -145,7 +146,7 @@ func TestRegenerationSkipsDeadLoadingOfflineAndNPCCharacters(t *testing.T) { } func TestRegenerationLateUpdateDoesNotReplayMissedTicks(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) world.advanceRegeneration(start.Add(time.Hour)) world.advanceRegeneration(start.Add(time.Hour)) @@ -156,7 +157,7 @@ func TestRegenerationLateUpdateDoesNotReplayMissedTicks(t *testing.T) { } func TestRegenerationStoppingAttackPreservesCounterPhase(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { t.Fatal(err) } diff --git a/server/remote_combat_stats_test.go b/server/remote_combat_stats_test.go @@ -89,7 +89,7 @@ func TestRemotePlayerSpawnCarriesUnmodifiedCombatFoundations(t *testing.T) { func TestRemoteAggDefChangesReachOnlyReadySamePlayfieldObservers(t *testing.T) { for _, value := range []int32{-100, -1, 0, 1, 100, -101, 101} { t.Run(fmt.Sprint(value), func(t *testing.T) { - world, owner := newCombatWorld() + world, owner := newCombatWorld(t) connections := []*combatTestConn{{}, {}, {}, {}} for index, conn := range connections { id := uint32(index + 2) diff --git a/server/resurrection_test.go b/server/resurrection_test.go @@ -77,9 +77,9 @@ func TestResurrectionNativeRequestRedirectsAndPersistsBeforeReconnect(t *testing } func TestResurrectionOnlyOnceAndClearsCombatForBothObservers(t *testing.T) { - world, conn := newCombatWorld() - loadResurrectionLocations(t, world) t.Chdir(t.TempDir()) + world, conn := newCombatWorld(t) + loadResurrectionLocations(t, world) player := world.characters[1] if err := world.saveUser_locked(player); err != nil { t.Fatal(err) @@ -128,7 +128,7 @@ func TestResurrectionOnlyOnceAndClearsCombatForBothObservers(t *testing.T) { func TestResurrectionRejectsInvalidRequests(t *testing.T) { for _, scenario := range []string{"alive", "loading", "unready", "replaced", "wrong owner", "wrong type"} { t.Run(scenario, func(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) client := world.clients[1] world.characters[1].health = 0 body := resurrectionRequest(1)[20:] @@ -159,9 +159,9 @@ func TestResurrectionRejectsInvalidRequests(t *testing.T) { } func TestResurrectionSaveFailureLeavesDeadCharacterAndSessionUnchanged(t *testing.T) { - world, conn := newCombatWorld() - loadResurrectionLocations(t, world) t.Chdir(t.TempDir()) + world, conn := newCombatWorld(t) + loadResurrectionLocations(t, world) if err := os.WriteFile("data", nil, 0600); err != nil { t.Fatal(err) } diff --git a/server/scene_visibility_test.go b/server/scene_visibility_test.go @@ -68,7 +68,7 @@ func TestSceneVisibilityRequiresDirectRoomPairAndDestinationSurface(t *testing.T } func TestSceneVisibilityRejectsOutdoorTerrainRidge(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) addCombatWall(world) world.geometry.surfaces[950<<16] = nil world.geometry.terrain[950] = &terrain{width: 3, height: 2, boundsWidth: 3, boundsHeight: 2, spacing: 10, scale: 1, diff --git a/server/shop_machines_test.go b/server/shop_machines_test.go @@ -40,7 +40,7 @@ func TestShopUseEvaluatesAuthoredAccessContracts(t *testing.T) { {"missing Can Use", 3221225572, 0, 1, 1, 0, false}, } { t.Run(scenario.name, func(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player, client := world.characters[1], world.clients[1] machine := gamedata.ShopMachines[scenario.machine] player.playfield, player.position = machine.Playfield, machine.Position @@ -75,7 +75,7 @@ func TestShopUseEvaluatesAuthoredAccessContracts(t *testing.T) { } func TestShopFullUpdatePreservesRotationAndHighLowMesh(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player, client := world.characters[1], world.clients[1] player.playfield, player.position = 1180, [3]float32{190.88559, 4.61, 166.79538} player.appearance = 0x315 diff --git a/server/shops_test.go b/server/shops_test.go @@ -425,7 +425,7 @@ func TestShopCommitFailureRollsBackCashAndOwnership(t *testing.T) { func TestShopUseRejectsIneligibleAndForgedRequests(t *testing.T) { for _, scenario := range []string{"Clan", "Neutral", "wrong zone", "too far", "dead", "loading", "unready", "replaced", "wrong owner", "wrong caller", "wrong machine", "wrong type", "reply", "wrong action", "11.0", "replay"} { t.Run(scenario, func(t *testing.T) { - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) client, player := world.clients[1], world.characters[1] player.position, player.appearance = [3]float32{60, 14.75, 53}, 0x515 body := shopUseRequest(1) diff --git a/server/signed_stats_test.go b/server/signed_stats_test.go @@ -176,7 +176,7 @@ func TestSignedLiteracyReachesDurableVendorSale(t *testing.T) { func TestSignedNegativeBodyDevelopmentRegeneratesWithoutUnsignedWrap(t *testing.T) { for _, full := range []bool{false, true} { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) player := world.characters[1] player.level = 200 player.activeNanos = syntheticNanoModifiers(t, [][2]int32{{152, -407}}) @@ -198,7 +198,7 @@ func TestSignedNegativeBodyDevelopmentRegeneratesWithoutUnsignedWrap(t *testing. } func TestSignedNegativeMartialArtsDoesNotWrapDamageScaling(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player := world.characters[1] player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1} player.activeNanos = syntheticNanoModifiers(t, [][2]int32{{100, -105}}) diff --git a/server/social_actions_test.go b/server/social_actions_test.go @@ -122,7 +122,7 @@ func TestSocialActionCompletesNativeCommandsWithoutDatabaseWrites(t *testing.T) func TestSocialActionRejectsMalformedUnauthorizedAndUnsupportedRequests(t *testing.T) { for _, scenario := range []string{"short prefix", "short command", "trailing data", "foreign owner", "wrong type", "wrong pass-on", "verified response", "unknown verification", "zero action", "unknown action", "replaced", "unready", "loading", "dead", "unsupported client"} { t.Run(scenario, func(t *testing.T) { - world, owner := newCombatWorld() + world, owner := newCombatWorld(t) client := world.clients[1] observer := &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950, health: 100} @@ -183,7 +183,7 @@ func TestSocialActionRejectsMalformedUnauthorizedAndUnsupportedRequests(t *testi func TestSocialActionExcludesOtherPlayfieldsAndUnreadyObservers(t *testing.T) { for _, scenario := range []string{"other playfield", "unready observer"} { t.Run(scenario, func(t *testing.T) { - world, owner := newCombatWorld() + world, owner := newCombatWorld(t) observer := &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950, health: 100} world.clients[2] = &worldClient{id: 2, target: true, ready: true, conn: observer} @@ -203,7 +203,7 @@ func TestSocialActionExcludesOtherPlayfieldsAndUnreadyObservers(t *testing.T) { } func TestSocialActionKeepsPostureAndHeldMovement(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) player, client := world.characters[1], world.clients[1] player.sitting, player.running = true, true world.characters[client.id].movement.forward, world.characters[client.id].movement.strafe, world.characters[client.id].movement.turn = 1, 1, 1 diff --git a/server/stacks_test.go b/server/stacks_test.go @@ -27,7 +27,7 @@ func stackActionPacket(owner, action, slot, argument uint32) []byte { func newStackWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.characters[1] player.name, player.level, player.appearance = "Stack Owner", 1, 277 player.rotation[3], player.stats = 1, testCharacterStats() diff --git a/server/stats_test.go b/server/stats_test.go @@ -67,7 +67,7 @@ func TestCharacterStatsPersistThroughProfileEditAndRestart(t *testing.T) { func TestCharacterStatsProfileEditClampsBothResources(t *testing.T) { t.Chdir(t.TempDir()) - world, _, _ := newRegenerationWorld() + world, _, _ := newRegenerationWorld(t) world.characters[1].stats = testCharacterStats() world.characters[1].stats.Body.BodyDevelopment = 300 world.characters[1].stats.Body.NanoPool = 300 @@ -84,7 +84,7 @@ func TestCharacterStatsProfileEditClampsBothResources(t *testing.T) { func TestRegenerationUsesEditedAbilitiesAndBodyDevelopment(t *testing.T) { for _, sitting := range []bool{false, true} { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) world.characters[1].stats = testCharacterStats() world.characters[1].stats.Abilities.Stamina, world.characters[1].stats.Abilities.Psychic = 60, 120 world.characters[1].stats.Body.BodyDevelopment, world.characters[1].stats.Body.NanoPool = 200, 100 @@ -105,7 +105,7 @@ func TestRegenerationUsesEditedAbilitiesAndBodyDevelopment(t *testing.T) { } func TestRegenerationHandlesMinimumIntervals(t *testing.T) { - world, _, start := newRegenerationWorld() + world, _, start := newRegenerationWorld(t) world.characters[1].stats = testCharacterStats() world.characters[1].stats.Abilities.Stamina, world.characters[1].stats.Abilities.Psychic = 1000, 1000 diff --git a/server/treatment_kit_test.go b/server/treatment_kit_test.go @@ -11,7 +11,7 @@ import ( func newTreatmentKitWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.characters[1] player.name, player.level, player.appearance = "Treatment Kit Owner", 1, 277 player.rotation[3], player.stats = 1, testCharacterStats() diff --git a/server/vehicle_test.go b/server/vehicle_test.go @@ -12,7 +12,7 @@ import ( func newVehicleWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() t.Chdir(t.TempDir()) - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.newCharacter() player.stats = testCharacterStats() player.playfield, player.position = 800, [3]float32{600, 67, 700} diff --git a/server/whompah_test.go b/server/whompah_test.go @@ -9,7 +9,7 @@ import ( func newWhomPahWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() - world, conn := newCombatWorld() + world, conn := newCombatWorld(t) player := world.newCharacter() player.playfield = 705 player.position = [3]float32{910.12, 16.9, 487.01} diff --git a/server/world_loading_test.go b/server/world_loading_test.go @@ -52,7 +52,7 @@ func TestWorldLoadingObserverReceivesPeriodicLifecycleAfterActorSnapshot(t *test } func TestWorldLoadingObserverReceivesWeaponTimelineWithoutBecomingATarget(t *testing.T) { - world, owner := newCombatWorld() + world, owner := newCombatWorld(t) observer := &combatTestConn{} world.characters[2] = &character{id: 2, playfield: 950, health: 100} world.clients[2] = &worldClient{id: 2, conn: observer, target: true, ready: true, loading: true, npcs: map[uint32]bool{1000000: true}} diff --git a/server/world_output_test.go b/server/world_output_test.go @@ -29,7 +29,7 @@ func (conn *blockingCloseConn) Close() error { } func TestWorldReplacementDoesNotWaitForOldTransportClose(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) host, peer := net.Pipe() conn := &blockingCloseConn{Conn: host, started: make(chan struct{}), release: make(chan struct{})} old := world.clients[1] diff --git a/server/world_posture_test.go b/server/world_posture_test.go @@ -91,7 +91,7 @@ func TestWorldObserverEntryReceivesExistingPosture(t *testing.T) { for _, sitting := range []bool{false, true} { for _, running := range []bool{false, true} { t.Run(map[bool]string{false: "standing", true: "sitting"}[sitting]+"/"+map[bool]string{false: "walk", true: "run"}[running], func(t *testing.T) { - world, _ := newCombatWorld() + world, _ := newCombatWorld(t) delete(world.characters, 1000000) world.characters[1].name, world.characters[1].sitting, world.characters[1].running = "Patient", sitting, running world.characters[2] = &character{id: 2, name: "Observer", playfield: 950, health: 100} diff --git a/server/zone_movement_test.go b/server/zone_movement_test.go @@ -71,7 +71,7 @@ func TestZoneMovementReplaysShopAndCheckpointsWithoutPerPacketWrites(t *testing. func TestZoneMovementRejectsInvalidMessagesBeforeSceneReplay(t *testing.T) { for _, scenario := range []string{"short", "long", "foreign owner", "wrong type", "wrong pass-on", "wrong action", "correction", "zero rotation", "replaced", "loading", "unready", "dead", "unsupported client"} { t.Run(scenario, func(t *testing.T) { - world, output := newCombatWorld() + world, output := newCombatWorld(t) player, client := world.characters[1], world.clients[1] player.position, player.rotation = [3]float32{60, 14, 54}, [4]float32{0, 0, 0, 1} request := zoneMovementRequest()