Skip to content

Commit e831178

Browse files
committed
Update tests
1 parent b11811f commit e831178

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

rust/hermes-ipfs/examples/hermes-ipfs-cli.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Hermes IPFS VFS compatibility
22
33
use clap::{Parser, Subcommand};
4+
use connexa::dummy;
45
use hermes_ipfs::{HermesIpfs, HermesIpfsBuilder};
56
use lipsum::lipsum;
67
use rust_ipfs::IpfsPath;
@@ -44,11 +45,11 @@ async fn main() -> anyhow::Result<()> {
4445
let args = Cli::parse();
4546
let base_dir = dirs::data_dir().unwrap_or_else(|| std::path::PathBuf::from("."));
4647
let ipfs_data_path = base_dir.as_path().join("hermes/ipfs");
47-
let builder = HermesIpfsBuilder::new()
48+
let builder = HermesIpfsBuilder::<dummy::Behaviour>::new()
4849
.with_default()
4950
.set_default_listener()
5051
// TODO(saibatizoku): Re-Enable default transport config when libp2p Cert bug is fixed
51-
.disable_tls()
52+
//.enable_secure_websocket()
5253
.set_disk_storage(ipfs_data_path);
5354
let hermes_node: HermesIpfs = builder.start().await?.into();
5455
match args.command {

rust/hermes-ipfs/examples/pubsub.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//! * The task that reads lines from stdin and publishes them as either node.
1515
use std::io::Write;
1616

17-
use hermes_ipfs::{pin_mut, FutureExt, HermesIpfs, StreamExt};
18-
use rust_ipfs::PubsubEvent;
17+
use futures::{pin_mut, FutureExt, StreamExt};
18+
use hermes_ipfs::HermesIpfs;
1919
use rustyline_async::Readline;
2020

2121
#[allow(clippy::indexing_slicing)]
@@ -57,15 +57,11 @@ async fn start_bootstrapped_nodes() -> anyhow::Result<(HermesIpfs, HermesIpfs)>
5757
/// Main function
5858
async fn main() -> anyhow::Result<()> {
5959
let topic = String::from("ipfs-chat");
60-
let option_topic = Option::Some(topic.clone());
6160

6261
// Initialize the repo and start a daemon
6362
let (hermes_a, hermes_b) = start_bootstrapped_nodes().await?;
6463
let (mut rl, mut stdout) = Readline::new(format!("{} > ", "Write message to publish"))?;
6564

66-
let mut event_stream = hermes_a.pubsub_events(option_topic.clone()).await?;
67-
let mut event_stream_b = hermes_b.pubsub_events(option_topic).await?;
68-
6965
let stream = hermes_a.pubsub_subscribe(topic.clone()).await?;
7066
let stream_b = hermes_b.pubsub_subscribe(topic.clone()).await?;
7167

@@ -79,24 +75,12 @@ async fn main() -> anyhow::Result<()> {
7975
tokio::select! {
8076
data = stream.next() => {
8177
if let Some(msg) = data {
82-
writeln!(stdout, "NODE A RECV: {}", String::from_utf8_lossy(&msg.data))?;
78+
writeln!(stdout, "NODE A RECV: {:?}", &msg)?;
8379
}
8480
}
8581
data = stream_b.next() => {
8682
if let Some(msg) = data {
87-
writeln!(stdout, "NODE B RECV: {}", String::from_utf8_lossy(&msg.data))?;
88-
}
89-
}
90-
Some(event) = event_stream.next() => {
91-
match event {
92-
PubsubEvent::Subscribe { peer_id, topic } => writeln!(stdout, "{peer_id} subscribed to {topic:?}")?,
93-
PubsubEvent::Unsubscribe { peer_id, topic } => writeln!(stdout, "{peer_id} unsubscribed from {topic:?}")?,
94-
}
95-
}
96-
Some(event) = event_stream_b.next() => {
97-
match event {
98-
PubsubEvent::Subscribe { peer_id , topic} => writeln!(stdout, "{peer_id} subscribed to {topic:?}")?,
99-
PubsubEvent::Unsubscribe { peer_id, topic } => writeln!(stdout, "{peer_id} unsubscribed from {topic:?}")?,
83+
writeln!(stdout, "NODE B RECV: {:?}", &msg)?;
10084
}
10185
}
10286
line = rl.readline().fuse() => match line {

rust/hermes-ipfs/examples/put-get-dht.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ async fn main() -> anyhow::Result<()> {
4848
println!("* Hermes IPFS node A is publishing 'my_key' to DHT.");
4949
hermes_ipfs_a.dht_put(b"my_key", ipfs_file).await?;
5050
println!("* Hermes IPFS node B is getting 'my_key' from DHT.");
51-
let data_retrieved = hermes_ipfs_b.dht_get(b"my_key").await?;
51+
let key: Vec<u8> = "my_key".bytes().collect();
52+
let data_retrieved = hermes_ipfs_b.dht_get(key).await?;
5253
let data = String::from_utf8(data_retrieved)?;
5354
println!(" Got data: {data:?}");
5455
// Stop the nodes and exit.

0 commit comments

Comments
 (0)