Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Update libp2p to v0.43.0 #499

Merged
merged 27 commits into from
Apr 1, 2022
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f601b8d
fix: update libp2p and renamed the changed types
rand0m-cloud Mar 18, 2022
c3a48c9
fix: updated libp2p in the bitswap crate
rand0m-cloud Mar 18, 2022
4e5ff4d
more libp2p updating
rand0m-cloud Mar 18, 2022
918d4d8
more updating of types
rand0m-cloud Mar 18, 2022
c1a5bba
some updates to pubsub
rand0m-cloud Mar 18, 2022
7e9da72
fix the pubsub network behaviour action type
rand0m-cloud Mar 18, 2022
085be77
replaced todo placeholders
rand0m-cloud Mar 18, 2022
e4002d6
re-add connection closed and established
rand0m-cloud Mar 18, 2022
a996922
added change to changelog
rand0m-cloud Mar 18, 2022
bdf977c
enable event_process for BehaviourEvent
rand0m-cloud Mar 18, 2022
93b31b3
chore: clean up type signature
rand0m-cloud Mar 18, 2022
25c8d58
fix: removed unneeded BehaviourEvent struct
rand0m-cloud Mar 18, 2022
3b59193
temp fix: changed field order to workaround bug in libp2p
rand0m-cloud Mar 18, 2022
31262b5
chore: more updating to libp2p
rand0m-cloud Mar 18, 2022
6c6fc3d
fix: update libp2p and renamed the changed types
rand0m-cloud Mar 18, 2022
77291ee
fix(swarm-test): add biased to tokio::select for non-random behavior
rand0m-cloud Mar 18, 2022
888e6f1
wip: re-add code fragment to handle dial failure
rand0m-cloud Mar 18, 2022
72ff95d
fix(swarm): corrected dial failure logic
rand0m-cloud Mar 21, 2022
1cee67d
fix: corrected faulty Vec::retain logic and updated WrongPeerId test
rand0m-cloud Mar 21, 2022
897c16f
fix: apply review suggestions and fix clippy lints
rand0m-cloud Mar 24, 2022
d4d3def
fix(pubsub): tell Floodsub about the peers we want to hear from
rand0m-cloud Mar 25, 2022
87a4114
ci(win): use windows-2019 image
koivunej Mar 30, 2022
82453e5
fix(build): stop building while writing an error
koivunej Mar 30, 2022
277954b
test(pubsub): disjoint topics as new test case
koivunej Apr 1, 2022
50ad10f
test(pubsub): simplify, comment
koivunej Apr 1, 2022
081a598
test(conf): ignore pubsub tests on windows for now
koivunej Apr 1, 2022
bf7a807
doc(p2p): add fixme for possible issue
koivunej Apr 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(pubsub): disjoint topics as new test case
originally created in 8eae8e1 by
altering the single topic test, included in this commit as duplicating
version.

Co-authored-by: Addy Bryant <[email protected]>
  • Loading branch information
koivunej and rand0m-cloud committed Apr 1, 2022
commit 277954b0d2eac651dbfb786509bd83d2bc4ea0c6
106 changes: 106 additions & 0 deletions tests/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,112 @@ async fn publish_between_two_nodes() {
assert!(disappeared, "timed out before a saw b's unsubscription");
}

#[tokio::test]
#[allow(clippy::mutable_key_type)] // clippy doesn't like Vec inside HashSet
async fn publish_between_two_nodes_different_topics() {
use futures::stream::StreamExt;
use std::collections::HashSet;

let nodes = spawn_nodes(2, Topology::Line).await;
let node_a = &nodes[0];
let node_b = &nodes[1];

let topic_a = "shared-a".to_owned();
let topic_b = "shared-b".to_owned();

// Node A subscribes to Topic B
// Node B subscribes to Topic A
let mut a_msgs = node_a.pubsub_subscribe(topic_b.clone()).await.unwrap();
let mut b_msgs = node_b.pubsub_subscribe(topic_a.clone()).await.unwrap();

// need to wait to see both sides so that the messages will get through
let mut appeared = false;
for _ in 0..100usize {
if node_a
.pubsub_peers(Some(topic_a.clone()))
.await
.unwrap()
.contains(&node_b.id)
&& node_b
.pubsub_peers(Some(topic_b.clone()))
.await
.unwrap()
.contains(&node_a.id)
{
appeared = true;
break;
}
timeout(Duration::from_millis(100), pending::<()>())
.await
.unwrap_err();
}

assert!(
appeared,
"timed out before both nodes appeared as pubsub peers"
);

// Each node publishes to their own topic
node_a
.pubsub_publish(topic_a.clone(), b"foobar".to_vec())
.await
.unwrap();
node_b
.pubsub_publish(topic_b.clone(), b"barfoo".to_vec())
.await
.unwrap();

// the order is not defined, but both should see the other's message
let expected = [
(&[topic_a.clone()], &node_a.id, b"foobar"),
(&[topic_b.clone()], &node_b.id, b"barfoo"),
]
.iter()
.cloned()
.map(|(topics, id, data)| (topics.to_vec(), *id, data.to_vec()))
.collect::<HashSet<_>>();

let mut actual = HashSet::new();
for (st, own_peer_id) in &mut [(b_msgs.by_ref(), node_b.id), (a_msgs.by_ref(), node_a.id)] {
let actual_msg = timeout(
Duration::from_secs(2),
st.take(1)
// 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))
.filter(|(_, source_peer_id, _)| future::ready(source_peer_id != own_peer_id))
.next(),
)
.await
.unwrap()
.unwrap();
actual.insert(actual_msg);
}

assert_eq!(expected, actual);

drop(b_msgs);

let mut disappeared = false;
for _ in 0..100usize {
if !node_a
.pubsub_peers(Some(topic_a.clone()))
.await
.unwrap()
.contains(&node_b.id)
{
disappeared = true;
break;
}
timeout(Duration::from_millis(100), pending::<()>())
.await
.unwrap_err();
}

assert!(disappeared, "timed out before a saw b's unsubscription");
}

#[cfg(any(feature = "test_go_interop", feature = "test_js_interop"))]
#[tokio::test]
#[ignore = "doesn't work yet"]
Expand Down