Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions lnwallet/chancloser/rbf_coop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,16 @@ func (r *rbfCloserTestHarness) assertSingleRbfIteration(
r.assertLocalClosePending()
}

// assertSingleRemoteRbfIteration asserts that a single RBF iteration initiated
// by the remote party completes successfully. The sendEvent callback controls
// when the event that kicks off the process is sent, which is useful for tests
// that need to set up mocks before the event is processed. The callback is
// provided with the context and the initial offer event so most callers can
// pass chanCloser.SendEvent directly.
func (r *rbfCloserTestHarness) assertSingleRemoteRbfIteration(
initEvent *OfferReceivedEvent, balanceAfterClose,
absoluteFee btcutil.Amount, sequence uint32, iteration bool,
sendInit bool) {
sendEvent func(context.Context, ProtocolEvent)) {

ctx := r.T.Context()

Expand All @@ -696,9 +702,7 @@ func (r *rbfCloserTestHarness) assertSingleRemoteRbfIteration(
absoluteFee, balanceAfterClose, false,
)

if sendInit {
r.chanCloser.SendEvent(ctx, initEvent)
}
sendEvent(ctx, initEvent)

// Our outer state should transition to ClosingNegotiation state.
transitions := []RbfState{
Expand Down Expand Up @@ -1386,10 +1390,13 @@ func TestRbfChannelFlushingTransitions(t *testing.T) {
// Now we'll send in the channel flushed event, and assert that
// this triggers a remote RBF iteration (we process their early
// offer and send our sig).
closeHarness.chanCloser.SendEvent(ctx, &flushEvent)
closeHarness.assertSingleRemoteRbfIteration(
remoteOffer, absoluteFee, absoluteFee, sequence, true,
false,
func(ctx context.Context, _ ProtocolEvent) {
closeHarness.chanCloser.SendEvent(
ctx, &flushEvent,
)
},
)
})

Expand Down Expand Up @@ -1857,7 +1864,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
// sig.
closeHarness.assertSingleRemoteRbfIteration(
feeOffer, balanceAfterClose, absoluteFee, sequence,
false, true,
false, closeHarness.chanCloser.SendEvent,
)

// Next, we'll receive an offer from the remote party, and drive
Expand All @@ -1867,7 +1874,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
absoluteFee = feeOffer.SigMsg.FeeSatoshis
closeHarness.assertSingleRemoteRbfIteration(
feeOffer, balanceAfterClose, absoluteFee, sequence,
true, true,
true, closeHarness.chanCloser.SendEvent,
)

closeHarness.assertNoStateTransitions()
Expand Down Expand Up @@ -1950,7 +1957,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
// sig.
closeHarness.assertSingleRemoteRbfIteration(
feeOffer, balanceAfterClose, absoluteFee, sequence,
false, true,
false, closeHarness.chanCloser.SendEvent,
)
})

Expand Down Expand Up @@ -2048,7 +2055,7 @@ func TestRbfCloseErr(t *testing.T) {
// sig.
closeHarness.assertSingleRemoteRbfIteration(
feeOffer, balanceAfterClose, absoluteFee, sequence,
true, true,
true, closeHarness.chanCloser.SendEvent,
)
})

Expand Down
Loading