@@ -144,7 +144,9 @@ func TestKVPaymentsDBSwitchFail(t *testing.T) {
144
144
attempt .AttemptID = 1
145
145
_ , err = paymentDB .RegisterAttempt (info .PaymentIdentifier , attempt )
146
146
require .NoError (t , err , "unable to send htlc message" )
147
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusInFlight )
147
+ assertPaymentStatus (
148
+ t , paymentDB , info .PaymentIdentifier , StatusInFlight ,
149
+ )
148
150
149
151
htlc = & htlcStatus {
150
152
HTLCAttemptInfo : attempt ,
@@ -176,7 +178,9 @@ func TestKVPaymentsDBSwitchFail(t *testing.T) {
176
178
spew .Sdump (payment .HTLCs [0 ].Route ), err )
177
179
}
178
180
179
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusSucceeded )
181
+ assertPaymentStatus (
182
+ t , paymentDB , info .PaymentIdentifier , StatusSucceeded ,
183
+ )
180
184
181
185
htlc .settle = & preimg
182
186
assertPaymentInfo (
@@ -226,7 +230,9 @@ func TestKVPaymentsDBSwitchDoubleSend(t *testing.T) {
226
230
// Record an attempt.
227
231
_ , err = paymentDB .RegisterAttempt (info .PaymentIdentifier , attempt )
228
232
require .NoError (t , err , "unable to send htlc message" )
229
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusInFlight )
233
+ assertPaymentStatus (
234
+ t , paymentDB , info .PaymentIdentifier , StatusInFlight ,
235
+ )
230
236
231
237
htlc := & htlcStatus {
232
238
HTLCAttemptInfo : attempt ,
@@ -250,10 +256,14 @@ func TestKVPaymentsDBSwitchDoubleSend(t *testing.T) {
250
256
},
251
257
)
252
258
require .NoError (t , err , "error shouldn't have been received, got" )
253
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusSucceeded )
259
+ assertPaymentStatus (
260
+ t , paymentDB , info .PaymentIdentifier , StatusSucceeded ,
261
+ )
254
262
255
263
htlc .settle = & preimg
256
- assertPaymentInfo (t , paymentDB , info .PaymentIdentifier , info , nil , htlc )
264
+ assertPaymentInfo (
265
+ t , paymentDB , info .PaymentIdentifier , info , nil , htlc ,
266
+ )
257
267
258
268
err = paymentDB .InitPayment (info .PaymentIdentifier , info )
259
269
if ! errors .Is (err , ErrAlreadyPaid ) {
@@ -361,7 +371,9 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
361
371
if err != nil {
362
372
t .Fatalf ("unable to send htlc message: %v" , err )
363
373
}
364
- _ , err = paymentDB .RegisterAttempt (info .PaymentIdentifier , attempt )
374
+ _ , err = paymentDB .RegisterAttempt (
375
+ info .PaymentIdentifier , attempt ,
376
+ )
365
377
if err != nil {
366
378
t .Fatalf ("unable to send htlc message: %v" , err )
367
379
}
@@ -385,13 +397,18 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
385
397
386
398
// Fail the payment, which should moved it to Failed.
387
399
failReason := FailureReasonNoRoute
388
- _ , err = paymentDB .Fail (info .PaymentIdentifier , failReason )
400
+ _ , err = paymentDB .Fail (
401
+ info .PaymentIdentifier , failReason ,
402
+ )
389
403
if err != nil {
390
404
t .Fatalf ("unable to fail payment hash: %v" , err )
391
405
}
392
406
393
407
// Verify the status is indeed Failed.
394
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusFailed )
408
+ assertPaymentStatus (
409
+ t , paymentDB , info .PaymentIdentifier ,
410
+ StatusFailed ,
411
+ )
395
412
396
413
htlc .failure = & htlcFailure
397
414
assertPaymentInfo (
@@ -407,21 +424,30 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
407
424
},
408
425
)
409
426
if err != nil {
410
- t .Fatalf ("error shouldn't have been received, got: %v" , err )
427
+ t .Fatalf ("error shouldn't have been received," +
428
+ " got: %v" , err )
411
429
}
412
430
413
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusSucceeded )
431
+ assertPaymentStatus (
432
+ t , paymentDB , info .PaymentIdentifier ,
433
+ StatusSucceeded ,
434
+ )
414
435
415
436
htlc .settle = & preimg
416
437
assertPaymentInfo (
417
- t , paymentDB , info .PaymentIdentifier , info , nil , htlc ,
438
+ t , paymentDB , info .PaymentIdentifier , info , nil ,
439
+ htlc ,
418
440
)
419
441
420
442
numSuccess ++
421
443
} else {
422
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusInFlight )
444
+ assertPaymentStatus (
445
+ t , paymentDB , info .PaymentIdentifier ,
446
+ StatusInFlight ,
447
+ )
423
448
assertPaymentInfo (
424
- t , paymentDB , info .PaymentIdentifier , info , nil , htlc ,
449
+ t , paymentDB , info .PaymentIdentifier , info , nil ,
450
+ htlc ,
425
451
)
426
452
427
453
numInflight ++
@@ -635,7 +661,8 @@ func TestKVPaymentsDBDeleteSinglePayment(t *testing.T) {
635
661
// Delete failed HTLC attempts for the third payment.
636
662
require .NoError (t , db .DeletePayment (payments [2 ].id , true ))
637
663
638
- // Only the successful HTLC attempt should be left for the third payment.
664
+ // Only the successful HTLC attempt should be left for the third
665
+ // payment.
639
666
payments [2 ].htlcs = 1
640
667
assertPayments (t , db , payments [2 :])
641
668
@@ -724,7 +751,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
724
751
a .AttemptID = i
725
752
attempts = append (attempts , & a )
726
753
727
- _ , err = paymentDB .RegisterAttempt (info .PaymentIdentifier , & a )
754
+ _ , err = paymentDB .RegisterAttempt (
755
+ info .PaymentIdentifier , & a ,
756
+ )
728
757
if err != nil {
729
758
t .Fatalf ("unable to send htlc message: %v" , err )
730
759
}
@@ -737,7 +766,8 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
737
766
HTLCAttemptInfo : & a ,
738
767
}
739
768
assertPaymentInfo (
740
- t , paymentDB , info .PaymentIdentifier , info , nil , htlc ,
769
+ t , paymentDB , info .PaymentIdentifier , info , nil ,
770
+ htlc ,
741
771
)
742
772
}
743
773
@@ -771,7 +801,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
771
801
)
772
802
773
803
// Payment should still be in-flight.
774
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusInFlight )
804
+ assertPaymentStatus (
805
+ t , paymentDB , info .PaymentIdentifier , StatusInFlight ,
806
+ )
775
807
776
808
// Depending on the test case, settle or fail the first attempt.
777
809
a = attempts [0 ]
@@ -795,7 +827,8 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
795
827
// Assert that the HTLC has had the preimage recorded.
796
828
htlc .settle = & preimg
797
829
assertPaymentInfo (
798
- t , paymentDB , info .PaymentIdentifier , info , nil , htlc ,
830
+ t , paymentDB , info .PaymentIdentifier , info , nil ,
831
+ htlc ,
799
832
)
800
833
} else {
801
834
_ , err := paymentDB .FailAttempt (
@@ -812,13 +845,16 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
812
845
// Assert the failure was recorded.
813
846
htlc .failure = & htlcFail
814
847
assertPaymentInfo (
815
- t , paymentDB , info .PaymentIdentifier , info , nil , htlc ,
848
+ t , paymentDB , info .PaymentIdentifier , info , nil ,
849
+ htlc ,
816
850
)
817
851
818
852
// We also record a payment level fail, to move it into
819
853
// a terminal state.
820
854
failReason := FailureReasonNoRoute
821
- _ , err = paymentDB .Fail (info .PaymentIdentifier , failReason )
855
+ _ , err = paymentDB .Fail (
856
+ info .PaymentIdentifier , failReason ,
857
+ )
822
858
if err != nil {
823
859
t .Fatalf ("unable to fail payment hash: %v" , err )
824
860
}
@@ -846,7 +882,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
846
882
require .ErrorIs (t , err , ErrPaymentPendingFailed )
847
883
}
848
884
849
- assertPaymentStatus (t , paymentDB , info .PaymentIdentifier , StatusInFlight )
885
+ assertPaymentStatus (
886
+ t , paymentDB , info .PaymentIdentifier , StatusInFlight ,
887
+ )
850
888
851
889
// Settle or fail the remaining attempt based on the testcase.
852
890
a = attempts [2 ]
@@ -893,7 +931,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
893
931
// write a terminal failure to the database without
894
932
// syncing.
895
933
failReason := FailureReasonPaymentDetails
896
- _ , err = paymentDB .Fail (info .PaymentIdentifier , failReason )
934
+ _ , err = paymentDB .Fail (
935
+ info .PaymentIdentifier , failReason ,
936
+ )
897
937
require .NoError (t , err , "unable to fail" )
898
938
}
899
939
@@ -1085,7 +1125,9 @@ func testDeleteFailedAttempts(t *testing.T, keepFailedPaymentAttempts bool) {
1085
1125
// Calling DeleteFailedAttempts on an in-flight payment should return
1086
1126
// an error.
1087
1127
if keepFailedPaymentAttempts {
1088
- require .NoError (t , paymentDB .DeleteFailedAttempts (payments [1 ].id ))
1128
+ require .NoError (
1129
+ t , paymentDB .DeleteFailedAttempts (payments [1 ].id ),
1130
+ )
1089
1131
} else {
1090
1132
require .Error (t , paymentDB .DeleteFailedAttempts (payments [1 ].id ))
1091
1133
}
@@ -1107,10 +1149,14 @@ func testDeleteFailedAttempts(t *testing.T, keepFailedPaymentAttempts bool) {
1107
1149
// DeleteFailedAttempts is ignored, even for non-existent
1108
1150
// payments, if the control tower is configured to keep failed
1109
1151
// HTLCs.
1110
- require .NoError (t , paymentDB .DeleteFailedAttempts (lntypes .ZeroHash ))
1152
+ require .NoError (
1153
+ t , paymentDB .DeleteFailedAttempts (lntypes .ZeroHash ),
1154
+ )
1111
1155
} else {
1112
1156
// Attempting to cleanup a non-existent payment returns an error.
1113
- require .Error (t , paymentDB .DeleteFailedAttempts (lntypes .ZeroHash ))
1157
+ require .Error (
1158
+ t , paymentDB .DeleteFailedAttempts (lntypes .ZeroHash ),
1159
+ )
1114
1160
}
1115
1161
}
1116
1162
@@ -1364,7 +1410,9 @@ func assertPayments(t *testing.T, db *DB, payments []*payment) {
1364
1410
1365
1411
// Make sure that the number of fetched payments is the same
1366
1412
// as expected.
1367
- require .Len (t , dbPayments , len (payments ), "unexpected number of payments" )
1413
+ require .Len (
1414
+ t , dbPayments , len (payments ), "unexpected number of payments" ,
1415
+ )
1368
1416
1369
1417
// Convert fetched payments of type MPPayment to our helper structure.
1370
1418
p := make ([]* payment , len (dbPayments ))
0 commit comments