Fix race condition in Espress input tests#73
Open
jbearer wants to merge 1 commit into
Open
Conversation
The combination of `wait_for_state_and_rewards` and `assert_reward_balances` used in many tests was problematic, because the former returned a specific Espresso block number without locking the Espresso state to that number. Now `wait_for_state_and_rewards` returns a lock on the Espresso state, to ensure that `assert_reward_balances` is called with the Espresso state at a known block number.
There was a problem hiding this comment.
Code Review
This pull request refactors the wait_for_state_and_rewards and assert_reward_balances test utilities in src/input/espresso.rs. The wait_for_state_and_rewards function now returns a RwLockReadGuard of the state, and assert_reward_balances has been updated to accept a direct reference to the state, streamlining the test flow and reducing redundant lock operations. I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The combination of
wait_for_state_and_rewardsandassert_reward_balancesused in many tests was problematic, because the former returned a specific Espresso block number without locking the Espresso state to that number.Now
wait_for_state_and_rewardsreturns a lock on the Espresso state, to ensure thatassert_reward_balancesis called with the Espresso state at a known block number.