aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Schwieren <tristan.schwieren@tum.de>2022-05-27 15:51:02 +0200
committerTristan Schwieren <tristan.schwieren@tum.de>2022-05-27 15:51:02 +0200
commit6649bed3a0a6bd0edd3fccdf8a7c2edf7766146c (patch)
treeb84fd09ac7176a9a442e8af56e74855e6b77651c /src
parent8d8e46d04de08c33b0c625eaef022b0020fce314 (diff)
downloadgnunet-6649bed3a0a6bd0edd3fccdf8a7c2edf7766146c.tar.gz
gnunet-6649bed3a0a6bd0edd3fccdf8a7c2edf7766146c.zip
- more tests
Diffstat (limited to 'src')
-rw-r--r--src/reclaim/test_did_helper.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/reclaim/test_did_helper.c b/src/reclaim/test_did_helper.c
index 873cb85cf..8e895d031 100644
--- a/src/reclaim/test_did_helper.c
+++ b/src/reclaim/test_did_helper.c
@@ -31,43 +31,66 @@
31#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
32#include "did_helper.h" 32#include "did_helper.h"
33 33
34static const char test_privkey[32] = { 34static const char test_skey_bytes[32] = {
35 0x9b, 0x93, 0x7b, 0x81, 0x32, 0x2d, 0x81, 0x6c, 35 0x9b, 0x93, 0x7b, 0x81, 0x32, 0x2d, 0x81, 0x6c,
36 0xfa, 0xb9, 0xd5, 0xa3, 0xba, 0xac, 0xc9, 0xb2, 36 0xfa, 0xb9, 0xd5, 0xa3, 0xba, 0xac, 0xc9, 0xb2,
37 0xa5, 0xfe, 0xbe, 0x4b, 0x14, 0x9f, 0x12, 0x6b, 37 0xa5, 0xfe, 0xbe, 0x4b, 0x14, 0x9f, 0x12, 0x6b,
38 0x36, 0x30, 0xf9, 0x3a, 0x29, 0x52, 0x70, 0x17 38 0x36, 0x30, 0xf9, 0x3a, 0x29, 0x52, 0x70, 0x17
39}; 39};
40 40
41static const char *test_did = "did:reclaim:000G0509BYD1MPAXVSTNV0KRD1JAT0YZMPJFQNM869B66S72PSF17K4Y8G"; 41// TODO: Create a did manual from private key / independet of implementation
42static char *test_did =
43 "did:reclaim:000G0509BYD1MPAXVSTNV0KRD1JAT0YZMPJFQNM869B66S72PSF17K4Y8G";
42 44
43static struct GNUNET_IDENTITY_PrivateKey skey; 45static struct GNUNET_IDENTITY_PrivateKey test_skey;
44static struct GNUNET_IDENTITY_PublicKey pkey; 46static struct GNUNET_IDENTITY_PublicKey test_pkey;
45 47
46// TODO: Create a did manual from private key / independet of implementation
47void 48void
48test_GNUNET_DID_pkey_to_did () 49test_GNUNET_DID_pkey_to_did ()
49{ 50{
50 char *str_did; 51 char *str_did;
51 str_did = GNUNET_DID_pkey_to_did(&pkey); 52 str_did = GNUNET_DID_pkey_to_did (&test_pkey);
52 GNUNET_assert(strcmp(test_did, str_did) == 0); 53 GNUNET_assert (strcmp (test_did, str_did) == 0);
53} 54}
54 55
55int 56void
56test_GNUNET_DID_did_to_pkey (); 57test_GNUNET_DID_did_to_pkey ()
58{
59 struct GNUNET_IDENTITY_PublicKey pkey;
60 GNUNET_DID_did_to_pkey (test_did, &pkey);
57 61
58int 62 GNUNET_assert (test_pkey.type = pkey.type);
63 GNUNET_assert (0 == strcmp (pkey.eddsa_key.q_y,
64 test_pkey.eddsa_key.q_y));
65}
66
67void
59test_GNUNET_DID_key_covert_multibase_base64_to_gnunet (); 68test_GNUNET_DID_key_covert_multibase_base64_to_gnunet ();
60 69
61int 70void
62test_GNUNET_DID_key_covert_gnunet_to_multibase_base64 (); 71test_GNUNET_DID_key_covert_gnunet_to_multibase_base64 ();
63 72
73void
74test_GNUNET_DID_pkey_to_did_document ()
75{
76 char *did_document = GNUNET_DID_pkey_to_did_document (&test_pkey);
77 printf("%s\n", did_document);
78
79 GNUNET_assert(0 == 0);
80}
81
64int 82int
65main () 83main ()
66{ 84{
67 skey.type = htonl(GNUNET_IDENTITY_TYPE_EDDSA); 85 // Setup
68 memcpy (&(skey.eddsa_key), test_privkey, sizeof(struct GNUNET_CRYPTO_EddsaPrivateKey)); 86 test_skey.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA);
69 GNUNET_IDENTITY_key_get_public (&skey, &pkey); 87 memcpy (&(test_skey.eddsa_key), test_skey_bytes, sizeof(struct
88 GNUNET_CRYPTO_EddsaPrivateKey));
89 GNUNET_IDENTITY_key_get_public (&test_skey, &test_pkey);
70 90
71 test_GNUNET_DID_pkey_to_did(); 91 // Do tests
92 test_GNUNET_DID_pkey_to_did ();
93 test_GNUNET_DID_did_to_pkey ();
94 test_GNUNET_DID_pkey_to_did_document ();
72 return 0; 95 return 0;
73} \ No newline at end of file 96} \ No newline at end of file