chancloser: fix flake by registering subscriber first

Fixes another flake in the unit-race test: Sometimes we miss startup
events if there's a high CPU load (in CI for example).
To avoid that, we register our subscriber before starting the state
machine.
This commit is contained in:
Oliver Gugger
2025-07-21 13:53:25 +02:00
parent 15d8f963ce
commit 1882939cd8

View File

@@ -825,10 +825,13 @@ func newRbfCloserTestHarness(t *testing.T,
).Return(nil)
chanCloser := protofsm.NewStateMachine(protoCfg)
chanCloser.Start(ctx)
// We register our subscriber before starting the state machine, to make
// sure we don't miss any events.
harness.stateSub = chanCloser.RegisterStateEvents()
chanCloser.Start(ctx)
harness.chanCloser = &chanCloser
return harness