Skip to content

test(telegram): wait for events instead of racing them - #53

Merged
groupsky merged 1 commit into
mainfrom
fix/flaky-telegram-tests
Oct 14, 2026
Merged

groupsky merged 1 commit into
mainfrom
fix/flaky-telegram-tests

Conversation

@groupsky

Copy link
Copy Markdown
Contributor

What

Two tests in internal/telegram failed now and then, also in CI. Both were test bugs; the approver code is unchanged.

  • TestCoreRedeliveredTapKeepsResult: the old broker's last getUpdates call could still reach the shared fake server after the broker stopped, and confirm the tap the test had just sent again, so the new broker never got it. Each broker now has its own fake server, closed when it stops.
  • TestCoreExpiredTap: the approver answers a tap and then reports it; the test counted reports right after the answer. It now waits for the report.
  • The fake now stores a message in the same step as it records the call.
  • Other tests that slept or retried now wait for the exact event, with a deadline: TestCoreDoubleTap, TestCoreEarlyTap, TestCoreApproveOnce, TestCoreWrongMessage, TestTapDataCannotForgeAnAnchor.

Tests

go test -race -count=200 -cpu 1,2,4 -run TestCore ./internal/telegram/ passes with Go 1.27 and Go 1.26. Before the fix, the first test failed 26 to 29 of 120 runs.

Review

One round with the security-reviewer agent: "ready to commit". A restart can lose only taps the old broker had already handled; no test got weaker.

Closes #51

@groupsky groupsky added this to the v1 milestone Oct 14, 2026
@groupsky
groupsky merged commit 6c2040f into main Oct 14, 2026
6 checks passed
@groupsky
groupsky deleted the fix/flaky-telegram-tests branch October 14, 2026 22:26
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.

Telegram: TestCoreExpiredTap is flaky

1 participant