Merge pull request #8962 from ProofOfKeags/refactor/quiescence-micro-spinoffs
[NANO]: Refactor/quiescence micro spinoffs
This commit is contained in:
3 files changed
+12
-12
No files matched your search
+3
-3
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
crand "crypto/rand"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
prand "math/rand"
|
||||
"sync"
|
||||
@@ -13,7 +14,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
@@ -480,7 +480,7 @@ var _ ChannelLink = (*channelLink)(nil)
|
||||
// NOTE: Part of the ChannelLink interface.
|
||||
func (l *channelLink) Start() error {
|
||||
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")
|
||||
return err
|
||||
}
|
||||
@@ -4080,7 +4080,7 @@ func (l *channelLink) sendMalformedHTLCError(htlcIndex uint64,
|
||||
// remote peer.
|
||||
func (l *channelLink) fail(linkErr LinkFailureError,
|
||||
format string, a ...interface{}) {
|
||||
reason := errors.Errorf(format, a...)
|
||||
reason := fmt.Errorf(format, a...)
|
||||
|
||||
// Return if we have already notified about a failure.
|
||||
if l.failed {
|
||||
|
||||
@@ -444,7 +444,7 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Setup a alice-bob network.
|
||||
alice, bob, err := createTwoClusterChannels(
|
||||
alice, bob, err := createMirroredChannel(
|
||||
t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5,
|
||||
)
|
||||
require.NoError(t, err, "unable to create channel")
|
||||
@@ -6318,7 +6318,7 @@ func TestChannelLinkCanceledInvoice(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Setup a alice-bob network.
|
||||
alice, bob, err := createTwoClusterChannels(
|
||||
alice, bob, err := createMirroredChannel(
|
||||
t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5,
|
||||
)
|
||||
require.NoError(t, err, "unable to create channel")
|
||||
@@ -6374,7 +6374,7 @@ type hodlInvoiceTestCtx struct {
|
||||
|
||||
func newHodlInvoiceTestCtx(t *testing.T) (*hodlInvoiceTestCtx, error) {
|
||||
// Setup a alice-bob network.
|
||||
alice, bob, err := createTwoClusterChannels(
|
||||
alice, bob, err := createMirroredChannel(
|
||||
t, btcutil.SatoshiPerBitcoin*3, btcutil.SatoshiPerBitcoin*5,
|
||||
)
|
||||
require.NoError(t, err, "unable to create channel")
|
||||
|
||||
@@ -1053,17 +1053,17 @@ func serverOptionRejectHtlc(alice, bob, carol bool) serverOption {
|
||||
}
|
||||
}
|
||||
|
||||
// createTwoClusterChannels creates lightning channels which are needed for
|
||||
// a 2 hop network cluster to be initialized.
|
||||
func createTwoClusterChannels(t *testing.T, aliceToBob,
|
||||
bobToCarol btcutil.Amount) (*testLightningChannel,
|
||||
// createMirroredChannel creates two LightningChannel objects which represent
|
||||
// the state machines on either side of a single channel between alice and bob.
|
||||
func createMirroredChannel(t *testing.T, aliceToBob,
|
||||
bobToAlice btcutil.Amount) (*testLightningChannel,
|
||||
*testLightningChannel, error) {
|
||||
|
||||
_, _, 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,
|
||||
aliceToBob, aliceToBob, 0, 0, firstChanID,
|
||||
aliceToBob, bobToAlice, 0, 0, firstChanID,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Errorf("unable to create "+
|
||||
|
||||
Reference in new issue
Block a user