From 21892b9504a08249199114b57a14d73debec719f Mon Sep 17 00:00:00 2001 From: muXxer Date: Mon, 18 Nov 2024 18:02:49 +0100 Subject: [PATCH 1/9] feat: replace ssh with https --- msim-tokio/Cargo.toml | 2 +- msim/Cargo.toml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/msim-tokio/Cargo.toml b/msim-tokio/Cargo.toml index c0fc39b..159b6a9 100644 --- a/msim-tokio/Cargo.toml +++ b/msim-tokio/Cargo.toml @@ -58,7 +58,7 @@ msim.path = "../msim" [dependencies] tracing = "0.1" -real_tokio = { git = "ssh://git@github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] } +real_tokio = { git = "https://github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] } bytes = { version = "1.7" } futures = { version = "0.3", features = ["async-await"] } mio = { version = "1.0" } diff --git a/msim/Cargo.toml b/msim/Cargo.toml index de80152..1dc4a54 100644 --- a/msim/Cargo.toml +++ b/msim/Cargo.toml @@ -36,8 +36,8 @@ ahash = "0.8" downcast-rs = "1.2" libc = "0.2" naive-timer = "0.2" -tokio = { git = "ssh://git@github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] } -tokio-util = { git = "ssh://git@github.com/iotaledger/tokio-madsim-fork.git", branch = "main", features = ["full"] } +tokio = { git = "https://github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] } +tokio-util = { git = "https://github.com/iotaledger/tokio-madsim-fork.git", branch = "main", features = ["full"] } toml = "0.8" socket2 = "0.5" erasable = "1.2" @@ -46,7 +46,7 @@ async-task = "4.7" [dev-dependencies] criterion = "0.5" structopt = "0.3" -tokio = { git = "ssh://git@github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] } +tokio = { git = "https://github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] } [package.metadata.docs.rs] # all-features = true From 269740f9ec6f373ea1ecdf21e00a7bafaf996cef Mon Sep 17 00:00:00 2001 From: muXxer Date: Mon, 18 Nov 2024 18:22:50 +0100 Subject: [PATCH 2/9] fix(ci): rename madsim to msim --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0674c90..fccd366 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - name: Clippy sim uses: actions-rs/cargo@v1 env: - RUSTFLAGS: "--cfg madsim" + RUSTFLAGS: "--cfg msim" with: command: clippy args: -- -D warnings @@ -50,7 +50,7 @@ jobs: - name: Build sim uses: actions-rs/cargo@v1 env: - RUSTFLAGS: "--cfg madsim" + RUSTFLAGS: "--cfg msim" with: command: build @@ -70,8 +70,8 @@ jobs: - name: Test sim uses: actions-rs/cargo@v1 env: - RUSTFLAGS: "--cfg madsim" - RUSTDOCFLAGS: "--cfg madsim" + RUSTFLAGS: "--cfg msim" + RUSTDOCFLAGS: "--cfg msim" with: command: test args: --release --no-fail-fast @@ -88,7 +88,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: bench - args: -p madsim + args: -p msim doc: runs-on: ubuntu-latest @@ -102,8 +102,8 @@ jobs: - name: Doc uses: actions-rs/cargo@v1 env: - RUSTFLAGS: "--cfg madsim" - RUSTDOCFLAGS: "--cfg madsim --cfg docsrs" + RUSTFLAGS: "--cfg msim" + RUSTDOCFLAGS: "--cfg msim --cfg docsrs" with: command: doc args: --no-deps From 618068dc079de04d8bccf7f4e82198fca286dcd7 Mon Sep 17 00:00:00 2001 From: muXxer Date: Mon, 18 Nov 2024 18:57:44 +0100 Subject: [PATCH 3/9] fix: fix clippy errors --- msim-tokio/src/poller.rs | 2 +- msim-tokio/src/sim/io.rs | 2 +- msim-tokio/src/sim/net.rs | 2 +- msim-tokio/src/sim/runtime.rs | 6 ++++++ msim-tokio/src/sim/udp.rs | 4 ++-- msim/Cargo.toml | 1 + msim/src/sim/collections.rs | 6 +++--- msim/src/sim/config.rs | 9 ++++++--- msim/src/sim/intercept.rs | 4 ++-- msim/src/sim/net/config.rs | 2 +- msim/src/sim/net/mod.rs | 9 ++++----- msim/src/sim/net/network.rs | 15 +++------------ msim/src/sim/rand.rs | 2 +- msim/src/sim/runtime/context.rs | 4 ++-- msim/src/sim/task.rs | 8 ++++---- msim/src/sim/time/mod.rs | 2 +- test-crates/jsonrpsee-test/Cargo.toml | 2 +- 17 files changed, 40 insertions(+), 40 deletions(-) diff --git a/msim-tokio/src/poller.rs b/msim-tokio/src/poller.rs index 8eedf22..fcb9b16 100644 --- a/msim-tokio/src/poller.rs +++ b/msim-tokio/src/poller.rs @@ -31,7 +31,7 @@ impl Poller { let fut: &mut PollerPinFut = poller.as_mut().unwrap(); let res = fut.as_mut().poll(cx); - if let Poll::Ready(_) = res { + if res.is_ready() { poller.take(); } res diff --git a/msim-tokio/src/sim/io.rs b/msim-tokio/src/sim/io.rs index 7ef8538..f124eec 100644 --- a/msim-tokio/src/sim/io.rs +++ b/msim-tokio/src/sim/io.rs @@ -160,7 +160,7 @@ pub mod unix { _ => unimplemented!("unhandled interested {:?}", interest), } - Ok(AsyncFdReadyMutGuard { async_fd: self }).into() + Ok(AsyncFdReadyMutGuard { async_fd: self }) } #[allow(clippy::needless_lifetimes)] // The lifetime improves rustdoc rendering. diff --git a/msim-tokio/src/sim/net.rs b/msim-tokio/src/sim/net.rs index a7d81a1..970a158 100644 --- a/msim-tokio/src/sim/net.rs +++ b/msim-tokio/src/sim/net.rs @@ -493,7 +493,7 @@ impl TcpStream { } pub async fn peek(&self, buf: &mut [u8]) -> io::Result { - if buf.len() == 0 { + if buf.is_empty() { return Ok(0); } diff --git a/msim-tokio/src/sim/runtime.rs b/msim-tokio/src/sim/runtime.rs index 05327a0..2ebd1dc 100644 --- a/msim-tokio/src/sim/runtime.rs +++ b/msim-tokio/src/sim/runtime.rs @@ -362,6 +362,12 @@ impl fmt::Debug for Builder { #[derive(Debug)] pub struct LocalSet; +impl Default for LocalSet { + fn default() -> Self { + Self::new() + } +} + impl LocalSet { /// Returns a new local task set. pub fn new() -> LocalSet { diff --git a/msim-tokio/src/sim/udp.rs b/msim-tokio/src/sim/udp.rs index e9c9022..2bc5e18 100644 --- a/msim-tokio/src/sim/udp.rs +++ b/msim-tokio/src/sim/udp.rs @@ -64,11 +64,11 @@ impl UdpSocket { } pub fn local_addr(&self) -> io::Result { - Ok(self.ep.local_addr()?) + self.ep.local_addr() } pub fn peer_addr(&self) -> io::Result { - Ok(self.ep.peer_addr()?) + self.ep.peer_addr() } pub async fn connect(&self, addr: A) -> io::Result<()> { diff --git a/msim/Cargo.toml b/msim/Cargo.toml index 1dc4a54..a8019fd 100644 --- a/msim/Cargo.toml +++ b/msim/Cargo.toml @@ -44,6 +44,7 @@ erasable = "1.2" async-task = "4.7" [dev-dependencies] +anyhow = "1.0.71" criterion = "0.5" structopt = "0.3" tokio = { git = "https://github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] } diff --git a/msim/src/sim/collections.rs b/msim/src/sim/collections.rs index 083a9cb..fa9c747 100644 --- a/msim/src/sim/collections.rs +++ b/msim/src/sim/collections.rs @@ -202,7 +202,7 @@ impl<'a, T, S> IntoIterator for &'a HashSet { type Item = &'a T; type IntoIter = hash_set::Iter<'a, T>; fn into_iter(self) -> Self::IntoIter { - (&self.0).iter() + self.0.iter() } } @@ -359,7 +359,7 @@ impl<'a, K, V, S> IntoIterator for &'a HashMap { type Item = (&'a K, &'a V); type IntoIter = hash_map::Iter<'a, K, V>; fn into_iter(self) -> Self::IntoIter { - (&self.0).iter() + self.0.iter() } } @@ -367,7 +367,7 @@ impl<'a, K, V, S> IntoIterator for &'a mut HashMap { type Item = (&'a K, &'a mut V); type IntoIter = hash_map::IterMut<'a, K, V>; fn into_iter(self) -> Self::IntoIter { - (&mut self.0).iter_mut() + self.0.iter_mut() } } diff --git a/msim/src/sim/config.rs b/msim/src/sim/config.rs index 9d09ba9..4be0204 100644 --- a/msim/src/sim/config.rs +++ b/msim/src/sim/config.rs @@ -63,17 +63,20 @@ mod test { // output). #[sim_test(crate = "crate", config = "test_config()")] - async fn config_test() { + async fn config_test() -> Result<(), anyhow::Error> { println!("single {:08x}", rand::thread_rng().gen::()); + Ok(()) } #[sim_test(crate = "crate", config = "test_config_multiple()")] - async fn config_test_multiple() { + async fn config_test_multiple() -> Result<(), anyhow::Error> { println!("multiple {:08x}", rand::thread_rng().gen::()); + Ok(()) } #[sim_test(crate = "crate", config = "test_config_multiple_repeat()")] - async fn config_test_multiple_repeat() { + async fn config_test_multiple_repeat() -> Result<(), anyhow::Error> { println!("multiple repeat {:08x}", rand::thread_rng().gen::()); + Ok(()) } } diff --git a/msim/src/sim/intercept.rs b/msim/src/sim/intercept.rs index a76bb5d..be36022 100644 --- a/msim/src/sim/intercept.rs +++ b/msim/src/sim/intercept.rs @@ -2,7 +2,7 @@ use std::cell::Cell; use tracing::info; thread_local! { - static INTERCEPTS_ENABLED: Cell = Cell::new(false); + static INTERCEPTS_ENABLED: Cell = const { Cell::new(false) }; } // This is called at the beginning of the test thread so that clock calls inside the test are @@ -43,7 +43,7 @@ macro_rules! define_sys_interceptor { }; } - if !crate::sim::intercept::intercepts_enabled() { + if !$crate::sim::intercept::intercepts_enabled() { return NEXT_DL_SYM($($param),*); } diff --git a/msim/src/sim/net/config.rs b/msim/src/sim/net/config.rs index fcbcbef..3866ec8 100644 --- a/msim/src/sim/net/config.rs +++ b/msim/src/sim/net/config.rs @@ -91,7 +91,7 @@ impl InterNodeLatency for InterNodeLatencyMap { return Some(dist.sample(rng)); } - return None; + None } } diff --git a/msim/src/sim/net/mod.rs b/msim/src/sim/net/mod.rs index d6d8a81..692eb4a 100644 --- a/msim/src/sim/net/mod.rs +++ b/msim/src/sim/net/mod.rs @@ -336,7 +336,7 @@ unsafe fn accept_impl( let endpoint = socket .endpoint .as_ref() - .ok_or_else(|| ((-1, libc::EINVAL)))?; + .ok_or((-1, libc::EINVAL))?; if endpoint.peer.is_some() { // attempt to accept on a socket that is already connected. @@ -740,7 +740,7 @@ define_sys_interceptor!( flags: libc::c_int, ) -> libc::c_int { HostNetworkState::with_socket(sockfd, |socket| { - let msgs = std::slice::from_raw_parts_mut(msgvec as *mut libc::mmsghdr, vlen as _); + let msgs = std::slice::from_raw_parts_mut(msgvec, vlen as _); for msg in msgs.iter_mut() { let dst_addr = msg_hdr_to_socket(&msg.msg_hdr); @@ -825,7 +825,7 @@ unsafe fn recv_impl(ep: &Endpoint, msg: *mut libc::msghdr) -> CResult bool { - match self.ty { - PayloadType::Udp => true, - _ => false, - } + matches!(self.ty, PayloadType::Udp) } pub fn is_tcp_data(&self) -> bool { - match self.ty { - PayloadType::TcpData => true, - _ => false, - } + matches!(self.ty, PayloadType::TcpData) } pub fn is_tcp_connect(&self) -> bool { - match self.ty { - PayloadType::TcpSignalConnect => true, - _ => false, - } + matches!(self.ty, PayloadType::TcpSignalConnect) } } diff --git a/msim/src/sim/rand.rs b/msim/src/sim/rand.rs index 5490412..ad999cf 100644 --- a/msim/src/sim/rand.rs +++ b/msim/src/sim/rand.rs @@ -171,7 +171,7 @@ fn init_std_random_state(seed: u64) -> bool { } thread_local! { - static SEED: Cell> = Cell::new(None); + static SEED: Cell> = const { Cell::new(None) }; } /// Obtain a series of random bytes. diff --git a/msim/src/sim/runtime/context.rs b/msim/src/sim/runtime/context.rs index 32de052..a442e0c 100644 --- a/msim/src/sim/runtime/context.rs +++ b/msim/src/sim/runtime/context.rs @@ -7,8 +7,8 @@ use crate::{ use std::{cell::RefCell, sync::Arc}; thread_local! { - static CONTEXT: RefCell> = RefCell::new(None); - static TASK: RefCell>> = RefCell::new(None); + static CONTEXT: RefCell> = const { RefCell::new(None) }; + static TASK: RefCell>> = const { RefCell::new(None) }; } pub(crate) fn current(map: impl FnOnce(&Handle) -> T) -> T { diff --git a/msim/src/sim/task.rs b/msim/src/sim/task.rs index 07b2665..2c73f5a 100644 --- a/msim/src/sim/task.rs +++ b/msim/src/sim/task.rs @@ -633,7 +633,7 @@ impl JoinHandle { /// Return an AbortHandle corresponding for the task. pub fn abort_handle(&self) -> AbortHandle { let inner = ErasablePtr::erase(Box::new(self.inner.clone())); - let id = self.id.clone(); + let id = self.id; AbortHandle { id, inner } } } @@ -648,11 +648,11 @@ impl Future for JoinHandle { let mut lock = self.inner.task.lock().unwrap(); let task = lock.as_mut(); if task.is_none() { - return std::task::Poll::Ready(Err(join_error::cancelled(self.id.clone()))); + return std::task::Poll::Ready(Err(join_error::cancelled(self.id))); } std::pin::Pin::new(task.unwrap()).poll(cx).map(|res| { // TODO: decide cancelled or panic - res.ok_or(join_error::cancelled(self.id.clone())) + res.ok_or(join_error::cancelled(self.id)) }) } } @@ -988,7 +988,7 @@ mod tests { time::sleep(Duration::from_secs(1)).await; join_set.detach_all(); time::sleep(Duration::from_secs(5)).await; - assert_eq!(flag.load(Ordering::Relaxed), true); + assert!(flag.load(Ordering::Relaxed)); }); } } diff --git a/msim/src/sim/time/mod.rs b/msim/src/sim/time/mod.rs index fa73b09..e474f38 100644 --- a/msim/src/sim/time/mod.rs +++ b/msim/src/sim/time/mod.rs @@ -570,7 +570,7 @@ mod tests { let std_t0 = std::time::Instant::now(); // Verify that times in other threads are not intercepted. - let std_t1 = std::thread::spawn(|| std::time::Instant::now()) + let std_t1 = std::thread::spawn(std::time::Instant::now) .join() .unwrap(); assert_ne!(std_t0, std_t1); diff --git a/test-crates/jsonrpsee-test/Cargo.toml b/test-crates/jsonrpsee-test/Cargo.toml index 77a5923..564cf2e 100644 --- a/test-crates/jsonrpsee-test/Cargo.toml +++ b/test-crates/jsonrpsee-test/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1" +anyhow = "1.0.71" tokio = "1" jsonrpsee = { version = "0.16.1", features = ["server", "macros", "http-client", "ws-client", "wasm-client", "client-ws-transport", "client-web-transport", "client-core"] } jsonrpsee-core = "0.16.1" From 86717828667e4cd86c2b84cf489661e55b073cfc Mon Sep 17 00:00:00 2001 From: muXxer Date: Mon, 18 Nov 2024 19:02:08 +0100 Subject: [PATCH 4/9] fix: rustfmt --- msim/src/sim/net/mod.rs | 11 ++--------- msim/src/sim/time/mod.rs | 4 +--- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/msim/src/sim/net/mod.rs b/msim/src/sim/net/mod.rs index 692eb4a..85b1c19 100644 --- a/msim/src/sim/net/mod.rs +++ b/msim/src/sim/net/mod.rs @@ -333,10 +333,7 @@ unsafe fn accept_impl( let net = plugin::simulator::(); let network = net.network.lock().unwrap(); - let endpoint = socket - .endpoint - .as_ref() - .ok_or((-1, libc::EINVAL))?; + let endpoint = socket.endpoint.as_ref().ok_or((-1, libc::EINVAL))?; if endpoint.peer.is_some() { // attempt to accept on a socket that is already connected. @@ -824,11 +821,7 @@ unsafe fn recv_impl(ep: &Endpoint, msg: *mut libc::msghdr) -> CResult Date: Mon, 18 Nov 2024 19:31:22 +0100 Subject: [PATCH 5/9] chore: bump rust toolchain --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c6e4d7d..a56a283 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.79" +channel = "1.80.1" From 253274185ea77d92ce09ea156d77596b3ab31973 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Mon, 18 Nov 2024 13:46:39 -0500 Subject: [PATCH 6/9] define some types --- msim/src/sim/runtime/mod.rs | 5 +++-- msim/src/sim/task.rs | 16 ++++++++-------- msim/src/sim/time/mod.rs | 1 + msim/src/sim/time/timer.rs | 2 +- rust-toolchain.toml | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/msim/src/sim/runtime/mod.rs b/msim/src/sim/runtime/mod.rs index e7a1168..b69056f 100644 --- a/msim/src/sim/runtime/mod.rs +++ b/msim/src/sim/runtime/mod.rs @@ -4,7 +4,7 @@ use super::*; use crate::assert_send_sync; use crate::context::TaskEnterGuard; use crate::net::NetSim; -use crate::task::{JoinHandle, NodeId}; +use crate::task::{InitFn, JoinHandle, NodeId}; use ::rand::Rng; use std::{ any::TypeId, @@ -372,7 +372,7 @@ pub struct NodeBuilder<'a> { handle: &'a Handle, name: Option, ip: Option, - init: Option>, + init: Option, } impl<'a> NodeBuilder<'a> { @@ -483,6 +483,7 @@ impl NodeHandle { /// Join the node. /// TODO: unimplemented + #[expect(clippy::result_unit_err)] pub fn join(self) -> Result<(), ()> { warn!("TODO: implement NodeHandle::join()"); Ok(()) diff --git a/msim/src/sim/task.rs b/msim/src/sim/task.rs index 2c73f5a..cb25783 100644 --- a/msim/src/sim/task.rs +++ b/msim/src/sim/task.rs @@ -73,7 +73,9 @@ struct PanicWrapper { restart_after: Option, } -struct PanicHookGuard(Option) + Sync + Send + 'static>>); +type PanicFn = Box) + Sync + Send + 'static>; + +struct PanicHookGuard(Option); impl PanicHookGuard { fn new() -> Self { @@ -337,11 +339,13 @@ pub(crate) struct TaskHandle { } assert_send_sync!(TaskHandle); +pub(crate) type InitFn = Arc; + struct Node { info: Arc, paused: Vec, /// A function to spawn the initial task. - init: Option>, + init: Option, } impl TaskHandle { @@ -392,11 +396,7 @@ impl TaskHandle { } /// Create a new node. - pub fn create_node( - &self, - name: Option, - init: Option>, - ) -> TaskNodeHandle { + pub fn create_node(&self, name: Option, init: Option) -> TaskNodeHandle { let id = NodeId(self.next_node_id.fetch_add(1, Ordering::SeqCst)); let name = name.unwrap_or_else(|| format!("node-{}", id.0)); let info = Arc::new(TaskInfo::new(id, name)); @@ -690,7 +690,7 @@ impl AbortHandle { ret } - fn inner(&self) -> Box>> { + fn inner(&self) -> Arc> { unsafe { ErasablePtr::unerase(self.inner) } } } diff --git a/msim/src/sim/time/mod.rs b/msim/src/sim/time/mod.rs index ace6cd4..89c4ee3 100644 --- a/msim/src/sim/time/mod.rs +++ b/msim/src/sim/time/mod.rs @@ -543,6 +543,7 @@ define_sys_interceptor!( // used by Instant libc::CLOCK_MONOTONIC | libc::CLOCK_MONOTONIC_RAW | libc::CLOCK_MONOTONIC_COARSE => { // Instant is the same layout as timespec on linux + #[allow(clippy::missing_transmute_annotations)] ts.write(std::mem::transmute(time.now_instant())); } diff --git a/msim/src/sim/time/timer.rs b/msim/src/sim/time/timer.rs index 1c1f03b..f9d214f 100644 --- a/msim/src/sim/time/timer.rs +++ b/msim/src/sim/time/timer.rs @@ -113,7 +113,7 @@ impl Eq for Event {} // BinaryHeap is a max-heap. So we need to reverse the order. impl PartialOrd for Event { fn partial_cmp(&self, other: &Self) -> Option { - other.deadline.partial_cmp(&self.deadline) + Some(self.cmp(other)) } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a56a283..4cef0b7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.81" From a354091ea2c502d6b62078c2f3e0c9e94b0769f7 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Mon, 18 Nov 2024 15:05:04 -0500 Subject: [PATCH 7/9] try to fix erased ptr --- msim/src/sim/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msim/src/sim/task.rs b/msim/src/sim/task.rs index cb25783..e80a155 100644 --- a/msim/src/sim/task.rs +++ b/msim/src/sim/task.rs @@ -632,7 +632,7 @@ impl JoinHandle { /// Return an AbortHandle corresponding for the task. pub fn abort_handle(&self) -> AbortHandle { - let inner = ErasablePtr::erase(Box::new(self.inner.clone())); + let inner = ErasablePtr::erase(self.inner.clone()); let id = self.id; AbortHandle { id, inner } } From 673d9db47f19734a73eb3521adab3366784b4903 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Mon, 18 Nov 2024 15:28:35 -0500 Subject: [PATCH 8/9] fix docs --- msim/src/sim/net/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/msim/src/sim/net/mod.rs b/msim/src/sim/net/mod.rs index 85b1c19..84d4992 100644 --- a/msim/src/sim/net/mod.rs +++ b/msim/src/sim/net/mod.rs @@ -3,7 +3,7 @@ //! # Examples //! //! ``` -//! use msim::{runtime::Runtime, net::Endpoint}; +//! use msim::{runtime::Runtime, net::{Endpoint, network::Payload}}; //! use std::sync::Arc; //! use std::net::SocketAddr; //! @@ -16,14 +16,14 @@ //! let barrier_ = barrier.clone(); //! //! node1.spawn(async move { -//! let net = Endpoint::bind(addr1).await.unwrap(); +//! let net = Endpoint::bind(libc::SOCK_STREAM, addr1).await.unwrap(); //! barrier_.wait().await; // make sure addr2 has bound //! -//! net.send_to(addr2, 1, &[1]).await.unwrap(); +//! net.send_to(addr2, 1, Payload::new_udp(Box::new(vec![1u8]))).await.unwrap(); //! }); //! //! let f = node2.spawn(async move { -//! let net = Endpoint::bind(addr2).await.unwrap(); +//! let net = Endpoint::bind(libc::SOCK_STREAM, addr2).await.unwrap(); //! barrier.wait().await; //! //! let mut buf = vec![0; 0x10]; @@ -1140,11 +1140,11 @@ impl Endpoint { /// /// # Example /// ``` - /// use msim::{runtime::Runtime, net::Endpoint}; + /// use msim::{runtime::Runtime, net::{Endpoint, network::Payload}}; /// /// Runtime::new().block_on(async { - /// let net = Endpoint::bind("127.0.0.1:0").await.unwrap(); - /// net.send_to("127.0.0.1:4242", 0, &[0; 10]).await.expect("couldn't send data"); + /// let net = Endpoint::bind(libc::SOCK_STREAM, "127.0.0.1:4242").await.unwrap(); + /// net.send_to("127.0.0.1:4242", 0, Payload::new_udp(Box::new([0; 10]))).await.expect("couldn't send data"); /// }); /// ``` pub async fn send_to( @@ -1165,7 +1165,7 @@ impl Endpoint { /// use msim::{runtime::Runtime, net::Endpoint}; /// /// Runtime::new().block_on(async { - /// let net = Endpoint::bind("127.0.0.1:0").await.unwrap(); + /// let net = Endpoint::bind(libc::SOCK_STREAM, "127.0.0.1:0").await.unwrap(); /// let mut buf = [0; 10]; /// let (len, src) = net.recv_from(0, &mut buf).await.expect("couldn't receive data"); /// }); From 6026695207d66840617743050b90e02229ff7cb9 Mon Sep 17 00:00:00 2001 From: muXxer Date: Tue, 19 Nov 2024 10:43:08 +0100 Subject: [PATCH 9/9] fix: use version 1.0 for anyhow Co-authored-by: DaughterOfMars --- msim/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msim/Cargo.toml b/msim/Cargo.toml index a8019fd..6adc3ee 100644 --- a/msim/Cargo.toml +++ b/msim/Cargo.toml @@ -44,7 +44,7 @@ erasable = "1.2" async-task = "4.7" [dev-dependencies] -anyhow = "1.0.71" +anyhow = "1.0" criterion = "0.5" structopt = "0.3" tokio = { git = "https://github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] }