Skip to content

Fix coordination window watcher test#4006

Open
mswilkison wants to merge 1 commit into
mainfrom
codex/fix-coordination-window-test
Open

Fix coordination window watcher test#4006
mswilkison wants to merge 1 commit into
mainfrom
codex/fix-coordination-window-test

Conversation

@mswilkison
Copy link
Copy Markdown
Contributor

@mswilkison mswilkison commented May 26, 2026

Fixes #4004.

Summary

  • Replaces the 1ms ticker simulation in TestWatchCoordinationWindows with direct block injection.
  • Keeps coverage for non-window blocks, duplicate window blocks, and the expected 900/1800 coordination windows without relying on wall-clock block generation.

Validation

  • go test ./pkg/tbtc -run TestWatchCoordinationWindows -count=1
  • go test ./pkg/tbtc

Summary by CodeRabbit

  • Tests
    • Improved test determinism and reliability for coordination window validation by removing time-dependent blocking mechanisms and introducing controlled block sequencing.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3b085be0-b636-48bc-9f27-c6102617f2e6

📥 Commits

Reviewing files that changed from the base of the PR and between 980587b and de40ab1.

📒 Files selected for processing (1)
  • pkg/tbtc/coordination_test.go

📝 Walkthrough

Walkthrough

The test TestWatchCoordinationWindows is refactored to eliminate non-deterministic timing by exposing a controllable block channel to the test fixture and removing the internal ticker goroutine. It now uses a cancelable context, deterministic helper functions to send blocks and assert window emissions, and explicit selection logic instead of polling loops.

Changes

Test Determinism Refactor

Layer / File(s) Summary
Deterministic coordination window test
pkg/tbtc/coordination_test.go
TestWatchCoordinationWindows removes non-deterministic goroutine/ticker block generation and replaces it with explicit sendBlock and expectWindow helpers that use select + time.After to control test flow. The watchBlocksFn fixture now returns a controllable blocksChan instead of auto-generating blocks until context timeout. Test assertion switches from polling-loop collection of windows to deterministic per-block window validation for coordination windows 900 and 1800.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A channel's path now cleared and free,
No ticker tick to hide the spree—
With helpers bold to guide each test,
Coordination windows shine their best!
Determinism blooms at last, 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the TestWatchCoordinationWindows test by replacing a flaky ticker-based approach with direct block injection.
Linked Issues check ✅ Passed The PR directly addresses issue #4004 by fixing the standalone test failure through refactoring the test to use deterministic block injection instead of wall-clock timing.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the coordination window watcher test as required by issue #4004; no unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-coordination-window-test

Comment @coderabbitai help to get the list of available commands and usage tips.

@mswilkison mswilkison changed the title [codex] Fix coordination window watcher test Fix coordination window watcher test May 26, 2026
@mswilkison mswilkison marked this pull request as ready for review May 26, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Track standalone TestWatchCoordinationWindows failure

1 participant