chancloser: fix flake in TestRbfCloseClosingNegotiationRemote

This fixes the actual flake: We didn't wait for next iterations to _not_
come in, so depending on timing, we could read another transition in a
second run.
But making sure we expect all transitions at the same time and then make
sure no further transitions come in makes this not depend on time.
This commit is contained in:
Oliver Gugger
2025-07-18 14:00:01 +02:00
parent 263d070624
commit bc33986bfa

View File

@@ -128,7 +128,7 @@ func assertStateTransitions[Event any, Env protofsm.Environment](
select {
case newState := <-stateSub.NewItemCreated.ChanOut():
t.Fatalf("unexpected state transition: %v", newState)
default:
case <-time.After(defaultPoll):
}
}
@@ -701,15 +701,21 @@ func (r *rbfCloserTestHarness) assertSingleRemoteRbfIteration(
}
// Our outer state should transition to ClosingNegotiation state.
r.assertStateTransitions(&ClosingNegotiation{})
transitions := []RbfState{
&ClosingNegotiation{},
}
// If this is an iteration, then we'll go from ClosePending ->
// RemoteCloseStart -> ClosePending. So we'll assert an extra transition
// here.
if iteration {
r.assertStateTransitions(&ClosingNegotiation{})
transitions = append(transitions, &ClosingNegotiation{})
}
// Now that we know how many state transitions to expect, we'll wait
// for them.
r.assertStateTransitions(transitions...)
// If we examine the final resting state, we should see that the we're
// now in the ClosePending state for the remote peer.
currentState := assertStateT[*ClosingNegotiation](r)
@@ -1734,7 +1740,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
closeHarness.assertNoStateTransitions()
})
// If our balance, is dust, then the remote party should send a
// If our balance is dust, then the remote party should send a
// signature that doesn't include our output.
t.Run("recv_offer_err_closer_no_closee", func(t *testing.T) {
// We'll modify our local balance to be dust.