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

@mswilkison mswilkison commented May 26, 2026

Copy link
Copy Markdown
Contributor

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 using controlled block sequencing instead of time-dependent blocking.
    • Enhanced the test flow to explicitly emit and verify the expected coordination windows in order, with per-step timeouts for clearer, more robust assertions.

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Review Change Stack

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: 13157646-fa7b-4cd4-a215-e92da8568bcf

📥 Commits

Reviewing files that changed from the base of the PR and between de40ab1 and 9864e9a.

📒 Files selected for processing (1)
  • pkg/tbtc/coordination_test.go
🚧 Files skipped from review as they are similar to previous changes (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 'Fix coordination window watcher test' clearly and specifically describes the main change—fixing a test that was failing when run standalone.
Linked Issues check ✅ Passed The PR directly addresses issue #4004 by replacing unreliable 1ms ticker simulation with deterministic block injection, resolving the timeout failure when test runs standalone.
Out of Scope Changes check ✅ Passed All changes are confined to the test file coordination_test.go and directly target the test failure described in issue #4004 without introducing unrelated modifications.

✏️ 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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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
@piotr-roslaniec piotr-roslaniec force-pushed the codex/fix-coordination-window-test branch from de40ab1 to 9864e9a Compare June 15, 2026 07:53
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

2 participants