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

Fix Reversed Logic for QuantaUpkeepInstant.now() #223

Merged
merged 5 commits into from
Feb 15, 2024

Conversation

waynerobinson
Copy link
Contributor

@waynerobinson waynerobinson commented Feb 15, 2024

Logic for comparing self.reference and self.clock.recent() was reversed resulting in now() always returning Nanos(0).

@antifuchs
Copy link
Collaborator

Whooooops! Good catch, thanks!

@@ -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),
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@antifuchs
Copy link
Collaborator

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

@waynerobinson
Copy link
Contributor Author

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.

Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f0cb09c) 98.25% compared to head (b60cc4a) 98.18%.
Report is 2 commits behind head on master.

Files Patch % Lines
governor/src/clock/quanta.rs 91.66% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@antifuchs
Copy link
Collaborator

OK, that looks better, now there's just one tiny amount of formatting to fix up ((:

@waynerobinson
Copy link
Contributor Author

I really need to add auto-formatting on save to my IDE! 😅

@waynerobinson
Copy link
Contributor Author

I don't understand that codecov failure… it's pointing at the actual error message in the test!

@antifuchs antifuchs added this pull request to the merge queue Feb 15, 2024
Merged via the queue into boinkor-net:master with commit 1ef6f50 Feb 15, 2024
16 of 18 checks passed
@antifuchs
Copy link
Collaborator

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! (:

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