Skip to content

Commit 0a82845

Browse files
author
“ramfox”
committed
test: fix hanging test by calling store.flush()
1 parent f79471a commit 0a82845

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

src/store/fs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ mod tests {
11211121
.collect::<Result<Vec<_>>>()?;
11221122

11231123
assert_eq!(expected, actual);
1124-
1124+
store.flush()?;
11251125
Ok(())
11261126
}
11271127

@@ -1138,7 +1138,7 @@ mod tests {
11381138
}
11391139

11401140
// TODO: write test checking that the indexing is done correctly
1141-
1141+
store.flush()?;
11421142
Ok(())
11431143
}
11441144
}

src/sync.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,9 @@ mod tests {
13581358
assert_eq!(entries_second.len(), 12);
13591359
assert_eq!(entries, entries_second.into_iter().collect::<Vec<_>>());
13601360

1361-
test_lru_cache_like_behaviour(&mut store, myspace.id())
1361+
test_lru_cache_like_behaviour(&mut store, myspace.id())?;
1362+
store.flush()?;
1363+
Ok(())
13621364
}
13631365

13641366
/// Test that [`Store::register_useful_peer`] behaves like a LRUCache of size
@@ -1585,7 +1587,7 @@ mod tests {
15851587
.get_exact(namespace.id(), author.id(), key, false)?
15861588
.unwrap();
15871589
assert_eq!(res, entry);
1588-
1590+
store.flush()?;
15891591
Ok(())
15901592
}
15911593

@@ -1637,7 +1639,8 @@ mod tests {
16371639
check_entries(&mut alice_store, &myspace.id(), &author, &bob_set)?;
16381640
check_entries(&mut bob_store, &myspace.id(), &author, &alice_set)?;
16391641
check_entries(&mut bob_store, &myspace.id(), &author, &bob_set)?;
1640-
1642+
alice_store.flush()?;
1643+
bob_store.flush()?;
16411644
Ok(())
16421645
}
16431646

@@ -1700,7 +1703,8 @@ mod tests {
17001703
get_content_hash(&mut alice_store, namespace.id(), author.id(), key)?,
17011704
Some(alice_hash_2)
17021705
);
1703-
1706+
alice_store.flush()?;
1707+
bob_store.flush()?;
17041708
Ok(())
17051709
}
17061710

@@ -1758,7 +1762,7 @@ mod tests {
17581762
get_entry(&mut store, namespace.id(), author.id(), key)?,
17591763
entry2
17601764
);
1761-
1765+
store.flush()?;
17621766
Ok(())
17631767
}
17641768

@@ -1772,6 +1776,7 @@ mod tests {
17721776
let hash = Hash::new(b"");
17731777
let res = replica.insert(b"foo", &alice, hash, 0);
17741778
assert!(matches!(res, Err(InsertError::EntryIsEmpty)));
1779+
store.flush()?;
17751780
Ok(())
17761781
}
17771782

@@ -1824,7 +1829,7 @@ mod tests {
18241829
store.get_exact(myspace.id(), alice.id(), b"foo", false)?,
18251830
None
18261831
);
1827-
1832+
store.flush()?;
18281833
Ok(())
18291834
}
18301835

@@ -1876,7 +1881,8 @@ mod tests {
18761881
sync(&mut alice, &mut bob)?;
18771882
check_entries(&mut alice_store, &myspace.id(), &author, &["fog", "fooz"])?;
18781883
check_entries(&mut bob_store, &myspace.id(), &author, &["fog", "fooz"])?;
1879-
1884+
alice_store.flush()?;
1885+
bob_store.flush()?;
18801886
Ok(())
18811887
}
18821888

@@ -1928,6 +1934,7 @@ mod tests {
19281934
.get_many(namespace.id(), Query::all())?
19291935
.collect::<Vec<_>>();
19301936
assert_eq!(res.len(), 1);
1937+
store.flush()?;
19311938
Ok(())
19321939
}
19331940

@@ -1994,6 +2001,7 @@ mod tests {
19942001
namespace.id(),
19952002
vec![vec![1u8, 0u8], vec![1u8, 2u8]],
19962003
);
2004+
store.flush()?;
19972005
Ok(())
19982006
}
19992007

@@ -2033,7 +2041,7 @@ mod tests {
20332041
let mut latest_keys: Vec<Vec<u8>> = latest.iter().map(|r| r.2.to_vec()).collect();
20342042
latest_keys.sort();
20352043
assert_eq!(latest_keys, vec![b"a0.2".to_vec(), b"a1.1".to_vec()]);
2036-
2044+
store.flush()?;
20372045
Ok(())
20382046
}
20392047

@@ -2083,6 +2091,7 @@ mod tests {
20832091
namespace.id(),
20842092
vec![vec![1u8, 0u8], vec![1u8, 2u8], vec![0u8, 255u8]],
20852093
);
2094+
store.flush()?;
20862095
Ok(())
20872096
}
20882097

@@ -2130,6 +2139,7 @@ mod tests {
21302139
let mut replica = store.open_replica(&namespace.id())?;
21312140
let res = replica.hash_and_insert(b"foo", &author, b"bar");
21322141
assert!(res.is_ok());
2142+
store.flush()?;
21332143
Ok(())
21342144
}
21352145

@@ -2246,7 +2256,8 @@ mod tests {
22462256
assert_eq!(state1.num_recv, 0);
22472257
assert_eq!(state2.num_sent, 0);
22482258
assert_eq!(state2.num_recv, 1);
2249-
2259+
store1.flush()?;
2260+
store2.flush()?;
22502261
Ok(())
22512262
}
22522263

@@ -2436,7 +2447,7 @@ mod tests {
24362447
("hi", &a3),
24372448
],
24382449
);
2439-
2450+
store.flush()?;
24402451
Ok(())
24412452
}
24422453

@@ -2470,6 +2481,7 @@ mod tests {
24702481
store.set_download_policy(&id, policy.clone())?;
24712482
let retrieved_policy = store.get_download_policy(&id)?;
24722483
assert_eq!(retrieved_policy, policy);
2484+
store.flush()?;
24732485
Ok(())
24742486
}
24752487

0 commit comments

Comments
 (0)