Skip to content

Commit 233742c

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 233742c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lnwallet/chancloser/rbf_coop_test.go

Lines changed: 13 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,13 @@ 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(
1395+
ctx, &flushEvent,
1396+
)
1397+
},
13931398
)
13941399
})
13951400

@@ -1857,7 +1862,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
18571862
// sig.
18581863
closeHarness.assertSingleRemoteRbfIteration(
18591864
feeOffer, balanceAfterClose, absoluteFee, sequence,
1860-
false, true,
1865+
false, nil,
18611866
)
18621867

18631868
// Next, we'll receive an offer from the remote party, and drive
@@ -1867,7 +1872,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
18671872
absoluteFee = feeOffer.SigMsg.FeeSatoshis
18681873
closeHarness.assertSingleRemoteRbfIteration(
18691874
feeOffer, balanceAfterClose, absoluteFee, sequence,
1870-
true, true,
1875+
true, nil,
18711876
)
18721877

18731878
closeHarness.assertNoStateTransitions()
@@ -1950,7 +1955,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
19501955
// sig.
19511956
closeHarness.assertSingleRemoteRbfIteration(
19521957
feeOffer, balanceAfterClose, absoluteFee, sequence,
1953-
false, true,
1958+
false, nil,
19541959
)
19551960
})
19561961

@@ -2048,7 +2053,7 @@ func TestRbfCloseErr(t *testing.T) {
20482053
// sig.
20492054
closeHarness.assertSingleRemoteRbfIteration(
20502055
feeOffer, balanceAfterClose, absoluteFee, sequence,
2051-
true, true,
2056+
true, nil,
20522057
)
20532058
})
20542059

0 commit comments

Comments
 (0)