refactor: deprecate int32 (#7025)

* refactor: deprecate int32

* fix(db): reject legacy user quota schemas at startup

* fix(quota): enforce wallet bounds and saturating billing conversions

* fix(rate-limit): keep count*duration from wrapping int64

* fix: error message
This commit is contained in:
Seefs
2026-08-26 20:57:54 +08:00
committed by GitHub
parent 2d8e50bf36
commit a073f74b38
35 changed files with 445 additions and 116 deletions
+6 -6
View File
@@ -297,7 +297,7 @@ func TestRechargeEpayRejectsQuotaOverflowBeforeCompletingOrder(t *testing.T) {
truncateTables(t)
oldQuotaPerUnit := common.QuotaPerUnit
common.QuotaPerUnit = float64(common.MaxQuota)
common.QuotaPerUnit = float64(common.MaxWalletQuota + 1)
t.Cleanup(func() { common.QuotaPerUnit = oldQuotaPerUnit })
user := insertUserForPaymentGuardTest(t, 505, 3)
@@ -323,15 +323,15 @@ func TestRechargeEpayEnforcesFinalWalletQuotaLimit(t *testing.T) {
}{
{
name: "allows exact highest representable wallet balance",
currentQuota: common.MaxQuota - 1 - 1_000_000,
wantQuota: common.MaxQuota - 1,
currentQuota: common.MaxWalletQuota - 1_000_000,
wantQuota: common.MaxWalletQuota,
wantStatus: common.TopUpStatusSuccess,
},
{
name: "rejects balance above int32 quota domain",
currentQuota: common.MaxQuota - 1_000_000,
name: "rejects balance above wallet quota domain",
currentQuota: common.MaxWalletQuota - 999_999,
wantErr: true,
wantQuota: common.MaxQuota - 1_000_000,
wantQuota: common.MaxWalletQuota - 999_999,
wantStatus: common.TopUpStatusPending,
},
}