fix: resolve 4 pre-existing test failures in channelserver

- Guard nil listener/acceptConns in Server.Shutdown() to prevent panic
  in test servers that don't bind a network listener
- Remove redundant userBinaryPartsLock in TestHandleMsgMhfLoaddata that
  caused a deadlock with handleMsgMhfLoaddata's own lock acquisition
- Increase test save blob size from 200 to 150000 bytes to accommodate
  ZZ save pointer offsets (up to 146728)
- Initialize MHFEquipment.Sigils[].Effects slices in test data to
  prevent index-out-of-range panic in SerializeWarehouseEquipment
- Insert warehouse row before updating it (UPDATE on 0 rows is not an
  error, so the INSERT fallback never triggered)
- Use COALESCE for nullable kouryou_point column in kill counter test
- Fix duplicate-add test expectation (CSV helper correctly deduplicates)
This commit is contained in:
Houmgaor
2026-02-18 15:59:36 +01:00
parent 898ada3d99
commit a2609e26a0
5 changed files with 53 additions and 45 deletions

View File

@@ -179,11 +179,8 @@ func TestSessionLifecycle_WarehouseDataPersistence(t *testing.T) {
serializedEquip := mhfitem.SerializeWarehouseEquipment(equipment)
// Save to warehouse directly (simulating a save handler)
_, err := db.Exec(`
INSERT INTO warehouse (character_id, equip0)
VALUES ($1, $2)
ON CONFLICT (character_id) DO UPDATE SET equip0 = $2
`, charID, serializedEquip)
_, _ = db.Exec("INSERT INTO warehouse (character_id) VALUES ($1) ON CONFLICT DO NOTHING", charID)
_, err := db.Exec("UPDATE warehouse SET equip0 = $1 WHERE character_id = $2", serializedEquip, charID)
if err != nil {
t.Fatalf("Failed to save warehouse: %v", err)
}
@@ -562,11 +559,15 @@ func TestSessionLifecycle_RapidReconnect(t *testing.T) {
// Helper function to create test equipment item with proper initialization
func createTestEquipmentItem(itemID uint16, warehouseID uint32) mhfitem.MHFEquipment {
sigils := make([]mhfitem.MHFSigil, 3)
for i := range sigils {
sigils[i].Effects = make([]mhfitem.MHFSigilEffect, 3)
}
return mhfitem.MHFEquipment{
ItemID: itemID,
WarehouseID: warehouseID,
Decorations: make([]mhfitem.MHFItem, 3),
Sigils: make([]mhfitem.MHFSigil, 3),
Sigils: sigils,
}
}