diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-02 12:08:41 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-02 12:08:41 +0000 |
commit | fb9b068cf1b3783f7346d234fbbe84a3b6051524 (patch) | |
tree | 5462ee633ba7e0a64f62e2fd97e1e39e13c81f03 /src/namestore/test_namestore_api_remove.c | |
parent | 37673118e3a345079bd70ed5b806d77c67c179a3 (diff) | |
download | gnunet-fb9b068cf1b3783f7346d234fbbe84a3b6051524.tar.gz gnunet-fb9b068cf1b3783f7346d234fbbe84a3b6051524.zip |
- use record_cmp
Diffstat (limited to 'src/namestore/test_namestore_api_remove.c')
-rw-r--r-- | src/namestore/test_namestore_api_remove.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c index 3dfc2cc5c..78a5be56a 100644 --- a/src/namestore/test_namestore_api_remove.c +++ b/src/namestore/test_namestore_api_remove.c | |||
@@ -49,7 +49,7 @@ static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | |||
49 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 49 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
50 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | 50 | struct GNUNET_CRYPTO_RsaSignature *s_signature; |
51 | static GNUNET_HashCode s_zone; | 51 | static GNUNET_HashCode s_zone; |
52 | struct GNUNET_NAMESTORE_RecordData *first_record; | 52 | struct GNUNET_NAMESTORE_RecordData *s_rd; |
53 | static char *s_name; | 53 | static char *s_name; |
54 | 54 | ||
55 | 55 | ||
@@ -117,8 +117,8 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
117 | 117 | ||
118 | int c; | 118 | int c; |
119 | for (c = 0; c < RECORDS; c++) | 119 | for (c = 0; c < RECORDS; c++) |
120 | GNUNET_free_non_null((void *) first_record[c].data); | 120 | GNUNET_free_non_null((void *) s_rd[c].data); |
121 | GNUNET_free (first_record); | 121 | GNUNET_free (s_rd); |
122 | 122 | ||
123 | if (privkey != NULL) | 123 | if (privkey != NULL) |
124 | GNUNET_CRYPTO_rsa_key_free (privkey); | 124 | GNUNET_CRYPTO_rsa_key_free (privkey); |
@@ -167,11 +167,11 @@ void name_lookup_proc (void *cls, | |||
167 | 167 | ||
168 | for (c = 0; c < rd_count; c++) | 168 | for (c = 0; c < rd_count; c++) |
169 | { | 169 | { |
170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Record [%u]: type: %u, size %u\n", c, rd[c].record_type, rd[c].data_size); | 170 | if (GNUNET_NO == GNUNET_NAMESTORE_records_cmp (&rd[c], &s_rd[c+1])) |
171 | GNUNET_break (rd[c].expiration.abs_value == first_record[c+1].expiration.abs_value); | 171 | { |
172 | GNUNET_break (rd[c].record_type == TEST_RECORD_TYPE); | 172 | GNUNET_break (0); |
173 | GNUNET_break (rd[c].data_size == TEST_RECORD_DATALEN); | 173 | failed = GNUNET_YES; |
174 | GNUNET_break (0 == memcmp (rd[c].data, first_record[c+1].data, TEST_RECORD_DATALEN)); | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature)) | 177 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature)) |
@@ -226,7 +226,7 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
226 | res = 0; | 226 | res = 0; |
227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for `%s'\n", name); | 227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for `%s'\n", name); |
228 | 228 | ||
229 | GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &first_record[0], &remove_cont, name); | 229 | GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &s_rd[0], &remove_cont, name); |
230 | } | 230 | } |
231 | else | 231 | else |
232 | { | 232 | { |
@@ -295,14 +295,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
295 | 295 | ||
296 | /* create record */ | 296 | /* create record */ |
297 | s_name = "dummy.dummy.gnunet"; | 297 | s_name = "dummy.dummy.gnunet"; |
298 | first_record = create_record (RECORDS); | 298 | s_rd = create_record (RECORDS); |
299 | 299 | ||
300 | rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, first_record); | 300 | rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd); |
301 | char rd_ser[rd_ser_len]; | 301 | char rd_ser[rd_ser_len]; |
302 | GNUNET_NAMESTORE_records_serialize(RECORDS, first_record, rd_ser_len, rd_ser); | 302 | GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser); |
303 | 303 | ||
304 | /* sign */ | 304 | /* sign */ |
305 | s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, first_record, RECORDS); | 305 | s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_rd, RECORDS); |
306 | 306 | ||
307 | /* create random zone hash */ | 307 | /* create random zone hash */ |
308 | GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | 308 | GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); |
@@ -316,12 +316,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
316 | nsh = GNUNET_NAMESTORE_connect (cfg); | 316 | nsh = GNUNET_NAMESTORE_connect (cfg); |
317 | GNUNET_break (NULL != nsh); | 317 | GNUNET_break (NULL != nsh); |
318 | 318 | ||
319 | GNUNET_break (first_record != NULL); | 319 | GNUNET_break (s_rd != NULL); |
320 | GNUNET_break (s_name != NULL); | 320 | GNUNET_break (s_name != NULL); |
321 | 321 | ||
322 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, | 322 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, |
323 | GNUNET_TIME_absolute_get_forever(), | 323 | GNUNET_TIME_absolute_get_forever(), |
324 | RECORDS, first_record, s_signature, put_cont, s_name); | 324 | RECORDS, s_rd, s_signature, put_cont, s_name); |
325 | 325 | ||
326 | 326 | ||
327 | 327 | ||