Merge pull request #8962 from ProofOfKeags/refactor/quiescence-micro-spinoffs

[NANO]: Refactor/quiescence micro spinoffs
This commit is contained in:
ProofOfKeags authored and GitHub committed 2024-08-01 13:57:29 -06:00
commit e3dd886580
3 files changed
+12 -12

No files matched your search

+3 -3
View File
@@ -4,6 +4,7 @@ import (
"bytes" "bytes"
crand "crypto/rand" crand "crypto/rand"
"crypto/sha256" "crypto/sha256"
"errors"
"fmt" "fmt"
prand "math/rand" prand "math/rand"
"sync" "sync"
@@ -13,7 +14,6 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog" "github.com/btcsuite/btclog"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models" "github.com/lightningnetwork/lnd/channeldb/models"
@@ -480,7 +480,7 @@ var _ ChannelLink = (*channelLink)(nil)
// NOTE: Part of the ChannelLink interface. // NOTE: Part of the ChannelLink interface.
func (l *channelLink) Start() error { func (l *channelLink) Start() error {
if !atomic.CompareAndSwapInt32(&l.started, 0, 1) { if !atomic.CompareAndSwapInt32(&l.started, 0, 1) {
err := errors.Errorf("channel link(%v): already started", l) err := fmt.Errorf("channel link(%v): already started", l)
l.log.Warn("already started") l.log.Warn("already started")
return err return err
} }
@@ -4080,7 +4080,7 @@ func (l *channelLink) sendMalformedHTLCError(htlcIndex uint64,
// remote peer. // remote peer.
func (l *channelLink) fail(linkErr LinkFailureError, func (l *channelLink) fail(linkErr LinkFailureError,
format string, a ...interface{}) { format string, a ...interface{}) {
reason := errors.Errorf(format, a...) reason := fmt.Errorf(format, a...)
// Return if we have already notified about a failure. // Return if we have already notified about a failure.
if l.failed { if l.failed {
+3 -3
View File
@@ -444,7 +444,7 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
t.Parallel() t.Parallel()
// Setup a alice-bob network. // Setup a alice-bob network.
alice, bob, err := createTwoClusterChannels( alice, bob, err := createMirroredChannel(
t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5, t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5,
) )
require.NoError(t, err, "unable to create channel") require.NoError(t, err, "unable to create channel")
@@ -6318,7 +6318,7 @@ func TestChannelLinkCanceledInvoice(t *testing.T) {
t.Parallel() t.Parallel()
// Setup a alice-bob network. // Setup a alice-bob network.
alice, bob, err := createTwoClusterChannels( alice, bob, err := createMirroredChannel(
t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5, t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5,
) )
require.NoError(t, err, "unable to create channel") require.NoError(t, err, "unable to create channel")
@@ -6374,7 +6374,7 @@ type hodlInvoiceTestCtx struct {
func newHodlInvoiceTestCtx(t *testing.T) (*hodlInvoiceTestCtx, error) { func newHodlInvoiceTestCtx(t *testing.T) (*hodlInvoiceTestCtx, error) {
// Setup a alice-bob network. // Setup a alice-bob network.
alice, bob, err := createTwoClusterChannels( alice, bob, err := createMirroredChannel(
t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5, t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5,
) )
require.NoError(t, err, "unable to create channel") require.NoError(t, err, "unable to create channel")
+6 -6
View File
@@ -1053,17 +1053,17 @@ func serverOptionRejectHtlc(alice, bob, carol bool) serverOption {
} }
} }
// createTwoClusterChannels creates lightning channels which are needed for // createMirroredChannel creates two LightningChannel objects which represent
// a 2 hop network cluster to be initialized. // the state machines on either side of a single channel between alice and bob.
func createTwoClusterChannels(t *testing.T, aliceToBob, func createMirroredChannel(t *testing.T, aliceToBob,
bobToCarol btcutil.Amount) (*testLightningChannel, bobToAlice btcutil.Amount) (*testLightningChannel,
*testLightningChannel, error) { *testLightningChannel, error) {
_, _, firstChanID, _ := genIDs() _, _, firstChanID, _ := genIDs()
// Create lightning channels between Alice<->Bob and Bob<->Carol // Create lightning channels between Alice<->Bob for Alice and Bob
alice, bob, err := createTestChannel(t, alicePrivKey, bobPrivKey, alice, bob, err := createTestChannel(t, alicePrivKey, bobPrivKey,
aliceToBob, aliceToBob, 0, 0, firstChanID, aliceToBob, bobToAlice, 0, 0, firstChanID,
) )
if err != nil { if err != nil {
return nil, nil, errors.Errorf("unable to create "+ return nil, nil, errors.Errorf("unable to create "+