Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ impl Simplex for SimplexBls12381MultisigMinPk {
type Elector = RoundRobin;

fn fixture(
namespace: &[u8],
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_multisig::fixture::<MinPk, _>(namespace, context, n)
bls12381_multisig::fixture::<MinPk, _>(context, namespace, n)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ impl Simplex for SimplexBls12381MultisigMinSig {
type Elector = RoundRobin;

fn fixture(
namespace: &[u8],
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_multisig::fixture::<MinSig, _>(namespace, context, n)
bls12381_multisig::fixture::<MinSig, _>(context, namespace, n)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ impl Simplex for SimplexBls12381MinPk {
type Elector = Random;

fn fixture(
namespace: &[u8],
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_threshold::fixture::<MinPk, _>(namespace, context, n)
bls12381_threshold::fixture::<MinPk, _>(context, namespace, n)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ impl Simplex for SimplexBls12381MinSig {
type Elector = Random;

fn fixture(
namespace: &[u8],
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_threshold::fixture::<MinSig, _>(namespace, context, n)
bls12381_threshold::fixture::<MinSig, _>(context, namespace, n)
}
}

Expand Down
4 changes: 2 additions & 2 deletions consensus/fuzz/fuzz_targets/simplex_ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ impl Simplex for SimplexEd25519 {
type Elector = RoundRobin;

fn fixture(
namespace: &[u8],
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
ed25519::fixture(namespace, context, n)
ed25519::fixture(context, namespace, n)
}
}

Expand Down
4 changes: 2 additions & 2 deletions consensus/fuzz/fuzz_targets/simplex_secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ impl Simplex for SimplexSecp256r1 {
type Elector = RoundRobin;

fn fixture(
namespace: &[u8],
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
secp256r1::fixture(namespace, context, n)
secp256r1::fixture(context, namespace, n)
}
}

Expand Down
4 changes: 2 additions & 2 deletions consensus/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ where
type Scheme: Scheme<Sha256Digest, PublicKey = Ed25519PublicKey>;
type Elector: Elector<Self::Scheme>;
fn fixture(
namespace: &[u8],
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme>;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ fn run<P: Simplex>(input: FuzzInput) {
schemes,
verifier: _,
..
} = P::fixture(NAMESPACE, &mut context, n);
} = P::fixture(&mut context, NAMESPACE, n);

let mut registrations = register(&mut oracle, &participants).await;

Expand Down
32 changes: 16 additions & 16 deletions consensus/src/aggregation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ mod tests {
fn all_online<S, F>(fixture: F)
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: FnOnce(&[u8], &mut deterministic::Context, u32) -> Fixture<S>,
F: FnOnce(&mut deterministic::Context, &[u8], u32) -> Fixture<S>,
{
let runner = deterministic::Runner::timed(Duration::from_secs(30));

runner.start(|mut context| async move {
let num_validators = 4;
let fixture = fixture(TEST_NAMESPACE, &mut context, num_validators);
let fixture = fixture(&mut context, TEST_NAMESPACE, num_validators);
let epoch = Epoch::new(111);

let (mut oracle, mut registrations) =
Expand Down Expand Up @@ -353,13 +353,13 @@ mod tests {
fn byzantine_proposer<S, F>(fixture: F)
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: FnOnce(&[u8], &mut deterministic::Context, u32) -> Fixture<S>,
F: FnOnce(&mut deterministic::Context, &[u8], u32) -> Fixture<S>,
{
let runner = deterministic::Runner::timed(Duration::from_secs(30));

runner.start(|mut context| async move {
let num_validators = 4;
let fixture = fixture(TEST_NAMESPACE, &mut context, num_validators);
let fixture = fixture(&mut context, TEST_NAMESPACE, num_validators);
let epoch = Epoch::new(111);

let (mut oracle, mut registrations) =
Expand Down Expand Up @@ -393,7 +393,7 @@ mod tests {
fn unclean_byzantine_shutdown<S, F>(fixture: F)
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: Fn(&[u8], &mut StdRng, u32) -> Fixture<S>,
F: Fn(&mut StdRng, &[u8], u32) -> Fixture<S>,
{
// Test parameters
let num_validators = 4;
Expand All @@ -408,7 +408,7 @@ mod tests {

// Generate fixture once (persists across restarts)
let mut rng = test_rng();
let fixture = fixture(TEST_NAMESPACE, &mut rng, num_validators);
let fixture = fixture(&mut rng, TEST_NAMESPACE, num_validators);

// Continue until shared reporter reaches target or max shutdowns exceeded
let mut shutdown_count = 0;
Expand Down Expand Up @@ -550,7 +550,7 @@ mod tests {
fn unclean_shutdown_with_unsigned_index<S, F>(fixture: F)
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: Fn(&[u8], &mut StdRng, u32) -> Fixture<S>,
F: Fn(&mut StdRng, &[u8], u32) -> Fixture<S>,
{
// Test parameters
let num_validators = 4;
Expand All @@ -560,7 +560,7 @@ mod tests {

// Generate fixture once (persists across restarts)
let mut rng = test_rng();
let fixture = fixture(TEST_NAMESPACE, &mut rng, num_validators);
let fixture = fixture(&mut rng, TEST_NAMESPACE, num_validators);

// First run: let validators skip signing at skip_index and reach beyond it
let f = |context: Context| {
Expand Down Expand Up @@ -743,7 +743,7 @@ mod tests {
fn slow_and_lossy_links<S, F>(fixture: F, seed: u64) -> String
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: FnOnce(&[u8], &mut deterministic::Context, u32) -> Fixture<S>,
F: FnOnce(&mut deterministic::Context, &[u8], u32) -> Fixture<S>,
{
let cfg = deterministic::Config::new()
.with_seed(seed)
Expand All @@ -752,7 +752,7 @@ mod tests {

runner.start(|mut context| async move {
let num_validators = 4;
let fixture = fixture(TEST_NAMESPACE, &mut context, num_validators);
let fixture = fixture(&mut context, TEST_NAMESPACE, num_validators);
let epoch = Epoch::new(111);

// Use degraded network links with realistic conditions
Expand Down Expand Up @@ -855,13 +855,13 @@ mod tests {
fn one_offline<S, F>(fixture: F)
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: FnOnce(&[u8], &mut deterministic::Context, u32) -> Fixture<S>,
F: FnOnce(&mut deterministic::Context, &[u8], u32) -> Fixture<S>,
{
let runner = deterministic::Runner::timed(Duration::from_secs(30));

runner.start(|mut context| async move {
let num_validators = 5;
let mut fixture = fixture(TEST_NAMESPACE, &mut context, num_validators);
let mut fixture = fixture(&mut context, TEST_NAMESPACE, num_validators);
let epoch = Epoch::new(111);

// Truncate to only 4 validators (one offline)
Expand Down Expand Up @@ -900,13 +900,13 @@ mod tests {
fn network_partition<S, F>(fixture: F)
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: FnOnce(&[u8], &mut deterministic::Context, u32) -> Fixture<S>,
F: FnOnce(&mut deterministic::Context, &[u8], u32) -> Fixture<S>,
{
let runner = deterministic::Runner::timed(Duration::from_secs(60));

runner.start(|mut context| async move {
let num_validators = 4;
let fixture = fixture(TEST_NAMESPACE, &mut context, num_validators);
let fixture = fixture(&mut context, TEST_NAMESPACE, num_validators);
let epoch = Epoch::new(111);

let (mut oracle, mut registrations) =
Expand Down Expand Up @@ -965,13 +965,13 @@ mod tests {
fn insufficient_validators<S, F>(fixture: F)
where
S: Scheme<Sha256Digest, PublicKey = PublicKey>,
F: FnOnce(&[u8], &mut deterministic::Context, u32) -> Fixture<S>,
F: FnOnce(&mut deterministic::Context, &[u8], u32) -> Fixture<S>,
{
let runner = deterministic::Runner::timed(Duration::from_secs(15));

runner.start(|mut context| async move {
let num_validators = 5;
let fixture = fixture(TEST_NAMESPACE, &mut context, num_validators);
let fixture = fixture(&mut context, TEST_NAMESPACE, num_validators);
let epoch = Epoch::new(111);

// Set up simulated network
Expand Down
8 changes: 4 additions & 4 deletions consensus/src/aggregation/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ mod tests {
fn codec<S, F>(fixture: F)
where
S: Scheme<Sha256Digest>,
F: FnOnce(&[u8], &mut StdRng, u32) -> Fixture<S>,
F: FnOnce(&mut StdRng, &[u8], u32) -> Fixture<S>,
{
let mut rng = test_rng();
let fixture = fixture(NAMESPACE, &mut rng, 4);
let fixture = fixture(&mut rng, NAMESPACE, 4);
let schemes = &fixture.schemes;
let item = Item {
index: 100,
Expand Down Expand Up @@ -572,9 +572,9 @@ mod tests {
fn activity_invalid_enum<S, F>(fixture: F)
where
S: Scheme<Sha256Digest>,
F: FnOnce(&[u8], &mut StdRng, u32) -> Fixture<S>,
F: FnOnce(&mut StdRng, &[u8], u32) -> Fixture<S>,
{
let fixture = fixture(NAMESPACE, &mut test_rng(), 4);
let fixture = fixture(&mut test_rng(), NAMESPACE, 4);
let mut buf = BytesMut::new();
3u8.write(&mut buf); // Invalid discriminant

Expand Down
Loading
Loading