From 5317135416df06c3926182f12df26c14fd0b4a4f Mon Sep 17 00:00:00 2001 From: Vitalii Date: Wed, 19 Jul 2023 13:03:30 +0300 Subject: [PATCH] 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 --- satellite/console/service.go | 2 +- satellite/payments/billing/chore_test.go | 15 ++++++--------- scripts/testdata/satellite-config.yaml.lock | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/satellite/console/service.go b/satellite/console/service.go index 014eb6b9c..196e46d3d 100644 --- a/satellite/console/service.go +++ b/satellite/console/service.go @@ -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 diff --git a/satellite/payments/billing/chore_test.go b/satellite/payments/billing/chore_test.go index 22914c0a0..b5f100a99 100644 --- a/satellite/payments/billing/chore_test.go +++ b/satellite/payments/billing/chore_test.go @@ -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 { diff --git a/scripts/testdata/satellite-config.yaml.lock b/scripts/testdata/satellite-config.yaml.lock index e7c05f32c..14ff6750b 100755 --- a/scripts/testdata/satellite-config.yaml.lock +++ b/scripts/testdata/satellite-config.yaml.lock @@ -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