aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-25 22:07:37 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-25 22:07:37 +0000
commitf5f5d0877b5598ff90ff9ebeaa5fa63da929f132 (patch)
treed7a76e0b3e77749af31824978403fbd6553159e2 /src/namestore
parent33e0596398ef8487a444d731d7ab65eb9ef2a7a6 (diff)
downloadgnunet-f5f5d0877b5598ff90ff9ebeaa5fa63da929f132.tar.gz
gnunet-f5f5d0877b5598ff90ff9ebeaa5fa63da929f132.zip
-extend test to cover iteration over empty store
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c
index 3cfe05d7e..d018b74c5 100644
--- a/src/namestore/test_namestore_api_zone_iteration.c
+++ b/src/namestore/test_namestore_api_zone_iteration.c
@@ -328,11 +328,11 @@ put_cont (void *cls, int32_t success, const char *emsg)
328 returned_records = 0; 328 returned_records = 0;
329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); 329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n");
330 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, 330 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
331 NULL, 331 NULL,
332 GNUNET_NAMESTORE_RF_NONE, 332 GNUNET_NAMESTORE_RF_NONE,
333 GNUNET_NAMESTORE_RF_NONE, 333 GNUNET_NAMESTORE_RF_NONE,
334 zone_proc, 334 &zone_proc,
335 &zone); 335 &zone);
336 if (zi == NULL) 336 if (zi == NULL)
337 { 337 {
338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); 338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
@@ -363,15 +363,27 @@ create_record (unsigned int count)
363} 363}
364 364
365 365
366/**
367 * Callback called from the zone iterator when we iterate over
368 * the empty zone. Check that we got no records and then
369 * start the actual tests by filling the zone.
370 */
366static void 371static void
367run (void *cls, 372empty_zone_proc (void *cls,
368 const struct GNUNET_CONFIGURATION_Handle *cfg, 373 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
369 struct GNUNET_TESTING_Peer *peer) 374 struct GNUNET_TIME_Absolute expire,
375 const char *name,
376 unsigned int rd_count,
377 const struct GNUNET_NAMESTORE_RecordData *rd,
378 const struct GNUNET_CRYPTO_RsaSignature *signature)
370{ 379{
371 char *hostkey_file; 380 char *hostkey_file;
372 struct GNUNET_TIME_Absolute et; 381 struct GNUNET_TIME_Absolute et;
373 382
374 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); 383 GNUNET_assert (nsh == cls);
384 GNUNET_assert (NULL == name);
385 GNUNET_assert (NULL == zone_key);
386 zi = NULL;
375 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, 387 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
376 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); 388 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); 389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
@@ -391,8 +403,6 @@ run (void *cls,
391 GNUNET_assert (privkey2 != NULL); 403 GNUNET_assert (privkey2 != NULL);
392 GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); 404 GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2);
393 GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); 405 GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2);
394 nsh = GNUNET_NAMESTORE_connect (cfg);
395 GNUNET_break (NULL != nsh);
396 406
397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); 407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n");
398 408
@@ -421,6 +431,31 @@ run (void *cls,
421} 431}
422 432
423 433
434static void
435run (void *cls,
436 const struct GNUNET_CONFIGURATION_Handle *cfg,
437 struct GNUNET_TESTING_Peer *peer)
438{
439 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL);
440 nsh = GNUNET_NAMESTORE_connect (cfg);
441 GNUNET_break (NULL != nsh);
442 /* first, iterate over empty namestore */
443 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
444 NULL,
445 GNUNET_NAMESTORE_RF_NONE,
446 GNUNET_NAMESTORE_RF_NONE,
447 &empty_zone_proc,
448 nsh);
449 if (NULL == zi)
450 {
451 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
452 GNUNET_break (0);
453 GNUNET_SCHEDULER_cancel (endbadly_task);
454 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
455 }
456}
457
458
424int 459int
425main (int argc, char *argv[]) 460main (int argc, char *argv[])
426{ 461{