From 8bc672c50f7c98af110bfbcdda2e1e7e7fd49d69 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 3 Apr 2012 11:45:16 +0000 Subject: -array of fixes, finally finished test --- src/gns/Makefile.am | 28 +-- src/gns/gnunet-service-gns.c | 38 +++- src/gns/gnunet-service-gns_resolver.c | 1 - src/gns/gnunet-service-gns_resolver.h | 2 +- src/gns/plugin_block_gns.c | 16 +- src/gns/test_gns_dht_threepeer.c | 341 ++++++++++++++++++++-------------- 6 files changed, 255 insertions(+), 171 deletions(-) (limited to 'src/gns') diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 7c0cb3f31..cbf4a02bb 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am @@ -39,8 +39,8 @@ check_PROGRAMS = \ test_gns_simple_zkey_lookup \ test_gns_dht_delegated_lookup \ test_gns_pseu_shorten \ - test_gns_max_queries -# test_gns_dht_threepeer + test_gns_max_queries \ + test_gns_dht_threepeer # test_gns_simple_lookup @@ -51,18 +51,18 @@ check_PROGRAMS = \ plugin_LTLIBRARIES = \ libgnunet_plugin_block_gns.la -#test_gns_dht_threepeer_SOURCES = \ -# test_gns_dht_threepeer.c -#test_gns_dht_threepeer_LDADD = \ -# $(top_builddir)/src/util/libgnunetutil.la \ -# $(top_builddir)/src/namestore/libgnunetnamestore.la \ -# $(top_builddir)/src/gns/libgnunetgns.la \ -# $(top_builddir)/src/testing/libgnunettesting.la -#test_gns_dht_threepeer_DEPENDENCIES = \ -# $(top_builddir)/src/util/libgnunetutil.la \ -# $(top_builddir)/src/namestore/libgnunetnamestore.la \ -# $(top_builddir)/src/gns/libgnunetgns.la \ -# $(top_builddir)/src/testing/libgnunettesting.la +test_gns_dht_threepeer_SOURCES = \ + test_gns_dht_threepeer.c +test_gns_dht_threepeer_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la \ + $(top_builddir)/src/gns/libgnunetgns.la \ + $(top_builddir)/src/testing/libgnunettesting.la +test_gns_dht_threepeer_DEPENDENCIES = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la \ + $(top_builddir)/src/gns/libgnunetgns.la \ + $(top_builddir)/src/testing/libgnunettesting.la test_gns_simple_lookup_SOURCES = \ test_gns_simple_lookup.c diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 970e001c9..c2ea2a44d 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -142,6 +142,11 @@ struct GNUNET_CRYPTO_ShortHashCode zone_hash; */ static int num_public_records = 3600; +/** + * update interval in seconds + */ +static unsigned long long int dht_max_update_interval; + /* dht update interval FIXME define? */ static struct GNUNET_TIME_Relative dht_update_interval; @@ -253,11 +258,11 @@ put_gns_record(void *cls, { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Zone iteration finished. Rescheduling put in %ds\n", - GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL); + dht_max_update_interval); zone_update_taskid = GNUNET_SCHEDULER_add_delayed ( GNUNET_TIME_relative_multiply( GNUNET_TIME_UNIT_SECONDS, - GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL + dht_max_update_interval ), &update_zone_dht_start, NULL); @@ -324,6 +329,9 @@ put_gns_record(void *cls, GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "putting records for %s under key: %s with size %d\n", name, (char*)&xor_hash_string, rd_payload_length); + + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "DHT req to %d\n", DHT_OPERATION_TIMEOUT.rel_value); GNUNET_DHT_put (dht_handle, &xor_hash, DHT_GNS_REPLICATION_LEVEL, @@ -363,20 +371,20 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { dht_update_interval = GNUNET_TIME_relative_multiply( GNUNET_TIME_UNIT_SECONDS, - GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL); + dht_max_update_interval); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "No records in db. Adjusted DHT update interval to %ds\n", - GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL); + dht_max_update_interval); } else { dht_update_interval = GNUNET_TIME_relative_multiply( - GNUNET_TIME_UNIT_SECONDS, - (3600/num_public_records)); + GNUNET_TIME_UNIT_SECONDS, + (dht_max_update_interval/num_public_records)); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adjusted DHT update interval to %ds!\n", - (3600/num_public_records)); + (dht_max_update_interval/num_public_records)); } /* start counting again */ @@ -567,6 +575,7 @@ static void handle_get_authority(void *cls, char name[MAX_DNS_NAME_LENGTH]; char* nameptr = name; + if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientGetAuthMessage)) { GNUNET_break_op (0); @@ -819,6 +828,18 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, } + dht_max_update_interval = GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL; + + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (c, "gns", + "DHT_MAX_UPDATE_INTERVAL", + &dht_max_update_interval)) + { + GNUNET_log(GNUNET_ERROR_TYPE_INFO, + "DHT zone update interval: %d\n", + dht_max_update_interval); + } + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (c, "gns", "MAX_PARALLEL_BACKGROUND_QUERIES", @@ -854,7 +875,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, * handle to the dht */ dht_handle = GNUNET_DHT_connect(c, - max_parallel_bg_queries); //FIXME get ht_len from cfg + //max_parallel_bg_queries); //FIXME get ht_len from cfg + 1024); if (NULL == dht_handle) { diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 964afb4f4..57fbef8b2 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -38,7 +38,6 @@ #include "gns.h" #include "gnunet-service-gns_resolver.h" -#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) #define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT #define DHT_GNS_REPLICATION_LEVEL 5 #define MAX_DNS_LABEL_LENGTH 63 diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index 17d0a7221..44c10fc52 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h @@ -4,7 +4,7 @@ #include "gns.h" #include "gnunet_dht_service.h" -#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) +#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) #define GNUNET_GNS_DEFAULT_LOOKUP_TIMEOUT \ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) #define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 46ce1249d..9d9513a09 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c @@ -215,16 +215,22 @@ block_plugin_gns_get_key (void *cls, enum GNUNET_BLOCK_Type type, { if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) return GNUNET_SYSERR; - GNUNET_HashCode name_hash; - GNUNET_HashCode pkey_hash; + struct GNUNET_CRYPTO_ShortHashCode name_hash; + struct GNUNET_CRYPTO_ShortHashCode pkey_hash; + GNUNET_HashCode name_hash_double; + GNUNET_HashCode pkey_hash_double; + struct GNSNameRecordBlock *nrb = (struct GNSNameRecordBlock *)block; - GNUNET_CRYPTO_hash(&nrb[1], strlen((char*)&nrb[1]), &name_hash); - GNUNET_CRYPTO_hash(&nrb->public_key, + GNUNET_CRYPTO_short_hash(&nrb[1], strlen((char*)&nrb[1]), &name_hash); + GNUNET_CRYPTO_short_hash(&nrb->public_key, sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pkey_hash); + + GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); + GNUNET_CRYPTO_short_hash_double(&pkey_hash, &pkey_hash_double); - GNUNET_CRYPTO_hash_xor(&name_hash, &pkey_hash, key); + GNUNET_CRYPTO_hash_xor(&name_hash_double, &pkey_hash_double, key); return GNUNET_OK; } diff --git a/src/gns/test_gns_dht_threepeer.c b/src/gns/test_gns_dht_threepeer.c index 7d8ed6c6b..04cbc2b81 100644 --- a/src/gns/test_gns_dht_threepeer.c +++ b/src/gns/test_gns_dht_threepeer.c @@ -43,12 +43,16 @@ /* Timeout for entire testcase */ #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 80) +#define ZONE_PUT_WAIT_TIME GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) /* If number of peers not in config file, use this number */ #define DEFAULT_NUM_PEERS 2 #define TEST_DOMAIN "www.buddy.bob.gnunet" #define TEST_IP "1.1.1.1" +#define TEST_DAVE_PSEU "hagbard" +#define TEST_NUM_PEERS 3 +#define TEST_NUM_CON 3 /* Globals */ @@ -101,43 +105,27 @@ static int ok; int bob_online, alice_online, dave_online; -struct GNUNET_CONFIGURATION_Handle *cfg_alice; +struct GNUNET_CONFIGURATION_Handle *alice_cfg; struct GNUNET_CONFIGURATION_Handle *cfg_bob; struct GNUNET_CONFIGURATION_Handle *cfg_dave; -/** - * Check whether peers successfully shut down. - */ -void -shutdown_callback (void *cls, const char *emsg) -{ - if (emsg != NULL) - { - if (ok == 0) - ok = 2; - } -} +struct GNUNET_CRYPTO_ShortHashCode bob_hash; +struct GNUNET_CRYPTO_ShortHashCode dave_hash; +struct GNUNET_TESTING_Daemon *alice_daemon; +struct GNUNET_TESTING_Daemon *bob_daemon; +struct GNUNET_TESTING_Daemon *dave_daemon; + +struct GNUNET_TESTING_PeerGroup *pg; +struct GNUNET_GNS_Handle *gh; /** * Function scheduled to be run on the successful completion of this * testcase. Specifically, called when our get request completes. */ static void -finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +finish_testing (void *cls, const char *emsg) { - ok = 0; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down alice!\n"); - GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL, - GNUNET_YES, GNUNET_NO); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down bob!\n"); - GNUNET_TESTING_daemon_stop (d2, TIMEOUT, &shutdown_callback, NULL, - GNUNET_YES, GNUNET_NO); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down dave\n"); - GNUNET_TESTING_daemon_stop (d3, TIMEOUT, &shutdown_callback, NULL, - GNUNET_YES, GNUNET_NO); - GNUNET_DISK_file_copy ("testdb/sqlite-alice.db.bak", - "testdb/sqlite-alice.db.bak"); - GNUNET_SCHEDULER_cancel(die_task); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test finished! (ret=%d)\n", ok); } /** @@ -147,16 +135,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - if (d1 != NULL) - GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL, - GNUNET_YES, GNUNET_NO); - if (d2 != NULL) - GNUNET_TESTING_daemon_stop (d2, TIMEOUT, &shutdown_callback, NULL, - GNUNET_YES, GNUNET_NO); -; - if (d3 != NULL) - GNUNET_TESTING_daemon_stop (d3, TIMEOUT, &shutdown_callback, NULL, - GNUNET_YES, GNUNET_NO); + GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &finish_testing, NULL); } /** @@ -173,33 +152,58 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ok = 1; } + static void -commence_testing(void) +on_lookup_result(void *cls, uint32_t rd_count, + const struct GNUNET_NAMESTORE_RecordData *rd) { - struct hostent *he; - struct in_addr a; - char* addr; - - he = gethostbyname (TEST_DOMAIN); + int i; + char* string_val; + const char* typename; - if (he) + if (rd_count == 0) { - GNUNET_log(GNUNET_ERROR_TYPE_INFO, "name: %s\n", he->h_name); - while (*he->h_addr_list) + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Lookup failed!\n"); + ok = 2; + } + else + { + ok = 1; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls); + for (i=0; ih_addr_list++, (char *) &a, sizeof(a)); - addr = inet_ntoa(a); - GNUNET_log(GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr); - if (strcmp(addr, TEST_IP) == 0) + typename = GNUNET_NAMESTORE_number_to_typename (rd[i].record_type); + string_val = GNUNET_NAMESTORE_value_to_string(rd[i].record_type, + rd[i].data, + rd[i].data_size); + printf("Got %s record: %s\n", typename, string_val); + if (0 == strcmp(string_val, TEST_IP)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "%s correctly resolved to %s!\n", TEST_DOMAIN, string_val); ok = 0; + } } } - else - ok = 1; - //do lookup here - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 30), - &finish_testing, NULL); + GNUNET_GNS_disconnect(gh); + GNUNET_SCHEDULER_cancel(die_task); + GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &finish_testing, NULL); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down!\n"); + +} + +static void +commence_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + + + gh = GNUNET_GNS_connect(alice_cfg); + + GNUNET_GNS_lookup(gh, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, + &on_lookup_result, TEST_DOMAIN); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from lookup"); } @@ -213,7 +217,7 @@ commence_testing(void) * failure (peers failed to connect). */ void -notify_connect (void *cls, const struct GNUNET_PeerIdentity *first, +daemon_connected (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, @@ -248,9 +252,10 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *first, total_connections); #endif GNUNET_SCHEDULER_cancel (die_task); - die_task = - GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from connect"); - commence_testing(); + //die_task = + // GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from connect"); + + //commence_testing(); } else if (total_connections + failed_connections == expected_connections) @@ -260,96 +265,154 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *first, GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting peers dave, bob\n"); - GNUNET_TESTING_daemons_connect (d3, d2, TIMEOUT, 5, 1, - ¬ify_connect, NULL); - } } -/** - * Set up some data, and call API PUT function - */ -static void -connect_ab (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +void +all_connected(void *cls, const char *emsg) { - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting peers alice, bob\n"); - GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, 5, 1, - ¬ify_connect, NULL); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Created all connections! Starting next phase of testing.\n"); + GNUNET_SCHEDULER_add_delayed (ZONE_PUT_WAIT_TIME, &commence_testing, NULL); } +void +ns_create_cont(void *cls, int32_t s, const char *emsg) +{ + GNUNET_NAMESTORE_disconnect((struct GNUNET_NAMESTORE_Handle *)cls, 0); +} static void -dave_started (void *cls, const struct GNUNET_PeerIdentity *id, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_TESTING_Daemon *d, const char *emsg) +daemon_started (void *cls, const struct GNUNET_PeerIdentity *id, + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_TESTING_Daemon *d, const char *emsg) { - if (emsg != NULL) + struct GNUNET_NAMESTORE_Handle *ns; + char* keyfile; + struct GNUNET_CRYPTO_RsaPrivateKey *key; + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; + struct in_addr *web; + struct GNUNET_NAMESTORE_RecordData rd; + + rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_NONE; + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; + + if (NULL == dave_daemon) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to start daemon with error: `%s'\n", emsg); + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", + "ZONEKEY", + &keyfile)) + { + GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); + ok = -1; + return; + } + dave_daemon = d; + + key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); + + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "This is now dave\n"); + ns = GNUNET_NAMESTORE_connect(cfg); + + GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); + GNUNET_CRYPTO_short_hash(&pkey, sizeof(pkey), &dave_hash); + + web = GNUNET_malloc(sizeof(struct in_addr)); + GNUNET_assert(1 == inet_pton (AF_INET, TEST_IP, web)); + rd.data_size = sizeof(struct in_addr); + rd.data = web; + rd.record_type = GNUNET_GNS_RECORD_TYPE_A; + + GNUNET_NAMESTORE_record_create (ns, key, "www", &rd, NULL, NULL); + + rd.data_size = strlen(TEST_DAVE_PSEU); + rd.data = TEST_DAVE_PSEU; + rd.record_type = GNUNET_GNS_RECORD_PSEU; + + GNUNET_NAMESTORE_record_create (ns, key, "+", &rd, ns_create_cont, ns); + + GNUNET_CRYPTO_rsa_key_free(key); + GNUNET_free(keyfile); + GNUNET_free(web); + return; } - GNUNET_assert (id != NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 2), - &connect_ab, NULL); -} + + if (NULL == bob_daemon) + { + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", + "ZONEKEY", + &keyfile)) + { + GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); + ok = -1; + return; + } + bob_daemon = d; + key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "This is now bob\n"); + ns = GNUNET_NAMESTORE_connect(cfg); + + GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); + GNUNET_CRYPTO_short_hash(&pkey, sizeof(pkey), &bob_hash); + + rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); + rd.data = &dave_hash; + rd.record_type = GNUNET_GNS_RECORD_PKEY; + + GNUNET_NAMESTORE_record_create (ns, key, "buddy", &rd, ns_create_cont, ns); + + GNUNET_CRYPTO_rsa_key_free(key); + GNUNET_free(keyfile); -static void -bob_started (void *cls, const struct GNUNET_PeerIdentity *id, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_TESTING_Daemon *d, const char *emsg) -{ - if (emsg != NULL) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to start daemon with error: `%s'\n", emsg); return; } - GNUNET_assert (id != NULL); + - //Start bob - d3 = GNUNET_TESTING_daemon_start(cfg_dave, TIMEOUT, GNUNET_NO, NULL, NULL, 0, - NULL, NULL, NULL, &dave_started, NULL); + + if (NULL == alice_daemon) + { -} + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", + "ZONEKEY", + &keyfile)) + { + GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); + ok = -1; + return; + } + alice_daemon = d; + alice_cfg = cfg; + key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "This is now alice\n"); + ns = GNUNET_NAMESTORE_connect(cfg); + + rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); + rd.data = &bob_hash; + rd.record_type = GNUNET_GNS_RECORD_PKEY; -/** - * Callback which is called whenever a peer is started (as a result of the - * GNUNET_TESTING_daemons_start call. - * - * @param cls closure argument given to GNUNET_TESTING_daemons_start - * @param id the GNUNET_PeerIdentity of the started peer - * @param cfg the configuration for this specific peer (needed to connect - * to the DHT) - * @param d the handle to the daemon started - * @param emsg NULL if peer started, non-NULL on error - */ -static void -alice_started (void *cls, const struct GNUNET_PeerIdentity *id, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_TESTING_Daemon *d, const char *emsg) -{ - if (emsg != NULL) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to start daemon with error: `%s'\n", emsg); + GNUNET_NAMESTORE_record_create (ns, key, "bob", &rd, ns_create_cont, ns); + + GNUNET_CRYPTO_rsa_key_free(key); + GNUNET_free(keyfile); + + GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, + GNUNET_TESTING_TOPOLOGY_OPTION_ALL, + 0, + TIMEOUT, + 3, + &all_connected, NULL); return; + } - GNUNET_assert (id != NULL); - - //Start bob - d2 = GNUNET_TESTING_daemon_start(cfg_bob, TIMEOUT, GNUNET_NO, NULL, NULL, 0, - NULL, NULL, NULL, &bob_started, NULL); + + + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "This is a random guy\n"); } static void @@ -366,6 +429,8 @@ run (void *cls, char *const *args, const char *cfgfile, return; } + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "starting\n"); + /* Get number of peers to start from configuration (should be two) */ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", @@ -375,22 +440,14 @@ run (void *cls, char *const *args, const char *cfgfile, /* Set peers_left so we know when all peers started */ peers_left = num_peers; - /** - * Modify some config options for peers - */ - cfg_alice = GNUNET_CONFIGURATION_create(); - GNUNET_CONFIGURATION_load (cfg_alice, "test_gns_dht_alice.conf"); + bob_daemon = NULL; + dave_daemon = NULL; + alice_daemon = NULL; - cfg_bob = GNUNET_CONFIGURATION_create(); - GNUNET_CONFIGURATION_load (cfg_bob, "test_gns_dht_bob.conf"); + pg = GNUNET_TESTING_daemons_start (cfg, TEST_NUM_PEERS, TEST_NUM_CON, + TEST_NUM_CON, TIMEOUT, NULL, NULL, &daemon_started, NULL, + &daemon_connected, NULL, NULL); - cfg_dave = GNUNET_CONFIGURATION_create(); - GNUNET_CONFIGURATION_load (cfg_dave, "test_gns_dht_dave.conf"); - - GNUNET_CONFIGURATION_load (cfg_alice, "test_gns_dht_alice.conf"); - GNUNET_CONFIGURATION_load (cfg_bob, "test_gns_dht_bob.conf"); - GNUNET_CONFIGURATION_load (cfg_dave, "test_gns_dht_dave.conf"); - /* Set up a task to end testing if peer start fails */ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, @@ -402,8 +459,8 @@ run (void *cls, char *const *args, const char *cfgfile, expected_connections = 2; /* Start alice */ - d1 = GNUNET_TESTING_daemon_start(cfg_alice, TIMEOUT, GNUNET_NO, NULL, NULL, 0, - NULL, NULL, NULL, &alice_started, NULL); + //d1 = GNUNET_TESTING_daemon_start(cfg_alice, TIMEOUT, GNUNET_NO, NULL, NULL, 0, + // NULL, NULL, NULL, &alice_started, NULL); @@ -418,7 +475,7 @@ check () /* Arguments for GNUNET_PROGRAM_run */ char *const argv[] = { "test-gns-twopeer", /* Name to give running binary */ "-c", - "test_gns_twopeer.conf", /* Config file to use */ + "test_gns_dht_default.conf", /* Config file to use */ #if VERBOSE "-L", "DEBUG", #endif -- cgit v1.2.3