Skip to content

Commit e965f4f

Browse files
committed
accounts: remove UpdateAccount calls from store_test
Remove the call to UpdateAccount from the TestAccountStore test and instead replace it with all the other calls we have added.
1 parent 8b1c9a2 commit e965f4f

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

accounts/store_test.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,41 @@ func TestAccountStore(t *testing.T) {
3838
_, err = store.NewAccount(ctx, 123, time.Time{}, "0011223344556677")
3939
require.ErrorContains(t, err, "is not allowed as it can be mistaken")
4040

41+
now := clock.Now()
42+
4143
// Update all values of the account that we can modify.
44+
//
45+
// Update the balance and expiry.
46+
err = store.UpdateAccountBalanceAndExpiry(
47+
ctx, acct1.ID, fn.Some(int64(-500)), fn.Some(now),
48+
)
49+
require.NoError(t, err)
50+
51+
// Add 2 payments.
52+
_, err = store.UpsertAccountPayment(
53+
ctx, acct1.ID, lntypes.Hash{12, 34, 56, 78}, 123456,
54+
lnrpc.Payment_FAILED,
55+
)
56+
require.NoError(t, err)
57+
58+
_, err = store.UpsertAccountPayment(
59+
ctx, acct1.ID, lntypes.Hash{34, 56, 78, 90}, 789456123789,
60+
lnrpc.Payment_SUCCEEDED,
61+
)
62+
require.NoError(t, err)
63+
64+
// Add 2 invoices.
65+
err = store.AddAccountInvoice(
66+
ctx, acct1.ID, lntypes.Hash{12, 34, 56, 78},
67+
)
68+
require.NoError(t, err)
69+
err = store.AddAccountInvoice(
70+
ctx, acct1.ID, lntypes.Hash{34, 56, 78, 90},
71+
)
72+
require.NoError(t, err)
73+
74+
// Update the in-memory account so that we can compare it with the
75+
// account we get from the store.
4276
acct1.CurrentBalance = -500
4377
acct1.ExpirationDate = clock.Now()
4478
acct1.Payments[lntypes.Hash{12, 34, 56, 78}] = &PaymentEntry{
@@ -51,8 +85,6 @@ func TestAccountStore(t *testing.T) {
5185
}
5286
acct1.Invoices[lntypes.Hash{12, 34, 56, 78}] = struct{}{}
5387
acct1.Invoices[lntypes.Hash{34, 56, 78, 90}] = struct{}{}
54-
err = store.UpdateAccount(ctx, acct1)
55-
require.NoError(t, err)
5688

5789
dbAccount, err = store.Account(ctx, acct1.ID)
5890
require.NoError(t, err)

0 commit comments

Comments
 (0)