Skip to content

Commit d458242

Browse files
committed
accounts: remove UpdateAccount calls from store_test
1 parent 8cd2a70 commit d458242

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

accounts/store_test.go

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,43 @@ func TestAccountStore(t *testing.T) {
3636
_, err = store.NewAccount(ctx, 123, time.Time{}, "0011223344556677")
3737
require.ErrorContains(t, err, "is not allowed as it can be mistaken")
3838

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

5587
dbAccount, err = store.Account(ctx, acct1.ID)
5688
require.NoError(t, err)
@@ -96,8 +128,8 @@ func assertEqualAccounts(t *testing.T, expected,
96128
actual.LastUpdate = time.Time{}
97129

98130
require.Equal(t, expected, actual)
99-
require.Equal(t, expectedExpiry.UnixNano(), actualExpiry.UnixNano())
100-
require.Equal(t, expectedUpdate.UnixNano(), actualUpdate.UnixNano())
131+
require.Equal(t, expectedExpiry.Unix(), actualExpiry.Unix())
132+
require.Equal(t, expectedUpdate.Unix(), actualUpdate.Unix())
101133

102134
// Restore the old values to not influence the tests.
103135
expected.ExpirationDate = expectedExpiry

0 commit comments

Comments
 (0)