Skip to content

Commit

Permalink
chore: cleanup linting in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Sep 29, 2024
1 parent e2e5038 commit 3bbab8b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,7 @@ mod tests {
let block = Block::new(cid, data).unwrap();

let cid: Cid = ipfs.put_block(&block).await.unwrap();
let new_block = ipfs.get_block(&cid).await.unwrap();
let new_block = ipfs.get_block(cid).await.unwrap();
assert_eq!(block, new_block);
}

Expand All @@ -2759,8 +2759,8 @@ mod tests {
let data = ipld!([-1, -2, -3]);
let cid = ipfs.put_dag(data.clone()).pin(false).await.unwrap();

assert!(ipfs.is_pinned(&cid).await.unwrap());
assert!(ipfs.is_pinned(cid).await.unwrap());
ipfs.remove_pin(cid).await.unwrap();
assert!(!ipfs.is_pinned(&cid).await.unwrap());
assert!(!ipfs.is_pinned(cid).await.unwrap());
}
}
6 changes: 3 additions & 3 deletions src/refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ where
let borrowed = repo.borrow();

let block = if download_blocks {
match borrowed.get_block(&cid).providers(&providers).set_local(!download_blocks).timeout(timeout).await {
match borrowed.get_block(cid).providers(&providers).set_local(!download_blocks).timeout(timeout).await {
Ok(block) => block,
Err(e) => {
warn!("failed to load {}, linked from {}: {}", cid, source, e);
Expand Down Expand Up @@ -416,7 +416,7 @@ mod tests {
"QmRgutAxd8t7oGkSm4wmeuByG6M51wcTso6cubDdQtuEfL",
);

let root_block = ipfs.get_block(&Cid::try_from(root).unwrap()).await.unwrap();
let root_block = ipfs.get_block(Cid::try_from(root).unwrap()).await.unwrap();
let ipld = root_block.to_ipld().unwrap();

let all_edges: Vec<_> =
Expand Down Expand Up @@ -464,7 +464,7 @@ mod tests {
"QmRgutAxd8t7oGkSm4wmeuByG6M51wcTso6cubDdQtuEfL",
);

let root_block = ipfs.get_block(&Cid::try_from(root).unwrap()).await.unwrap();
let root_block = ipfs.get_block(Cid::try_from(root).unwrap()).await.unwrap();
let ipld = root_block.to_ipld().unwrap();

let destinations: HashSet<_> =
Expand Down
4 changes: 2 additions & 2 deletions src/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ impl IntoFuture for RepoFetch {
// Although getting a block adds a guard, we will add a read guard here a head of time so we can hold it throughout this future
let _g = repo.inner.gclock.read().await;
let block = repo
.get_block(&cid)
.get_block(cid)
.providers(&providers)
.timeout(timeout)
.await?;
Expand Down Expand Up @@ -1400,7 +1400,7 @@ impl IntoFuture for RepoInsertPin {
// Although getting a block adds a guard, we will add a read guard here a head of time so we can hold it throughout this future
let _g = repo.inner.gclock.read().await;
let block = repo
.get_block(&cid)
.get_block(cid)
.providers(&providers)
.set_local(local)
.timeout(timeout)
Expand Down
2 changes: 1 addition & 1 deletion tests/bitswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn bitswap_stress_test() {

for (i, node) in nodes.iter().enumerate() {
if !filter(i) {
node.get_block(&cid).await.unwrap();
node.get_block(cid).await.unwrap();
}
}
}
4 changes: 1 addition & 3 deletions tests/block_exchange.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use futures_timeout::TimeoutExt;
use ipld_core::cid::Cid;
use multihash_codetable::{Code, MultihashDigest};
use rust_ipfs::Block;
Expand Down Expand Up @@ -26,8 +25,7 @@ async fn two_node_put_get() {
.get_block(block.cid())
.timeout(Duration::from_secs(10))
.await
.expect("get_block did not complete in time")
.unwrap();
.expect("get_block did not complete in time");

assert_eq!(block.data(), found_block.data());
}
Expand Down
3 changes: 1 addition & 2 deletions tests/kademlia.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use futures::{pin_mut, StreamExt};
use futures_timeout::TimeoutExt;
use ipld_core::cid::Cid;
use libp2p::{kad::Quorum, multiaddr::Protocol, Multiaddr};
use multihash_codetable::{Code, MultihashDigest};
Expand Down Expand Up @@ -150,7 +149,7 @@ async fn dht_popular_content_discovery() {
.unwrap();

assert!(peer
.get_block(&cid)
.get_block(cid)
.timeout(Duration::from_secs(10))
.await
.is_ok());
Expand Down
6 changes: 3 additions & 3 deletions tests/wantlist_and_cancellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async fn wantlist_cancellation() {
// start a get_request future
let ipfs_clone = ipfs.clone();
let (abort_handle1, abort_reg) = AbortHandle::new_pair();
let abortable_req = Abortable::new(async move { ipfs_clone.get_block(&cid).await }, abort_reg);
let abortable_req = Abortable::new(async move { ipfs_clone.get_block(cid).await }, abort_reg);
let _get_request1 = task::spawn(abortable_req);

// verify that the requested Cid is in the wantlist
Expand All @@ -86,7 +86,7 @@ async fn wantlist_cancellation() {

// fire up an additional get request, this time within the same async task...
let ipfs_clone = ipfs.clone();
let get_request2 = ipfs_clone.get_block(&cid);
let get_request2 = ipfs_clone.get_block(cid);
let get_timeout = timeout(Duration::from_millis(100), pending::<()>());
let get_request2 = match select(get_timeout.boxed(), get_request2.boxed()).await {
Either::Left((_, fut)) => fut,
Expand All @@ -98,7 +98,7 @@ async fn wantlist_cancellation() {

// ...and an additional one within the same task, for good measure
let ipfs_clone = ipfs.clone();
let get_request3 = ipfs_clone.get_block(&cid);
let get_request3 = ipfs_clone.get_block(cid);
let get_timeout = timeout(Duration::from_millis(100), pending::<()>());
let get_request3 = match select(get_timeout.boxed(), get_request3.boxed()).await {
Either::Left((_, fut)) => fut,
Expand Down

0 comments on commit 3bbab8b

Please sign in to comment.