From 1a91013c1482c093bee4a9d795d4bb0ffa723bf9 Mon Sep 17 00:00:00 2001 From: nsa Date: Fri, 26 Jun 2020 21:51:51 -0400 Subject: [PATCH] peer_test+test_utils: remove duplicate *LightningChannel return param It was already present in the peer object that was returned. --- peer_test.go | 10 +++++----- test_utils.go | 44 ++++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/peer_test.go b/peer_test.go index 1d1afbc0..adbb6570 100644 --- a/peer_test.go +++ b/peer_test.go @@ -40,7 +40,7 @@ func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) { } broadcastTxChan := make(chan *wire.MsgTx) - alicePeer, _, bobChan, cleanUp, err := createTestPeer( + alicePeer, bobChan, cleanUp, err := createTestPeer( notifier, broadcastTxChan, noUpdate, ) if err != nil { @@ -141,7 +141,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) { } broadcastTxChan := make(chan *wire.MsgTx) - alicePeer, _, bobChan, cleanUp, err := createTestPeer( + alicePeer, bobChan, cleanUp, err := createTestPeer( notifier, broadcastTxChan, noUpdate, ) if err != nil { @@ -262,7 +262,7 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) { } broadcastTxChan := make(chan *wire.MsgTx) - alicePeer, _, bobChan, cleanUp, err := createTestPeer( + alicePeer, bobChan, cleanUp, err := createTestPeer( notifier, broadcastTxChan, noUpdate, ) if err != nil { @@ -454,7 +454,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) { } broadcastTxChan := make(chan *wire.MsgTx) - alicePeer, _, bobChan, cleanUp, err := createTestPeer( + alicePeer, bobChan, cleanUp, err := createTestPeer( notifier, broadcastTxChan, noUpdate, ) if err != nil { @@ -788,7 +788,7 @@ func TestCustomShutdownScript(t *testing.T) { broadcastTxChan := make(chan *wire.MsgTx) // Open a channel. - alicePeer, _, bobChan, cleanUp, err := createTestPeer( + alicePeer, bobChan, cleanUp, err := createTestPeer( notifier, broadcastTxChan, test.update, ) if err != nil { diff --git a/test_utils.go b/test_utils.go index 0e032ee0..d0f9a68d 100644 --- a/test_utils.go +++ b/test_utils.go @@ -102,7 +102,7 @@ var noUpdate = func(a, b *channeldb.OpenChannel) {} // the channel states for each peer. func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, updateChan func(a, b *channeldb.OpenChannel)) (*peer, *lnwallet.LightningChannel, - *lnwallet.LightningChannel, func(), error) { + func(), error) { aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes( btcec.S256(), alicesPrivKey, @@ -178,23 +178,23 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize()) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } bobCommitPoint := input.ComputeCommitmentPoint(bobFirstRevoke[:]) aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize()) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } aliceCommitPoint := input.ComputeCommitmentPoint(aliceFirstRevoke[:]) @@ -203,33 +203,33 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, bobCommitPoint, *fundingTxIn, channeldb.SingleFunderTweaklessBit, ) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } alicePath, err := ioutil.TempDir("", "alicedb") if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } dbAlice, err := channeldb.Open(alicePath) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } bobPath, err := ioutil.TempDir("", "bobdb") if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } dbBob, err := channeldb.Open(bobPath) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } estimator := chainfee.NewStaticEstimator(12500, 0) feePerKw, err := estimator.EstimateFeePerKW(1) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } // TODO(roasbeef): need to factor in commit fee? @@ -254,7 +254,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, var chanIDBytes [8]byte if _, err := io.ReadFull(crand.Reader, chanIDBytes[:]); err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } shortChanID := lnwire.NewShortChanIDFromInt( @@ -305,7 +305,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, } if err := aliceChannelState.SyncPending(aliceAddr, 0); err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } bobAddr := &net.TCPAddr{ @@ -314,7 +314,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, } if err := bobChannelState.SyncPending(bobAddr, 0); err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } cleanUpFunc := func() { @@ -330,7 +330,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, aliceSigner, aliceChannelState, alicePool, ) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } alicePool.Start() @@ -339,7 +339,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, bobSigner, bobChannelState, bobPool, ) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } bobPool.Start() @@ -384,7 +384,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, _, currentHeight, err := s.cc.chainIO.GetBestBlock() if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } htlcSwitch, err := htlcswitch.New(htlcswitch.Config{ @@ -399,10 +399,10 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, htlcswitch.DefaultAckInterval), }, uint32(currentHeight)) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } if err = htlcSwitch.Start(); err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } s.htlcSwitch = htlcSwitch @@ -422,10 +422,10 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, ApplyChannelUpdate: func(*lnwire.ChannelUpdate) error { return nil }, }) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } if err = chanStatusMgr.Start(); err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } s.chanStatusMgr = chanStatusMgr @@ -458,5 +458,5 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx, alicePeer.wg.Add(1) go alicePeer.channelManager() - return alicePeer, channelAlice, channelBob, cleanUpFunc, nil + return alicePeer, channelBob, cleanUpFunc, nil }