From a7be6d3bfd5de9c5e3ca5c13c637839a513265bd Mon Sep 17 00:00:00 2001 From: onyinyang Date: Sun, 3 Apr 2022 05:54:53 +0000 Subject: [PATCH] Added Updated tests file and readme --- crates/lox-library/src/readme.md | 17 ++++ crates/lox-library/src/tests.rs | 150 +++++++++++++++---------------- 2 files changed, 92 insertions(+), 75 deletions(-) create mode 100644 crates/lox-library/src/readme.md diff --git a/crates/lox-library/src/readme.md b/crates/lox-library/src/readme.md new file mode 100644 index 0000000..cf94798 --- /dev/null +++ b/crates/lox-library/src/readme.md @@ -0,0 +1,17 @@ +# Lox + +Lox is a reputation-based bridge distribution system that provides privacy protection to users and their social graph and is open to all users. +Lox is written in rust and requires `cargo` to test. [Install Rust](https://www.rust-lang.org/tools/install) + +### To run the tests used for our experimental results: + +``` +cargo test -- --nocapture stats_test > stats_test.log +``` +Note that: our implementation is coded such that the reachability certificate expires at 00:00 UTC. A workaround has been included in each test to pause if it is too close to this time so the request won't fail. In reality, if the bucket is still reachable, a user could simply request a new reachability token if their request fails for this reason (a new certificate should be available prior to the outdated certificate expiring). + +### To run all Lox tests: + +``` +cargo test -- --nocapture test > testing.log +``` diff --git a/crates/lox-library/src/tests.rs b/crates/lox-library/src/tests.rs index 9fed337..08430f1 100644 --- a/crates/lox-library/src/tests.rs +++ b/crates/lox-library/src/tests.rs @@ -372,7 +372,7 @@ impl TestHarness { } } -//#[test] +#[test] fn test_open_invite() { let mut th = TestHarness::new(); @@ -393,7 +393,7 @@ fn test_open_invite() { assert!(bridgeline == bucket.0[0]); } -//#[test] +#[test] fn test_trust_promotion() { let mut th = TestHarness::new(); @@ -417,7 +417,7 @@ fn test_trust_promotion() { assert!(th.ba.verify_reachability(&bucket.1.unwrap())); } -//#[test] +#[test] fn test_level0_migration() { let mut th = TestHarness::new(); @@ -448,7 +448,7 @@ fn test_level0_migration() { assert!(th.ba.verify_reachability(&bucket.1.unwrap())); } -//#[test] +#[test] fn test_level_up() { let mut th = TestHarness::new(); @@ -503,7 +503,7 @@ fn test_level_up() { assert!(th.ba.verify_lox(&cred4)); } -//#[test] +#[test] fn test_issue_invite() { let mut th = TestHarness::new(); @@ -543,7 +543,7 @@ fn test_issue_invite() { println!("invite = {:?}", invite); } -//#[test] +#[test] fn test_redeem_invite() { let mut th = TestHarness::new(); @@ -593,7 +593,7 @@ fn test_redeem_invite() { println!("bob_cred = {:?}", bob_cred); } -//#[test] +#[test] fn test_mark_unreachable() { let mut th = TestHarness::new(); @@ -643,7 +643,7 @@ fn test_mark_unreachable() { println!("openinv = {:?}\n", th.bdb.openinv_buckets); } -//#[test] +#[test] fn test_blockage_migration() { let mut th = TestHarness::new(); @@ -714,9 +714,9 @@ fn test_blockage_migration() { assert!(th.ba.verify_lox(&cred4)); } -//#[test] +#[test] fn stats_test_trust_levels() { - let buckets: Vec = vec![900, 1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -754,7 +754,7 @@ fn stats_test_trust_levels() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -857,9 +857,9 @@ fn stats_test_trust_levels() { } } -//#[test] +#[test] fn stats_test_invitations() { - let buckets: Vec = vec![1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -878,7 +878,7 @@ fn stats_test_invitations() { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -918,9 +918,9 @@ fn stats_test_invitations() { } } -//#[test] +#[test] fn stats_test_blockage_migration_5() { - let buckets: Vec = vec![1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -928,7 +928,7 @@ fn stats_test_blockage_migration_5() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -951,9 +951,9 @@ fn stats_test_blockage_migration_5() { } } -//#[test] +#[test] fn stats_test_blockage_migration_10() { - let buckets: Vec = vec![1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -961,7 +961,7 @@ fn stats_test_blockage_migration_10() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -984,9 +984,9 @@ fn stats_test_blockage_migration_10() { } } -//#[test] +#[test] fn stats_test_blockage_migration_15() { - let buckets: Vec = vec![1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -994,7 +994,7 @@ fn stats_test_blockage_migration_15() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1017,9 +1017,9 @@ fn stats_test_blockage_migration_15() { } } -//#[test] +#[test] fn stats_test_blockage_migration_20() { - let buckets: Vec = vec![1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1027,7 +1027,7 @@ fn stats_test_blockage_migration_20() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1050,9 +1050,9 @@ fn stats_test_blockage_migration_20() { } } -//#[test] +#[test] fn stats_test_blockage_migration_25() { - let buckets: Vec = vec![1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1060,7 +1060,7 @@ fn stats_test_blockage_migration_25() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1083,9 +1083,9 @@ fn stats_test_blockage_migration_25() { } } -//#[test] +#[test] fn stats_test_blockage_migration_30() { - let buckets: Vec = vec![1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1093,7 +1093,7 @@ fn stats_test_blockage_migration_30() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1116,9 +1116,9 @@ fn stats_test_blockage_migration_30() { } } -//#[test] +#[test] fn stats_test_blockage_migration_35() { - let buckets: Vec = vec![1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1126,7 +1126,7 @@ fn stats_test_blockage_migration_35() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1151,7 +1151,7 @@ fn stats_test_blockage_migration_35() { #[test] fn stats_test_blockage_migration_40() { - let buckets: Vec = vec![900]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1159,7 +1159,7 @@ fn stats_test_blockage_migration_40() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1184,7 +1184,7 @@ fn stats_test_blockage_migration_40() { #[test] fn stats_test_blockage_migration_45() { - let buckets: Vec = vec![900]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1192,7 +1192,7 @@ fn stats_test_blockage_migration_45() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1217,7 +1217,7 @@ fn stats_test_blockage_migration_45() { #[test] fn stats_test_blockage_migration_50() { - let buckets: Vec = vec![1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1225,7 +1225,7 @@ fn stats_test_blockage_migration_50() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1250,7 +1250,7 @@ fn stats_test_blockage_migration_50() { #[test] fn stats_test_blockage_migration_55() { - let buckets: Vec = vec![900]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1258,7 +1258,7 @@ fn stats_test_blockage_migration_55() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1281,9 +1281,9 @@ fn stats_test_blockage_migration_55() { } } -////#[test] +#[test] fn stats_test_blockage_migration_60() { - let buckets: Vec = vec![1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1291,7 +1291,7 @@ fn stats_test_blockage_migration_60() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1314,9 +1314,9 @@ fn stats_test_blockage_migration_60() { } } -//#[test] +#[test] fn stats_test_blockage_migration_65() { - let buckets: Vec = vec![1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1324,7 +1324,7 @@ fn stats_test_blockage_migration_65() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1347,9 +1347,9 @@ fn stats_test_blockage_migration_65() { } } -//#[test] +#[test] fn stats_test_blockage_migration_70() { - let buckets: Vec = vec![1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1357,7 +1357,7 @@ fn stats_test_blockage_migration_70() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1380,9 +1380,9 @@ fn stats_test_blockage_migration_70() { } } -//#[test] +#[test] fn stats_test_blockage_migration_75() { - let buckets: Vec = vec![1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1390,7 +1390,7 @@ fn stats_test_blockage_migration_75() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1413,9 +1413,9 @@ fn stats_test_blockage_migration_75() { } } -//#[test] +#[test] fn stats_test_blockage_migration_80() { - let buckets: Vec = vec![900, 1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1423,7 +1423,7 @@ fn stats_test_blockage_migration_80() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1446,9 +1446,9 @@ fn stats_test_blockage_migration_80() { } } -//#[test] +#[test] fn stats_test_blockage_migration_85() { - let buckets: Vec = vec![1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1456,7 +1456,7 @@ fn stats_test_blockage_migration_85() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1479,9 +1479,9 @@ fn stats_test_blockage_migration_85() { } } -//#[test] +#[test] fn stats_test_blockage_migration_90() { - let buckets: Vec = vec![1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1489,7 +1489,7 @@ fn stats_test_blockage_migration_90() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1512,9 +1512,9 @@ fn stats_test_blockage_migration_90() { } } -//#[test] +#[test] fn stats_test_blockage_migration_95() { - let buckets: Vec = vec![1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1522,7 +1522,7 @@ fn stats_test_blockage_migration_95() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1545,9 +1545,9 @@ fn stats_test_blockage_migration_95() { } } -//#[test] +#[test] fn stats_test_blockage_migration_100() { - let buckets: Vec = vec![750, 900, 1050, 1200, 1350, 1500]; + let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; for x in buckets { let mut th = TestHarness::new_buckets(x, x); @@ -1555,7 +1555,7 @@ fn stats_test_blockage_migration_100() { for _ in 0..10000 { let h: NaiveTime = DateTime::time(&Utc::now()); if h.hour() == 23 && h.minute() == 59 { - println!("Biding my time for a minute"); + println!("Wait for UTC 00:00"); thread::sleep(Duration::new(60,0)); println!("Ready to work again"); } @@ -1667,11 +1667,11 @@ fn print_test_results(perf_stat: PerfStat) { println!("Response handle time = {:?}", perf_stat.resp_handle_t); } -fn print_time_test_results(perf_stat: PerfStat) { - println!("Request time = {:?}", perf_stat.req_t); - println!("Response time = {:?}", perf_stat.resp_t); - println!("Response handle time = {:?}", perf_stat.resp_handle_t); -} +//fn print_time_test_results(perf_stat: PerfStat) { +// println!("Request time = {:?}", perf_stat.req_t); +// println!("Response time = {:?}", perf_stat.resp_t); +// println!("Response handle time = {:?}", perf_stat.resp_handle_t); +//} fn print_stats_test_results( req_size: Vec,