Fixed clean up blocked test

This commit is contained in:
onyinyang 2023-07-18 17:43:07 -04:00
parent 9c2b7703a8
commit 6191970d9a
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
1 changed files with 4 additions and 11 deletions

View File

@ -599,13 +599,7 @@ fn test_clean_up_blocked() {
let mut th = TestHarness::new_buckets(50, 50);
let mut credentials: Vec<cred::Lox> = Vec::new();
// Users
for _ in 0..100 {
let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60, 0));
println!("Ready to work again");
}
for _ in 0..25 {
let cred = th.open_invite().1 .0;
th.advance_days(30);
let (_, migcred) = th.trust_promotion(&cred);
@ -682,7 +676,7 @@ fn test_clean_up_open_entry() {
let mut credentials: Vec<cred::Lox> = Vec::new();
let mut level_1_credentials: Vec<cred::Lox> = Vec::new();
// Users
for _ in 0..100 {
for _ in 0..25 {
let cred = th.open_invite().1 .0;
credentials.push(cred);
}
@ -748,7 +742,6 @@ fn test_clean_up_open_entry() {
// Let's also make sure that open invitation works again
let cred = th.open_invite().1 .0;
println!("Yep, worked!");
th.advance_days(30);
assert!(
@ -776,13 +769,13 @@ fn find_next_available_key() {}
fn block_bridges(th: &mut TestHarness, percentage: usize, credentials: Vec<cred::Lox>) -> usize {
let blockable_num = th.ba.bridge_table.buckets.len()
- th.ba.bridge_table.spares.len()
- th.bdb.openinv_buckets.len();
- (th.bdb.openinv_buckets.len() / 3);
let blockable_range = th.ba.bridge_table.buckets.len() - th.ba.bridge_table.spares.len();
let to_block: usize = blockable_num * percentage / 100;
let mut block_index: HashSet<usize> = HashSet::new();
let mut rng = rand::thread_rng();
while block_index.len() < to_block {
while block_index.len() < to_block + 1 {
let rand_num = rng.gen_range(0, blockable_range);
if !th.bdb.openinv_buckets.contains(&(rand_num as u32)) {
block_index.insert(rand_num);