@@ -38,7 +38,41 @@ func TestAccountStore(t *testing.T) {
38
38
_ , err = store .NewAccount (ctx , 123 , time.Time {}, "0011223344556677" )
39
39
require .ErrorContains (t , err , "is not allowed as it can be mistaken" )
40
40
41
+ now := clock .Now ()
42
+
41
43
// 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.
42
76
acct1 .CurrentBalance = - 500
43
77
acct1 .ExpirationDate = clock .Now ()
44
78
acct1 .Payments [lntypes.Hash {12 , 34 , 56 , 78 }] = & PaymentEntry {
@@ -51,8 +85,6 @@ func TestAccountStore(t *testing.T) {
51
85
}
52
86
acct1 .Invoices [lntypes.Hash {12 , 34 , 56 , 78 }] = struct {}{}
53
87
acct1 .Invoices [lntypes.Hash {34 , 56 , 78 , 90 }] = struct {}{}
54
- err = store .UpdateAccount (ctx , acct1 )
55
- require .NoError (t , err )
56
88
57
89
dbAccount , err = store .Account (ctx , acct1 .ID )
58
90
require .NoError (t , err )
0 commit comments