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:
gamer147
2026-06-08 20:44:52 -04:00
parent ca36792be3
commit f1d881b26a
6 changed files with 22 additions and 25 deletions

View File

@@ -84,8 +84,12 @@ public class GiftController : SVSimController
{
if (state == 1)
{
// Wire reward_type on the gift endpoint follows a gift-specific scheme that
// diverges from UserGoodsType for currencies: wire "1" means Crystal (enum=2),
// wire "9" means Rupy (enum=9), wire "4" means Item (enum=4). A naked cast would
// resolve wire 1 -> UserGoodsType.RedEther and silently grant the wrong wallet.
var granted = await tx.GrantAsync(
(UserGoodsType)p.RewardType,
WireRewardTypeToUserGoodsType(p.RewardType),
p.RewardDetailId,
(int)p.RewardCount);
@@ -161,6 +165,14 @@ public class GiftController : SVSimController
};
}
private static UserGoodsType WireRewardTypeToUserGoodsType(int wireType) => wireType switch
{
1 => UserGoodsType.Crystal,
4 => UserGoodsType.Item,
9 => UserGoodsType.Rupy,
_ => throw new InvalidOperationException($"Unmapped gift wire reward_type {wireType}"),
};
private async Task<(List<ViewerPresent> Unclaimed, List<ViewerPresent> History)> ReadTopWindowAsync(
long viewerId, int page)
{