test_gns_simple_shorten \
test_gns_simple_get_authority \
test_gns_simple_lookup \
- test_gns_simple_delegated_lookup
+ test_gns_simple_delegated_lookup \
+ test_gns_dht_delegated_lookup
# test_gns_simple_lookup
$(top_builddir)/src/gns/libgnunetgns.la \
$(top_builddir)/src/testing/libgnunettesting.la
-#test_gns_dht_delegated_lookup_SOURCES = \
-# test_gns_dht_delegated_lookup.c
-#test_gns_dht_delegated_lookup_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/namestore/libgnunetnamestore.la \
-# $(top_builddir)/src/dht/libgnunetdht.la \
-# $(top_builddir)/src/testing/libgnunettesting.la
-#test_gns_dht_delegated_lookup_DEPENDENCIES = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/namestore/libgnunetnamestore.la \
-# $(top_builddir)/src/dht/libgnunetdht.la \
-# $(top_builddir)/src/testing/libgnunettesting.la
+test_gns_dht_delegated_lookup_SOURCES = \
+ test_gns_dht_delegated_lookup.c
+test_gns_dht_delegated_lookup_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/dht/libgnunetdht.la \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/testing/libgnunettesting.la
+test_gns_dht_delegated_lookup_DEPENDENCIES = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/dht/libgnunetdht.la \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/testing/libgnunettesting.la
test_gns_simple_shorten_SOURCES = \
test_gns_simple_shorten.c
uint32_t record_xquery;
unsigned int record_match;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "BLOCK_TEST\n");
+
if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
if (reply_block_size == 0)
GNUNET_CRYPTO_hash_xor(&pkey_hash, &name_hash, &query_key);
+ struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp;
+ struct GNUNET_CRYPTO_HashAsciiEncoded xor_got;
+ GNUNET_CRYPTO_hash_to_enc (&query_key, &xor_exp);
+ GNUNET_CRYPTO_hash_to_enc (query, &xor_got);
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "BLOCK_TEST for %s got %s expected %s\n",
+ name, (char*) &xor_got, (char*) &xor_exp);
+
/* Check query key against public key */
if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key))
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
{
exp = GNUNET_TIME_absolute_min (exp, rd[i].expiration);
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Got record of size %d\n", rd[i].data_size);
if ((record_xquery != 0)
&& (rd[i].record_type == record_xquery))
record_match++;
}
}
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Verifying signature of %d records for name %s\n",
+ rd_count, name);
if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key,
exp,
}
}
- //No record matches query
if ((record_xquery != 0) && (record_match == 0))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "No record matches query!\n");
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+ }
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Records match\n");
static struct GNUNET_NAMESTORE_Handle *namestore_handle;
+static struct GNUNET_GNS_Handle *gns_handle;
+
static struct GNUNET_DHT_Handle *dht_handle;
const struct GNUNET_CONFIGURATION_Handle *cfg;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "done(ret=%d)!\n", ok);
}
-/**
- * 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, const struct GNUNET_SCHEDULER_TaskContext *tc)
+on_lookup_result(void *cls, uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
- struct hostent *he;
struct in_addr a;
+ int i;
char* addr;
-
- GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES);
- GNUNET_DHT_disconnect(dht_handle);
-
- he = gethostbyname (TEST_DOMAIN);
-
- if (!he)
+
+ if (rd_count == 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "gethostbyname failed, rp_filtering?\n");
+ "Lookup failed, rp_filtering?\n");
ok = 2;
}
else
{
ok = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", he->h_name);
- while (*he->h_addr_list)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls);
+ for (i=0; i<rd_count; i++)
{
- memcpy(&a, *he->h_addr_list++, sizeof(a));
- addr = inet_ntoa(a);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr);
- if (0 == strcmp(addr, TEST_IP))
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type);
+ if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_A)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ memcpy(&a, rd[i].data, sizeof(a));
+ addr = inet_ntoa(a);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr);
+ if (0 == strcmp(addr, TEST_IP))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"%s correctly resolved to %s!\n", TEST_DOMAIN, addr);
- ok = 0;
+ ok = 0;
+ }
}
else
{
GNUNET_YES, GNUNET_NO);
}
+
+/**
+ * Function scheduled to be run on the successful start of services
+ * tries to look up the dns record for TEST_DOMAIN
+ */
+static void
+commence_testing (void *cls, int32_t success, const char *emsg)
+{
+ GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES);
+
+ gns_handle = GNUNET_GNS_connect(cfg);
+
+ if (NULL == gns_handle)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to GNS!\n");
+ }
+
+ GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+ &on_lookup_result, TEST_DOMAIN);
+}
+
/**
* Continuation for the GNUNET_DHT_get_stop call, so that we don't shut
* down the peers without freeing memory associated with GET request.
nrb->public_key = bob_pkey;
nrb->rd_count = htonl(1);
memset(&nrb[1], 0, strlen(TEST_RECORD_NAME) + 1);
- memcpy(&nrb[1], TEST_RECORD_NAME, strlen(TEST_RECORD_NAME));
+ strcpy(&nrb[1], TEST_RECORD_NAME);
nrb_data = (char*)&nrb[1];
nrb_data += strlen(TEST_RECORD_NAME) + 1;
NULL,
NULL);
GNUNET_free (nrb);
- GNUNET_SCHEDULER_add_delayed(TIMEOUT, &finish_testing, NULL);
+ GNUNET_SCHEDULER_add_delayed(TIMEOUT, &commence_testing, NULL);
}
static void
int ret;
/* Arguments for GNUNET_PROGRAM_run */
- char *const argv[] = { "test-gns-simple-lookup", /* Name to give running binary */
+ char *const argv[] = { "test-gns-dht-delegated-lookup", /* Name to give running binary */
"-c",
"test_gns_simple_lookup.conf", /* Config file to use */
#if VERBOSE
/* Run the run function as a new program */
ret =
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
- "test-gns-simple-lookup", "nohelp", options, &run,
+ "test-gns-dht-delegated-lookup", "nohelp", options, &run,
&ok);
if (ret != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "`test-gns-simple-lookup': Failed with error code %d\n", ret);
+ "`test-gns-dht-delegated-lookup': Failed with error code %d\n", ret);
}
return ok;
}