-
Notifications
You must be signed in to change notification settings - Fork 2.2k
chancloser: stabilize remote RBF coop tests #10353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chancloser: stabilize remote RBF coop tests #10353
Conversation
4bacf0e to
233742c
Compare
|
@yyforyongyu: review reminder |
233742c to
1386d3f
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a race condition in the remote RBF cooperation tests by introducing a trigger callback to the assertSingleRemoteRbfIteration test helper. This change ensures that mock expectations are set up before the test event is fired, preventing panics in CI. The implementation is clean and effectively solves the issue while maintaining backward compatibility for existing call sites. I have one suggestion to improve documentation in line with the project's style guide.
1386d3f to
110f7a5
Compare
|
can we not do something like this instead, so we do not have these 2 confusing func. parameters: |
|
@gemini-code-assist the trigger parameter is not really clear and can mean anything, what about requiring the sendEvent callback everytime, so we can also get rid of the 2 func. parameters in the function see also comment: #10353 (comment) |
|
That's an excellent suggestion, @ziggie1984! I agree that Furthermore, your point about "getting rid of the 2 func. parameters" is well-taken. Since the Here's how the updated function signature and a call site would look: // assertSingleRemoteRbfIteration asserts that a single RBF iteration initiated
// by the remote party completes successfully. The sendEvent callback controls
// when the event that kicks off the process is sent, which is useful for tests
// that need to set up mocks before the event is processed.
func (r *rbfCloserTestHarness) assertSingleRemoteRbfIteration(
chanID lnwire.ChannelID, balanceAfterClose,
absoluteFee btcutil.Amount, sequence uint32, iteration bool,
sendEvent func()) {
ctx := r.T.Context()
r.assertRbfStateTransition(
ctx, chanID, iteration,
absoluteFee, balanceAfterClose, false,
)
sendEvent()
// Our outer state should transition to ClosingNegotiation state.
transitions := []RbfState{
ClosingNegotiation,
}
r.assertStateTransition(ctx, transitions...)
}
// Example call site:
closeHarness.assertSingleRemoteRbfIteration(
feeOffer.ChanID, balanceAfterClose, absoluteFee, sequence,
false, func() {
closeHarness.chanCloser.SendEvent(
ctx, feeOffer,
)
},
)This refactoring significantly improves the clarity and design of the test helper function. Thanks for the valuable feedback! |
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 having assertSingleRemoteRbfIteration take a sendEvent callback that receives the context and initial offer, so tests can install expectations first and then fire the event via SendEvent (or the early-offer test's custom flush sender). 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.
110f7a5 to
d47d86c
Compare
|
@ziggie1984 Thanks for the suggestion! I applied it. Also changed the type of the callback so it is sufficient to pass @gemini-code-assist check the latest version. |
|
Thanks for the update, @starius! I've reviewed the latest changes, and they look great. I particularly appreciate how you've refined the The refactoring has significantly improved the clarity and robustness of the |
ziggie1984
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
yyforyongyu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM🪛
Change Description
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 mockCloseSignerexpectations. When that happened, the mock complained thatCreateCloseProposalwas unexpected:Fix this by having
assertSingleRemoteRbfIterationtake asendEventcallback that receives the context and initial offer, so tests can install expectations first and then fire the event viaSendEvent(or the early-offer test's custom flush sender).Steps to Test
Reproduction (on master)
lnwallet/chancloser/rbf_coop_test.gotime.Sleep(10 * time.Millisecond)before the first call ofcloseHarness.assertSingleRemoteRbfIteration(in functionTestRbfChannelFlushingTransitions).go test ./lnwallet/chancloser -run TestRbfChannelFlushingTransitions/early_offerThe panic reproduces immediately.
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.