diff --git a/http/src/v0.rs b/http/src/v0.rs index 4a21023b..78b20178 100644 --- a/http/src/v0.rs +++ b/http/src/v0.rs @@ -175,7 +175,7 @@ mod tests { routes(&ipfs, shutdown_tx) } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn not_found_as_plaintext() { let routes = testing_routes().await; let resp = warp::test::request() @@ -189,7 +189,7 @@ mod tests { assert_eq!(resp.body(), "404 page not found"); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn invalid_peer_id_as_messageresponse() { let routes = testing_routes().await; let resp = warp::test::request() diff --git a/http/src/v0/pubsub.rs b/http/src/v0/pubsub.rs index 0696ee71..41c534d4 100644 --- a/http/src/v0/pubsub.rs +++ b/http/src/v0/pubsub.rs @@ -536,7 +536,7 @@ mod tests { }) } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn url_hacked_args() { let response = request() .path("/pubsub/pub?arg=some_channel&arg=foobar") @@ -546,7 +546,7 @@ mod tests { assert_eq!(body, r#"{"message":"foobar","topic":"some_channel"}"#); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn message_in_body() { let response = request() .path("/pubsub/pub?arg=some_channel") diff --git a/http/src/v0/refs.rs b/http/src/v0/refs.rs index ba90c232..ae1a8013 100644 --- a/http/src/v0/refs.rs +++ b/http/src/v0/refs.rs @@ -626,7 +626,7 @@ mod tests { use std::collections::HashSet; use std::convert::TryFrom; - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_inner_local() { let filter = local(&*preloaded_testing_ipfs().await); @@ -673,7 +673,7 @@ mod tests { assert!(diff.is_empty(), "{:?}", diff); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn all_refs_from_root() { let Node { ipfs, bg_task: _bt } = preloaded_testing_ipfs().await; @@ -714,7 +714,7 @@ mod tests { assert_edges(&expected, all_edges.as_slice()); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn all_unique_refs_from_root() { let Node { ipfs, bg_task: _bt } = preloaded_testing_ipfs().await; @@ -757,7 +757,7 @@ mod tests { assert!(diff.is_empty(), "{:?}", diff); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn refs_with_path() { let ipfs = preloaded_testing_ipfs().await; diff --git a/http/src/v0/root_files.rs b/http/src/v0/root_files.rs index 773e3dac..ca021864 100644 --- a/http/src/v0/root_files.rs +++ b/http/src/v0/root_files.rs @@ -316,7 +316,7 @@ mod tests { } } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn very_long_file_and_symlink_names() { let ipfs = Node::new("test_node").await; @@ -372,7 +372,7 @@ mod tests { assert_eq!(found, expected); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn get_multiblock_file() { let ipfs = Node::new("test_node").await; diff --git a/http/src/v0/root_files/add.rs b/http/src/v0/root_files/add.rs index 71c73136..0c53d353 100644 --- a/http/src/v0/root_files/add.rs +++ b/http/src/v0/root_files/add.rs @@ -377,7 +377,7 @@ impl serde::Serialize for Quoted { mod tests { use crate::v0::root_files::add; - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn add_single_block_file() { let ipfs = tokio_ipfs().await; diff --git a/src/dag.rs b/src/dag.rs index f9680158..bb061dc9 100644 --- a/src/dag.rs +++ b/src/dag.rs @@ -95,7 +95,7 @@ mod tests { use super::*; use crate::{make_ipld, Node}; - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_resolve_root_cid() { let Node { ipfs, bg_task: _bt } = Node::new("test_node").await; let dag = IpldDag::new(ipfs); @@ -105,7 +105,7 @@ mod tests { assert_eq!(res, data); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_resolve_array_elem() { let Node { ipfs, bg_task: _bt } = Node::new("test_node").await; let dag = IpldDag::new(ipfs); @@ -118,7 +118,7 @@ mod tests { assert_eq!(res, make_ipld!(2)); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_resolve_nested_array_elem() { let Node { ipfs, bg_task: _bt } = Node::new("test_node").await; let dag = IpldDag::new(ipfs); @@ -131,7 +131,7 @@ mod tests { assert_eq!(res, make_ipld!(2)); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_resolve_object_elem() { let Node { ipfs, bg_task: _bt } = Node::new("test_node").await; let dag = IpldDag::new(ipfs); @@ -146,7 +146,7 @@ mod tests { assert_eq!(res, make_ipld!(false)); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_resolve_cid_elem() { let Node { ipfs, bg_task: _bt } = Node::new("test_node").await; let dag = IpldDag::new(ipfs); diff --git a/src/ipns/dns.rs b/src/ipns/dns.rs index 5a2fe2d2..bfc264bc 100644 --- a/src/ipns/dns.rs +++ b/src/ipns/dns.rs @@ -79,13 +79,13 @@ pub async fn resolve(domain: &str) -> Result { mod tests { use super::*; - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_resolve1() { let res = resolve("ipfs.io").await.unwrap().to_string(); assert_eq!(res, "/ipns/website.ipfs.io"); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_resolve2() { let res = resolve("website.ipfs.io").await.unwrap().to_string(); assert_eq!( diff --git a/src/lib.rs b/src/lib.rs index ccc0f376..3bc6a1f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1260,7 +1260,7 @@ mod tests { )); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_put_and_get_block() { let ipfs = Node::new("test_node").await; @@ -1273,7 +1273,7 @@ mod tests { assert_eq!(block, new_block); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_put_and_get_dag() { let ipfs = Node::new("test_node").await; @@ -1283,7 +1283,7 @@ mod tests { assert_eq!(data, new_data); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_pin_and_unpin() { let ipfs = Node::new("test_node").await; diff --git a/src/p2p/swarm.rs b/src/p2p/swarm.rs index 265ee6ca..bac252b7 100644 --- a/src/p2p/swarm.rs +++ b/src/p2p/swarm.rs @@ -339,7 +339,7 @@ mod tests { )); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn swarm_api() { let (peer1_id, trans) = mk_transport(); let mut swarm1 = Swarm::new(trans, SwarmApi::default(), peer1_id); diff --git a/src/repo/fs.rs b/src/repo/fs.rs index 0d63cf5d..618bdb3d 100644 --- a/src/repo/fs.rs +++ b/src/repo/fs.rs @@ -147,7 +147,7 @@ mod tests { use multihash::Sha2_256; use std::env::temp_dir; - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_fs_blockstore() { let mut tmp = temp_dir(); tmp.push("blockstore1"); @@ -185,7 +185,7 @@ mod tests { std::fs::remove_dir_all(tmp).ok(); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_fs_blockstore_open() { let mut tmp = temp_dir(); tmp.push("blockstore2"); @@ -210,7 +210,7 @@ mod tests { std::fs::remove_dir_all(&tmp).ok(); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_fs_blockstore_list() { let mut tmp = temp_dir(); tmp.push("blockstore_list"); diff --git a/src/repo/mem.rs b/src/repo/mem.rs index 7e9a6aaa..6a8b8474 100644 --- a/src/repo/mem.rs +++ b/src/repo/mem.rs @@ -154,7 +154,7 @@ mod tests { use multihash::Sha2_256; use std::env::temp_dir; - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_mem_blockstore() { let tmp = temp_dir(); let store = MemBlockStore::new(tmp); @@ -187,7 +187,7 @@ mod tests { assert_eq!(get.await.unwrap(), None); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_mem_blockstore_list() { let tmp = temp_dir(); let mem_store = MemBlockStore::new(tmp); @@ -210,7 +210,7 @@ mod tests { } } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_mem_datastore() { let tmp = temp_dir(); let store = MemDataStore::new(tmp); diff --git a/src/repo/mod.rs b/src/repo/mod.rs index 7db78418..b422312d 100644 --- a/src/repo/mod.rs +++ b/src/repo/mod.rs @@ -370,7 +370,7 @@ pub(crate) mod tests { Repo::new(options) } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn test_repo() { let (repo, _) = create_mock_repo(); repo.init().await.unwrap(); diff --git a/src/subscription.rs b/src/subscription.rs index f95f388d..e58627b0 100644 --- a/src/subscription.rs +++ b/src/subscription.rs @@ -443,7 +443,7 @@ mod tests { } } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn subscription_basics() { let registry = SubscriptionRegistry::::default(); let s1 = registry.create_subscription(0.into(), None); @@ -455,7 +455,7 @@ mod tests { assert_eq!(s3.await.unwrap(), 10); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn subscription_cancelled_on_dropping_registry() { let registry = SubscriptionRegistry::::default(); let s1 = registry.create_subscription(0.into(), None); @@ -463,7 +463,7 @@ mod tests { assert_eq!(s1.await, Err(SubscriptionErr::Cancelled)); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn subscription_cancelled_on_shutdown() { let registry = SubscriptionRegistry::::default(); let s1 = registry.create_subscription(0.into(), None); @@ -471,7 +471,7 @@ mod tests { assert_eq!(s1.await, Err(SubscriptionErr::Cancelled)); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn new_subscriptions_cancelled_after_shutdown() { let registry = SubscriptionRegistry::::default(); registry.shutdown(); @@ -479,7 +479,7 @@ mod tests { assert_eq!(s1.await, Err(SubscriptionErr::Cancelled)); } - #[tokio::test] + #[tokio::test(max_threads = 1)] async fn dropping_subscription_future_after_registering() { use std::time::Duration; use tokio::time::timeout; diff --git a/tests/bitswap_cleanup.rs b/tests/bitswap_cleanup.rs index 58537cc6..80985ba3 100644 --- a/tests/bitswap_cleanup.rs +++ b/tests/bitswap_cleanup.rs @@ -6,7 +6,7 @@ async fn wait(millis: u64) { } // Ensure that the Bitswap object doesn't leak. -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn check_bitswap_cleanups() { // create a few nodes let node_a = Node::new("a").await; diff --git a/tests/bitswap_stress_test.rs b/tests/bitswap_stress_test.rs index 4255913e..b3568ad8 100644 --- a/tests/bitswap_stress_test.rs +++ b/tests/bitswap_stress_test.rs @@ -12,7 +12,7 @@ fn filter(i: usize) -> bool { // testing the bitswap protocol (though it would be advised to uncomment // the tracing_subscriber for stress-testing purposes) #[ignore] -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn bitswap_stress_test() { tracing_subscriber::fmt::init(); diff --git a/tests/connect_two.rs b/tests/connect_two.rs index 7439c831..ef4cd65b 100644 --- a/tests/connect_two.rs +++ b/tests/connect_two.rs @@ -3,7 +3,7 @@ use std::time::Duration; use tokio::time::timeout; // Make sure two instances of ipfs can be connected by `Multiaddr`. -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn connect_two_nodes_by_addr() { let node_a = Node::new("a").await; let node_b = Node::new("b").await; @@ -22,7 +22,7 @@ async fn connect_two_nodes_by_addr() { // order to connect by PeerId) already performs a dial to the // given peer within Pubsub::add_node_to_partial_view it calls #[ignore] -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn connect_two_nodes_by_peer_id() { let node_a = Node::new("a").await; let node_b = Node::new("b").await; @@ -40,7 +40,7 @@ async fn connect_two_nodes_by_peer_id() { } // Make sure two instances of ipfs can be connected with a multiaddr+peer combo. -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn connect_two_nodes_by_addr_and_peer() { let node_a = Node::new("a").await; let node_b = Node::new("b").await; @@ -59,7 +59,7 @@ async fn connect_two_nodes_by_addr_and_peer() { } // Ensure that duplicate connection attempts don't cause hangs. -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn connect_duplicate_multiaddr() { let node_a = Node::new("a").await; let node_b = Node::new("b").await; @@ -77,7 +77,7 @@ async fn connect_duplicate_multiaddr() { } // Ensure that duplicate connection attempts don't cause hangs. -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn connect_duplicate_peer_id() { let node_a = Node::new("a").await; let node_b = Node::new("b").await; @@ -98,7 +98,7 @@ async fn connect_duplicate_peer_id() { // More complicated one to the above; first node will have two listening addresses and the second // one should dial both of the addresses, resulting in two connections. -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn connect_two_nodes_with_two_connections_doesnt_panic() { let node_a = Node::new("a").await; let node_b = Node::new("b").await; diff --git a/tests/exchange_block.rs b/tests/exchange_block.rs index 7b82b921..df455d58 100644 --- a/tests/exchange_block.rs +++ b/tests/exchange_block.rs @@ -4,7 +4,7 @@ use multihash::Sha2_256; use std::time::Duration; use tokio::time::timeout; -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn exchange_block() { tracing_subscriber::fmt::init(); diff --git a/tests/kademlia.rs b/tests/kademlia.rs index dcd3395b..a45e5c51 100644 --- a/tests/kademlia.rs +++ b/tests/kademlia.rs @@ -4,7 +4,7 @@ use libp2p::{Multiaddr, PeerId}; use std::time::Duration; use tokio::time::timeout; -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn kademlia_local_peer_discovery() { const BOOTSTRAPPER_COUNT: usize = 20; @@ -54,7 +54,7 @@ async fn kademlia_local_peer_discovery() { } #[ignore = "targets an actual bootstrapper, so random failures can happen"] -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn kademlia_popular_content_discovery() { let (bootstrapper_id, bootstrapper_addr): (PeerId, Multiaddr) = ( "QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ" diff --git a/tests/multiple_listening_addresses.rs b/tests/multiple_listening_addresses.rs index 46bdb770..18b15c89 100644 --- a/tests/multiple_listening_addresses.rs +++ b/tests/multiple_listening_addresses.rs @@ -1,4 +1,4 @@ -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn multiple_consecutive_ephemeral_listening_addresses() { let node = ipfs::Node::new("test_node").await; @@ -12,7 +12,7 @@ async fn multiple_consecutive_ephemeral_listening_addresses() { assert_ne!(first, second); } -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn multiple_concurrent_ephemeral_listening_addresses_on_same_ip() { let node = ipfs::Node::new("test_node").await; @@ -41,7 +41,7 @@ async fn multiple_concurrent_ephemeral_listening_addresses_on_same_ip() { ); } -#[tokio::test] +#[tokio::test(max_threads = 1)] #[cfg(not(target_os = "macos"))] async fn multiple_concurrent_ephemeral_listening_addresses_on_different_ip() { let node = ipfs::Node::new("test_node").await; @@ -59,7 +59,7 @@ async fn multiple_concurrent_ephemeral_listening_addresses_on_different_ip() { second.unwrap(); } -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn adding_unspecified_addr_resolves_with_first() { let node = ipfs::Node::new("test_node").await; // there is no test in trying to match this with others as ... that would be quite @@ -69,7 +69,7 @@ async fn adding_unspecified_addr_resolves_with_first() { .unwrap(); } -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn listening_for_multiple_unspecified_addresses() { let node = ipfs::Node::new("test_node").await; // there is no test in trying to match this with others as ... that would be quite @@ -93,7 +93,7 @@ async fn listening_for_multiple_unspecified_addresses() { ); } -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn remove_listening_address() { let node = ipfs::Node::new("test_node").await; diff --git a/tests/pubsub.rs b/tests/pubsub.rs index 1f389af0..fa40e54c 100644 --- a/tests/pubsub.rs +++ b/tests/pubsub.rs @@ -4,14 +4,14 @@ use ipfs::{Node, PeerId}; use std::time::Duration; use tokio::time::timeout; -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn subscribe_only_once() { let a = Node::new("test_node").await; let _stream = a.pubsub_subscribe("some_topic".into()).await.unwrap(); a.pubsub_subscribe("some_topic".into()).await.unwrap_err(); } -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn resubscribe_after_unsubscribe() { let a = Node::new("test_node").await; @@ -23,7 +23,7 @@ async fn resubscribe_after_unsubscribe() { drop(a.pubsub_subscribe("topic".into()).await.unwrap()); } -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn unsubscribe_via_drop() { let a = Node::new("test_node").await; @@ -36,7 +36,7 @@ async fn unsubscribe_via_drop() { assert_eq!(a.pubsub_subscribed().await.unwrap(), empty); } -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn can_publish_without_subscribing() { let a = Node::new("test_node").await; a.pubsub_publish("topic".into(), b"foobar".to_vec()) @@ -44,7 +44,7 @@ async fn can_publish_without_subscribing() { .unwrap() } -#[tokio::test] +#[tokio::test(max_threads = 1)] #[allow(clippy::mutable_key_type)] // clippy doesn't like Vec inside HashSet async fn publish_between_two_nodes() { use futures::stream::StreamExt; diff --git a/tests/wantlist_and_cancellation.rs b/tests/wantlist_and_cancellation.rs index 810217a2..489f6de7 100644 --- a/tests/wantlist_and_cancellation.rs +++ b/tests/wantlist_and_cancellation.rs @@ -47,7 +47,7 @@ async fn check_cid_subscriptions(ipfs: &Node, cid: &Cid, expected_count: usize) } /// Check if canceling a Cid affects the wantlist. -#[tokio::test] +#[tokio::test(max_threads = 1)] async fn wantlist_cancellation() { tracing_subscriber::fmt::init();