Skip to content

Commit

Permalink
Rename TestingSessionParams to TestSessionParams, to be uniform with …
Browse files Browse the repository at this point in the history
…the rest of the mocks
  • Loading branch information
fjarri committed Oct 24, 2024
1 parent b1f3b85 commit 3895469
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions examples/src/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ mod tests {

use manul::{
session::{signature::Keypair, SessionOutcome},
testing::{run_sync, TestSigner, TestVerifier, TestingSessionParams},
testing::{run_sync, TestSessionParams, TestSigner, TestVerifier},
};
use rand_core::OsRng;
use tracing_subscriber::EnvFilter;
Expand Down Expand Up @@ -389,7 +389,7 @@ mod tests {
.with_env_filter(EnvFilter::from_default_env())
.finish();
let reports = tracing::subscriber::with_default(my_subscriber, || {
run_sync::<Round1<TestVerifier>, TestingSessionParams>(&mut OsRng, inputs).unwrap()
run_sync::<Round1<TestVerifier>, TestSessionParams>(&mut OsRng, inputs).unwrap()
});

for (_id, report) in reports {
Expand Down
8 changes: 4 additions & 4 deletions examples/src/simple_malicious.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use manul::{
Artifact, DirectMessage, FinalizeError, FinalizeOutcome, FirstRound, LocalError, Payload, Round, SessionId,
},
session::signature::Keypair,
testing::{round_override, run_sync, RoundOverride, RoundWrapper, TestSigner, TestVerifier, TestingSessionParams},
testing::{round_override, run_sync, RoundOverride, RoundWrapper, TestSessionParams, TestSigner, TestVerifier},
};
use rand_core::{CryptoRngCore, OsRng};
use tracing_subscriber::EnvFilter;
Expand Down Expand Up @@ -174,7 +174,7 @@ fn serialized_garbage() {
.with_env_filter(EnvFilter::from_default_env())
.finish();
let mut reports = tracing::subscriber::with_default(my_subscriber, || {
run_sync::<MaliciousRound1<TestVerifier>, TestingSessionParams>(&mut OsRng, run_inputs).unwrap()
run_sync::<MaliciousRound1<TestVerifier>, TestSessionParams>(&mut OsRng, run_inputs).unwrap()
});

let v0 = signers[0].verifying_key();
Expand Down Expand Up @@ -220,7 +220,7 @@ fn attributable_failure() {
.with_env_filter(EnvFilter::from_default_env())
.finish();
let mut reports = tracing::subscriber::with_default(my_subscriber, || {
run_sync::<MaliciousRound1<TestVerifier>, TestingSessionParams>(&mut OsRng, run_inputs).unwrap()
run_sync::<MaliciousRound1<TestVerifier>, TestSessionParams>(&mut OsRng, run_inputs).unwrap()
});

let v0 = signers[0].verifying_key();
Expand Down Expand Up @@ -266,7 +266,7 @@ fn attributable_failure_round2() {
.with_env_filter(EnvFilter::from_default_env())
.finish();
let mut reports = tracing::subscriber::with_default(my_subscriber, || {
run_sync::<MaliciousRound1<TestVerifier>, TestingSessionParams>(&mut OsRng, run_inputs).unwrap()
run_sync::<MaliciousRound1<TestVerifier>, TestSessionParams>(&mut OsRng, run_inputs).unwrap()
});

let v0 = signers[0].verifying_key();
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/async_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use manul::{
signature::Keypair, CanFinalize, LocalError, MessageBundle, RoundOutcome, Session, SessionId,
SessionParameters, SessionReport,
},
testing::{TestSigner, TestingSessionParams},
testing::{TestSessionParams, TestSigner},
};
use manul_example::simple::{Inputs, Round1, SimpleProtocol};
use rand::Rng;
Expand Down Expand Up @@ -241,7 +241,7 @@ where
#[tokio::test]
async fn async_run() {
// The kind of Session we need to run the `SimpleProtocol`.
type SimpleSession = Session<SimpleProtocol, TestingSessionParams>;
type SimpleSession = Session<SimpleProtocol, TestSessionParams>;

// Create 4 parties
let signers = (0..3).map(TestSigner::new).collect::<Vec<_>>();
Expand Down
6 changes: 3 additions & 3 deletions manul/benches/empty_rounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use manul::{
LocalError, Payload, Protocol, ProtocolError, ProtocolValidationError, ReceiveError, Round, RoundId,
},
session::{signature::Keypair, SessionId, SessionOutcome},
testing::{run_sync, TestSigner, TestVerifier, TestingSessionParams},
testing::{run_sync, TestSessionParams, TestSigner, TestVerifier},
};
use rand_core::{CryptoRngCore, OsRng};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -205,7 +205,7 @@ fn bench_empty_rounds(c: &mut Criterion) {
group.bench_function("25 nodes, 5 rounds, no echo", |b| {
b.iter(|| {
assert!(
run_sync::<EmptyRound<TestVerifier>, TestingSessionParams>(&mut OsRng, inputs_no_echo.clone())
run_sync::<EmptyRound<TestVerifier>, TestSessionParams>(&mut OsRng, inputs_no_echo.clone())
.unwrap()
.values()
.all(|report| matches!(report.outcome, SessionOutcome::Result(_)))
Expand Down Expand Up @@ -235,7 +235,7 @@ fn bench_empty_rounds(c: &mut Criterion) {
group.bench_function("25 nodes, 5 rounds, echo each round", |b| {
b.iter(|| {
assert!(
run_sync::<EmptyRound<TestVerifier>, TestingSessionParams>(&mut OsRng, inputs_echo.clone())
run_sync::<EmptyRound<TestVerifier>, TestSessionParams>(&mut OsRng, inputs_echo.clone())
.unwrap()
.values()
.all(|report| matches!(report.outcome, SessionOutcome::Result(_)))
Expand Down
12 changes: 6 additions & 6 deletions manul/src/session/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ mod tests {
DeserializationError, DirectMessage, EchoBroadcast, LocalError, Protocol, ProtocolError,
ProtocolValidationError, RoundId,
},
testing::TestingSessionParams,
testing::TestSessionParams,
};

#[test]
Expand Down Expand Up @@ -746,15 +746,15 @@ mod tests {

// We need `Session` to be `Send` so that we send a `Session` object to a task
// to run the loop there.
assert!(impls!(Session<DummyProtocol, TestingSessionParams>: Send));
assert!(impls!(Session<DummyProtocol, TestSessionParams>: Send));

// This is needed so that message processing offloaded to a task could use `&Session`.
assert!(impls!(Session<DummyProtocol, TestingSessionParams>: Sync));
assert!(impls!(Session<DummyProtocol, TestSessionParams>: Sync));

// These objects are sent to/from message processing tasks
assert!(impls!(MessageBundle: Send));
assert!(impls!(ProcessedArtifact<TestingSessionParams>: Send));
assert!(impls!(VerifiedMessageBundle<TestingSessionParams>: Send));
assert!(impls!(ProcessedMessage<DummyProtocol, TestingSessionParams>: Send));
assert!(impls!(ProcessedArtifact<TestSessionParams>: Send));
assert!(impls!(VerifiedMessageBundle<TestSessionParams>: Send));
assert!(impls!(ProcessedMessage<DummyProtocol, TestSessionParams>: Send));
}
}
4 changes: 2 additions & 2 deletions manul/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ When testing round based protocols it can be complicated to "inject" the proper
process, e.g. to emulate a malicious participant. This module provides facilities to make this
easier, by providing a [`RoundOverride`] type along with a [`round_override`] macro.
The [`TestingSessionParams`] provides an implementation of the [`SessionParameters`](crate::session::SessionParameters) trait,
The [`TestSessionParams`] provides an implementation of the [`SessionParameters`](crate::session::SessionParameters) trait,
which in turn is used to setup [`Session`](crate::session::Session)s to drive the protocol.
The [`run_sync`] method is helpful to execute a protocol synchronously and collect the outcomes.
Expand All @@ -15,6 +15,6 @@ mod identity;
mod macros;
mod run_sync;

pub use identity::{TestHasher, TestSignature, TestSigner, TestVerifier, TestingSessionParams};
pub use identity::{TestHasher, TestSessionParams, TestSignature, TestSigner, TestVerifier};
pub use macros::{round_override, RoundOverride, RoundWrapper};
pub use run_sync::run_sync;
4 changes: 2 additions & 2 deletions manul/src/testing/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ impl digest::OutputSizeUser for TestHasher {

/// An implementation of [`SessionParameters`] using the testing signer/verifier types.
#[derive(Debug, Clone, Copy)]
pub struct TestingSessionParams;
pub struct TestSessionParams;

impl SessionParameters for TestingSessionParams {
impl SessionParameters for TestSessionParams {
type Signer = TestSigner;
type Verifier = TestVerifier;
type Signature = TestSignature;
Expand Down

0 comments on commit 3895469

Please sign in to comment.