Skip to content

Commit e714b31

Browse files
committed
channeldb: fix linter
1 parent c9d21fc commit e714b31

File tree

2 files changed

+65
-23
lines changed

2 files changed

+65
-23
lines changed

channeldb/payments.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ func (p *KVPaymentsDB) DeleteFailedAttempts(hash lntypes.Hash) error {
431431
return err
432432
}
433433
}
434+
434435
return nil
435436
}
436437

@@ -454,6 +455,7 @@ func createPaymentIndexEntry(tx kvdb.RwTx, sequenceNumber []byte,
454455
}
455456

456457
indexes := tx.ReadWriteBucket(paymentsIndexBucket)
458+
457459
return indexes.Put(sequenceNumber, b.Bytes())
458460
}
459461

@@ -621,6 +623,7 @@ func (p *KVPaymentsDB) RegisterAttempt(paymentHash lntypes.Hash,
621623

622624
// Retrieve attempt info for the notification.
623625
payment, err = fetchPayment(bucket)
626+
624627
return err
625628
})
626629
if err != nil {
@@ -861,7 +864,6 @@ func fetchPaymentBucket(tx kvdb.RTx, paymentHash lntypes.Hash) (
861864
}
862865

863866
return bucket, nil
864-
865867
}
866868

867869
// fetchPaymentBucketUpdate is identical to fetchPaymentBucket, but it returns a

channeldb/payments_test.go

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,9 @@ func TestKVPaymentsDBSwitchDoubleSend(t *testing.T) {
10531053
},
10541054
)
10551055
require.NoError(t, err, "error shouldn't have been received, got")
1056-
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusSucceeded)
1056+
assertPaymentStatus(
1057+
t, pControl, info.PaymentIdentifier, StatusSucceeded,
1058+
)
10571059

10581060
htlc.settle = &preimg
10591061
assertPaymentInfo(t, pControl, info.PaymentIdentifier, info, nil, htlc)
@@ -1164,7 +1166,9 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
11641166
if err != nil {
11651167
t.Fatalf("unable to send htlc message: %v", err)
11661168
}
1167-
_, err = pControl.RegisterAttempt(info.PaymentIdentifier, attempt)
1169+
_, err = pControl.RegisterAttempt(
1170+
info.PaymentIdentifier, attempt,
1171+
)
11681172
if err != nil {
11691173
t.Fatalf("unable to send htlc message: %v", err)
11701174
}
@@ -1188,13 +1192,18 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
11881192

11891193
// Fail the payment, which should moved it to Failed.
11901194
failReason := FailureReasonNoRoute
1191-
_, err = pControl.Fail(info.PaymentIdentifier, failReason)
1195+
_, err = pControl.Fail(
1196+
info.PaymentIdentifier, failReason,
1197+
)
11921198
if err != nil {
11931199
t.Fatalf("unable to fail payment hash: %v", err)
11941200
}
11951201

11961202
// Verify the status is indeed Failed.
1197-
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusFailed)
1203+
assertPaymentStatus(
1204+
t, pControl, info.PaymentIdentifier,
1205+
StatusFailed,
1206+
)
11981207

11991208
htlc.failure = &htlcFailure
12001209
assertPaymentInfo(
@@ -1210,21 +1219,30 @@ func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
12101219
},
12111220
)
12121221
if err != nil {
1213-
t.Fatalf("error shouldn't have been received, got: %v", err)
1222+
t.Fatalf("error shouldn't have been "+
1223+
"received, got: %v", err)
12141224
}
12151225

1216-
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusSucceeded)
1226+
assertPaymentStatus(
1227+
t, pControl, info.PaymentIdentifier,
1228+
StatusSucceeded,
1229+
)
12171230

12181231
htlc.settle = &preimg
12191232
assertPaymentInfo(
1220-
t, pControl, info.PaymentIdentifier, info, nil, htlc,
1233+
t, pControl, info.PaymentIdentifier, info, nil,
1234+
htlc,
12211235
)
12221236

12231237
numSuccess++
12241238
} else {
1225-
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusInFlight)
1239+
assertPaymentStatus(
1240+
t, pControl, info.PaymentIdentifier,
1241+
StatusInFlight,
1242+
)
12261243
assertPaymentInfo(
1227-
t, pControl, info.PaymentIdentifier, info, nil, htlc,
1244+
t, pControl, info.PaymentIdentifier, info, nil,
1245+
htlc,
12281246
)
12291247

12301248
numInflight++
@@ -1438,7 +1456,8 @@ func TestKVPaymentsDBDeleteSinglePayment(t *testing.T) {
14381456
// Delete failed HTLC attempts for the third payment.
14391457
require.NoError(t, db.DeletePayment(payments[2].id, true))
14401458

1441-
// Only the successful HTLC attempt should be left for the third payment.
1459+
// Only the successful HTLC attempt should be left for the third
1460+
// payment.
14421461
payments[2].htlcs = 1
14431462
assertPayments(t, db, payments[2:])
14441463

@@ -1527,7 +1546,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
15271546
a.AttemptID = i
15281547
attempts = append(attempts, &a)
15291548

1530-
_, err = pControl.RegisterAttempt(info.PaymentIdentifier, &a)
1549+
_, err = pControl.RegisterAttempt(
1550+
info.PaymentIdentifier, &a,
1551+
)
15311552
if err != nil {
15321553
t.Fatalf("unable to send htlc message: %v", err)
15331554
}
@@ -1540,7 +1561,8 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
15401561
HTLCAttemptInfo: &a,
15411562
}
15421563
assertPaymentInfo(
1543-
t, pControl, info.PaymentIdentifier, info, nil, htlc,
1564+
t, pControl, info.PaymentIdentifier, info, nil,
1565+
htlc,
15441566
)
15451567
}
15461568

