multi: formatting and comment fixes

This commit is contained in:
Oliver Gugger committed 2022-02-10 11:02:02 +01:00
1 parent ffee7d1bcf
commit 895a2e497b
160 files changed
+159 -260

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ var (
// outpointBucket stores all of our channel outpoints and a tlv
// stream containing channel data.
//
// outpoint -> tlv stream
// outpoint -> tlv stream.
//
outpointBucket = []byte("outpoint-bucket")
+1
View File
@@ -658,6 +658,7 @@ func TestChannelStateTransition(t *testing.T) {
if !reflect.DeepEqual(
dbUnsignedAckedUpdates[0], unsignedAckedUpdates[0],
) {
t.Fatalf("unexpected update: expected %v, got %v",
spew.Sdump(unsignedAckedUpdates[0]),
spew.Sdump(dbUnsignedAckedUpdates))
-1
View File
@@ -759,5 +759,4 @@ func TestFetchHistoricalChannel(t *testing.T) {
if err != ErrChannelNotFound {
t.Fatalf("expected chan not found, got: %v", err)
}
}
-1
View File
@@ -150,7 +150,6 @@ func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
creationInfo, err := deserializeDuplicatePaymentCreationInfo(r)
if err != nil {
return nil, err
}
// Get failure reason if available.
-3
View File
@@ -520,7 +520,6 @@ func (c *ChannelGraph) FetchNodeFeatures(
// Fallback that uses the database.
targetNode, err := c.FetchLightningNode(node)
switch err {
// If the node exists and has features, return them directly.
case nil:
return targetNode.Features, nil
@@ -592,7 +591,6 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
channels[e.ChannelID] = directedChannel
return nil
})
if err != nil {
return err
@@ -2429,7 +2427,6 @@ func makeZombiePubkeys(info *ChannelEdgeInfo,
e1, e2 *ChannelEdgePolicy) ([33]byte, [33]byte) {
switch {
// If we don't have either edge policy, we'll return both pubkeys so
// that the channel can be resurrected by either party.
case e1 == nil && e2 == nil:
-1
View File
@@ -467,7 +467,6 @@ func (c *GraphCache) ForEachChannel(node route.Vertex,
if err := cb(channel); err != nil {
return err
}
}
return nil
+1 -1
View File
@@ -1279,6 +1279,7 @@ func TestGraphCacheTraversal(t *testing.T) {
if !bytes.Equal(
inPolicyNodeKey[:], node.PubKeyBytes[:],
) {
return fmt.Errorf("wrong outgoing edge")
}
@@ -3784,7 +3785,6 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
var numChans int
err = graph.ForEachNodeChannel(nil, node1.PubKeyBytes,
func(channel *DirectedChannel) error {
numChans++
return nil
})
+1 -3
View File
@@ -1010,7 +1010,6 @@ func TestScanInvoices(t *testing.T) {
invoices = make(map[lntypes.Hash]*Invoice)
callCount = 0
resetCount++
}
scanFunc := func(paymentHash lntypes.Hash, invoice *Invoice) error {
@@ -1661,7 +1660,6 @@ func TestHTLCSet(t *testing.T) {
ampData = &InvoiceHtlcAMPData{
Record: *record.NewAMP([32]byte{0}, *h.setID, 0),
}
}
// Add the HTLC to the invoice's set of HTLCs.
@@ -2045,7 +2043,7 @@ func TestUnexpectedInvoicePreimage(t *testing.T) {
getUpdateInvoice(invoice.Terms.Value),
)
//Assert that we get ErrUnexpectedInvoicePreimage.
// Assert that we get ErrUnexpectedInvoicePreimage.
require.Error(t, ErrUnexpectedInvoicePreimage, err)
}
+1 -9
View File
@@ -422,7 +422,7 @@ func (c ContractState) String() string {
return "Unknown"
}
// IsFinal returns a boolean indicating whether an invoice state is final
// IsFinal returns a boolean indicating whether an invoice state is final.
func (c ContractState) IsFinal() bool {
return c == ContractSettled || c == ContractCanceled
}
@@ -1156,7 +1156,6 @@ func fetchInvoiceNumByRef(invoiceIndex, payAddrIndex, setIDIndex kvdb.RBucket,
invoiceNumByHash := getInvoiceNumByHash()
invoiceNumByAddr := getInvoiceNumByAddr()
switch {
// If payment address and payment hash both reference an existing
// invoice, ensure they reference the _same_ invoice.
case invoiceNumByAddr != nil && invoiceNumByHash != nil:
@@ -2814,7 +2813,6 @@ func (d *DB) updateInvoice(hash *lntypes.Hash, refSetID *SetID, invoices,
if setID != nil && update.State != nil {
preimage, ok := update.State.HTLCPreimages[key]
switch {
// If we don't already have a preimage for this HTLC, we
// can set it now.
case ok && htlc.AMP.Preimage == nil:
@@ -2890,7 +2888,6 @@ func (d *DB) updateInvoice(hash *lntypes.Hash, refSetID *SetID, invoices,
if !invoiceIsAMP {
invoice.AmtPaid = amtPaid
} else {
invoice.AmtPaid += amtPaid
}
@@ -2941,7 +2938,6 @@ func updateInvoiceState(invoice *Invoice, hash *lntypes.Hash,
}
switch invoice.State {
// Once a contract is accepted, we can only transition to settled or
// canceled. Forbid transitioning back into this state. Otherwise this
// state is identical to ContractOpen, so we fallthrough to apply the
@@ -2979,7 +2975,6 @@ func updateInvoiceState(invoice *Invoice, hash *lntypes.Hash,
}
switch {
// If an invoice-level preimage was supplied, but the InvoiceRef
// doesn't specify a hash (e.g. AMP invoices) we fail.
case update.Preimage != nil && hash == nil:
@@ -3063,7 +3058,6 @@ func updateHtlc(resolveTime time.Time, htlc *InvoiceHTLC,
// the invoice level. For AMP HTLCs, verify that the
// per-HTLC preimage-hash pair is valid.
switch {
// Non-AMP HTLCs can be settle immediately since we
// already know the preimage is valid due to checks at
// the invoice level.
@@ -3112,7 +3106,6 @@ func updateHtlc(resolveTime time.Time, htlc *InvoiceHTLC,
}
switch invState {
case ContractCanceled:
if htlc.State == HtlcStateAccepted {
htlc.State = HtlcStateCanceled
@@ -3369,7 +3362,6 @@ func (d *DB) DeleteInvoice(invoicesToDelete []InvoiceDeleteRef) error {
if err != nil {
return err
}
}
// In addition to deleting the main invoice state, if
@@ -257,7 +257,8 @@ func readChanConfig(b io.Reader, c *common.ChannelConfig) error { // nolint: dup
)
}
func DeserializeCloseChannelSummary(r io.Reader) (*common.ChannelCloseSummary, error) { // nolint: dupl
func DeserializeCloseChannelSummary(
r io.Reader) (*common.ChannelCloseSummary, error) { // nolint: dupl
c := &common.ChannelCloseSummary{}
+3 -1
View File
@@ -175,7 +175,6 @@ var (
// migrate three areas: open channel commit diffs, open channel unacked updates,
// and network results in the switch.
func TestMigrateDatabaseWireMessages(t *testing.T) {
var pub [33]byte
copy(pub[:], key[:])
@@ -344,6 +343,7 @@ func TestMigrateDatabaseWireMessages(t *testing.T) {
if !reflect.DeepEqual(
newUpdates, testCommitDiff.LogUpdates,
) {
return fmt.Errorf("updates mismatch: expected "+
"%v, got %v",
spew.Sdump(testCommitDiff.LogUpdates),
@@ -365,6 +365,7 @@ func TestMigrateDatabaseWireMessages(t *testing.T) {
if !reflect.DeepEqual(
newUpdates, testCommitDiff.LogUpdates,
) {
return fmt.Errorf("updates mismatch: expected "+
"%v, got %v",
spew.Sdump(testCommitDiff.LogUpdates),
@@ -402,6 +403,7 @@ func TestMigrateDatabaseWireMessages(t *testing.T) {
if !reflect.DeepEqual(
newChanCloseSummary, testChanCloseSummary,
) {
return fmt.Errorf("summary mismatch: expected "+
"%v, got %v",
spew.Sdump(testChanCloseSummary),
-1
View File
@@ -140,7 +140,6 @@ func migrateHtlcsBucket(htlcs kvdb.RwBucket) error {
if err := htlcs.Put(newKey, settleInfo); err != nil {
return err
}
}
failInfo := attempt.Get(oldFailInfoKey)
-2
View File
@@ -72,7 +72,6 @@ func restoreDB(bucket kvdb.RwBucket, data map[string]interface{}) error {
key := []byte(k)
switch value := v.(type) {
// Key contains value.
case string:
err := bucket.Put(key, []byte(value))
@@ -114,7 +113,6 @@ func verifyDB(bucket kvdb.RBucket, data map[string]interface{}) error {
key := []byte(k)
switch value := v.(type) {
// Key contains value.
case string:
expectedValue := []byte(value)
-1
View File
@@ -10,7 +10,6 @@ import (
// TestDefaultOptions tests the default options are created as intended.
func TestDefaultOptions(t *testing.T) {
opts := channeldb.DefaultOptions()
require.True(t, opts.NoFreelistSync)
-1
View File
@@ -69,7 +69,6 @@ func (p paginator) cursorStart() ([]byte, []byte) {
// handle a few offset cases.
if p.reversed {
switch {
// This indicates the default case, where no offset was
// specified. In that case we just start from the last
// entry.
-1
View File
@@ -324,7 +324,6 @@ func (p *PaymentControl) RegisterAttempt(paymentHash lntypes.Hash,
hMpp := h.Route.FinalHop().MPP
switch {
// We tried to register a non-MPP attempt for a MPP
// payment.
case mpp == nil && hMpp != nil:
-1
View File
@@ -1254,7 +1254,6 @@ func createTestPayments(t *testing.T, p *PaymentControl, payments []*payment) {
require.NoError(t, err, "unable to send htlc message")
switch payments[i].status {
// Fail the attempt and the payment overall.
case StatusFailed:
htlcFailure := HTLCFailUnreadable
-2
View File
@@ -357,7 +357,6 @@ func fetchPayment(bucket kvdb.RBucket) (*MPPayment, error) {
var paymentStatus PaymentStatus
switch {
// If any of the the HTLCs did succeed and there are no HTLCs in
// flight, the payment succeeded.
case !inflight && settled:
@@ -1093,7 +1092,6 @@ func deserializeHTLCAttemptInfo(r io.Reader) (*HTLCAttemptInfo, error) {
_, err = io.ReadFull(r, hash[:])
switch {
// Older payment attempts wouldn't have the hash set, in which case we
// can just return.
case err == io.EOF, err == io.ErrUnexpectedEOF:
+1
View File
@@ -487,6 +487,7 @@ func TestQueryPayments(t *testing.T) {
}
if tt.firstIndex != querySlice.FirstIndexOffset ||
tt.lastIndex != querySlice.LastIndexOffset {
t.Errorf("First or last index does not match "+
"expected index. Want (%d, %d), got (%d, %d).",
tt.firstIndex, tt.lastIndex,