-
Notifications
You must be signed in to change notification settings - Fork 260
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 <jayant@dourolabs.xyz>
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
@@ -203,3 +203,87 @@ mod test { | |||
run_hash_chain_test([0u8; 32], 100, 55); | |||
} | |||
} | |||
|
|||
#[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 <jayant@dourolabs.xyz>
Add unit tests for HashChainState
This PR adds comprehensive unit tests for the
HashChainState
struct in the fortuna codebase. The tests cover:from_chain_at_offset
Link to Devin run: https://app.devin.ai/sessions/28a349ec6b4245d197df7d831bcf1088
Requested by: Jayant Krishnamurthy