浏览代码

Added results of cargo clippy --fix

Lindsey Tulloch 2 年之前
父节点
当前提交
dcb23017aa

+ 2 - 2
src/bridge_table.rs

@@ -287,7 +287,7 @@ impl BridgeTable {
             let nonce = GenericArray::from_slice(&noncebytes);
             // Encrypt
             let cipher = Aes128Gcm::new(aeskey);
-            let ciphertext: Vec<u8> = cipher.encrypt(&nonce, plainbucket.as_ref()).unwrap();
+            let ciphertext: Vec<u8> = cipher.encrypt(nonce, plainbucket.as_ref()).unwrap();
             encbucket[0..12].copy_from_slice(&noncebytes);
             encbucket[12..].copy_from_slice(ciphertext.as_slice());
             self.encbuckets.push(encbucket);
@@ -307,7 +307,7 @@ impl BridgeTable {
         let aeskey = GenericArray::from_slice(key);
         // Decrypt
         let cipher = Aes128Gcm::new(aeskey);
-        let plaintext: Vec<u8> = cipher.decrypt(&nonce, encbucket[12..].as_ref())?;
+        let plaintext: Vec<u8> = cipher.decrypt(nonce, encbucket[12..].as_ref())?;
         // Convert the plaintext bytes to an array of BridgeLines
         Ok(BridgeLine::bucket_decode(
             plaintext.as_slice().try_into().unwrap(),

+ 71 - 0
src/migration.txt

@@ -0,0 +1,71 @@
+
+running 2 tests
+test tests::stats_test_blockage_migration_40 has been running for over 60 seconds
+test tests::stats_test_blockage_migration_45 has been running for over 60 seconds
+
+---------------Check Blockage 40---------------
+
+Average Request size = 744
+Request Standard Deviation = 0
+Average Request Time = 17.560349ms
+Request time Standard Deviation = 527.939µs
+Average Response size = 1364
+Response Standard Deviation = 0
+Average Response Time = 29.160633ms
+Response Time Standard Deviation = 957.851µs
+Average Response Handling Time = 1.632675ms
+Response Handling Time Standard Deviation = 80.419µs
+
+---------------Blockage Migration 40---------------
+
+Average Request size = 1224
+Request Standard Deviation = 0
+Average Request Time = 31.246734ms
+Request time Standard Deviation = 863.903µs
+Average Response size = 840
+Response Standard Deviation = 0
+Average Response Time = 47.96312ms
+Response Time Standard Deviation = 1.132074ms
+Average Response Handling Time = 20.067194ms
+Response Handling Time Standard Deviation = 560.91µs
+test tests::stats_test_blockage_migration_40 ... ok
+
+---------------Check Blockage 45---------------
+
+Average Request size = 744
+Request Standard Deviation = 0
+Average Request Time = 16.879235ms
+Request time Standard Deviation = 1.012876ms
+Average Response size = 2204
+Response Standard Deviation = 0
+Average Response Time = 33.453128ms
+Response Time Standard Deviation = 2.007504ms
+Average Response Handling Time = 1.873567ms
+Response Handling Time Standard Deviation = 134.745µs
+
+---------------Blockage Migration 45---------------
+
+Average Request size = 1224
+Request Standard Deviation = 0
+Average Request Time = 29.964257ms
+Request time Standard Deviation = 1.732654ms
+Average Response size = 840
+Response Standard Deviation = 0
+Average Response Time = 46.019155ms
+Response Time Standard Deviation = 2.632306ms
+Average Response Handling Time = 19.222321ms
+Response Handling Time Standard Deviation = 1.180166ms
+test tests::stats_test_blockage_migration_45 ... ok
+
+test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 21 filtered out; finished in 11763.27s
+
+
+running 0 tests
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.00s
+
+
+running 0 tests
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
+

+ 2 - 2
src/migration_table.rs

@@ -127,7 +127,7 @@ pub fn encrypt_cred(
     let aeskey = GenericArray::from_slice(&fullhash[16..]);
     // Encrypt
     let cipher = Aes128Gcm::new(aeskey);
-    let ciphertext: Vec<u8> = cipher.encrypt(&nonce, credbytes.as_ref()).unwrap();
+    let ciphertext: Vec<u8> = cipher.encrypt(nonce, credbytes.as_ref()).unwrap();
     let mut enccredbytes: [u8; ENC_MIGRATION_BYTES] = [0; ENC_MIGRATION_BYTES];
     enccredbytes[..12].copy_from_slice(&noncebytes);
     enccredbytes[12..].copy_from_slice(ciphertext.as_slice());
@@ -239,7 +239,7 @@ pub fn decrypt_cred(
     // Decrypt
     let nonce = GenericArray::from_slice(&ciphertext[..12]);
     let cipher = Aes128Gcm::new(aeskey);
-    let plaintext: Vec<u8> = match cipher.decrypt(&nonce, ciphertext[12..].as_ref()) {
+    let plaintext: Vec<u8> = match cipher.decrypt(nonce, ciphertext[12..].as_ref()) {
         Ok(v) => v,
         Err(_) => return None,
     };

+ 4 - 4
src/proto/blockage_migration.rs

@@ -299,8 +299,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P_lox: &P_lox,
             CBucket: &CBucket,
             CSince: &CSince,
@@ -531,8 +531,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 2 - 2
src/proto/check_blockage.rs

@@ -186,8 +186,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CSince: &CSince,

+ 5 - 5
src/proto/issue_invite.rs

@@ -408,8 +408,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CLevel: &CLevel,
@@ -464,7 +464,7 @@ pub fn request(
             id_client: &id_client,
             inv_id_client: &inv_id_client,
             einv_id_client: &einv_id_client,
-            invremain_inverse: &invremain_inverse,
+            invremain_inverse,
             zinvremain_inverse: &zinvremain_inverse,
         },
     )
@@ -698,8 +698,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 4 - 4
src/proto/level_up.rs

@@ -524,8 +524,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CSince: &CSince,
@@ -874,8 +874,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 4 - 4
src/proto/migration.rs

@@ -246,8 +246,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P_lox: &P_lox,
             CBucket: &CBucket,
             CSince: &CSince,
@@ -428,8 +428,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 3 - 3
src/proto/open_invite.rs

@@ -121,7 +121,7 @@ pub fn request(invite: &[u8; OPENINV_LENGTH]) -> (Request, State) {
     let piUserBlinding = userblinding::prove_compact(
         &mut transcript,
         userblinding::ProveAssignments {
-            B: &B,
+            B,
             D: &D,
             EncIdClient0: &EncIdClient.0,
             EncIdClient1: &EncIdClient.1,
@@ -228,8 +228,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 4 - 4
src/proto/redeem_invite.rs

@@ -290,8 +290,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CDate: &CDate,
             CBucket: &CBucket,
@@ -498,8 +498,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 2 - 2
src/proto/trust_promotion.rs

@@ -301,8 +301,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CSince: &CSince,

+ 69 - 0
src/stddev.py

@@ -0,0 +1,69 @@
+log_file = open("test_raw_data.log", "r").readlines()
+test_file = open("issue_stddev.csv", "w")
+block_file = open("redeem_stddev.csv", "w")
+open_file = open("open_stddev.csv", "w")
+promo_file = open("promo_stddev.csv", "w")
+
+test_file.write("RequestT,ResponseT,ResponseHT\n")
+block_file.write("RequestT,ResponseT,ResponseHT\n")
+open_file.write("RequestT,ResponseT,ResponseHT\n")
+promo_file.write("RequestT,ResponseT,ResponseHT\n")
+
+
+
+blockage = 0
+num = 0
+req_time = 0
+resp_time = 0
+resp_handle = 0
+endline = 0
+
+# Loop over the remaining lines in the file
+for line in log_file:
+    if "ISSUE_INVITE" in line:
+        blockage = 1
+
+    elif "REDEEM_INVITE" in line:
+        blockage = 2
+
+    elif "OPEN_INVITE" in line:
+        blockage = 3
+    elif "TRUST_PROMOTION" in line:
+        blockage = 4
+
+    elif "tests::stats" in line:
+        blockage = 0
+
+    elif blockage:
+        value = line.split(" = ")
+        if value[0].startswith("Request"):
+            to_sec = value[1][:-3]
+            req_time = to_sec
+
+        elif value[0].startswith("Response"):
+            to_sec = value[1][:-3]
+            if "handle" in value[0]:
+                resp_handle_time = to_sec
+                endline = 1
+            else:
+                resp_time = to_sec
+
+
+    if endline == 1:
+        if blockage == 1:
+            test_file.write(str(req_time)+ "," + str(resp_time) + "," + str(resp_handle_time) + "\n")
+            endline = 0
+        elif blockage == 2:
+            block_file.write(str(req_time) + ","  + str(resp_time) + "," + str(resp_handle_time) + "\n")
+            endline = 0
+        elif blockage == 3:
+            open_file.write(str(req_time) + ","  + str(resp_time) + "," + str(resp_handle_time) + "\n")
+            endline = 0
+        elif blockage == 4:
+            promo_file.write(str(req_time) + ","  + str(resp_time) + "," + str(resp_handle_time) + "\n")
+            endline = 0
+        blockage = 0
+
+test_file.close()
+block_file.close()
+print("Done.")

+ 9 - 9
src/tests.rs

@@ -108,7 +108,7 @@ impl TestHarness {
     fn trust_promotion(&mut self, cred: &cred::Lox) -> (PerfStat, cred::Migration) {
         let req_start = Instant::now();
         let (promreq, promstate) =
-            trust_promotion::request(&cred, &self.ba.lox_pub, self.ba.today()).unwrap();
+            trust_promotion::request(cred, &self.ba.lox_pub, self.ba.today()).unwrap();
         let encoded: Vec<u8> = bincode::serialize(&promreq).unwrap();
         let req_t = req_start.elapsed();
         let req_len = encoded.len();
@@ -187,7 +187,7 @@ impl TestHarness {
         // level
         let req_start = Instant::now();
         let (req, state) = level_up::request(
-            &cred,
+            cred,
             &reachcred,
             &self.ba.lox_pub,
             &self.ba.reachability_pub,
@@ -233,7 +233,7 @@ impl TestHarness {
 
         let req_start = Instant::now();
         let (req, state) = issue_invite::request(
-            &cred,
+            cred,
             &reachcred,
             &self.ba.lox_pub,
             &self.ba.reachability_pub,
@@ -277,7 +277,7 @@ impl TestHarness {
     fn redeem_invite(&mut self, inv: &cred::Invitation) -> (PerfStat, cred::Lox) {
         let req_start = Instant::now();
         let (req, state) =
-            redeem_invite::request(&inv, &self.ba.invitation_pub, self.ba.today()).unwrap();
+            redeem_invite::request(inv, &self.ba.invitation_pub, self.ba.today()).unwrap();
         let encoded: Vec<u8> = bincode::serialize(&req).unwrap();
         let req_t = req_start.elapsed();
         let req_len = encoded.len();
@@ -308,7 +308,7 @@ impl TestHarness {
 
     fn check_blockage(&mut self, cred: &cred::Lox) -> (PerfStat, cred::Migration) {
         let req_start = Instant::now();
-        let (req, state) = check_blockage::request(&cred, &self.ba.lox_pub).unwrap();
+        let (req, state) = check_blockage::request(cred, &self.ba.lox_pub).unwrap();
         let encoded: Vec<u8> = bincode::serialize(&req).unwrap();
         let req_t = req_start.elapsed();
         let req_len = encoded.len();
@@ -344,7 +344,7 @@ impl TestHarness {
     ) -> (PerfStat, cred::Lox) {
         let req_start = Instant::now();
         let (req, state) =
-            blockage_migration::request(&cred, &mig, &self.ba.lox_pub, &self.ba.migration_pub)
+            blockage_migration::request(cred, mig, &self.ba.lox_pub, &self.ba.migration_pub)
                 .unwrap();
         let encoded: Vec<u8> = bincode::serialize(&req).unwrap();
         let req_t = req_start.elapsed();
@@ -1592,11 +1592,11 @@ fn block_bridges(th: &mut TestHarness, percentage: usize, credentials: Vec<cred:
         - th.ba.bridge_table.spares.len()
         - th.bdb.openinv_buckets.len();
     let blockable_range = th.ba.bridge_table.buckets.len() - th.ba.bridge_table.spares.len();
-    let to_block: usize = (blockable_num * percentage / 100).into();
+    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 - 1 {
+    while block_index.len() < to_block {
         let rand_num = rng.gen_range(0, blockable_range);
         if !th.bdb.openinv_buckets.contains(&(rand_num as u32)) {
             block_index.insert(rand_num);
@@ -1631,7 +1631,7 @@ fn block_bridges(th: &mut TestHarness, percentage: usize, credentials: Vec<cred:
         let mut count = 0;
         for bridge_line in &bucket.0 {
             if th.ba.bridge_table.reachable.contains_key(bridge_line) {
-                count = count + 1;
+                count += 1;
             }
         }