Add immediate firing capability for time alerts and corresponding test #2745
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.
Summary
This pull request introduces a new feature to handle cases where a time alert is set for the exact current time in the
TestClock
implementation. It ensures that such alerts fire immediately and includes corresponding unit tests to validate this behavior.Bug fix: Immediate Firing for Current Time Alerts
crates/common/src/clock.rs
: Modified theTestTimer::new
invocation to include a newfire_immediately
parameter, which is set totrue
when the alert time equals the current time. This ensures immediate firing of the alert.Type of change
Release notes
RELEASES.md
that follows the existing conventions (when applicable)Testing
Ensure new or changed logic is covered by tests.
Testing Enhancements
crates/common/src/clock.rs
: Added a new test case,test_set_time_alert_when_alert_time_equals_current_time
, to verify that alerts set for the current time fire immediately. This test checks the timer count, advances the clock, and asserts the correct event behavior.# Pull Request