Skip to content

Commit 67dd72d

Browse files
committed
multi: fix linter issues
1 parent c01e0b5 commit 67dd72d

File tree

1 file changed

+74
-26
lines changed

1 file changed

+74
-26
lines changed

channeldb/payments_kv_store_test.go

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ func TestKVPaymentsDBSwitchFail(t *testing.T) {
144144
attempt.AttemptID = 1
145145
_, err = paymentDB.RegisterAttempt(info.PaymentIdentifier, attempt)
146146
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+
)
148150

149151
htlc = &htlcStatus{
150152
HTLCAttemptInfo: attempt,
@@ -176,7 +178,9 @@ func TestKVPaymentsDBSwitchFail(t *testing.T) {
176178
spew.Sdump(payment.HTLCs[0].Route), err)
177179
}
178180

179-
assertPaymentStatus(t, paymentDB, info.PaymentIdentifier, StatusSucceeded)
181+
assertPaymentStatus(
182+
t, paymentDB, info.PaymentIdentifier, StatusSucceeded,
183+
)
180184

181185
htlc.settle = &preimg
182186
assertPaymentInfo(
@@ -226,7 +230,9 @@ func TestKVPaymentsDBSwitchDoubleSend(t *testing.T) {
226230
// Record an attempt.
227231
_, err = paymentDB.RegisterAttempt(info.PaymentIdentifier, attempt)
228232
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+
)
230236

231237
htlc := &htlcStatus{
232238
HTLCAttemptInfo: attempt,
@@ -250,10 +256,14 @@ func TestKVPaymentsDBSwitchDoubleSend(t *testing.T) {
250256
},
251257
)
252258
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+
)
254262

255263
htlc.settle = &preimg
256-
assertPaymentInfo(t, paymentDB, info.PaymentIdentifier, info, nil, htlc)
264+
assertPaymentInfo(
265+
t, paymentDB, info.PaymentIdentifier, info, nil, htlc,
266+
)
257267

258268
err = paymentDB.InitPayment(info.PaymentIdentifier, info)
259269
if !errors.Is(err, ErrAlreadyPaid) {
@@ -361,7 +371,9 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
361371
if err != nil {
362372
t.Fatalf("unable to send htlc message: %v", err)
363373
}
364-
_, err = paymentDB.RegisterAttempt(info.PaymentIdentifier, attempt)
374+
_, err = paymentDB.RegisterAttempt(
375+
info.PaymentIdentifier, attempt,
376+
)
365377
if err != nil {
366378
t.Fatalf("unable to send htlc message: %v", err)
367379
}
@@ -385,13 +397,18 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
385397

386398
// Fail the payment, which should moved it to Failed.
387399
failReason := FailureReasonNoRoute
388-
_, err = paymentDB.Fail(info.PaymentIdentifier, failReason)
400+
_, err = paymentDB.Fail(
401+
info.PaymentIdentifier, failReason,
402+
)
389403
if err != nil {
390404
t.Fatalf("unable to fail payment hash: %v", err)
391405
}
392406

393407
// Verify the status is indeed Failed.
394-
assertPaymentStatus(t, paymentDB, info.PaymentIdentifier, StatusFailed)
408+
assertPaymentStatus(
409+
t, paymentDB, info.PaymentIdentifier,
410+
StatusFailed,
411+
)
395412

396413
htlc.failure = &htlcFailure
397414
assertPaymentInfo(
@@ -407,21 +424,30 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
407424
},
408425
)
409426
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)
411429
}
412430

413-
assertPaymentStatus(t, paymentDB, info.PaymentIdentifier, StatusSucceeded)
431+
assertPaymentStatus(
432+
t, paymentDB, info.PaymentIdentifier,
433+
StatusSucceeded,
434+
)
414435

415436
htlc.settle = &preimg
416437
assertPaymentInfo(
417-
t, paymentDB, info.PaymentIdentifier, info, nil, htlc,
438+
t, paymentDB, info.PaymentIdentifier, info, nil,
439+
htlc,
418440
)
419441

420442
numSuccess++
421443
} else {
422-
assertPaymentStatus(t, paymentDB, info.PaymentIdentifier, StatusInFlight)
444+
assertPaymentStatus(
445+
t, paymentDB, info.PaymentIdentifier,
446+
StatusInFlight,
447+
)
423448
assertPaymentInfo(
424-
t, paymentDB, info.PaymentIdentifier, info, nil, htlc,
449+
t, paymentDB, info.PaymentIdentifier, info, nil,
450+
htlc,
425451
)
426452

427453
numInflight++
@@ -635,7 +661,8 @@ func TestKVPaymentsDBDeleteSinglePayment(t *testing.T) {
635661
// Delete failed HTLC attempts for the third payment.
636662
require.NoError(t, db.DeletePayment(payments[2].id, true))
637663

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.
639666
payments[2].htlcs = 1
640667
assertPayments(t, db, payments[2:])
641668

@@ -724,7 +751,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
724751
a.AttemptID = i
725752
attempts = append(attempts, &a)
726753

727-
_, err = paymentDB.RegisterAttempt(info.PaymentIdentifier, &a)
754+
_, err = paymentDB.RegisterAttempt(
755+
info.PaymentIdentifier, &a,
756+
)
728757
if err != nil {
729758
t.Fatalf("unable to send htlc message: %v", err)
730759
}
@@ -737,7 +766,8 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
737766
HTLCAttemptInfo: &a,
738767
}
739768
assertPaymentInfo(
740-
t, paymentDB, info.PaymentIdentifier, info, nil, htlc,
769+
t, paymentDB, info.PaymentIdentifier, info, nil,
770+
htlc,
741771
)
742772
}
743773

