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

Minor improvements to Utils package #1206

Merged
merged 13 commits into from
Nov 19, 2024

Conversation

andrew-fleming
Copy link
Collaborator

@andrew-fleming andrew-fleming commented Nov 12, 2024

PR Checklist

  • Tests
  • Documentation
  • Added entry to CHANGELOG.md
  • Tried the feature on a public network

This PR proposes to add fuzz tests for the math module (which only includes the average fn ATM)

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.12%. Comparing base (4c0e16f) to head (e578d7d).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1206      +/-   ##
==========================================
+ Coverage   92.06%   92.12%   +0.05%     
==========================================
  Files          49       49              
  Lines        1399     1396       -3     
==========================================
- Hits         1288     1286       -2     
+ Misses        111      110       -1     
Files with missing lines Coverage Δ
packages/utils/src/cryptography/snip12.cairo 83.33% <ø> (ø)
packages/utils/src/deployments.cairo 95.00% <100.00%> (+3.69%) ⬆️
packages/utils/src/structs/checkpoint.cairo 91.07% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c0e16f...e578d7d. Read the comment docs.

---- 🚨 Try these New Features:

fn length(self: StoragePath<Trace>) -> u64 {
self.checkpoints.len()
}

/// Returns the checkpoint at given position.
Copy link
Member

Choose a reason for hiding this comment

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

I think position is easier to read here, maybe we can update the param name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mmm I honestly like pos as the param name—unless you prefer a new name? I'll switch the comment back. Looking at it now, I agree position is easier to read

@immrsd immrsd self-requested a review November 15, 2024 14:43
@andrew-fleming andrew-fleming marked this pull request as ready for review November 18, 2024 22:14
use crate::math::average;

#[test]
fn test_average_u8(a: u8, b: u8) {
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that fuzzing actually takes a significant amount of time when running tests, not only in compilation. Did you noticed the same thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did...it's only a few tests though so relative to the whole repo, IMO it's not a huge deal. If we want to improve performance, we can configure it to a smaller amount either in the tests themselves or globally when running the test cmd i.e. snforge test ... --fuzzer-runs 25

Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

Left a small comment, looks good to me otherwise!

packages/utils/src/cryptography/snip12.cairo Outdated Show resolved Hide resolved
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
Copy link
Collaborator

@immrsd immrsd left a comment

Choose a reason for hiding this comment

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

LGTM

@andrew-fleming andrew-fleming merged commit c77b4b1 into OpenZeppelin:main Nov 19, 2024
8 checks passed
@andrew-fleming andrew-fleming deleted the preaudit-utils branch November 19, 2024 15:53
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.

3 participants