Skip to content

Commit

Permalink
Correct the coordinator tests
Browse files Browse the repository at this point in the history
They weren't updated with the past couple of commits.
  • Loading branch information
kayabaNerve committed Sep 29, 2023
1 parent bd5491d commit aa59f53
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ hex = "0.4"
zeroize = { version = "1", default-features = false }
rand_core = { version = "0.6", default-features = false }

blake2 = "0.10"
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["ristretto", "secp256k1"] }
schnorrkel = "0.11"
dkg = { path = "../../crypto/dkg", default-features = false, features = ["tests"] }

messages = { package = "serai-processor-messages", path = "../../processor/messages" }

scale = { package = "parity-scale-codec", version = "3" }

serai-client = { path = "../../substrate/client", features = ["serai"] }
serai-message-queue = { path = "../../message-queue" }

Expand Down
18 changes: 15 additions & 3 deletions tests/coordinator/src/tests/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ use std::{
use zeroize::Zeroizing;
use rand_core::{RngCore, OsRng};

use blake2::{
digest::{consts::U32, Digest},
Blake2b,
};
use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto, Secp256k1};

use dkg::Participant;

use scale::Encode;

use serai_client::{
primitives::{NetworkId, BlockHash, Signature},
in_instructions::{
Expand All @@ -35,6 +40,12 @@ pub async fn batch(
attempt: 0,
};

for processor in processors.iter_mut() {
processor
.send_message(messages::substrate::ProcessorMessage::Batch { batch: batch.clone() })
.await;
}

// Select a random participant to exclude, so we know for sure who *is* participating
assert_eq!(COORDINATORS - THRESHOLD, 1);
let excluded_signer =
Expand Down Expand Up @@ -168,7 +179,7 @@ pub async fn batch(

for processor in processors.iter_mut() {
processor
.send_message(messages::substrate::ProcessorMessage::Update { batch: batch.clone() })
.send_message(messages::substrate::ProcessorMessage::SignedBatch { batch: batch.clone() })
.await;
}

Expand All @@ -194,7 +205,8 @@ pub async fn batch(
InInstructionsEvent::Batch {
network: batch.batch.network,
id: batch.batch.id,
block: batch.batch.block
block: batch.batch.block,
instructions_hash: Blake2b::<U32>::digest(batch.batch.instructions.encode()).into(),
}
);
break 'outer;
Expand Down
2 changes: 1 addition & 1 deletion tests/processor/src/tests/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ fn batch_test() {
},
};

// Make sure the proceessors picked it up by checking they're trying to sign a batch for it
// Make sure the processors picked it up by checking they're trying to sign a batch for it
let (mut id, mut preprocesses) =
recv_batch_preprocesses(&mut coordinators, &key_pair.0 .0, &expected_batch, 0).await;
// Trigger a random amount of re-attempts
Expand Down

0 comments on commit aa59f53

Please sign in to comment.