onyinyang 4 месяцев назад
Родитель
Сommit
c73bf68802
4 измененных файлов с 11 добавлено и 35 удалено
  1. 7 0
      src/lib.rs
  2. 0 31
      src/mock_auth.rs
  3. 2 2
      src/proto/check_blockage.rs
  4. 2 2
      src/proto/trust_promotion.rs

+ 7 - 0
src/lib.rs

@@ -984,6 +984,13 @@ impl BridgeAuth {
         }
         &self.bridge_table.encbuckets
     }
+
+    //#[cfg(test)]
+    // For testing only: manually advance the day by the given number
+    // of days
+    pub fn advance_days(&mut self, days: u16) {
+        self.time_offset += time::Duration::days(days.into());
+    }
 }
 
 pub fn scalar_u32(s: &Scalar) -> Option<u32> {

+ 0 - 31
src/mock_auth.rs

@@ -60,37 +60,6 @@ impl TestHarness {
         }
     }
 
-    /// Blocks a percentage of the bridges for the passed Test Harness
-    /// excluding the hot spare buckets as they will not have been handed out.
-    /// The logic assumes hot spare buckets are appended to the end of the bridge_table
-    /// bucket list.
-
-    fn block_percent_bridges(&mut self, percent_blockage: usize) {
-        let blockable_range =
-            self.ba.bridge_table.buckets.len() - self.ba.bridge_table.spares.len();
-        let mut block_index: HashSet<usize> = HashSet::new();
-        let mut rng = rand::rngs::OsRng;
-
-        while block_index.len() < percent_blockage {
-            let rand_num = rng.gen_range(1..blockable_range);
-            if !self.bdb.openinv_buckets.contains(&(rand_num as u32))
-                && !self.bdb.distributed_buckets.contains(&(rand_num as u32))
-                && !block_index.contains(&rand_num)
-            {
-                block_index.insert(rand_num);
-            }
-        }
-
-        for index in block_index {
-            let ba_clone = self.ba.bridge_table.buckets.clone();
-            if let Some(bridgelines) = ba_clone.get(&u32::try_from(index).unwrap()) {
-                for bridgeline in bridgelines {
-                    self.ba.bridge_blocked(bridgeline, &mut self.bdb);
-                }
-            }
-        }
-    }
-
     /// Verify the two MACs on a Lox credential
     pub fn verify_lox(&self, cred: &lox_creds::Lox) {
         assert!(

+ 2 - 2
src/proto/check_blockage.rs

@@ -36,9 +36,9 @@ use super::super::{scalar_u32, G};
 use super::errors::CredentialError;
 use super::level_up::MAX_LEVEL;
 use crate::lox_creds::{Lox, Migration, MigrationKey};
-use crate::migration_table;
 #[cfg(feature = "bridgeauth")]
-use crate::migration_table::{EncMigrationTable, WNAF_SIZE};
+use crate::migration_table::WNAF_SIZE;
+use crate::migration_table::{self, EncMigrationTable};
 use cmz::*;
 use group::Group;
 #[cfg(feature = "bridgeauth")]

+ 2 - 2
src/proto/trust_promotion.rs

@@ -34,9 +34,9 @@ use super::super::BridgeAuth;
 use super::super::{scalar_u32, G};
 use super::errors::CredentialError;
 use crate::lox_creds::{Lox, Migration, MigrationKey};
-use crate::migration_table;
 #[cfg(feature = "bridgeauth")]
-use crate::migration_table::{EncMigrationTable, WNAF_SIZE};
+use crate::migration_table::WNAF_SIZE;
+use crate::migration_table::{self, EncMigrationTable};
 use cmz::*;
 use group::Group;
 #[cfg(feature = "bridgeauth")]