peer_test+test_utils: remove duplicate *LightningChannel return param
It was already present in the peer object that was returned.
This commit is contained in:
parent
02fd905f61
commit
1a91013c14
10
peer_test.go
10
peer_test.go
@ -40,7 +40,7 @@ func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
broadcastTxChan := make(chan *wire.MsgTx)
|
broadcastTxChan := make(chan *wire.MsgTx)
|
||||||
|
|
||||||
alicePeer, _, bobChan, cleanUp, err := createTestPeer(
|
alicePeer, bobChan, cleanUp, err := createTestPeer(
|
||||||
notifier, broadcastTxChan, noUpdate,
|
notifier, broadcastTxChan, noUpdate,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -141,7 +141,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
|
|||||||
}
|
}
|
||||||
broadcastTxChan := make(chan *wire.MsgTx)
|
broadcastTxChan := make(chan *wire.MsgTx)
|
||||||
|
|
||||||
alicePeer, _, bobChan, cleanUp, err := createTestPeer(
|
alicePeer, bobChan, cleanUp, err := createTestPeer(
|
||||||
notifier, broadcastTxChan, noUpdate,
|
notifier, broadcastTxChan, noUpdate,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -262,7 +262,7 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
broadcastTxChan := make(chan *wire.MsgTx)
|
broadcastTxChan := make(chan *wire.MsgTx)
|
||||||
|
|
||||||
alicePeer, _, bobChan, cleanUp, err := createTestPeer(
|
alicePeer, bobChan, cleanUp, err := createTestPeer(
|
||||||
notifier, broadcastTxChan, noUpdate,
|
notifier, broadcastTxChan, noUpdate,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -454,7 +454,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
|
|||||||
}
|
}
|
||||||
broadcastTxChan := make(chan *wire.MsgTx)
|
broadcastTxChan := make(chan *wire.MsgTx)
|
||||||
|
|
||||||
alicePeer, _, bobChan, cleanUp, err := createTestPeer(
|
alicePeer, bobChan, cleanUp, err := createTestPeer(
|
||||||
notifier, broadcastTxChan, noUpdate,
|
notifier, broadcastTxChan, noUpdate,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -788,7 +788,7 @@ func TestCustomShutdownScript(t *testing.T) {
|
|||||||
broadcastTxChan := make(chan *wire.MsgTx)
|
broadcastTxChan := make(chan *wire.MsgTx)
|
||||||
|
|
||||||
// Open a channel.
|
// Open a channel.
|
||||||
alicePeer, _, bobChan, cleanUp, err := createTestPeer(
|
alicePeer, bobChan, cleanUp, err := createTestPeer(
|
||||||
notifier, broadcastTxChan, test.update,
|
notifier, broadcastTxChan, test.update,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -102,7 +102,7 @@ var noUpdate = func(a, b *channeldb.OpenChannel) {}
|
|||||||
// the channel states for each peer.
|
// the channel states for each peer.
|
||||||
func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
||||||
updateChan func(a, b *channeldb.OpenChannel)) (*peer, *lnwallet.LightningChannel,
|
updateChan func(a, b *channeldb.OpenChannel)) (*peer, *lnwallet.LightningChannel,
|
||||||
*lnwallet.LightningChannel, func(), error) {
|
func(), error) {
|
||||||
|
|
||||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(
|
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(
|
||||||
btcec.S256(), alicesPrivKey,
|
btcec.S256(), alicesPrivKey,
|
||||||
@ -178,23 +178,23 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
|
|
||||||
bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize())
|
bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot)
|
bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot)
|
||||||
bobFirstRevoke, err := bobPreimageProducer.AtIndex(0)
|
bobFirstRevoke, err := bobPreimageProducer.AtIndex(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
bobCommitPoint := input.ComputeCommitmentPoint(bobFirstRevoke[:])
|
bobCommitPoint := input.ComputeCommitmentPoint(bobFirstRevoke[:])
|
||||||
|
|
||||||
aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize())
|
aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot)
|
alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot)
|
||||||
aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0)
|
aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
aliceCommitPoint := input.ComputeCommitmentPoint(aliceFirstRevoke[:])
|
aliceCommitPoint := input.ComputeCommitmentPoint(aliceFirstRevoke[:])
|
||||||
|
|
||||||
@ -203,33 +203,33 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
bobCommitPoint, *fundingTxIn, channeldb.SingleFunderTweaklessBit,
|
bobCommitPoint, *fundingTxIn, channeldb.SingleFunderTweaklessBit,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
alicePath, err := ioutil.TempDir("", "alicedb")
|
alicePath, err := ioutil.TempDir("", "alicedb")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dbAlice, err := channeldb.Open(alicePath)
|
dbAlice, err := channeldb.Open(alicePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
bobPath, err := ioutil.TempDir("", "bobdb")
|
bobPath, err := ioutil.TempDir("", "bobdb")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dbBob, err := channeldb.Open(bobPath)
|
dbBob, err := channeldb.Open(bobPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
estimator := chainfee.NewStaticEstimator(12500, 0)
|
estimator := chainfee.NewStaticEstimator(12500, 0)
|
||||||
feePerKw, err := estimator.EstimateFeePerKW(1)
|
feePerKw, err := estimator.EstimateFeePerKW(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): need to factor in commit fee?
|
// 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
|
var chanIDBytes [8]byte
|
||||||
if _, err := io.ReadFull(crand.Reader, chanIDBytes[:]); err != nil {
|
if _, err := io.ReadFull(crand.Reader, chanIDBytes[:]); err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
shortChanID := lnwire.NewShortChanIDFromInt(
|
shortChanID := lnwire.NewShortChanIDFromInt(
|
||||||
@ -305,7 +305,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := aliceChannelState.SyncPending(aliceAddr, 0); err != nil {
|
if err := aliceChannelState.SyncPending(aliceAddr, 0); err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
bobAddr := &net.TCPAddr{
|
bobAddr := &net.TCPAddr{
|
||||||
@ -314,7 +314,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := bobChannelState.SyncPending(bobAddr, 0); err != nil {
|
if err := bobChannelState.SyncPending(bobAddr, 0); err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanUpFunc := func() {
|
cleanUpFunc := func() {
|
||||||
@ -330,7 +330,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
aliceSigner, aliceChannelState, alicePool,
|
aliceSigner, aliceChannelState, alicePool,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
alicePool.Start()
|
alicePool.Start()
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
bobSigner, bobChannelState, bobPool,
|
bobSigner, bobChannelState, bobPool,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
bobPool.Start()
|
bobPool.Start()
|
||||||
|
|
||||||
@ -384,7 +384,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
|
|
||||||
_, currentHeight, err := s.cc.chainIO.GetBestBlock()
|
_, currentHeight, err := s.cc.chainIO.GetBestBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
htlcSwitch, err := htlcswitch.New(htlcswitch.Config{
|
htlcSwitch, err := htlcswitch.New(htlcswitch.Config{
|
||||||
@ -399,10 +399,10 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
htlcswitch.DefaultAckInterval),
|
htlcswitch.DefaultAckInterval),
|
||||||
}, uint32(currentHeight))
|
}, uint32(currentHeight))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
if err = htlcSwitch.Start(); err != nil {
|
if err = htlcSwitch.Start(); err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
s.htlcSwitch = htlcSwitch
|
s.htlcSwitch = htlcSwitch
|
||||||
|
|
||||||
@ -422,10 +422,10 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
ApplyChannelUpdate: func(*lnwire.ChannelUpdate) error { return nil },
|
ApplyChannelUpdate: func(*lnwire.ChannelUpdate) error { return nil },
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
if err = chanStatusMgr.Start(); err != nil {
|
if err = chanStatusMgr.Start(); err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
s.chanStatusMgr = chanStatusMgr
|
s.chanStatusMgr = chanStatusMgr
|
||||||
|
|
||||||
@ -458,5 +458,5 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, publTx chan *wire.MsgTx,
|
|||||||
alicePeer.wg.Add(1)
|
alicePeer.wg.Add(1)
|
||||||
go alicePeer.channelManager()
|
go alicePeer.channelManager()
|
||||||
|
|
||||||
return alicePeer, channelAlice, channelBob, cleanUpFunc, nil
|
return alicePeer, channelBob, cleanUpFunc, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user