-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fix Reversed Logic for QuantaUpkeepInstant.now() #223
Fix Reversed Logic for QuantaUpkeepInstant.now() #223
Conversation
Whooooops! Good catch, thanks! |
governor/src/clock/quanta.rs
Outdated
@@ -100,8 +100,7 @@ impl Clock for QuantaUpkeepClock { | |||
|
|||
fn now(&self) -> Self::Instant { | |||
QuantaInstant(Nanos::from( | |||
self.reference | |||
.saturating_duration_since(self.clock.recent()), | |||
self.clock.recent().saturating_duration_since(self.reference), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you re-run cargo fmt
and commit the change, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problems, reformatted and combined the new advance test as only one Upkeep thread can be running at a time and this seemed the simplest way to avoid issues.
Thought there might have been a solution to running multiple tests against Upkeep in the Quanta repo, but they only have one too. Didn't catch it the first time around as I use nextest and it had these tests isolated.
OK, this is truly weird: running the tests in "coverage" mode, it sounds like the clock isn't advancing! https://github.com/boinkor-net/governor/actions/runs/7919482513/job/21626813726?pr=223#step:5:246 |
I just decreased the frequencies to see if its an issue with the background task not running fast enough. I did have the interval set to 10µs, which is relatively fast. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #223 +/- ##
==========================================
- Coverage 98.25% 98.18% -0.08%
==========================================
Files 31 31
Lines 2182 2148 -34
==========================================
- Hits 2144 2109 -35
- Misses 38 39 +1 ☔ View full report in Codecov by Sentry. |
OK, that looks better, now there's just one tiny amount of formatting to fix up ((: |
I really need to add auto-formatting on save to my IDE! 😅 |
I don't understand that codecov failure… it's pointing at the actual error message in the test! |
1ef6f50
Oh yeah, that's a problem in rcov; it counts line-broken expressions as separate lines, and since this is a macro in which the formatter arguments aren't evaluated unless the tests fail, they count as "uncovered". It's silly & unless we redo the macro as a single line, it's unavoidable. The change merges regardless! (: |
Logic for comparing
self.reference
andself.clock.recent()
was reversed resulting innow()
always returningNanos(0)
.