Commit a34304f
fix: flaky TestSessionBetweenPeers with shuffle enabled (#1022)
* fix: flaky TestSessionBetweenPeers with shuffle enabled
The test was flaky when run with -shuffle=on because of a race condition
in message counting. After fetching the first block (cids[0]), which
triggers a broadcast want-have to all peers and then a CANCEL when
received, the test immediately continued fetching more blocks.
During this time, the session's internal timers (idle tick or periodic
search) could fire and cause a rebroadcast of wants before the test
checked message counts on uninvolved nodes. With test shuffling,
goroutine scheduling changes made this timing issue more likely,
causing uninvolved nodes to sometimes receive 3 messages instead of
the expected 2.
Adding a small delay after the first block fetch ensures the CANCEL
is fully processed and the session stabilizes before continuing,
preventing the race condition.
* Update bitswap/client/bitswap_with_sessions_test.go
---------
Co-authored-by: Andrew Gillis <[email protected]>1 parent 3a7437a commit a34304f
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
206 | 211 | | |
207 | 212 | | |
208 | 213 | | |
| |||
0 commit comments