diff --git a/tests/coordinator/src/tests/key_gen.rs b/tests/coordinator/src/tests/key_gen.rs index 17bf43e7..8ea14cbc 100644 --- a/tests/coordinator/src/tests/key_gen.rs +++ b/tests/coordinator/src/tests/key_gen.rs @@ -10,6 +10,7 @@ use ciphersuite::{ group::{ff::Field, GroupEncoding}, Ciphersuite, Ristretto, Secp256k1, }; +use dkg::ThresholdParams; use serai_client::{ primitives::NetworkId, @@ -31,30 +32,31 @@ pub async fn key_gen( let id = KeyGenId { session: set.session, attempt: 0 }; for (i, processor) in processors.iter_mut().enumerate() { - loop { - let msg = processor.recv_message().await; - match &msg { - CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::GenerateKey { - id: this_id, - params, - shares, - }) => { - assert_eq!(id, *this_id); - assert_eq!(params.t(), u16::try_from(((coordinators * 2) / 3) + 1).unwrap()); - assert_eq!(params.n(), u16::try_from(coordinators).unwrap()); - assert_eq!(*shares, 1); - participant_is.push(params.i()); - break; - } - CoordinatorMessage::Substrate( - messages::substrate::CoordinatorMessage::ConfirmKeyPair { .. }, - ) => { - continue; - } - _ => panic!("unexpected message: {msg:?}"), + let msg = processor.recv_message().await; + match &msg { + CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::GenerateKey { + params, + .. + }) => { + participant_is.push(params.i()); } + _ => panic!("unexpected message: {msg:?}"), } + assert_eq!( + msg, + CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::GenerateKey { + id, + params: ThresholdParams::new( + u16::try_from(((coordinators * 2) / 3) + 1).unwrap(), + u16::try_from(coordinators).unwrap(), + participant_is[i], + ) + .unwrap(), + shares: 1, + }) + ); + processor .send_message(messages::key_gen::ProcessorMessage::Commitments { id, diff --git a/tests/coordinator/src/tests/rotation.rs b/tests/coordinator/src/tests/rotation.rs index 4a8b95ff..1c817cf7 100644 --- a/tests/coordinator/src/tests/rotation.rs +++ b/tests/coordinator/src/tests/rotation.rs @@ -129,7 +129,7 @@ async fn set_rotation_test() { new_test( |mut processors: Vec| async move { // exclude the last processor from keygen since we will add him later - let excluded = processors.pop().unwrap(); + let mut excluded = processors.pop().unwrap(); assert_eq!(processors.len(), COORDINATORS); let pair5 = insecure_pair_from_name("Eve"); @@ -142,6 +142,13 @@ async fn set_rotation_test() { // genesis keygen let _ = key_gen::(&mut processors, Session(0)).await; + // Even the excluded processor should receive the key pair confirmation + match excluded.recv_message().await { + CoordinatorMessage::Substrate( + messages::substrate::CoordinatorMessage::ConfirmKeyPair { session, .. }, + ) => assert_eq!(session, Session(0)), + _ => panic!("excluded got message other than ConfirmKeyPair"), + } // wait until next session to see the effect on coordinator wait_till_next_epoch(&serai).await;