[Repo Assist] fix(tests): make node auto-approve tests deterministic#464
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
Replace Task.Delay timing waits with deterministic synchronisation signals: - Add postApproveDelay constructor parameter to GatewayConnectionManager (defaults to 1s for production; tests pass TimeSpan.Zero for instant completion) - Add internal AutoApproveDecisionCompleted event that fires when each auto-approve handler finishes (regardless of whether an approval was made) - Extract OnNodePairingStatusChanged auto-approve body into RunNodeSideAutoApproveAsync so the completion event fires from a single try/finally - Update NodePairListUpdated lambda to fire AutoApproveDecisionCompleted after TryOperatorAutoApproveOwnNodePairAsync returns - Replace all Task.Delay(200) negative-assertion waits and the Task.Delay(1100) post-approve wait with WaitForAutoApproveDecisionAsync helper Eliminates the timing-sensitive 1100ms wait that depended on the production 1s reconnect delay, plus six 200ms waits in negative-assertion tests. Closes #460 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Resolves timing-sensitivity in
NodePairAutoApproveTestsby introducing deterministic synchronisation signals to replaceTask.Delaywaits.Root Cause
Several tests used
await Task.Delay(200)for negative assertions ("nothing happened") and one test usedawait Task.Delay(1100)that directly depended on the production 1-second post-approve reconnect delay.Fix
GatewayConnectionManagerchangespostApproveDelayconstructor parameter (defaults toTimeSpan.FromSeconds(1)for production; tests passTimeSpan.Zeroso post-approve reconnects complete instantly)internal event EventHandler? AutoApproveDecisionCompletedthat fires at the end of each auto-approve decision, regardless of outcomeOnNodePairingStatusChangedintoRunNodeSideAutoApproveAsyncso the event fires from a singletry/finallyNodePairListUpdatedlambda to fire the event afterTryOperatorAutoApproveOwnNodePairAsyncreturnsNodePairAutoApproveTestschangesCreateConnectedManagernow passespostApproveDelay: TimeSpan.ZeroWaitForAutoApproveDecisionAsync(manager)helper that returns a Task completing on the nextAutoApproveDecisionCompletedeventTask.Delay(200)negative waits replaced withWaitForAutoApproveDecisionAsyncTask.Delay(1100)post-approve wait replaced withawait firstDecisionTrade-offs
postApproveDelayis an optional parameter appended to the existing long constructor. No callers are affected (all existing callers use the default).AutoApproveDecisionCompletedevent isinternaland only accessible withinOpenClaw.Connectionand its test assembly — zero public API impact.Test Status
All 229
OpenClaw.Connection.Testspass (including all 9NodePairAutoApprovetests).Closes #460