fix: flaky test by cloning instead of try_unwrap

This commit is contained in:
Joonas Koivunen 2020-03-27 19:08:33 +02:00 committed by Mark Robert Henderson
parent ef8dc79cd1
commit 305e152aec
2 changed files with 4 additions and 2 deletions

View File

@ -28,7 +28,7 @@ pub struct Pubsub {
}
/// Adaptation hopefully supporting somehow both Floodsub and Gossipsub Messages in the future
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct PubsubMessage {
pub source: PeerId,
pub data: Vec<u8>,

View File

@ -95,7 +95,9 @@ async fn publish_between_two_nodes() {
for st in &mut [b_msgs.by_ref(), a_msgs.by_ref()] {
let actual = st
.take(2)
.map(|msg| Arc::try_unwrap(msg).expect("single subscriber"))
// Arc::try_unwrap will fail sometimes here as the sender side in src/p2p/pubsub.rs:305
// can still be looping
.map(|msg| (*msg).clone())
.map(|msg| (msg.topics, msg.source, msg.data))
.collect::<HashSet<_>>()
.await;