From 57710b3ea68a1aa0dfec307496e5209c390f9e91 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Fri, 2 Mar 2012 22:10:38 +0000 Subject: [PATCH] -new test, fixes --- src/gns/Makefile.am | 15 +++++++++++- src/gns/gnunet-service-gns.c | 41 ++++++++++++++++---------------- src/gns/test_gns_simple_lookup.c | 12 ++++++---- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index d5753290c..6ca49b2e4 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am @@ -28,7 +28,8 @@ check_SCRIPTS = \ test_gnunet_gns.sh check_PROGRAMS = \ - test_gns_simple_lookup + test_gns_simple_lookup \ + test_gns_simple_delegated_lookup plugin_LTLIBRARIES = \ @@ -56,6 +57,18 @@ test_gns_simple_lookup_DEPENDENCIES = \ $(top_builddir)/src/namestore/libgnunetnamestore.la \ $(top_builddir)/src/testing/libgnunettesting.la +test_gns_simple_delegated_lookup_SOURCES = \ + test_gns_simple_delegated_lookup.c +test_gns_simple_delegated_lookup_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la \ + $(top_builddir)/src/testing/libgnunettesting.la +test_gns_simple_delegated_lookup_DEPENDENCIES = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la \ + $(top_builddir)/src/testing/libgnunettesting.la + + #gnunet_gns_lookup_SOURCES = \ # gnunet-gns-lookup.c #gnunet_gns_lookup_LDADD = \ diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index af5468eba..9ec08b205 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -606,30 +606,29 @@ process_authority_lookup(void* cls, if (rd[i].record_type != GNUNET_GNS_RECORD_PKEY) continue; - if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value - == 0) + if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value + == 0) + { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "This pkey is expired.\n"); + if (remaining_time.rel_value == 0) { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "This pkey is expired.\n"); - if (remaining_time.rel_value == 0) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "This dht entry is expired. Refreshing\n"); - resolve_authority_dht(rh); - } - - continue; + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "This dht entry is expired. Refreshing\n"); + resolve_authority_dht(rh); } - /** - * Resolve rest of query with new authority - */ - GNUNET_assert(rd[i].record_type == GNUNET_GNS_RECORD_PKEY); - GNUNET_CRYPTO_hash(rd[i].data, - sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), - &rh->authority); - resolve_name(rh); - return; - + continue; + } + + /** + * Resolve rest of query with new authority + */ + GNUNET_assert(rd[i].record_type == GNUNET_GNS_RECORD_PKEY); + GNUNET_CRYPTO_hash(rd[i].data, + sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + &rh->authority); + resolve_name(rh); + return; } /** diff --git a/src/gns/test_gns_simple_lookup.c b/src/gns/test_gns_simple_lookup.c index ea274cdc2..28372d6b8 100644 --- a/src/gns/test_gns_simple_lookup.c +++ b/src/gns/test_gns_simple_lookup.c @@ -75,7 +75,7 @@ GNUNET_SCHEDULER_TaskIdentifier die_task; /* Global return value (0 for success, anything else for failure) */ static int ok; -static struct GNUNUET_NAMESTORE_Handle *namestore_handle; +static struct GNUNET_NAMESTORE_Handle *namestore_handle; const struct GNUNET_CONFIGURATION_Handle *cfg; @@ -95,8 +95,8 @@ shutdown_callback (void *cls, const char *emsg) } /** - * Function scheduled to be run on the successful completion of this - * testcase. Specifically, called when our get request completes. + * Function scheduled to be run on the successful start of services + * tries to look up the dns record for TEST_DOMAIN */ static void finish_testing (void *cls, int32_t success, const char *emsg) @@ -168,7 +168,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -do_lookup(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_TESTING_Daemon *d, const char *emsg) { struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; @@ -189,7 +191,7 @@ do_lookup(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "ZONEKEY", &alice_keyfile)) { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get alice's key from cfg\n"); + GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); ok = -1; return; } -- 2.25.1