Skip to content

fix(communities): reuse the request clock for RequestedToJoinAt - #7792

Open
friofry wants to merge 4 commits into
developfrom
claude/status-go-flaky-tests-61dee2
Open

fix(communities): reuse the request clock for RequestedToJoinAt#7792
friofry wants to merge 4 commits into
developfrom
claude/status-go-flaky-tests-61dee2

Conversation

@friofry

@friofry friofry commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
  1. TestRequestAccessAgain, TestSyncCommunity_RequestToJoin, TestDeletePendingRequestAccessWithDeclinedState.

SaveRequestToJoinAndCommunity read the wall clock a second time instead of reusing the clock of the request
it was saving:

-community.config.RequestedToJoinAt = uint64(time.Now().Unix())
+community.config.RequestedToJoinAt = requestToJoin.Clock

(similar topersistence_mapping.go:137 RequestedToJoinAt = requestToJoin.clock)

  1. TestCommunityContactCodeAdvertisement it read response.Contacts[0] from a batch that
    can carry more than one contact. RetrieveAll drains the batch, so picking the wrong one was not retryable;
    it now looks Bob up by ID.

  2. Skipped tests are tracked in Fix flaky unit tests #7791

@friofry friofry mentioned this pull request Sep 1, 2026
@status-im-auto

status-im-auto commented Sep 1, 2026

Copy link
Copy Markdown
Member

Jenkins Builds

Click to see older builds (25)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 83d9e07 1 2026-09-01 12:45:17 ~3 min linux/status-go 📦zip
✔️ 83d9e07 1 2026-09-01 12:50:14 ~7 min windows/status-go 📦zip
✖️ 83d9e07 1 2026-09-01 12:50:34 ~8 min tests 📄log
✔️ 83d9e07 1 2026-09-01 13:01:38 ~19 min tests-rpc 📄log
✔️ 83d9e07 1 2026-09-01 13:03:03 ~20 min macos/status-go 📦zip
✔️ 83d9e07 1 2026-09-01 13:22:51 ~40 min tests-rpc-compat 📄log
✔️ c31e01e 2 2026-09-01 13:13:36 ~2 min linux/status-go 📦zip
✔️ c31e01e 2 2026-09-01 13:18:45 ~7 min windows/status-go 📦zip
✔️ c31e01e 2 2026-09-01 13:21:18 ~10 min tests 📄log
✔️ c31e01e 2 2026-09-01 13:36:35 ~25 min tests-rpc 📄log
✔️ c31e01e 2 2026-09-01 13:38:32 ~27 min macos/status-go 📦zip
✔️ dc3a671 3 2026-09-01 13:19:12 ~2 min linux/status-go 📦zip
✔️ dc3a671 3 2026-09-01 13:31:16 ~9 min tests 📄log
✔️ dc3a671 3 2026-09-01 13:33:41 ~14 min windows/status-go 📦zip
✔️ dc3a671 3 2026-09-01 13:49:52 ~11 min macos/status-go 📦zip
✔️ dc3a671 3 2026-09-01 14:01:02 ~24 min tests-rpc 📄log
✔️ dc3a671 2 2026-09-01 14:05:33 ~42 min tests-rpc-compat 📄log
✔️ d9bada4 4 2026-09-01 13:49:02 ~6 min linux/status-go 📦zip
✔️ d9bada4 4 2026-09-01 13:49:26 ~6 min windows/status-go 📦zip
✔️ d9bada4 4 2026-09-01 13:57:38 ~15 min tests 📄log
✔️ d9bada4 4 2026-09-01 14:04:51 ~14 min macos/status-go 📦zip
✔️ d9bada4 4 2026-09-01 14:32:58 ~31 min tests-rpc 📄log
d9bada4 4 2026-09-01 14:45:32 ~1 hr 3 min unknown 📄log
✔️ d9bada4 3 2026-09-01 14:57:24 ~51 min tests-rpc-compat 📄log
d9bada4 5 2026-09-01 16:43:52 ~1 hr 21 min unknown 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 4bd5eb7 5 2026-09-01 17:58:52 ~4 min linux/status-go 📦zip
✔️ 4bd5eb7 5 2026-09-01 17:59:38 ~5 min macos/status-go 📦zip
✔️ 4bd5eb7 5 2026-09-01 18:02:19 ~7 min windows/status-go 📦zip
✖️ 4bd5eb7 5 2026-09-01 18:04:07 ~9 min tests 📄log
✖️ 4bd5eb7 5 2026-09-01 18:22:31 ~27 min tests-rpc 📄log
✔️ 4bd5eb7 4 2026-09-01 18:35:00 ~40 min tests-rpc-compat 📄log
✔️ 4bd5eb7 6 2026-09-01 20:05:34 ~26 min tests-rpc 📄log
✔️ 4bd5eb7 6 2026-09-01 20:09:08 ~9 min tests 📄log

