-
Notifications
You must be signed in to change notification settings - Fork 302
test(fortuna): add unit tests for HashChainState #2698
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
Conversation
Co-Authored-By: Jayant Krishnamurthy <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
apps/fortuna/src/state.rs
Outdated
| } | ||
|
|
||
| #[test] | ||
| fn test_reveal_at_offset() -> Result<()> { |
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.
very similar to test_reveal_valid_sequence. not adding a lot of value
apps/fortuna/src/state.rs
Outdated
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod hash_chain_state_test { |
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.
any reason to have these in a separate mod?
| #[test] | ||
| fn test_reveal_sequence_too_large() { | ||
| let chain = PebbleHashChain::new([0u8; 32], 10, 1); | ||
| let hash_chain_state = HashChainState::from_chain_at_offset(5, chain); |
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.
not related to this PR but we should make this from_chain_at_offset function only for tests.
apps/fortuna/src/state.rs
Outdated
| let chain2 = PebbleHashChain::new([1u8; 32], 10, 1); | ||
| let expected_hash2 = chain2.reveal_ith(3)?; | ||
|
|
||
| let mut hash_chain_state = HashChainState::from_chain_at_offset(5, chain1); |
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.
let's just construct the hash_chain_state directly from fields for better readability
apps/fortuna/src/state.rs
Outdated
| let expected_hash2 = chain2.reveal_ith(3)?; | ||
|
|
||
| let mut hash_chain_state = HashChainState::from_chain_at_offset(5, chain1); | ||
| hash_chain_state.offsets.push(20); |
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 we also test this 20 boundary?
| crate::state::{HashChainState, PebbleHashChain}, | ||
| anyhow::Result, | ||
| }; | ||
|
|
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.
add some tests for overlapping PebbleHashChains.
Co-Authored-By: Jayant Krishnamurthy <[email protected]>
Add unit tests for HashChainState
This PR adds comprehensive unit tests for the
HashChainStatestruct in the fortuna codebase. The tests cover:from_chain_at_offsetLink to Devin run: https://app.devin.ai/sessions/28a349ec6b4245d197df7d831bcf1088
Requested by: Jayant Krishnamurthy