You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2020/06/27 17:21:41 UTC

[incubator-tuweni] branch master updated: Add tests for identity (#99)

This is an automated email from the ASF dual-hosted git repository.

toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git


The following commit(s) were added to refs/heads/master by this push:
     new 17a1ac6  Add tests for identity (#99)
17a1ac6 is described below

commit 17a1ac654c1f4c6c36d5b94c545752f9af179b56
Author: Antoine Toulme <at...@users.noreply.github.com>
AuthorDate: Sat Jun 27 10:21:32 2020 -0700

    Add tests for identity (#99)
---
 .../org/apache/tuweni/scuttlebutt/IdentityTest.java     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/scuttlebutt/src/test/java/org/apache/tuweni/scuttlebutt/IdentityTest.java b/scuttlebutt/src/test/java/org/apache/tuweni/scuttlebutt/IdentityTest.java
index c3dfb80..ce4dee7 100644
--- a/scuttlebutt/src/test/java/org/apache/tuweni/scuttlebutt/IdentityTest.java
+++ b/scuttlebutt/src/test/java/org/apache/tuweni/scuttlebutt/IdentityTest.java
@@ -166,5 +166,22 @@ class IdentityTest {
     assertThrows(UnsupportedOperationException.class, () -> Identity.randomSECP256K1().ed25519PublicKey());
   }
 
+  @Test
+  void testRandomEd25519() {
+    Identity random1 = Identity.randomEd25519();
+    Identity random2 = Identity.randomEd25519();
+    assertNotEquals(random1, random2);
+    assertNotEquals(random1.hashCode(), random2.hashCode());
+  }
 
+  @Test
+  void testPublicKeyHashCodeAndEquals() {
+    Signature.KeyPair kp = Signature.KeyPair.random();
+    Identity id1 = Identity.fromKeyPair(kp);
+    Identity id2 = Identity.fromKeyPair(kp);
+    assertEquals(Identity.fromPublicKey(id1.ed25519PublicKey()), Identity.fromPublicKey(id2.ed25519PublicKey()));
+    assertEquals(
+        Identity.fromPublicKey(id1.ed25519PublicKey()).hashCode(),
+        Identity.fromPublicKey(id2.ed25519PublicKey()).hashCode());
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org