chancloser: use separate broadcast channels
This doesn't change the behavior but makes the use of the broadcast channels more clear.
This commit is contained in:
1 file changed
+8
-5
@@ -509,7 +509,10 @@ func TestTaprootFastClose(t *testing.T) {
|
|||||||
aliceChan := newMockTaprootChan(t, true)
|
aliceChan := newMockTaprootChan(t, true)
|
||||||
bobChan := newMockTaprootChan(t, false)
|
bobChan := newMockTaprootChan(t, false)
|
||||||
|
|
||||||
broadcastSignal := make(chan struct{}, 2)
|
// We'll create two distinct broadcast signals to ensure that each party
|
||||||
|
// broadcasts at the correct time.
|
||||||
|
aliceBroadcast := make(chan struct{}, 1)
|
||||||
|
bobBroadcast := make(chan struct{}, 1)
|
||||||
|
|
||||||
idealFee := chainfee.SatPerKWeight(506)
|
idealFee := chainfee.SatPerKWeight(506)
|
||||||
|
|
||||||
@@ -520,7 +523,7 @@ func TestTaprootFastClose(t *testing.T) {
|
|||||||
Channel: aliceChan,
|
Channel: aliceChan,
|
||||||
MusigSession: newMockMusigSession(),
|
MusigSession: newMockMusigSession(),
|
||||||
BroadcastTx: func(_ *wire.MsgTx, _ string) error {
|
BroadcastTx: func(_ *wire.MsgTx, _ string) error {
|
||||||
broadcastSignal <- struct{}{}
|
aliceBroadcast <- struct{}{}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
MaxFee: chainfee.SatPerKWeight(1000),
|
MaxFee: chainfee.SatPerKWeight(1000),
|
||||||
@@ -538,7 +541,7 @@ func TestTaprootFastClose(t *testing.T) {
|
|||||||
MusigSession: newMockMusigSession(),
|
MusigSession: newMockMusigSession(),
|
||||||
MaxFee: chainfee.SatPerKWeight(1000),
|
MaxFee: chainfee.SatPerKWeight(1000),
|
||||||
BroadcastTx: func(_ *wire.MsgTx, _ string) error {
|
BroadcastTx: func(_ *wire.MsgTx, _ string) error {
|
||||||
broadcastSignal <- struct{}{}
|
bobBroadcast <- struct{}{}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
FeeEstimator: &SimpleCoopFeeEstimator{},
|
FeeEstimator: &SimpleCoopFeeEstimator{},
|
||||||
@@ -591,7 +594,7 @@ func TestTaprootFastClose(t *testing.T) {
|
|||||||
|
|
||||||
// At this point, Bob has accepted the offer, so he can broadcast the
|
// At this point, Bob has accepted the offer, so he can broadcast the
|
||||||
// closing transaction, and considers the channel closed.
|
// closing transaction, and considers the channel closed.
|
||||||
_, err = lnutils.RecvOrTimeout(broadcastSignal, time.Second*1)
|
_, err = lnutils.RecvOrTimeout(bobBroadcast, time.Second*1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Bob's fee proposal should exactly match Alice's initial fee.
|
// Bob's fee proposal should exactly match Alice's initial fee.
|
||||||
@@ -623,7 +626,7 @@ func TestTaprootFastClose(t *testing.T) {
|
|||||||
aliceClosingSigned = oClosingSigned.UnwrapOrFail(t)
|
aliceClosingSigned = oClosingSigned.UnwrapOrFail(t)
|
||||||
|
|
||||||
// Alice should now also broadcast her closing transaction.
|
// Alice should now also broadcast her closing transaction.
|
||||||
_, err = lnutils.RecvOrTimeout(broadcastSignal, time.Second*1)
|
_, err = lnutils.RecvOrTimeout(aliceBroadcast, time.Second*1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Finally, Bob will process Alice's echo message, and conclude.
|
// Finally, Bob will process Alice's echo message, and conclude.
|
||||||
|
|||||||
Reference in new issue
Block a user