From 1882939cd802473a7b549f1c608a517a39bbc5ca Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 21 Jul 2025 13:53:25 +0200 Subject: [PATCH] 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. --- lnwallet/chancloser/rbf_coop_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lnwallet/chancloser/rbf_coop_test.go b/lnwallet/chancloser/rbf_coop_test.go index 0f2b6055d..485aef17b 100644 --- a/lnwallet/chancloser/rbf_coop_test.go +++ b/lnwallet/chancloser/rbf_coop_test.go @@ -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