diff --git a/htlcswitch/link.go b/htlcswitch/link.go index eaeaf2e87..083677ec7 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -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 { diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index f508ede06..36f273112 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -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") diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index 9a72197ec..0b3b0fcdf 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -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 "+