@@ -1574,7 +1596,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
15741596
)
15751597

15761598
// Payment should still be in-flight.
1577-
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusInFlight)
1599+
assertPaymentStatus(
1600+
t, pControl, info.PaymentIdentifier, StatusInFlight,
1601+
)
15781602

15791603
// Depending on the test case, settle or fail the first attempt.
15801604
a = attempts[0]
@@ -1598,7 +1622,8 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
15981622
// Assert that the HTLC has had the preimage recorded.
15991623
htlc.settle = &preimg
16001624
assertPaymentInfo(
1601-
t, pControl, info.PaymentIdentifier, info, nil, htlc,
1625+
t, pControl, info.PaymentIdentifier, info, nil,
1626+
htlc,
16021627
)
16031628
} else {
16041629
_, err := pControl.FailAttempt(
@@ -1615,13 +1640,16 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
16151640
// Assert the failure was recorded.
16161641
htlc.failure = &htlcFail
16171642
assertPaymentInfo(
1618-
t, pControl, info.PaymentIdentifier, info, nil, htlc,
1643+
t, pControl, info.PaymentIdentifier, info, nil,
1644+
htlc,
16191645
)
16201646

16211647
// We also record a payment level fail, to move it into
16221648
// a terminal state.
16231649
failReason := FailureReasonNoRoute
1624-
_, err = pControl.Fail(info.PaymentIdentifier, failReason)
1650+
_, err = pControl.Fail(
1651+
info.PaymentIdentifier, failReason,
1652+
)
16251653
if err != nil {
16261654
t.Fatalf("unable to fail payment hash: %v", err)
16271655
}
@@ -1649,7 +1677,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
16491677
require.ErrorIs(t, err, ErrPaymentPendingFailed)
16501678
}
16511679

1652-
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusInFlight)
1680+
assertPaymentStatus(
1681+
t, pControl, info.PaymentIdentifier, StatusInFlight,
1682+
)
16531683

16541684
// Settle or fail the remaining attempt based on the testcase.
16551685
a = attempts[2]
@@ -1696,7 +1726,9 @@ func TestKVPaymentsDBMultiShard(t *testing.T) {
16961726
// write a terminal failure to the database without
16971727
// syncing.
16981728
failReason := FailureReasonPaymentDetails
1699-
_, err = pControl.Fail(info.PaymentIdentifier, failReason)
1729+
_, err = pControl.Fail(
1730+
info.PaymentIdentifier, failReason,
1731+
)
17001732
require.NoError(t, err, "unable to fail")
17011733
}
17021734

@@ -1888,7 +1920,9 @@ func testDeleteFailedAttempts(t *testing.T, keepFailedPaymentAttempts bool) {
18881920
// Calling DeleteFailedAttempts on an in-flight payment should return
18891921
// an error.
18901922
if keepFailedPaymentAttempts {
1891-
require.NoError(t, pControl.DeleteFailedAttempts(payments[1].id))
1923+
require.NoError(
1924+
t, pControl.DeleteFailedAttempts(payments[1].id),
1925+
)
18921926
} else {
18931927
require.Error(t, pControl.DeleteFailedAttempts(payments[1].id))
18941928
}
@@ -1910,10 +1944,14 @@ func testDeleteFailedAttempts(t *testing.T, keepFailedPaymentAttempts bool) {
19101944
// DeleteFailedAttempts is ignored, even for non-existent
19111945
// payments, if the control tower is configured to keep failed
19121946
// HTLCs.
1913-
require.NoError(t, pControl.DeleteFailedAttempts(lntypes.ZeroHash))
1947+
require.NoError(
1948+
t, pControl.DeleteFailedAttempts(lntypes.ZeroHash),
1949+
)
19141950
} else {
19151951
// Attempting to cleanup a non-existent payment returns an error.
1916-
require.Error(t, pControl.DeleteFailedAttempts(lntypes.ZeroHash))
1952+
require.Error(
1953+
t, pControl.DeleteFailedAttempts(lntypes.ZeroHash),
1954+
)
19171955
}
19181956
}
19191957

@@ -2167,7 +2205,9 @@ func assertPayments(t *testing.T, db *DB, payments []*payment) {
21672205

21682206
// Make sure that the number of fetched payments is the same
21692207
// as expected.
2170-
require.Len(t, dbPayments, len(payments), "unexpected number of payments")
2208+
require.Len(
2209+
t, dbPayments, len(payments), "unexpected number of payments",
2210+
)
21712211

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

0 commit comments

Comments
 (0)