feat(tutorial): add /tutorial/gift_receive — grant + receipt + idempotent re-claim

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-28 12:13:12 -04:00
parent 2034034c1b
commit f6f9216162
5 changed files with 323 additions and 1 deletions

View File

@@ -384,6 +384,18 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
return viewer.MissionData.TutorialState;
}
/// <summary>
/// Reads the viewer's current currency balances from the DB. Used by gift_receive tests
/// to assert delta grants after claiming tutorial presents.
/// </summary>
public async Task<(ulong Crystals, ulong Rupees, ulong RedEther)> GetViewerCurrencyAsync(long viewerId)
{
using var scope = Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
var viewer = await db.Viewers.FirstAsync(v => v.Id == viewerId);
return (viewer.Currency.Crystals, viewer.Currency.Rupees, viewer.Currency.RedEther);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);