Skip to content

Commit 4bacf0e

Browse files
committed
chancloser: stabilize remote RBF coop tests
CI started panicking in TestRbfChannelFlushingTransitions/early_offer / TestRbfCloseClosingNegotiationRemote (see GitHub Actions run https://github.com/lightningnetwork/lnd/actions/runs/19155841408/job/54756127218?pr=10352) because the cached remote offer could fire before the test harness registered its mock CloseSigner expectations. When that happened, the mock complained that CreateCloseProposal was unexpected: panic: assert: mock: I don't know what to return because the method call was unexpected. Fix this by letting assertSingleRemoteRbfIteration take a trigger callback. Tests that rely on asynchronously replayed offers now install their expectations first and then fire the event via the callback. All other call sites pass nil, preserving their existing behavior. Reproduction (on master) ------------------------ 1. Modify lnwallet/chancloser/rbf_coop_test.go Add time.Sleep(10 * time.Millisecond) before the first call of closeHarness.assertSingleRemoteRbfIteration (in function TestRbfChannelFlushingTransitions). 2. go test ./lnwallet/chancloser -run TestRbfChannelFlushingTransitions/early_offer 3. The panic reproduces immediately.
1 parent 096ab65 commit 4bacf0e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lnwallet/chancloser/rbf_coop_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ func (r *rbfCloserTestHarness) assertSingleRbfIteration(
684684
func (r *rbfCloserTestHarness) assertSingleRemoteRbfIteration(
685685
initEvent *OfferReceivedEvent, balanceAfterClose,
686686
absoluteFee btcutil.Amount, sequence uint32, iteration bool,
687-
sendInit bool) {
687+
trigger func()) {
688688

689689
ctx := r.T.Context()
690690

@@ -696,7 +696,9 @@ func (r *rbfCloserTestHarness) assertSingleRemoteRbfIteration(
696696
absoluteFee, balanceAfterClose, false,
697697
)
698698

699-
if sendInit {
699+
if trigger != nil {
700+
trigger()
701+
} else {
700702
r.chanCloser.SendEvent(ctx, initEvent)
701703
}
702704

@@ -1386,10 +1388,11 @@ func TestRbfChannelFlushingTransitions(t *testing.T) {
13861388
// Now we'll send in the channel flushed event, and assert that
13871389
// this triggers a remote RBF iteration (we process their early
13881390
// offer and send our sig).
1389-
closeHarness.chanCloser.SendEvent(ctx, &flushEvent)
13901391
closeHarness.assertSingleRemoteRbfIteration(
13911392
remoteOffer, absoluteFee, absoluteFee, sequence, true,
1392-
false,
1393+
func() {
1394+
closeHarness.chanCloser.SendEvent(ctx, &flushEvent)
1395+
},
13931396
)
13941397
})
13951398

@@ -1857,7 +1860,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
18571860
// sig.
18581861
closeHarness.assertSingleRemoteRbfIteration(
18591862
feeOffer, balanceAfterClose, absoluteFee, sequence,
1860-
false, true,
1863+
false, nil,
18611864
)
18621865

18631866
// Next, we'll receive an offer from the remote party, and drive
@@ -1867,7 +1870,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
18671870
absoluteFee = feeOffer.SigMsg.FeeSatoshis
18681871
closeHarness.assertSingleRemoteRbfIteration(
18691872
feeOffer, balanceAfterClose, absoluteFee, sequence,
1870-
true, true,
1873+
true, nil,
18711874
)
18721875

18731876
closeHarness.assertNoStateTransitions()
@@ -1950,7 +1953,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
19501953
// sig.
19511954
closeHarness.assertSingleRemoteRbfIteration(
19521955
feeOffer, balanceAfterClose, absoluteFee, sequence,
1953-
false, true,
1956+
false, nil,
19541957
)
19551958
})
19561959

@@ -2048,7 +2051,7 @@ func TestRbfCloseErr(t *testing.T) {
20482051
// sig.
20492052
closeHarness.assertSingleRemoteRbfIteration(
20502053
feeOffer, balanceAfterClose, absoluteFee, sequence,
2051-
true, true,
2054+
true, nil,
20522055
)
20532056
})
20542057

0 commit comments

Comments
 (0)