fix(gift): drop RowVersion (SQLite incompatible) + restore wire reward_type map
[Timestamp] byte[] doesn't work under SQLite (the test backend) — EF expects the DB to populate it on insert, but SQLite has no equivalent of Postgres's xmin. The WHERE Status = Unclaimed filter plus IInventoryService's viewer-level concurrency is the practical defense; RowVersion was only a backstop. Regenerated the migration without the RowVersion column. Wire reward_type on the gift endpoint uses a gift-specific scheme that diverges from UserGoodsType for currencies: wire 1 = Crystal (enum=2), wire 9 = Rupy (enum=9), wire 4 = Item (enum=4). A naked cast resolves wire 1 to UserGoodsType.RedEther and silently grants the wrong wallet — restored the explicit WireRewardTypeToUserGoodsType map from the old tutorial controller. Retrofits existing GiftControllerTests to call SeedTutorialPresentsAsync on the new helper (RegisterViewer doesn't auto-seed; only the prod signup path does). All 7 existing tests pass.
This commit is contained in:
@@ -16,6 +16,7 @@ public class GiftControllerTests
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
|
||||
await factory.SeedTutorialPresentsAsync(viewerId);
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var response = await client.PostAsync("/tutorial/gift_top",
|
||||
@@ -54,6 +55,7 @@ public class GiftControllerTests
|
||||
using var factory = new SVSimTestFactory();
|
||||
await factory.SeedGlobalsAsync();
|
||||
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
|
||||
await factory.SeedTutorialPresentsAsync(viewerId);
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var pre = await factory.GetViewerCurrencyAsync(viewerId);
|
||||
@@ -100,6 +102,7 @@ public class GiftControllerTests
|
||||
using var factory = new SVSimTestFactory();
|
||||
await factory.SeedGlobalsAsync();
|
||||
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
|
||||
await factory.SeedTutorialPresentsAsync(viewerId);
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var json = $$"""{"present_id_array":["71478626"],"state":1,{{BaseAuthBlock}}}""";
|
||||
@@ -129,6 +132,7 @@ public class GiftControllerTests
|
||||
using var factory = new SVSimTestFactory();
|
||||
await factory.SeedGlobalsAsync();
|
||||
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
|
||||
await factory.SeedTutorialPresentsAsync(viewerId);
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var json = $$"""{"present_id_array":["71478626","71478627"],"state":1,{{BaseAuthBlock}}}""";
|
||||
@@ -167,6 +171,7 @@ public class GiftControllerTests
|
||||
// 100, not the hardcoded 41 the endpoint used to emit, or the client's tutorial
|
||||
// state machine regresses on a no-op retry.
|
||||
long viewerId = await factory.SeedViewerAsync(tutorialState: 100);
|
||||
await factory.SeedTutorialPresentsAsync(viewerId);
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var json = $$"""{"present_id_array":["71478626"],"state":1,{{BaseAuthBlock}}}""";
|
||||
@@ -192,6 +197,7 @@ public class GiftControllerTests
|
||||
// found and incremented, not duplicated. The (ViewerId, ItemId) unique index
|
||||
// added 2026-05-25 would otherwise throw on SaveChanges → 500 to the client.
|
||||
await factory.SeedOwnedItemAsync(viewerId, itemId: 1, count: 5, itemName: "PreOwnedItem");
|
||||
await factory.SeedTutorialPresentsAsync(viewerId);
|
||||
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
@@ -224,6 +230,7 @@ public class GiftControllerTests
|
||||
using var factory = new SVSimTestFactory();
|
||||
await factory.SeedGlobalsAsync();
|
||||
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
|
||||
await factory.SeedTutorialPresentsAsync(viewerId);
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var preFirst = await factory.GetViewerCurrencyAsync(viewerId);
|
||||
|
||||
Reference in New Issue
Block a user