Skip to content

Conversation

@SimonRastikian
Copy link
Contributor

Closes #145

@SimonRastikian SimonRastikian self-assigned this Nov 11, 2025
@codecov-commenter
Copy link

codecov-commenter commented Nov 11, 2025

Codecov Report

❌ Patch coverage is 76.31579% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.60%. Comparing base (4bee396) to head (1faa085).

Files with missing lines Patch % Lines
src/test_utils/run_protocol.rs 54.66% 29 Missing and 5 partials ⚠️
src/test_utils/snapshot.rs 88.61% 23 Missing ⚠️
src/test_utils/participant_simulation.rs 0.00% 15 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           simon/test_utils_folder     #218      +/-   ##
===========================================================
- Coverage                    87.95%   87.60%   -0.35%     
===========================================================
  Files                           47       49       +2     
  Lines                         9064     9365     +301     
  Branches                      9064     9365     +301     
===========================================================
+ Hits                          7972     8204     +232     
- Misses                         645      709      +64     
- Partials                       447      452       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@gilcu3 gilcu3 left a comment

Choose a reason for hiding this comment

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

I did not find any big issue, but did have a lot of suggestions, therefore marking the review as "Request changes". Most of them should be quite easy to solve though.

Once that is done, I can do a quick pass again and approve.

let max_malicious = 2;
let participants = generate_participants(5);

let f = Polynomial::generate_polynomial(None, max_malicious, &mut OsRng).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

same, please lets use deterministic tests

}

#[test]
fn test_snapshot_on_ecdsa_protocol() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this test does not belong to this file, as here we are just implementing general snapshot structs. Not sure what the proper place would be though.

}

#[test]
fn test_snapshot_on_ecdsa_protocol() {
Copy link
Contributor

Choose a reason for hiding this comment

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

as far I can see this only runs presign, so the function name is a bit misleading

Comment on lines +57 to +116
pub fn run_protocol_with_snapshots<T>(
mut ps: Vec<(Participant, Box<dyn Protocol<Output = T>>)>,
) -> Result<(Vec<(Participant, T)>, ProtocolSnapshot), ProtocolError> {
// Get the participants
let participants: Vec<_> = ps.iter().map(|(p, _)| *p).collect();
// Build the snapshot
let mut protocol_snapshots = ProtocolSnapshot::new_empty(participants);

// Compute the participants indices
let indices: HashMap<Participant, usize> =
ps.iter().enumerate().map(|(i, (p, _))| (*p, i)).collect();

let size = ps.len();
let mut out = Vec::with_capacity(size);
while out.len() < size {
for i in 0..size {
while {
let action = ps[i].1.poke()?;
match action {
Action::Wait => false,
Action::SendMany(m) => {
for j in 0..size {
if i == j {
continue;
}
let from = ps[i].0;
let to = ps[j].0;
protocol_snapshots
.push_message(to, from, m.clone())
.ok_or_else(|| {
ProtocolError::Other(
"Participant not found in snapshot".to_string(),
)
})?;
ps[j].1.message(from, m.clone());
}
true
}
Action::SendPrivate(to, m) => {
let from = ps[i].0;
protocol_snapshots
.push_message(to, from, m.clone())
.ok_or_else(|| {
ProtocolError::Other(
"Participant not found in snapshot".to_string(),
)
})?;
ps[indices[&to]].1.message(from, m);
true
}
Action::Return(r) => {
out.push((ps[i].0, r));
false
}
}
} {}
}
}
Ok((out, protocol_snapshots))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This function has an almost identical implementation to the previous one. It would be nice to refactor them so that the logic is only implemented once (in a third function)

use rand_chacha::{rand_core::SeedableRng, ChaCha12Rng};

/// Used for deterministic Rngs and only in testing
#[derive(Debug, Clone, PartialEq, Eq)]
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels a bit strange, but I guess if they are implemented for ChaCha12Rng then its nice for us to have them as well

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

@netrome netrome left a comment

Choose a reason for hiding this comment

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

Some nits from my side, but overall I think it looks good. I agree with the general comments about test organization from Reynaldo.

The only blockers I see are:

  1. Some docstrings are a bit confusing right now.
  2. The tests that use OsRng should be made deterministic.

use rand_chacha::{rand_core::SeedableRng, ChaCha12Rng};

/// Used for deterministic Rngs and only in testing
#[derive(Debug, Clone, PartialEq, Eq)]
Copy link
Collaborator

Choose a reason for hiding this comment

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


use crate::{participants::Participant, protocol::MessageData};

/// Constructor for specific (sender, messages) pairs transmitted during a protocol run
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not a constructor. Is the docstring stale or would it be sufficient to just say something like

Suggested change
/// Constructor for specific (sender, messages) pairs transmitted during a protocol run
/// A single received message during a protocol run

}
}

/// Registers a particular participant's view of the received messages
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: "Registers" sounds confusing here since this is a data structure, not a behavior.

Suggested change
/// Registers a particular participant's view of the received messages
/// A participant's view of their received messages

}

#[test]
fn test_snapshot_on_ecdsa_protocol() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I understand this correctly, the purpose of the test is to verify that the protocol is deterministic. How about naming it something like:

Suggested change
fn test_snapshot_on_ecdsa_protocol() {
fn ecdsa_presign__should_return_same_snapshot_when_executed_twice() {

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.

[Benchmark] [Participant Simulation] Protocols Derandomization: Networking Layer Change

5 participants