From e9d09ef4e2567ad40ff1d2c86c8f74bab4e94d16 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 6 Aug 2024 03:03:12 -0400 Subject: [PATCH] Send/Recv Participation one at a time Sending all, then attempting to receive all in an expected order, wasn't working even with notable delays between sending messages. This points to the mempool not working as expected... --- tests/coordinator/src/tests/key_gen.rs | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tests/coordinator/src/tests/key_gen.rs b/tests/coordinator/src/tests/key_gen.rs index 90686505f..1ec31776f 100644 --- a/tests/coordinator/src/tests/key_gen.rs +++ b/tests/coordinator/src/tests/key_gen.rs @@ -30,7 +30,8 @@ pub async fn key_gen( // This is distinct from the result of evrf_public_keys for each processor, as there'll have some // ordering algorithm on-chain which won't match our ordering let mut evrf_public_keys_as_on_chain = None; - for (i, processor) in processors.iter_mut().enumerate() { + for processor in processors.iter_mut() { + // Receive GenerateKey let msg = processor.recv_message().await; match &msg { CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::GenerateKey { @@ -59,30 +60,33 @@ pub async fn key_gen( evrf_public_keys: evrf_public_keys_as_on_chain.clone().unwrap(), }) ); + } - processor + for i in 0 .. coordinators { + // Send Participation + processors[i] .send_message(messages::key_gen::ProcessorMessage::Participation { session, participation: vec![u8::try_from(u16::from(participant_is[i])).unwrap()], }) .await; - // Sleep so this participation gets included, before moving to the next participation - wait_for_tributary().await; - wait_for_tributary().await; - } + // Sleep so this participation gets included + for _ in 0 .. 2 { + wait_for_tributary().await; + } - wait_for_tributary().await; - for processor in processors.iter_mut() { - #[allow(clippy::needless_range_loop)] // This wouldn't improve readability/clarity - for i in 0 .. coordinators { + // Have every other processor recv this message too + for processor in processors.iter_mut() { assert_eq!( processor.recv_message().await, - CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::Participation { - session, - participant: participant_is[i], - participation: vec![u8::try_from(u16::from(participant_is[i])).unwrap()], - }) + messages::CoordinatorMessage::KeyGen( + messages::key_gen::CoordinatorMessage::Participation { + session, + participant: participant_is[i], + participation: vec![u8::try_from(u16::from(participant_is[i])).unwrap()], + } + ) ); } }