`SaveRequestToJoinAndCommunity` read the wall clock a second time instead of
reusing the clock of the request it was saving, so a call straddling a second
boundary left the in-memory community disagreeing with the value
`persistence_mapping.go` reads back from the request row.

Three tests asserted that equality and failed 3 runs in 5 locally
(TestRequestAccessAgain, TestSyncCommunity_RequestToJoin,
TestDeletePendingRequestAccessWithDeclinedState); they now pass 15 in 15.

Also de-flake TestCommunityContactCodeAdvertisement, which read
`response.Contacts[0]` from a batch that can carry more than one contact -
RetrieveAll drains the batch, so picking the wrong one was not retryable.

Skip five tests that flake for reasons not resolved here, tracked in #7791:

- TestBlockedContactSyncing - the unblock sync reaches the paired device with
  Blocked still true, so this looks like a product defect, not a test race
- TestAliceDidNotProcessOutdatedCommunityRequestToJoinResponse - the duplicate
  check needs the community clock and the request clock to land in the same second
- TestPeerExchange, TestHandleSegmentMessages,
  TestReevaluateMemberTokenMasterRoleInOpenCommunity_ERC721 - green locally
  under repetition, no hypothesis yet
- TestLocalDownloadWithContext_Cancellation - races cancellation against a
  download that may already have finished

Refs #7791
@friofry
friofry force-pushed the claude/status-go-flaky-tests-61dee2 branch from 83d9e07 to c31e01e Compare September 1, 2026 13:10
…tions of it

TestDownDebounceResetsAfterSilentRecovery failed in CI on the
`expectNoNotification(ch, 10*time.Millisecond)` right after the silent recovery.
Only two paths can emit there, and both require the 120ms timer armed by the
preceding Down to have already fired - that is, more than 120ms of wall time
elapsed across a wait the test budgets at 40ms. On a loaded agent a short
`time.After` can overrun several times over, and every debounce test here left a
margin under 2x.

Assertions about when a Down lands are now made by measuring elapsed time
(expectNotificationNoEarlierThan), which scheduling delays can only push later;
assertions that a specific update emitted nothing use a zero-wait channel check
(expectNoPendingNotification), since emission is synchronous inside Update; and
assertions that a stopped timer stays stopped watch past the moment it would have
fired (expectNoNotificationPast) instead of for a hand-tuned fraction of the
debounce. The shared testDownDebounce is 1s, so the tests' own bookkeeping has a
margin of 5x or more rather than 1.7x.

Verified the tests still catch what they guard, by mutation: a no-op
stopDownTimer fails TestDownDebounceResetsAfterSilentRecovery, firing the timer
immediately fails four of them, and a Pause that neither stops the timer nor
suppresses the emit fails TestPauseStopsPendingDownTimer. 40 concurrent runs at
GOMAXPROCS=1 are green. Suite runtime goes from ~3s to ~7s.
…adline

Folding the margin into a single `time.Until(deadline)+200ms` timeout meant a
caller already past the deadline got a non-positive duration, and a select whose
timeout has expired picks at random between the two ready cases - so a
notification sitting in the buffer would be missed half the time and the helper
would pass without observing anything.

Drain-check first, then wait out whatever is left of the window, then always
spend the margin as its own wait.

Raised by Copilot on #7793.
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.67%. Comparing base (eb985f6) to head (4bd5eb7).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7792      +/-   ##
===========================================
- Coverage    63.80%   63.67%   -0.13%     
===========================================
  Files          876      876              
  Lines       121449   121449              
===========================================
- Hits         77491    77336     -155     
- Misses       36084    36230     +146     
- Partials      7874     7883       +9     
Flag Coverage Δ
functional 43.01% <100.00%> (-0.05%) ⬇️
unit 57.43% <100.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/protocol/communities/manager.go 63.71% <100.00%> (ø)

... and 28 files with indirect coverage changes

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.

3 participants