Skip to content

Commit 1c0ca17

Browse files
rootulpclaude
authored andcommitted
fix: use assert.Eventually in TestReactorRecordsVotesAndBlockParts (#2841)
## Summary - Replace one-shot `assert.Equal` assertions with `assert.Eventually` in `TestReactorRecordsVotesAndBlockParts` to fix a flaky test - The race condition occurs because peer state vote/block-part counters may not be updated by the time assertions run after waiting for the first block - Also fixes a copy-paste typo in the second assertion message ("number of votes sent" → "number of block parts sent") ## Test plan - [x] Ran `TestReactorRecordsVotesAndBlockParts` 3 times with `-race` flag — all passed - [ ] CI passes on this PR 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 9442c08)
1 parent 262ba39 commit 1c0ca17

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

consensus/reactor_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,12 @@ func TestReactorRecordsVotesAndBlockParts(t *testing.T) {
454454
// Get peer state
455455
ps := peer.Get(types.PeerStateKey).(*PeerState)
456456

457-
assert.Equal(t, true, ps.VotesSent() > 0, "number of votes sent should have increased")
458-
assert.Equal(t, true, ps.BlockPartsSent() > 0, "number of votes sent should have increased")
457+
assert.Eventually(t, func() bool {
458+
return ps.VotesSent() > 0
459+
}, 10*time.Second, 100*time.Millisecond, "number of votes sent should have increased")
460+
assert.Eventually(t, func() bool {
461+
return ps.BlockPartsSent() > 0
462+
}, 10*time.Second, 100*time.Millisecond, "number of block parts sent should have increased")
459463
}
460464

461465
//-------------------------------------------------------------

0 commit comments

Comments
 (0)