@@ -771,7 +801,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
771801
)
772802

773803
// Payment should still be in-flight.
774-
assertPaymentStatus(t, paymentDB, info.PaymentIdentifier, StatusInFlight)
804+
assertPaymentStatus(
805+
t, paymentDB, info.PaymentIdentifier, StatusInFlight,
806+
)
775807

776808
// Depending on the test case, settle or fail the first attempt.
777809
a = attempts[0]
@@ -795,7 +827,8 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
795827
// Assert that the HTLC has had the preimage recorded.
796828
htlc.settle = &preimg
797829
assertPaymentInfo(
798-
t, paymentDB, info.PaymentIdentifier, info, nil, htlc,
830+
t, paymentDB, info.PaymentIdentifier, info, nil,
831+
htlc,
799832
)
800833
} else {
801834
_, err := paymentDB.FailAttempt(
@@ -812,13 +845,16 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
812845
// Assert the failure was recorded.
813846
htlc.failure = &htlcFail
814847
assertPaymentInfo(
815-
t, paymentDB, info.PaymentIdentifier, info, nil, htlc,
848+
t, paymentDB, info.PaymentIdentifier, info, nil,
849+
htlc,
816850
)
817851

818852
// We also record a payment level fail, to move it into
819853
// a terminal state.
820854
failReason := FailureReasonNoRoute
821-
_, err = paymentDB.Fail(info.PaymentIdentifier, failReason)
855+
_, err = paymentDB.Fail(
856+
info.PaymentIdentifier, failReason,
857+
)
822858
if err != nil {
823859
t.Fatalf("unable to fail payment hash: %v", err)
824860
}
@@ -846,7 +882,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
846882
require.ErrorIs(t, err, ErrPaymentPendingFailed)
847883
}
848884

849-
assertPaymentStatus(t, paymentDB, info.PaymentIdentifier, StatusInFlight)
885+
assertPaymentStatus(
886+
t, paymentDB, info.PaymentIdentifier, StatusInFlight,
887+
)
850888

851889
// Settle or fail the remaining attempt based on the testcase.
852890
a = attempts[2]
@@ -893,7 +931,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
893931
// write a terminal failure to the database without
894932
// syncing.
895933
failReason := FailureReasonPaymentDetails
896-
_, err = paymentDB.Fail(info.PaymentIdentifier, failReason)
934+
_, err = paymentDB.Fail(
935+
info.PaymentIdentifier, failReason,
936+
)
897937
require.NoError(t, err, "unable to fail")
898938
}
899939

@@ -1085,7 +1125,9 @@ func testDeleteFailedAttempts(t *testing.T, keepFailedPaymentAttempts bool) {
10851125
// Calling DeleteFailedAttempts on an in-flight payment should return
10861126
// an error.
10871127
if keepFailedPaymentAttempts {
1088-
require.NoError(t, paymentDB.DeleteFailedAttempts(payments[1].id))
1128+
require.NoError(
1129+
t, paymentDB.DeleteFailedAttempts(payments[1].id),
1130+
)
10891131
} else {
10901132
require.Error(t, paymentDB.DeleteFailedAttempts(payments[1].id))
10911133
}
@@ -1107,10 +1149,14 @@ func testDeleteFailedAttempts(t *testing.T, keepFailedPaymentAttempts bool) {
11071149
// DeleteFailedAttempts is ignored, even for non-existent
11081150
// payments, if the control tower is configured to keep failed
11091151
// HTLCs.
1110-
require.NoError(t, paymentDB.DeleteFailedAttempts(lntypes.ZeroHash))
1152+
require.NoError(
1153+
t, paymentDB.DeleteFailedAttempts(lntypes.ZeroHash),
1154+
)
11111155
} else {
11121156
// 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+
)
11141160
}
11151161
}
11161162

@@ -1364,7 +1410,9 @@ func assertPayments(t *testing.T, db *DB, payments []*payment) {
13641410

13651411
// Make sure that the number of fetched payments is the same
13661412
// 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+
)
13681416

13691417
// Convert fetched payments of type MPPayment to our helper structure.
13701418
p := make([]*payment, len(dbPayments))

0 commit comments

Comments
 (0)