Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace ssh with https #1

Merged
merged 9 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion msim-tokio/src/poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<R> Poller<R> {
let fut: &mut PollerPinFut<R> = poller.as_mut().unwrap();
let res = fut.as_mut().poll(cx);

if let Poll::Ready(_) = res {
if res.is_ready() {
poller.take();
}
res
Expand Down
2 changes: 1 addition & 1 deletion msim-tokio/src/sim/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion msim-tokio/src/sim/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ impl TcpStream {
}

pub async fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
if buf.len() == 0 {
if buf.is_empty() {
return Ok(0);
}

Expand Down
6 changes: 6 additions & 0 deletions msim-tokio/src/sim/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions msim-tokio/src/sim/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ impl UdpSocket {
}

pub fn local_addr(&self) -> io::Result<SocketAddr> {
Ok(self.ep.local_addr()?)
self.ep.local_addr()
}

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
Ok(self.ep.peer_addr()?)
self.ep.peer_addr()
}

pub async fn connect<A: ToSocketAddrs>(&self, addr: A) -> io::Result<()> {
Expand Down
1 change: 1 addition & 0 deletions msim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ erasable = "1.2"
async-task = "4.7"

[dev-dependencies]
anyhow = "1.0.71"
muXxer marked this conversation as resolved.
Show resolved Hide resolved
criterion = "0.5"
structopt = "0.3"
tokio = { git = "https://github.com/iotaledger/tokio-madsim-fork.git", branch = "main", package = "real_tokio", features = ["full"] }
Expand Down
6 changes: 3 additions & 3 deletions msim/src/sim/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<'a, T, S> IntoIterator for &'a HashSet<T, S> {
type Item = &'a T;
type IntoIter = hash_set::Iter<'a, T>;
fn into_iter(self) -> Self::IntoIter {
(&self.0).iter()
self.0.iter()
}
}

Expand Down Expand Up @@ -359,15 +359,15 @@ impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S> {
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()
}
}

impl<'a, K, V, S> IntoIterator for &'a mut HashMap<K, V, S> {
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()
}
}

Expand Down
9 changes: 6 additions & 3 deletions msim/src/sim/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u32>());
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::<u32>());
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::<u32>());
Ok(())
}
}
4 changes: 2 additions & 2 deletions msim/src/sim/intercept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::cell::Cell;
use tracing::info;

thread_local! {
static INTERCEPTS_ENABLED: Cell<bool> = Cell::new(false);
static INTERCEPTS_ENABLED: Cell<bool> = const { Cell::new(false) };
}

// This is called at the beginning of the test thread so that clock calls inside the test are
Expand Down Expand Up @@ -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),*);
}

Expand Down
2 changes: 1 addition & 1 deletion msim/src/sim/net/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl InterNodeLatency for InterNodeLatencyMap {
return Some(dist.sample(rng));
}

return None;
None
}
}

Expand Down
9 changes: 4 additions & 5 deletions msim/src/sim/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
//!
//! node1.spawn(async move {
//! let net = Endpoint::bind(addr1).await.unwrap();
//! barrier_.wait().await; // make sure addr2 has bound

Check failure on line 20 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied

Check failure on line 20 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied
//!
//! net.send_to(addr2, 1, &[1]).await.unwrap();
//! });

Check failure on line 23 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

mismatched types

Check failure on line 23 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

mismatched types
//!
//! let f = node2.spawn(async move {
//! let net = Endpoint::bind(addr2).await.unwrap();
//! barrier.wait().await;

Check failure on line 27 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied

Check failure on line 27 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied
//!
//! let mut buf = vec![0; 0x10];
//! let (len, from) = net.recv_from(1, &mut buf).await.unwrap();
Expand Down Expand Up @@ -336,7 +336,7 @@
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.
Expand Down Expand Up @@ -740,7 +740,7 @@
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);
Expand Down Expand Up @@ -825,7 +825,7 @@
msg.msg_flags |= libc::MSG_TRUNC;
}
std::ptr::copy_nonoverlapping(
payload.as_ptr() as *const u8,
payload.as_ptr(),
iov.iov_base as *mut u8,
copy_len,
);
Expand Down Expand Up @@ -1151,8 +1151,8 @@
///
/// 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");

Check failure on line 1154 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied

Check failure on line 1154 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied
/// });

Check failure on line 1155 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

mismatched types

Check failure on line 1155 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

mismatched types
/// ```
pub async fn send_to(
&self,
Expand All @@ -1173,7 +1173,7 @@
///
/// Runtime::new().block_on(async {
/// let net = Endpoint::bind("127.0.0.1:0").await.unwrap();
/// let mut buf = [0; 10];

Check failure on line 1176 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied

Check failure on line 1176 in msim/src/sim/net/mod.rs

View workflow job for this annotation

GitHub Actions / test

this function takes 2 arguments but 1 argument was supplied
/// let (len, src) = net.recv_from(0, &mut buf).await.expect("couldn't receive data");
/// });
/// ```
Expand Down Expand Up @@ -1536,8 +1536,7 @@
// FIXME: ep1 should not receive messages from other node
timeout(Duration::from_secs(1), ep1.recv_from(1, &mut []))
.await
.err()
.expect("localhost endpoint should not receive from other nodes");
.expect_err("localhost endpoint should not receive from other nodes");
// ep2 should receive
ep2.recv_from(1, &mut []).await.unwrap();
});
Expand Down
15 changes: 3 additions & 12 deletions msim/src/sim/net/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,24 +533,15 @@ impl Payload {
}

pub fn is_udp(&self) -> 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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion msim/src/sim/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn init_std_random_state(seed: u64) -> bool {
}

thread_local! {
static SEED: Cell<Option<u64>> = Cell::new(None);
static SEED: Cell<Option<u64>> = const { Cell::new(None) };
}

/// Obtain a series of random bytes.
Expand Down
4 changes: 2 additions & 2 deletions msim/src/sim/runtime/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
use std::{cell::RefCell, sync::Arc};

thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None);
static TASK: RefCell<Option<Arc<TaskInfo>>> = RefCell::new(None);
static CONTEXT: RefCell<Option<Handle>> = const { RefCell::new(None) };
static TASK: RefCell<Option<Arc<TaskInfo>>> = const { RefCell::new(None) };
}

pub(crate) fn current<T>(map: impl FnOnce(&Handle) -> T) -> T {
Expand Down
8 changes: 4 additions & 4 deletions msim/src/sim/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ impl<T> JoinHandle<T> {
/// 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 }
}
}
Expand All @@ -648,11 +648,11 @@ impl<T> Future for JoinHandle<T> {
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))
})
}
}
Expand Down Expand Up @@ -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));
});
}
}
2 changes: 1 addition & 1 deletion msim/src/sim/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test-crates/jsonrpsee-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading