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

test: Add more tests for light_utils main module #846

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

vadorovsky
Copy link
Contributor

Achieve full coverage there.

@vadorovsky vadorovsky force-pushed the vadorovsky/test-light-utils-lib branch from 0cf0ec3 to 776f078 Compare June 21, 2024 10:57
@vadorovsky vadorovsky marked this pull request as ready for review June 21, 2024 10:57
Copy link

nx-cloud bot commented Jun 21, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 776f078. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@vadorovsky vadorovsky force-pushed the vadorovsky/test-light-utils-lib branch from 776f078 to f03082b Compare June 22, 2024 08:53
@vadorovsky vadorovsky force-pushed the vadorovsky/test-light-utils-lib branch from f03082b to b94e701 Compare June 23, 2024 08:25
utils/src/lib.rs Outdated
let max_input = [u8::MAX; 32];
let (hashed_value, bump) = hash_to_bn254_field_size_be(max_input.as_slice())
.expect("Failed to find a hash within BN254 field size");
assert_eq!(bump, 255, "Bump seed should be 0");
Copy link
Contributor

Choose a reason for hiding this comment

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

The assert error msg confused me, shouldn't it read as follows?

Suggested change
assert_eq!(bump, 255, "Bump seed should be 0");
assert_eq!(bump, 255, "Bump seed should be 255");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

let bigint = modulus + 1.to_biguint().unwrap();
let bigint_bytes: [u8; 32] = bigint_to_be_bytes_array(&bigint).unwrap();
assert!(!is_smaller_than_bn254_field_size_be(&bigint_bytes));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

Copy link
Contributor

@ananas-block ananas-block left a comment

Choose a reason for hiding this comment

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

Thanks, just one nitpick in the assert error.

@ananas-block ananas-block merged commit 27dfaed into main Jun 25, 2024
7 checks passed
@ananas-block ananas-block deleted the vadorovsky/test-light-utils-lib branch June 25, 2024 23:21
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