commit 6649bed3a0a6bd0edd3fccdf8a7c2edf7766146c
parent 8d8e46d04de08c33b0c625eaef022b0020fce314
Author: Tristan Schwieren <tristan.schwieren@tum.de>
Date: Fri, 27 May 2022 15:51:02 +0200
- more tests
Diffstat:
1 file changed, 38 insertions(+), 15 deletions(-)
diff --git a/src/reclaim/test_did_helper.c b/src/reclaim/test_did_helper.c
@@ -31,43 +31,66 @@
#include "gnunet_gnsrecord_lib.h"
#include "did_helper.h"
-static const char test_privkey[32] = {
+static const char test_skey_bytes[32] = {
0x9b, 0x93, 0x7b, 0x81, 0x32, 0x2d, 0x81, 0x6c,
0xfa, 0xb9, 0xd5, 0xa3, 0xba, 0xac, 0xc9, 0xb2,
0xa5, 0xfe, 0xbe, 0x4b, 0x14, 0x9f, 0x12, 0x6b,
0x36, 0x30, 0xf9, 0x3a, 0x29, 0x52, 0x70, 0x17
};
-static const char *test_did = "did:reclaim:000G0509BYD1MPAXVSTNV0KRD1JAT0YZMPJFQNM869B66S72PSF17K4Y8G";
+// TODO: Create a did manual from private key / independet of implementation
+static char *test_did =
+ "did:reclaim:000G0509BYD1MPAXVSTNV0KRD1JAT0YZMPJFQNM869B66S72PSF17K4Y8G";
-static struct GNUNET_IDENTITY_PrivateKey skey;
-static struct GNUNET_IDENTITY_PublicKey pkey;
+static struct GNUNET_IDENTITY_PrivateKey test_skey;
+static struct GNUNET_IDENTITY_PublicKey test_pkey;
-// TODO: Create a did manual from private key / independet of implementation
void
test_GNUNET_DID_pkey_to_did ()
{
char *str_did;
- str_did = GNUNET_DID_pkey_to_did(&pkey);
- GNUNET_assert(strcmp(test_did, str_did) == 0);
+ str_did = GNUNET_DID_pkey_to_did (&test_pkey);
+ GNUNET_assert (strcmp (test_did, str_did) == 0);
}
-int
-test_GNUNET_DID_did_to_pkey ();
+void
+test_GNUNET_DID_did_to_pkey ()
+{
+ struct GNUNET_IDENTITY_PublicKey pkey;
+ GNUNET_DID_did_to_pkey (test_did, &pkey);
-int
+ GNUNET_assert (test_pkey.type = pkey.type);
+ GNUNET_assert (0 == strcmp (pkey.eddsa_key.q_y,
+ test_pkey.eddsa_key.q_y));
+}
+
+void
test_GNUNET_DID_key_covert_multibase_base64_to_gnunet ();
-int
+void
test_GNUNET_DID_key_covert_gnunet_to_multibase_base64 ();
+void
+test_GNUNET_DID_pkey_to_did_document ()
+{
+ char *did_document = GNUNET_DID_pkey_to_did_document (&test_pkey);
+ printf("%s\n", did_document);
+
+ GNUNET_assert(0 == 0);
+}
+
int
main ()
{
- skey.type = htonl(GNUNET_IDENTITY_TYPE_EDDSA);
- memcpy (&(skey.eddsa_key), test_privkey, sizeof(struct GNUNET_CRYPTO_EddsaPrivateKey));
- GNUNET_IDENTITY_key_get_public (&skey, &pkey);
+ // Setup
+ test_skey.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA);
+ memcpy (&(test_skey.eddsa_key), test_skey_bytes, sizeof(struct
+ GNUNET_CRYPTO_EddsaPrivateKey));
+ GNUNET_IDENTITY_key_get_public (&test_skey, &test_pkey);
- test_GNUNET_DID_pkey_to_did();
+ // Do tests
+ test_GNUNET_DID_pkey_to_did ();
+ test_GNUNET_DID_did_to_pkey ();
+ test_GNUNET_DID_pkey_to_did_document ();
return 0;
}
\ No newline at end of file