commit 2285b01e2d5979b144efb11abda6eb36ef86e6d3
parent 635e28a30d05a08f74fc3d921bac21c3a99e7cc9
Author: anon <anon@example.com>
Date: Sun, 25 Oct 2026 15:05:08 +0000
Reject partial mixed shop transactions after ignored database writes
Require changed item and placement writes to reach their intended rows, and
verify conditional inventory metadata and allocation updates before commit.
Keep the existing draft and live state intact when any required write fails.
Cover five charged and zero-value sales funding two purchases, 13 SQL and
commit failure points, retry/repeated acceptance, removed funding, and exact
charge-based affordability. Verify native rejection, committed replies,
page reload and real restart; record the remaining live-skill quote issue.
Validation: full server/catalog suite (5096 tests/subtests), focused family,
three race repetitions, vet, build and GPU WASM owner/observer checks.
Diffstat:
5 files changed, 344 insertions(+), 7 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -679,6 +679,20 @@ introduction and starting-item gameplay remain open below.
replies and reconnect/restart. Keep every owned item and credit accounted
for on both successful and rejected paths. Include effective skill changes
while a basket is open and removal of the sale funding a selected purchase.
+- [x] Verify one mixed five-row sale and two-package purchase atomically.
+ Check: partially used charges, a zero-credit sale, removal/re-addition of
+ funding, NoDrop and filled-backpack rejection preserve every item; SQL errors,
+ ignored required writes and commit failure roll back cash, ownership and ID
+ allocation together. Retry and repeated Accept commit once; native reload
+ and server restart retain the result. See [mixed baskets](docs/shop-multi-sale.md).
+- [ ] Resolve native shop quotes after live Computer Literacy changes.
+ Check: displayed BUY, affordability and final debit agree across skill rises
+ and drops, partial removal, an empty selection and re-addition. Reproduced:
+ adding a 230-credit Lock Pick at skill 39, then receiving +10, leaves BUY 230;
+ removal leaves 2 with no selected items, and current Accept charges 228.
+ Recover the historical pricing/lifecycle policy before freezing or rebuilding
+ drafts; ordinary TradeUpdated and Remove/Add do not repair the cache.
+ See [live quote findings](docs/shop-multi-sale.md).
- [x] Restore removed/cancelled sale offers into native first-free inventory
slots, rather than their original positions. Preserve stable TradeInv slots,
ownership and quantities; commit placement before acknowledgement and retain
diff --git a/docs/shop-multi-sale.md b/docs/shop-multi-sale.md
@@ -0,0 +1,101 @@
+# Mixed shop baskets and transaction failure checks
+
+Shop acceptance commits sold instances, purchased instances, their placements,
+the resulting cash and the item-ID allocation in one SQLite transaction.
+The inventory writer requires each changed item and placement write to affect
+its intended row. It also reads back conditional player metadata and world
+allocation updates before commit. An unchanged value needs no write; a required
+write silently skipped by SQLite must fail the entire transaction. The existing
+in-memory inventory and shop draft remain available for retry, and no Complete
+reply is sent before commit.
+
+The regression uses `RAISE(IGNORE)` as well as ordinary SQL errors. Without
+checking required writes, an ignored statement can report success while other
+statements commit, leaving cash, ownership or allocation inconsistent. The
+checks add reads rather than rewriting unchanged rows. Idle-world and player
+checkpoint cadence remain covered by the full suite.
+
+## Automated mixed-sale coverage
+
+`server/shop_multi_sale_test.go` stages five original QL1 items at the Omni
+Tools terminal, template 99491, with effective Computer Literacy 40:
+
+| Offered item | Remaining count | Awarded credits |
+| --- | ---: | ---: |
+| Kinetic Axe 209283 | 1 | 734 |
+| Treatment Laboratory 25812 | 49 | 8 |
+| Nano Recharger 85366 | 25 | 1 |
+| Treatment Laboratory 25812 | 1 | 0 |
+| Bullets 21605 | 100 | 1 |
+
+The 744-credit sale funds two Lock Picks at 228 each, leaving 288 credits.
+The zero-credit row is consumed along with the other sales. Every package
+receives one new persistent instance in a vacated first-free slot. Repeated
+Accept and cold restore preserve precisely that outcome.
+
+Thirteen injected failures cover error and ignored writes for cash, sold item
+deletion, sold placement deletion, purchased item insertion, purchase placement
+insertion and allocation, plus a deferred foreign-key failure at COMMIT.
+Each leaves durable state, live inventory, allocation and draft unchanged;
+removing the fault permits one successful outcome despite repeated Accept.
+
+Additional cases remove the funding sale while purchases remain selected,
+distinguish one remaining laboratory charge from 49 when funding a purchase,
+and sell a zero-value row with a trigger prohibiting any unchanged cash write.
+The native pending-funds estimate counts each sale row's whole price, so it
+cannot replace the charge-aware authoritative check at Accept.
+
+## Native WASM checks
+
+Two headed Chromium clients use the GPU and the shared HTTPS preview.
+Fixtures are created through the public control panel. Mouse and keyboard
+actions drive transactions; native heap, wire and SQLite reads verify results.
+The run checks:
+
+- A NoDrop solar pistol is rejected locally without changing the draft.
+- Offering a filled backpack reaches the server, aborts the draft and restores
+ the previously offered axe. The backpack and its contained Lock Pick survive.
+- All five sale rows quote 744 and two selected purchases quote 456. Removing
+ the axe leaves the purchases selected with only 10 sale credits. Native
+ Accept reports the 446-credit shortage and sends no Accept request.
+- Re-offering the axe completes with 288 credits. SQLite already contains both
+ new instances and the final balance when Complete reaches the client.
+- The owner sees all expected items after page reload. The other player's
+ private inventory and cash remain unchanged. The backpack opens with its
+ original contained item after the sales.
+- A real server restart and fresh native client restore the exact purchased
+ identities, final cash and backpack contents, including the later live-skill
+ test's third purchase. No transaction is replayed during reconnection.
+
+Artifacts, exact instance IDs, screenshots, packet checks, restart verification
+and fixture cleanup are retained under `local/shop-multi-sale-smoke/`.
+The full server/catalog suite passes 5,096 tests and subtests; the new cases
+also pass three repetitions under the race detector. Vet and server build pass.
+This completes this bounded mixed-basket and atomicity check, not the broader
+shop audit or historical stock/pricing reconstruction.
+
+## Open live Computer Literacy quote discrepancy
+
+The run also reproduces a stale native BUY total. At effective skill 39 a
+selected Lock Pick displays 230. A second player casts Computer Literacy
+Proficiency 26396, raising effective skill to 49 while the shop stays open.
+The selected total remains 230. Removing that selection leaves a two-credit
+BUY total with an empty basket; re-adding it returns the cache to 230. Accept
+uses the current server quote of 228 and reduces cash from 288 to 60.
+
+Original KKR `100a96b0` adds the current price to a cached aggregate;
+`100a97b0` subtracts the current price when removing a selection. DDR
+`10048d50` reads that aggregate rather than repricing the selected rows.
+TradeUpdated redraws it without rebuilding the aggregate. Remove/Add at the
+new skill preserves the residue. Complete's vending branch consumes sales and
+clears selections without debiting purchases; the server's absolute cash
+update supplies the resulting balance.
+
+These are client contracts and a reproduced current-server discrepancy.
+They do not establish whether the historical server froze prices, rebuilt
+drafts, or applied another policy after a skill change. An ordinary quote
+refresh primitive has not been recovered. Resolve that evidence and verify
+both skill increases and decreases before choosing a pricing/lifecycle change.
+The retained original evidence and precise call-path limits are in
+`local/shop-multi-sale-research/native/README.md` and
+`completion-and-repricing.md`.
diff --git a/docs/shops.md b/docs/shops.md
@@ -166,6 +166,9 @@ purchased instances and the resulting cash commit in the same SQLite
transaction. Sale proceeds can fund a purchase and vacated sale slots can hold
its result. Rejection or a database failure publishes none of those changes;
concurrent/repeated Accept or a lost reply cannot allocate another instance.
+Required SQL writes are checked even when SQLite silently ignores a statement.
+The five-row mixed basket, rollback/retry cases and open live-skill quote
+discrepancy are recorded in [mixed-shop verification](shop-multi-sale.md).
Complete clears the native selection and consumes staged sales; it does not
create purchases or debit cash. After the durable commit the server sends
diff --git a/server/item_database.go b/server/item_database.go
@@ -71,6 +71,13 @@ func (server *server) persistItems_locked(store itemStore) error {
references.Credits, references.MapFlags[0], references.MapFlags[1], references.MapFlags[2], id); err != nil {
return err
}
+ // Conditional updates may legitimately be unchanged, but never silently lost.
+ var savedID uint32
+ if err := tx.QueryRow(`SELECT id FROM players WHERE id=? AND
+ (credits, map_options, map_area_1, map_area_2) IS (?, ?, ?, ?)`,
+ id, references.Credits, references.MapFlags[0], references.MapFlags[1], references.MapFlags[2]).Scan(&savedID); err != nil {
+ return fmt.Errorf("player %d inventory metadata was not saved: %w", id, err)
+ }
// Learned programs are a set: retain existing rows and delete removed programs.
programs := []any{id}
@@ -106,8 +113,9 @@ func (server *server) persistItems_locked(store itemStore) error {
// Delete changed locations first so swaps respect the unique slot constraints.
for id, previous := range server.itemPlacements {
if next, exists := placements[id]; !exists || previous != next {
- if _, err := tx.Exec("DELETE FROM item_locations WHERE item_id = ?", id); err != nil {
- return err
+ var removedID uint32
+ if err := tx.QueryRow("DELETE FROM item_locations WHERE item_id = ? RETURNING item_id", id).Scan(&removedID); err != nil {
+ return fmt.Errorf("remove item %d placement: %w", id, err)
}
}
}
@@ -126,14 +134,15 @@ func (server *server) persistItems_locked(store itemStore) error {
if exists && previous.Type == record.Type && previous.Template == record.Template && previous.Quality == record.Quality && previous.Count == record.Count && previous.Ammo == record.Ammo {
continue
}
- if _, err := tx.Exec("INSERT INTO items (id, type, template, quality, count, ammo) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET type=excluded.type, template=excluded.template, quality=excluded.quality, count=excluded.count, ammo=excluded.ammo", id, record.Type, record.Template, record.Quality, record.Count, record.Ammo); err != nil {
+ if err := upsertRecord(tx, "items", id, "type, template, quality, count, ammo", []any{record.Type, record.Template, record.Quality, record.Count, record.Ammo}); err != nil {
return err
}
}
for id := range server.items {
if _, exists := store.Items[id]; !exists {
- if _, err := tx.Exec("DELETE FROM items WHERE id = ?", id); err != nil {
- return err
+ var removedID uint32
+ if err := tx.QueryRow("DELETE FROM items WHERE id = ? RETURNING id", id).Scan(&removedID); err != nil {
+ return fmt.Errorf("remove item %d: %w", id, err)
}
}
}
@@ -157,8 +166,9 @@ func (server *server) persistItems_locked(store itemStore) error {
if placement.ReclaimAt != "" {
reclaim = placement.ReclaimAt
}
- if _, err := tx.Exec("INSERT INTO item_locations (item_id, player_id, bank_player_id, backpack_id, corpse_id, slot, reclaim_at) VALUES (?, ?, ?, ?, ?, ?, ?)", id, player, bank, backpack, corpse, placement.Slot, reclaim); err != nil {
- return err
+ var savedID uint32
+ if err := tx.QueryRow("INSERT INTO item_locations (item_id, player_id, bank_player_id, backpack_id, corpse_id, slot, reclaim_at) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING item_id", id, player, bank, backpack, corpse, placement.Slot, reclaim).Scan(&savedID); err != nil {
+ return fmt.Errorf("save item %d placement: %w", id, err)
}
}
if store.edited != nil {
@@ -198,6 +208,12 @@ func (server *server) persistItems_locked(store itemStore) error {
store.LastID, server.nextCharacter, server.nextNPC, server.gameSeconds, started.UTC().Format(time.RFC3339Nano)); err != nil {
return err
}
+ var savedID uint32
+ if err := tx.QueryRow(`SELECT id FROM world WHERE id=1 AND last_item_id=? AND last_character_id>=?
+ AND (last_npc_id, game_seconds, clock_started, npcs_initialized) IS (?, ?, ?, 1)`,
+ store.LastID, server.nextCharacter, server.nextNPC, server.gameSeconds, started.UTC().Format(time.RFC3339Nano)).Scan(&savedID); err != nil {
+ return fmt.Errorf("world inventory allocation was not saved: %w", err)
+ }
if err := tx.Commit(); err != nil {
return err
}
diff --git a/server/shop_multi_sale_test.go b/server/shop_multi_sale_test.go
@@ -0,0 +1,203 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "reflect"
+ "slices"
+ "testing"
+)
+
+func newMultiSaleWorld(t *testing.T) (*server, *combatTestConn) {
+ t.Helper()
+ world, conn := newPurchaseWorld(t)
+ player := world.characters[1]
+ player.inventory.Credits, player.inventory.LastID = 0, 5
+ player.inventory.Items = []ownedItem{
+ {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ {ID: 2, Type: 51005, Template: 25812, Quality: 1, Slot: 65, Count: 49},
+ {ID: 3, Type: 51005, Template: 85366, Quality: 1, Slot: 66, Count: 25},
+ {ID: 4, Type: 51005, Template: 25812, Quality: 1, Slot: 67, Count: 1},
+ {ID: 5, Type: 51005, Template: 21605, Quality: 1, Slot: 68, Count: 100},
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ for slot := uint32(64); slot <= 68; slot++ {
+ if err := world.handleTrade(world.clients[1], shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{50000, 1}, [2]uint32{104, slot})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ for range 2 {
+ if err := world.handleTrade(world.clients[1], shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{51035, 3221488799}, [2]uint32{111, 0})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if world.clients[1].shop == nil || len(world.clients[1].shop.items) != 5 || world.clients[1].shop.purchases[0] != 2 {
+ t.Fatal("mixed charged-item basket was not staged")
+ }
+ conn.packets = nil
+ return world, conn
+}
+
+func TestShopMultiSaleCommitsChargedStacksAndZeroValueRowsOnce(t *testing.T) {
+ world, conn := newMultiSaleWorld(t)
+ client := world.clients[1]
+ accept := shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]
+
+ for range 2 {
+ if err := world.handleTrade(client, accept); err != nil {
+ t.Fatal(err)
+ }
+ }
+ cold := newTestInventoryServer(t).characters[1].inventory
+
+ want := []ownedItem{
+ {ID: 6, Type: 51005, Template: 95577, Quality: 1, Slot: 64, Count: 1},
+ {ID: 7, Type: 51005, Template: 95577, Quality: 1, Slot: 65, Count: 1},
+ }
+ if cold.Credits != 288 || world.characters[1].inventory.Credits != 288 || !reflect.DeepEqual(cold.Items, want) ||
+ !reflect.DeepEqual(world.characters[1].inventory.Items, want) || world.nextItem != 7 || client.shop != nil || len(world.items) != 2 ||
+ len(conn.packets) != 4 || binary.BigEndian.Uint32(conn.packets[0][33:37]) != 3 {
+ t.Fatalf("mixed sale lost a charge, zero-value row, purchase, identity or credit: %+v", cold)
+ }
+}
+
+func TestShopMultiSaleFailedWritesCannotCommitPartialCashOrOwnership(t *testing.T) {
+ for _, failure := range []struct{ name, statement string }{
+ {"credits", "CREATE TRIGGER fail_sale BEFORE UPDATE OF credits ON players BEGIN SELECT RAISE(FAIL, 'credits'); END"},
+ {"ignored credits", "CREATE TRIGGER fail_sale BEFORE UPDATE OF credits ON players BEGIN SELECT RAISE(IGNORE); END"},
+ {"sold item", "CREATE TRIGGER fail_sale BEFORE DELETE ON items WHEN OLD.id=2 BEGIN SELECT RAISE(FAIL, 'sold item'); END"},
+ {"ignored sold item", "CREATE TRIGGER fail_sale BEFORE DELETE ON items WHEN OLD.id=2 BEGIN SELECT RAISE(IGNORE); END"},
+ {"sold placement", "CREATE TRIGGER fail_sale BEFORE DELETE ON item_locations WHEN OLD.item_id=2 BEGIN SELECT RAISE(FAIL, 'sold placement'); END"},
+ {"ignored sold placement", "CREATE TRIGGER fail_sale BEFORE DELETE ON item_locations WHEN OLD.item_id=2 BEGIN SELECT RAISE(IGNORE); END"},
+ {"purchased item", "CREATE TRIGGER fail_sale BEFORE INSERT ON items WHEN NEW.id=6 BEGIN SELECT RAISE(FAIL, 'purchased item'); END"},
+ {"ignored purchased item", "CREATE TRIGGER fail_sale BEFORE INSERT ON items WHEN NEW.id=6 BEGIN SELECT RAISE(IGNORE); END"},
+ {"purchase placement", "CREATE TRIGGER fail_sale BEFORE INSERT ON item_locations WHEN NEW.item_id=6 BEGIN SELECT RAISE(FAIL, 'purchase placement'); END"},
+ {"ignored purchase placement", "CREATE TRIGGER fail_sale BEFORE INSERT ON item_locations WHEN NEW.item_id=6 BEGIN SELECT RAISE(IGNORE); END"},
+ {"allocation", "CREATE TRIGGER fail_sale BEFORE UPDATE OF last_item_id ON world BEGIN SELECT RAISE(FAIL, 'allocation'); END"},
+ {"ignored allocation", "CREATE TRIGGER fail_sale BEFORE UPDATE OF last_item_id ON world BEGIN SELECT RAISE(IGNORE); END"},
+ {"commit", "CREATE TABLE pending_sale (id INTEGER REFERENCES characters(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER fail_sale AFTER UPDATE OF credits ON players BEGIN INSERT INTO pending_sale VALUES (999999); END"},
+ } {
+ t.Run(failure.name, func(t *testing.T) {
+ world, conn := newMultiSaleWorld(t)
+ client, player := world.clients[1], world.characters[1]
+ items := slices.Clone(player.inventory.Items)
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := world.db.Exec(failure.statement); err != nil {
+ t.Fatal(err)
+ }
+ accept := shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]
+
+ failed := world.handleTrade(client, accept)
+ after, readErr := readTestItemStore(world)
+
+ if failed == nil || readErr != nil || !bytes.Equal(before, after) || player.inventory.Credits != 0 ||
+ !reflect.DeepEqual(player.inventory.Items, items) || world.nextItem != 5 || len(conn.packets) != 0 || client.shop == nil ||
+ len(client.shop.items) != 5 || client.shop.purchases[0] != 2 {
+ t.Fatalf("failed %s write published a partial basket: err=%v read=%v cash=%d", failure.name, failed, readErr, player.inventory.Credits)
+ }
+ if _, err := world.db.Exec("DROP TRIGGER fail_sale"); err != nil {
+ t.Fatal(err)
+ }
+ for range 2 {
+ if err := world.handleTrade(client, accept); err != nil {
+ t.Fatal(err)
+ }
+ }
+ cold := newTestInventoryServer(t).characters[1].inventory
+ if cold.Credits != 288 || len(cold.Items) != 2 || cold.Items[0].ID != 6 || cold.Items[1].ID != 7 || world.nextItem != 7 {
+ t.Fatal("retry after ignored write lost or duplicated the committed transaction", cold)
+ }
+ })
+ }
+}
+
+func TestShopMultiSaleRemovingItsFundingPreservesEveryItem(t *testing.T) {
+ world, _ := newMultiSaleWorld(t)
+ client, player := world.clients[1], world.characters[1]
+ before := slices.Clone(player.inventory.Items)
+
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 5, [2]uint32{50000, 1}, [2]uint32{108, 0})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if client.shop == nil || len(client.shop.items) != 4 || client.shop.purchases[0] != 2 {
+ t.Fatal("removing a sale unexpectedly cleared the remaining draft")
+ }
+ for range 2 {
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ cold := newTestInventoryServer(t).characters[1].inventory
+
+ if cold.Credits != 0 || !reflect.DeepEqual(cold.Items, before) || !reflect.DeepEqual(player.inventory.Items, before) ||
+ world.nextItem != 5 || client.shop != nil || len(world.items) != 5 {
+ t.Fatal("unfunded acceptance changed cash, charges or ownership", cold)
+ }
+}
+
+func TestShopChargedSaleFundingUsesItsRemainingChargesAtAccept(t *testing.T) {
+ for _, charges := range []uint16{1, 49} {
+ t.Run(map[uint16]string{1: "insufficient", 49: "exact fit"}[charges], func(t *testing.T) {
+ world, _ := newPurchaseWorld(t)
+ client, player := world.clients[1], world.characters[1]
+ player.inventory.Credits = 220
+ player.inventory.Items = []ownedItem{{ID: 1, Type: 51005, Template: 25812, Quality: 1, Slot: 64, Count: charges}}
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ for _, request := range [][]byte{
+ shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{50000, 1}, [2]uint32{104, 64})[20:],
+ shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{51035, 3221488799}, [2]uint32{111, 0})[20:],
+ } {
+ if err := world.handleTrade(client, request); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if client.shop == nil || client.shop.purchases[0] != 1 {
+ t.Fatal("native pending funding did not admit the draft")
+ }
+
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t).characters[1].inventory
+
+ want, cash, next := ownedItem{ID: 1, Type: 51005, Template: 25812, Quality: 1, Slot: 64, Count: 1}, uint32(220), uint32(1)
+ if charges == 49 {
+ want, cash, next = ownedItem{ID: 2, Type: 51005, Template: 95577, Quality: 1, Slot: 64, Count: 1}, 0, 2
+ }
+ if cold.Credits != cash || !reflect.DeepEqual(cold.Items, []ownedItem{want}) || world.nextItem != next || client.shop != nil {
+ t.Fatal("charged sale funding used a package price instead of remaining charges", cold)
+ }
+ })
+ }
+}
+
+func TestShopZeroValueSaleDoesNotRewriteUnchangedCash(t *testing.T) {
+ world, _ := newPurchaseWorld(t)
+ client, player := world.clients[1], world.characters[1]
+ player.inventory.Items = []ownedItem{{ID: 1, Type: 51005, Template: 25812, Quality: 1, Slot: 64, Count: 1}}
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := world.db.Exec("CREATE TRIGGER fail_cash BEFORE UPDATE OF credits ON players BEGIN SELECT RAISE(FAIL, 'unchanged cash'); END"); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{50000, 1}, [2]uint32{104, 64})[20:]); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t).characters[1].inventory
+
+ if cold.Credits != 1000 || len(cold.Items) != 0 || len(world.items) != 0 || world.nextItem != 1 || client.shop != nil {
+ t.Fatal("zero-value sale changed cash or retained the sold row", cold)
+ }
+}