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

Commit

Permalink
chore: tokio::test is now single-threaded
Browse files Browse the repository at this point in the history
  • Loading branch information
koivunej committed Jan 25, 2021
1 parent af19ed8 commit dc0c6a0
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 83 deletions.
4 changes: 2 additions & 2 deletions http/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mod tests {
routes(&ipfs, shutdown_tx)
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn not_found_as_plaintext() {
let routes = testing_routes().await;
let resp = warp::test::request()
Expand All @@ -199,7 +199,7 @@ mod tests {
assert_eq!(resp.body(), "404 page not found");
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn invalid_peer_id_as_messageresponse() {
let routes = testing_routes().await;
let resp = warp::test::request()
Expand Down
4 changes: 2 additions & 2 deletions http/src/v0/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ mod tests {
})
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn url_hacked_args() {
let response = request()
.path("/pubsub/pub?arg=some_channel&arg=foobar")
Expand All @@ -558,7 +558,7 @@ mod tests {
assert_eq!(body, r#"{"message":"foobar","topic":"some_channel"}"#);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn message_in_body() {
let response = request()
.path("/pubsub/pub?arg=some_channel")
Expand Down
4 changes: 2 additions & 2 deletions http/src/v0/refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ mod tests {
use std::collections::HashSet;
use std::convert::TryFrom;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_inner_local() {
let filter = local(&*preloaded_testing_ipfs().await);

Expand Down Expand Up @@ -263,7 +263,7 @@ mod tests {
assert!(diff.is_empty(), "{:?}", diff);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn refs_with_path() {
let ipfs = preloaded_testing_ipfs().await;

Expand Down
4 changes: 2 additions & 2 deletions http/src/v0/root_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ mod tests {
}
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn very_long_file_and_symlink_names() {
let ipfs = Node::new("test_node").await;

Expand Down Expand Up @@ -359,7 +359,7 @@ mod tests {
assert_eq!(found, expected);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn get_multiblock_file() {
let ipfs = Node::new("test_node").await;

Expand Down
2 changes: 1 addition & 1 deletion http/src/v0/root_files/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl<D: fmt::Display> serde::Serialize for Quoted<D> {
mod tests {
use crate::v0::root_files::add;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn add_single_block_file() {
let ipfs = tokio_ipfs().await;

Expand Down
20 changes: 10 additions & 10 deletions src/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ mod tests {
use super::*;
use crate::{make_ipld, Node};

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_resolve_root_cid() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand All @@ -610,7 +610,7 @@ mod tests {
assert_eq!(res, data);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_resolve_array_elem() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand All @@ -623,7 +623,7 @@ mod tests {
assert_eq!(res, make_ipld!(2));
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_resolve_nested_array_elem() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand All @@ -636,7 +636,7 @@ mod tests {
assert_eq!(res, make_ipld!(2));
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_resolve_object_elem() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand All @@ -651,7 +651,7 @@ mod tests {
assert_eq!(res, make_ipld!(false));
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_resolve_cid_elem() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand Down Expand Up @@ -845,7 +845,7 @@ mod tests {
);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn resolve_through_link() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand Down Expand Up @@ -874,7 +874,7 @@ mod tests {
}
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn fail_resolving_first_segment() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand All @@ -890,7 +890,7 @@ mod tests {
assert_eq!(e.to_string(), format!("no link named \"1\" under {}", cid2));
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn fail_resolving_last_segment() {
let Node { ipfs, .. } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
Expand All @@ -906,7 +906,7 @@ mod tests {
assert_eq!(e.to_string(), format!("no link named \"a\" under {}", cid1));
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn fail_resolving_through_file() {
let Node { ipfs, .. } = Node::new("test_node").await;

Expand Down Expand Up @@ -938,7 +938,7 @@ mod tests {
);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn fail_resolving_through_dir() {
let Node { ipfs, .. } = Node::new("test_node").await;

Expand Down
4 changes: 2 additions & 2 deletions src/ipns/dnslink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ pub async fn resolve(domain: &str) -> Result<IpfsPath, Error> {
mod tests {
use super::*;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
#[ignore]
async fn test_resolve1() {
let res = resolve("ipfs.io").await.unwrap().to_string();
assert_eq!(res, "/ipns/website.ipfs.io");
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
#[ignore]
async fn test_resolve2() {
let res = resolve("website.ipfs.io").await.unwrap().to_string();
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ mod tests {
use crate::make_ipld;
use multihash::Sha2_256;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_put_and_get_block() {
let ipfs = Node::new("test_node").await;

Expand All @@ -1769,7 +1769,7 @@ mod tests {
assert_eq!(block, new_block);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_put_and_get_dag() {
let ipfs = Node::new("test_node").await;

Expand All @@ -1779,7 +1779,7 @@ mod tests {
assert_eq!(data, new_data);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_pin_and_unpin() {
let ipfs = Node::new("test_node").await;

Expand Down
2 changes: 1 addition & 1 deletion src/p2p/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ mod tests {
use libp2p::{multiaddr::Protocol, multihash::Multihash, swarm::Swarm};
use std::convert::TryInto;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn swarm_api() {
let (peer1_id, trans) = mk_transport();
let mut swarm1 = Swarm::new(trans, SwarmApi::default(), peer1_id);
Expand Down
4 changes: 2 additions & 2 deletions src/refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ mod tests {
assert_eq!(links, ["african.txt", "americas.txt", "australian.txt",]);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn all_refs_from_root() {
let Node { ipfs, .. } = preloaded_testing_ipfs().await;

Expand Down Expand Up @@ -416,7 +416,7 @@ mod tests {
assert_edges(&expected, all_edges.as_slice());
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn all_unique_refs_from_root() {
let Node { ipfs, .. } = preloaded_testing_ipfs().await;

Expand Down
16 changes: 8 additions & 8 deletions src/repo/common_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macro_rules! pinstore_interface_tests {
use std::collections::HashMap;
use std::convert::TryFrom;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn pin_direct_twice_is_good() {
let repo = DSTestContext::with($factory).await;

Expand Down Expand Up @@ -84,7 +84,7 @@ macro_rules! pinstore_interface_tests {
);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn cannot_recursively_unpin_unpinned() {
let repo = DSTestContext::with($factory).await;
// root/nested/deeper: QmX5S2xLu32K6WxWnyLeChQFbDHy79ULV9feJYH2Hy9bgp
Expand All @@ -103,7 +103,7 @@ macro_rules! pinstore_interface_tests {
assert_eq!(e.to_string(), "not pinned or pinned indirectly");
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn cannot_unpin_indirect() {
let repo = DSTestContext::with($factory).await;
// root/nested/deeper: QmX5S2xLu32K6WxWnyLeChQFbDHy79ULV9feJYH2Hy9bgp
Expand Down Expand Up @@ -146,7 +146,7 @@ macro_rules! pinstore_interface_tests {
assert_eq!(e.to_string(), "not pinned or pinned indirectly");
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn can_pin_direct_as_recursive() {
// the other way around doesn't work
let repo = DSTestContext::with($factory).await;
Expand Down Expand Up @@ -188,7 +188,7 @@ macro_rules! pinstore_interface_tests {
assert!(both.is_empty(), "{:?}", both);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn pin_recursive_pins_all_blocks() {
let repo = DSTestContext::with($factory).await;

Expand Down Expand Up @@ -221,7 +221,7 @@ macro_rules! pinstore_interface_tests {
assert!(both.is_empty(), "{:?}", both);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn indirect_can_be_pinned_directly() {
let repo = DSTestContext::with($factory).await;

Expand Down Expand Up @@ -261,7 +261,7 @@ macro_rules! pinstore_interface_tests {
assert!(both.is_empty(), "{:?}", both);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn direct_and_indirect_when_parent_unpinned() {
let repo = DSTestContext::with($factory).await;

Expand Down Expand Up @@ -311,7 +311,7 @@ macro_rules! pinstore_interface_tests {
assert!(one.is_empty(), "{:?}", one);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn cannot_pin_recursively_pinned_directly() {
// this is a bit of odd as other ops are additive
let repo = DSTestContext::with($factory).await;
Expand Down
12 changes: 6 additions & 6 deletions src/repo/fs/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ mod tests {
use std::env::temp_dir;
use std::sync::Arc;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_fs_blockstore() {
let mut tmp = temp_dir();
tmp.push("blockstore1");
Expand Down Expand Up @@ -481,7 +481,7 @@ mod tests {
std::fs::remove_dir_all(tmp).ok();
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_fs_blockstore_open() {
let mut tmp = temp_dir();
tmp.push("blockstore2");
Expand All @@ -506,7 +506,7 @@ mod tests {
std::fs::remove_dir_all(&tmp).ok();
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_fs_blockstore_list() {
let mut tmp = temp_dir();
tmp.push("blockstore_list");
Expand All @@ -530,7 +530,7 @@ mod tests {
}
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn race_to_insert_new() {
// FIXME: why not tempdir?
let mut tmp = temp_dir();
Expand Down Expand Up @@ -561,7 +561,7 @@ mod tests {
assert_eq!(existing, count - 1);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn race_to_insert_with_existing() {
// FIXME: why not tempdir?
let mut tmp = temp_dir();
Expand Down Expand Up @@ -634,7 +634,7 @@ mod tests {
(writes, existing)
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn remove() {
// FIXME: why not tempdir?
let mut tmp = temp_dir();
Expand Down
6 changes: 3 additions & 3 deletions src/repo/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ mod tests {
use multihash::Sha2_256;
use std::env::temp_dir;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_mem_blockstore() {
let tmp = temp_dir();
let store = MemBlockStore::new(tmp);
Expand Down Expand Up @@ -718,7 +718,7 @@ mod tests {
assert_eq!(get.await.unwrap(), None);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_mem_blockstore_list() {
let tmp = temp_dir();
let mem_store = MemBlockStore::new(tmp);
Expand All @@ -741,7 +741,7 @@ mod tests {
}
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test]
async fn test_mem_datastore() {
let tmp = temp_dir();
let store = MemDataStore::new(tmp);
Expand Down
Loading

0 comments on commit dc0c6a0

Please sign in to comment.