Re-merge tests, test going from levels 4 -> 2 -> 3 -> 1
This commit is contained in:
parent
3bd99e9fbd
commit
1864f0ca83
|
@ -1331,77 +1331,7 @@ fn test_mark_unreachable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_blockage_migration_level_3() {
|
fn test_blockage_migration() {
|
||||||
let mut th = TestHarness::new();
|
|
||||||
|
|
||||||
// Join an untrusted user
|
|
||||||
let cred = th.open_invite().1 .0;
|
|
||||||
|
|
||||||
// Time passes
|
|
||||||
th.advance_days(47);
|
|
||||||
|
|
||||||
// Go up to level 1
|
|
||||||
let (_mperf_stat, migcred) = th.trust_promotion(&cred);
|
|
||||||
let (_perf_stat, cred1) = th.level0_migration(&cred, &migcred);
|
|
||||||
assert!(scalar_u32(&cred1.trust_level).unwrap() == 1);
|
|
||||||
|
|
||||||
// Time passes
|
|
||||||
th.advance_days(20);
|
|
||||||
|
|
||||||
// Go up to level 2
|
|
||||||
let (_two_perf_stat, cred2) = th.level_up(&cred1);
|
|
||||||
assert!(scalar_u32(&cred2.trust_level).unwrap() == 2);
|
|
||||||
println!("cred2 = {:?}", cred2);
|
|
||||||
assert!(th.ba.verify_lox(&cred2));
|
|
||||||
|
|
||||||
// Time passes
|
|
||||||
th.advance_days(29);
|
|
||||||
|
|
||||||
// Go up to level 3
|
|
||||||
let (_three_perf_stat, cred3) = th.level_up(&cred2);
|
|
||||||
assert!(scalar_u32(&cred3.trust_level).unwrap() == 3);
|
|
||||||
println!("cred3 = {:?}", cred3);
|
|
||||||
assert!(th.ba.verify_lox(&cred3));
|
|
||||||
|
|
||||||
// Get our bridges
|
|
||||||
let (id, key) = bridge_table::from_scalar(cred3.bucket).unwrap();
|
|
||||||
let encbuckets = th.ba.enc_bridge_table();
|
|
||||||
let bucket =
|
|
||||||
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets.get(&id).unwrap()).unwrap();
|
|
||||||
// We should have a Bridge Reachability credential
|
|
||||||
assert!(bucket.1.is_some());
|
|
||||||
|
|
||||||
// Oh, no! Two of our bridges are blocked!
|
|
||||||
th.ba.bridge_blocked(&bucket.0[0], &mut th.bdb);
|
|
||||||
th.ba.bridge_blocked(&bucket.0[2], &mut th.bdb);
|
|
||||||
|
|
||||||
println!("spares = {:?}", th.ba.bridge_table.spares);
|
|
||||||
println!("tmig = {:?}", th.ba.trustup_migration_table.table);
|
|
||||||
println!("bmig = {:?}", th.ba.blockage_migration_table.table);
|
|
||||||
println!("openinv = {:?}\n", th.bdb.openinv_buckets);
|
|
||||||
|
|
||||||
// Time passes
|
|
||||||
th.advance_days(1);
|
|
||||||
let encbuckets2 = th.ba.enc_bridge_table();
|
|
||||||
let bucket2 =
|
|
||||||
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets2.get(&id).unwrap()).unwrap();
|
|
||||||
// We should no longer have a Bridge Reachability credential
|
|
||||||
assert!(bucket2.1.is_none());
|
|
||||||
|
|
||||||
// See about getting a Migration credential for the blockage
|
|
||||||
let (_block_perf_stat, migration) = th.check_blockage(&cred3);
|
|
||||||
|
|
||||||
println!("migration = {:?}", migration);
|
|
||||||
|
|
||||||
// Migrate
|
|
||||||
let (_four_perf_stat, cred4) = th.blockage_migration(&cred3, &migration);
|
|
||||||
|
|
||||||
println!("cred4 = {:?}", cred4);
|
|
||||||
assert!(th.ba.verify_lox(&cred4));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_blockage_migration_level_4() {
|
|
||||||
let mut th = TestHarness::new();
|
let mut th = TestHarness::new();
|
||||||
|
|
||||||
// Join an untrusted user
|
// Join an untrusted user
|
||||||
|
@ -1475,8 +1405,55 @@ fn test_blockage_migration_level_4() {
|
||||||
// Migrate
|
// Migrate
|
||||||
let (_five_perf_stat, cred5) = th.blockage_migration(&cred4, &migration);
|
let (_five_perf_stat, cred5) = th.blockage_migration(&cred4, &migration);
|
||||||
|
|
||||||
|
assert!(scalar_u32(&cred5.trust_level).unwrap() == 2);
|
||||||
println!("cred5 = {:?}", cred5);
|
println!("cred5 = {:?}", cred5);
|
||||||
assert!(th.ba.verify_lox(&cred5));
|
assert!(th.ba.verify_lox(&cred5));
|
||||||
|
|
||||||
|
// Time passes
|
||||||
|
th.advance_days(29);
|
||||||
|
|
||||||
|
// Go up to level 3
|
||||||
|
let (_six_perf_stat, cred6) = th.level_up(&cred5);
|
||||||
|
assert!(scalar_u32(&cred6.trust_level).unwrap() == 3);
|
||||||
|
println!("cred6 = {:?}", cred6);
|
||||||
|
assert!(th.ba.verify_lox(&cred6));
|
||||||
|
|
||||||
|
// Get our bridges
|
||||||
|
let (id, key) = bridge_table::from_scalar(cred6.bucket).unwrap();
|
||||||
|
let encbuckets = th.ba.enc_bridge_table();
|
||||||
|
let bucket =
|
||||||
|
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets.get(&id).unwrap()).unwrap();
|
||||||
|
// We should have a Bridge Reachability credential
|
||||||
|
assert!(bucket.1.is_some());
|
||||||
|
|
||||||
|
// Oh, no! Two of our bridges are blocked!
|
||||||
|
th.ba.bridge_blocked(&bucket.0[1], &mut th.bdb);
|
||||||
|
th.ba.bridge_blocked(&bucket.0[2], &mut th.bdb);
|
||||||
|
|
||||||
|
println!("spares = {:?}", th.ba.bridge_table.spares);
|
||||||
|
println!("tmig = {:?}", th.ba.trustup_migration_table.table);
|
||||||
|
println!("bmig = {:?}", th.ba.blockage_migration_table.table);
|
||||||
|
println!("openinv = {:?}\n", th.bdb.openinv_buckets);
|
||||||
|
|
||||||
|
// Time passes
|
||||||
|
th.advance_days(1);
|
||||||
|
let encbuckets2 = th.ba.enc_bridge_table();
|
||||||
|
let bucket2 =
|
||||||
|
bridge_table::BridgeTable::decrypt_bucket(id, &key, encbuckets2.get(&id).unwrap()).unwrap();
|
||||||
|
// We should no longer have a Bridge Reachability credential
|
||||||
|
assert!(bucket2.1.is_none());
|
||||||
|
|
||||||
|
// See about getting a Migration credential for the blockage
|
||||||
|
let (_block_perf_stat, migration) = th.check_blockage(&cred6);
|
||||||
|
|
||||||
|
println!("migration = {:?}", migration);
|
||||||
|
|
||||||
|
// Migrate
|
||||||
|
let (_seven_perf_stat, cred7) = th.blockage_migration(&cred6, &migration);
|
||||||
|
|
||||||
|
assert!(scalar_u32(&cred7.trust_level).unwrap() == 1);
|
||||||
|
println!("cred7 = {:?}", cred7);
|
||||||
|
assert!(th.ba.verify_lox(&cred7));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_test_results(perf_stat: PerfStat) {
|
fn print_test_results(perf_stat: PerfStat) {
|
||||||
|
|
Loading…
Reference in New Issue