@@ -36,9 +36,43 @@ func TestAccountStore(t *testing.T) {
36
36
_ , err = store .NewAccount (ctx , 123 , time.Time {}, "0011223344556677" )
37
37
require .ErrorContains (t , err , "is not allowed as it can be mistaken" )
38
38
39
+ now := time .Now ()
40
+
39
41
// 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.
40
74
acct1 .CurrentBalance = - 500
41
- acct1 .ExpirationDate = time . Now ()
75
+ acct1 .ExpirationDate = now
42
76
acct1 .Payments [lntypes.Hash {12 , 34 , 56 , 78 }] = & PaymentEntry {
43
77
Status : lnrpc .Payment_FAILED ,
44
78
FullAmount : 123456 ,
@@ -49,8 +83,6 @@ func TestAccountStore(t *testing.T) {
49
83
}
50
84
acct1 .Invoices [lntypes.Hash {12 , 34 , 56 , 78 }] = struct {}{}
51
85
acct1 .Invoices [lntypes.Hash {34 , 56 , 78 , 90 }] = struct {}{}
52
- err = store .UpdateAccount (ctx , acct1 )
53
- require .NoError (t , err )
54
86
55
87
dbAccount , err = store .Account (ctx , acct1 .ID )
56
88
require .NoError (t , err )
@@ -96,8 +128,8 @@ func assertEqualAccounts(t *testing.T, expected,
96
128
actual .LastUpdate = time.Time {}
97
129
98
130
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 ())
101
133
102
134
// Restore the old values to not influence the tests.
103
135
expected .ExpirationDate = expectedExpiry
0 commit comments