Skip to content

lnwallet/chancloser: fix flake in TestRbfCloseClosingNegotiationLocal #9652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 20 additions & 20 deletions lnwallet/chancloser/rbf_coop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func (d dustExpectation) String() string {
// message to the remote party, and all the other intermediate steps.
func (r *rbfCloserTestHarness) expectHalfSignerIteration(
initEvent ProtocolEvent, balanceAfterClose, absoluteFee btcutil.Amount,
dustExpect dustExpectation) {
dustExpect dustExpectation, iteration bool) {

ctx := context.Background()
numFeeCalls := 2
Expand Down Expand Up @@ -569,8 +569,16 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
}

case *SendOfferEvent:

expectedStates = []RbfState{&ClosingNegotiation{}}

// If we're in the middle of an iteration, then we expect a
// transition from ClosePending -> LocalCloseStart.
if iteration {
expectedStates = append(
expectedStates, &ClosingNegotiation{},
)
}

case *ChannelFlushed:
// If we're sending a flush event here, then this means that we
// also have enough balance to cover the fee so we'll have
Expand All @@ -585,10 +593,6 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(

// We should transition from the negotiation state back to
// itself.
//
// TODO(roasbeef): take in expected set of transitions!!!
// * or base off of event, if shutdown recv'd know we're doing a full
// loop
r.assertStateTransitions(expectedStates...)

// If we examine the final resting state, we should see that
Expand All @@ -610,14 +614,15 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(

func (r *rbfCloserTestHarness) assertSingleRbfIteration(
initEvent ProtocolEvent, balanceAfterClose, absoluteFee btcutil.Amount,
dustExpect dustExpectation) {
dustExpect dustExpectation, iteration bool) {

ctx := context.Background()

// We'll now send in the send offer event, which should trigger 1/2 of
// the RBF loop, ending us in the LocalOfferSent state.
r.expectHalfSignerIteration(
initEvent, balanceAfterClose, absoluteFee, noDustExpect,
iteration,
)

// Now that we're in the local offer sent state, we'll send the
Expand Down Expand Up @@ -1299,7 +1304,7 @@ func TestRbfChannelFlushingTransitions(t *testing.T) {
// flow.
closeHarness.expectHalfSignerIteration(
&flushEvent, balanceAfterClose, absoluteFee,
noDustExpect,
noDustExpect, false,
)
})
}
Expand Down Expand Up @@ -1418,7 +1423,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
// pending state.
closeHarness.assertSingleRbfIteration(
sendOfferEvent, balanceAfterClose, absoluteFee,
noDustExpect,
noDustExpect, false,
)
})

Expand All @@ -1434,7 +1439,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
// event to advance the state machine.
closeHarness.expectHalfSignerIteration(
sendOfferEvent, balanceAfterClose, absoluteFee,
noDustExpect,
noDustExpect, false,
)

// We'll now craft the local sig received event, but this time
Expand Down Expand Up @@ -1489,7 +1494,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
// proper field is set.
closeHarness.expectHalfSignerIteration(
sendOfferEvent, balanceAfterClose, absoluteFee,
remoteDustExpect,
remoteDustExpect, false,
)
})

Expand All @@ -1516,7 +1521,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
dustBalance := btcutil.Amount(100)
closeHarness.expectHalfSignerIteration(
sendOfferEvent, dustBalance, absoluteFee,
localDustExpect,
localDustExpect, false,
)
})

Expand Down Expand Up @@ -1581,7 +1586,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
// assuming we start in this negotiation state.
closeHarness.assertSingleRbfIteration(
sendOfferEvent, balanceAfterClose, absoluteFee,
noDustExpect,
noDustExpect, false,
)

// Next, we'll send in a new SendOfferEvent event which
Expand All @@ -1596,12 +1601,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
// initiate a new local sig).
closeHarness.assertSingleRbfIteration(
localOffer, balanceAfterClose, absoluteFee,
noDustExpect,
)

// We should terminate in the negotiation state.
closeHarness.assertStateTransitions(
&ClosingNegotiation{},
noDustExpect, true,
)
})

Expand Down Expand Up @@ -2004,7 +2004,7 @@ func TestRbfCloseErr(t *testing.T) {
// initiate a new local sig).
closeHarness.assertSingleRbfIteration(
localOffer, balanceAfterClose, absoluteFee,
noDustExpect,
noDustExpect, false,
)

// We should terminate in the negotiation state.
Expand Down
Loading