Browse Source

Format and clippy nits.

Kestrel 2 years ago
parent
commit
014c128b76
5 changed files with 14 additions and 5 deletions
  1. 7 1
      src/fleck_core/crypto.rs
  2. 3 0
      src/fleck_core/msg.rs
  3. 1 1
      src/test/encryption.rs
  4. 2 2
      src/test/handshake.rs
  5. 1 1
      src/test/routing.rs

+ 7 - 1
src/fleck_core/crypto.rs

@@ -27,7 +27,7 @@ pub enum PacketHeader {
     Encrypted(u128),
 }
 
-#[derive(Default, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[derive(Default, Clone, serde::Serialize, serde::Deserialize)]
 pub struct PublicKey(ed25519_dalek::PublicKey);
 
 impl PublicKey {
@@ -36,6 +36,12 @@ impl PublicKey {
     }
 }
 
+impl PartialEq for PublicKey {
+    fn eq(&self, other: &Self) -> bool {
+        self.0 == other.0
+    }
+}
+
 // *technically* there may be equivalence classes, but we really don't care about those in this
 // context.
 impl Eq for PublicKey {

+ 3 - 0
src/fleck_core/msg.rs

@@ -100,6 +100,9 @@ impl Message {
     }
 
     pub fn with_node(mut self, node: Rc<fleck_core::Node>) -> Self {
+        if self.peer.is_none() {
+            self.peer = node.peer();
+        }
         self.node = Some(node);
         self
     }

+ 1 - 1
src/test/encryption.rs

@@ -71,7 +71,7 @@ fn one_way_test() {
     let node_for_f2 = f1
         .with_service(|ns: &fleck_core::NodeService| {
             ns.node_by_pubkey(
-                &f2.with_service(|ns: &fleck_core::NodeService| *ns.self_node().pubkey()),
+                &f2.with_service(|ns: &fleck_core::NodeService| ns.self_node().pubkey().clone()),
             )
         })
         .expect("handshake failure?");

+ 2 - 2
src/test/handshake.rs

@@ -23,8 +23,8 @@ fn end_to_end() {
         }
     }
 
-    let f1pk = f1.with_service(|ns: &fleck_core::NodeService| *ns.self_node().pubkey());
-    let f2pk = f1.with_service(|ns: &fleck_core::NodeService| *ns.self_node().pubkey());
+    let f1pk = f1.with_service(|ns: &fleck_core::NodeService| ns.self_node().pubkey().clone());
+    let f2pk = f1.with_service(|ns: &fleck_core::NodeService| ns.self_node().pubkey().clone());
 
     // check that they know about each other.
     f1.with_service(|ns: &fleck_core::NodeService| {

+ 1 - 1
src/test/routing.rs

@@ -39,7 +39,7 @@ fn one_way_test() {
     let span_f2 = tracing::span!(tracing::Level::TRACE, "f2");
     let span_f3 = tracing::span!(tracing::Level::TRACE, "f3");
 
-    let fvec = skeleton.initialize_nodes(2);
+    let fvec = skeleton.initialize_nodes(3);
     let f1 = fvec[0].clone();
     let f2 = fvec[1].clone();
     let f3 = fvec[2].clone();