satellite/payments: fix config value for auto upgrade user tier flow

Fixed config value which indicates how many base units of US micro dollars are needed to auto upgrade user to paid tier.

Change-Id: I22821ac22fc3eaeeea21c6dec4e6912025df63aa
This commit is contained in:
Vitalii 2023-07-19 13:03:30 +03:00 committed by Vitalii Shpital
parent 7cc873a62a
commit 5317135416
3 changed files with 9 additions and 12 deletions

View File

@ -194,7 +194,7 @@ type Config struct {
LoginAttemptsWithoutPenalty int `help:"number of times user can try to login without penalty" default:"3"`
FailedLoginPenalty float64 `help:"incremental duration of penalty for failed login attempts in minutes" default:"2.0"`
ProjectInvitationExpiration time.Duration `help:"duration that project member invitations are valid for" default:"168h"`
UserBalanceForUpgrade int64 `help:"amount of base units of US micro dollars needed to upgrade user's tier status'" default:"100000"`
UserBalanceForUpgrade int64 `help:"amount of base units of US micro dollars needed to upgrade user's tier status" default:"10000000"`
UsageLimits UsageLimitsConfig
Captcha CaptchaConfig
Session SessionConfig

View File

@ -172,8 +172,8 @@ func TestChore_UpgradeUserObserver(t *testing.T) {
billing.ObserverUpgradeUser: console.NewUpgradeUserObserver(db.Console(), db.Billing(), sat.Config.Console.UsageLimits, sat.Config.Console.UserBalanceForUpgrade),
}
amount1 := int64(2) // $2
amount2 := int64(8) // $8
amount1 := int64(200) // $2
amount2 := int64(800) // $8
transaction1 := makeFakeTransaction(user.ID, billing.StorjScanSource, billing.TransactionTypeCredit, amount1, ts, `{"fake": "transaction1"}`)
transaction2 := makeFakeTransaction(user.ID, billing.StorjScanSource, billing.TransactionTypeCredit, amount2, ts.Add(time.Second*2), `{"fake": "transaction2"}`)
paymentTypes := []billing.PaymentType{
@ -191,7 +191,7 @@ func TestChore_UpgradeUserObserver(t *testing.T) {
})
defer ctx.Check(chore.Close)
t.Run("user not upgraded", func(t *testing.T) {
t.Run("user upgrade status", func(t *testing.T) {
chore.TransactionCycle.Pause()
chore.TransactionCycle.TriggerWait()
chore.TransactionCycle.Pause()
@ -213,16 +213,13 @@ func TestChore_UpgradeUserObserver(t *testing.T) {
require.Equal(t, usageLimitsConfig.Bandwidth.Free, *p.BandwidthLimit)
require.Equal(t, usageLimitsConfig.Segment.Free, *p.SegmentLimit)
}
})
t.Run("user upgraded", func(t *testing.T) {
chore.TransactionCycle.Pause()
chore.TransactionCycle.TriggerWait()
chore.TransactionCycle.Pause()
balance, err := db.Billing().GetBalance(ctx, user.ID)
balance, err = db.Billing().GetBalance(ctx, user.ID)
require.NoError(t, err)
expected := currency.AmountFromBaseUnits((amount1+amount2)*int64(10000), currency.USDollarsMicro)
expected = currency.AmountFromBaseUnits((amount1+amount2)*int64(10000), currency.USDollarsMicro)
require.True(t, expected.Equal(balance))
user, err = db.Console().Users().Get(ctx, user.ID)
@ -233,7 +230,7 @@ func TestChore_UpgradeUserObserver(t *testing.T) {
require.Equal(t, usageLimitsConfig.Segment.Paid, user.ProjectSegmentLimit)
require.Equal(t, usageLimitsConfig.Project.Paid, user.ProjectLimit)
projects, err := db.Console().Projects().GetOwn(ctx, user.ID)
projects, err = db.Console().Projects().GetOwn(ctx, user.ID)
require.NoError(t, err)
for _, p := range projects {

View File

@ -406,8 +406,8 @@ compensation.withheld-percents: 75,75,75,50,50,50,25,25,25,0,0,0,0,0,0
# whether to use vuetify POC project
# console.use-vuetify-project: false
# amount of base units of US micro dollars needed to upgrade user's tier status'
# console.user-balance-for-upgrade: 100000
# amount of base units of US micro dollars needed to upgrade user's tier status
# console.user-balance-for-upgrade: 10000000
# whether to load templates on each request
# console.watch: false