From aa59f53ead0d7b8a8eb430b274c4c84cd7c0dcec Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 29 Sep 2023 04:35:00 -0400 Subject: [PATCH] Correct the coordinator tests They weren't updated with the past couple of commits. --- Cargo.lock | 2 ++ tests/coordinator/Cargo.toml | 3 +++ tests/coordinator/src/tests/batch.rs | 18 +++++++++++++++--- tests/processor/src/tests/batch.rs | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5a13dd9a..e3db9aa92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8191,10 +8191,12 @@ dependencies = [ name = "serai-coordinator-tests" version = "0.1.0" dependencies = [ + "blake2", "ciphersuite", "dkg", "dockertest", "hex", + "parity-scale-codec", "rand_core 0.6.4", "schnorrkel", "serai-client", diff --git a/tests/coordinator/Cargo.toml b/tests/coordinator/Cargo.toml index ced0d65e7..d52789f11 100644 --- a/tests/coordinator/Cargo.toml +++ b/tests/coordinator/Cargo.toml @@ -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" } diff --git a/tests/coordinator/src/tests/batch.rs b/tests/coordinator/src/tests/batch.rs index bc31f9c28..ea41807cc 100644 --- a/tests/coordinator/src/tests/batch.rs +++ b/tests/coordinator/src/tests/batch.rs @@ -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::{ @@ -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 = @@ -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; } @@ -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::::digest(batch.batch.instructions.encode()).into(), } ); break 'outer; diff --git a/tests/processor/src/tests/batch.rs b/tests/processor/src/tests/batch.rs index 6c4a32aba..b78836649 100644 --- a/tests/processor/src/tests/batch.rs +++ b/tests/processor/src/tests/batch.rs @@ -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