Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix hare3 unit tests #6754

Closed
wants to merge 7 commits into from

Conversation

poszu
Copy link
Contributor

@poszu poszu commented Feb 28, 2025

Motivation

Unflaking hare3 unit tests.

Description

In a failing test, one of the hares (in tests many hare nodes are talking to each other) doesn't receive all preround messages from other hares. In effect, this hare drops all proposals (they don't get enough votes).

The missing messages are sent but not delivered. The hare Handler rejects them because the hare hasn't set up the layer yet. Normally, in a real network this doesn't happen because hare waits preround delay. However, in the test, the time is emulated and moved manually. The test triggers a new layer and immediately moves time forward by the preround delay (effectively making the delay zero). Because of that there is a race between some hares being fast to send the preround message before other become ready to receive them.

This PR adds additional synchronization using the test tracer. The tracer is informed by calling its OnStart() method that hare started the layer. The test waits for this signal before it advances the time by preround delay.

Comment on lines +462 to +467
if err != nil {
// This is 'allowed' error as it happens in some tests
require.ErrorContains(cl.t, err, "dropped by graded gossip", "from = %d, to = %d", n.i, other.i)
} else {
require.NoError(cl.t, err, "from = %d, to = %d", n.i, other.i)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure about this error assertion. What if a test that should not return an error here then returns "dropped by graded gossip"? Would it make sense to pass the expected error to the setup method to make sure we catch if behaviour changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK it would be even more awkward. Ideally, the test in which these errors happen on purpose would have its own body and its own expectations.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.8%. Comparing base (6477d20) to head (b64212d).
Report is 1 commits behind head on develop.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #6754   +/-   ##
=======================================
  Coverage     76.8%   76.8%           
=======================================
  Files          369     369           
  Lines        50277   50278    +1     
=======================================
+ Hits         38639   38645    +6     
+ Misses        9427    9423    -4     
+ Partials      2211    2210    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@poszu
Copy link
Contributor Author

poszu commented Feb 28, 2025

bors merge

spacemesh-bors bot pushed a commit that referenced this pull request Feb 28, 2025
## Motivation

Unflaking hare3 unit tests.
@spacemesh-bors
Copy link

Pull request successfully merged into develop.

Build succeeded:

@spacemesh-bors spacemesh-bors bot changed the title Fix hare3 unit tests [Merged by Bors] - Fix hare3 unit tests Feb 28, 2025
@spacemesh-bors spacemesh-bors bot closed this Feb 28, 2025
@spacemesh-bors spacemesh-bors bot deleted the increase-hare-commitee-in-systests branch February 28, 2025 13:45
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.

2 participants