diff options
Diffstat (limited to 'src/namestore/test_namestore_api.c')
-rw-r--r-- | src/namestore/test_namestore_api.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c index 62cfa808a..b907c7139 100644 --- a/src/namestore/test_namestore_api.c +++ b/src/namestore/test_namestore_api.c | |||
@@ -34,6 +34,10 @@ static struct GNUNET_NAMESTORE_Handle * nsh; | |||
34 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 34 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
35 | static struct GNUNET_OS_Process *arm; | 35 | static struct GNUNET_OS_Process *arm; |
36 | 36 | ||
37 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | ||
38 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | ||
39 | static GNUNET_HashCode zone; | ||
40 | |||
37 | static int res; | 41 | static int res; |
38 | 42 | ||
39 | 43 | ||
@@ -76,6 +80,10 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
76 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 80 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
77 | nsh = NULL; | 81 | nsh = NULL; |
78 | 82 | ||
83 | if (privkey != NULL) | ||
84 | GNUNET_CRYPTO_rsa_key_free (privkey); | ||
85 | privkey = NULL; | ||
86 | |||
79 | if (NULL != arm) | 87 | if (NULL != arm) |
80 | stop_arm(); | 88 | stop_arm(); |
81 | 89 | ||
@@ -92,6 +100,10 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
92 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 100 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
93 | } | 101 | } |
94 | 102 | ||
103 | if (privkey != NULL) | ||
104 | GNUNET_CRYPTO_rsa_key_free (privkey); | ||
105 | privkey = NULL; | ||
106 | |||
95 | if (nsh != NULL) | 107 | if (nsh != NULL) |
96 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 108 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
97 | nsh = NULL; | 109 | nsh = NULL; |
@@ -112,19 +124,34 @@ void name_lookup_proc (void *cls, | |||
112 | const struct GNUNET_NAMESTORE_RecordData *rd, | 124 | const struct GNUNET_NAMESTORE_RecordData *rd, |
113 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 125 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
114 | { | 126 | { |
115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "name_lookup_proc %p `%s' %i %p %p\n", zone_key, name, rd_count, rd, signature); | 127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore lookup result %p `%s' %i %p %p\n", zone_key, name, rd_count, rd, signature); |
116 | res = 0; | 128 | res = 0; |
117 | GNUNET_SCHEDULER_add_now(&end, NULL); | 129 | GNUNET_SCHEDULER_add_now(&end, NULL); |
118 | } | 130 | } |
119 | 131 | ||
132 | void put_cont (void *cls, int32_t success, const char *emsg) | ||
133 | { | ||
134 | char * name = cls; | ||
135 | |||
136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name store added record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | ||
137 | |||
138 | GNUNET_NAMESTORE_lookup_record (nsh, &zone, name, 0, &name_lookup_proc, NULL); | ||
139 | } | ||
140 | |||
120 | static void | 141 | static void |
121 | run (void *cls, char *const *args, const char *cfgfile, | 142 | run (void *cls, char *const *args, const char *cfgfile, |
122 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 143 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
123 | { | 144 | { |
124 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | 145 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); |
125 | 146 | ||
126 | GNUNET_HashCode zone; | 147 | privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); |
127 | GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &zone); | 148 | GNUNET_assert (privkey != NULL); |
149 | GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); | ||
150 | |||
151 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &zone); | ||
152 | |||
153 | |||
154 | struct GNUNET_CRYPTO_RsaSignature signature; | ||
128 | char * name = "dummy.dummy.gnunet"; | 155 | char * name = "dummy.dummy.gnunet"; |
129 | 156 | ||
130 | start_arm (cfgfile); | 157 | start_arm (cfgfile); |
@@ -133,7 +160,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
133 | nsh = GNUNET_NAMESTORE_connect (cfg); | 160 | nsh = GNUNET_NAMESTORE_connect (cfg); |
134 | GNUNET_break (NULL != nsh); | 161 | GNUNET_break (NULL != nsh); |
135 | 162 | ||
136 | GNUNET_NAMESTORE_lookup_record (nsh, &zone, name, 0, &name_lookup_proc, NULL); | 163 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, name, |
164 | GNUNET_TIME_absolute_get_forever(), | ||
165 | 0, NULL, &signature, put_cont, name); | ||
137 | } | 166 | } |
138 | 167 | ||
139 | static int | 168 | static int |