From: Bart Polot Date: Thu, 5 Jan 2012 21:16:52 +0000 (+0000) Subject: - Improved test to count only relevant messages, completed info transmitted from... X-Git-Tag: initial-import-from-subversion-38251~15403 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3c5c48af5d473594a46903d9cba99c5a20fa5d95;p=oweals%2Fgnunet.git - Improved test to count only relevant messages, completed info transmitted from service --- diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 2c013b38f..a5ac0c32b 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c @@ -1091,11 +1091,19 @@ GDS_CLIENTS_process_monitor (uint16_t mtype, mmsg->header.size = htons (msize - sizeof (struct PendingMessage)); mmsg->header.type = htons (mtype); mmsg->expiration = GNUNET_TIME_absolute_hton(exp); + memcpy (&mmsg->key, key, sizeof (GNUNET_HashCode)); + mmsg->put_path_length = htonl(putl); + mmsg->get_path_length = htonl(getl); path = (struct GNUNET_PeerIdentity *) &mmsg[1]; - memcpy (path, put_path, putl * sizeof (struct GNUNET_PeerIdentity)); - path = &path[putl]; - memcpy (path, get_path, getl * sizeof (struct GNUNET_PeerIdentity)); - memcpy (&path[getl], data, size); + if (putl > 0) + { + memcpy (path, put_path, putl * sizeof (struct GNUNET_PeerIdentity)); + path = &path[putl]; + } + if (getl > 0) + memcpy (path, get_path, getl * sizeof (struct GNUNET_PeerIdentity)); + if (size > 0) + memcpy (&path[getl], data, size); add_pending_message (m->client, pm); } } diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index ae1cf3ecf..37e270d92 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c @@ -130,6 +130,8 @@ struct GNUNET_TESTING_Daemon *o; unsigned int monitor_counter; +int in_test; + /** * Check whether peers successfully shut down. */ @@ -241,6 +243,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, static void do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + in_test = GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n", GNUNET_h2s_full (&d_far->id.hashPubKey)); @@ -308,11 +311,16 @@ monitor_dht_cb (void *cls, const void *data, size_t size) { + const char *s_key; + + s_key = GNUNET_h2s(key); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u got a message of type %u for key %s\n", - cls, mtype, GNUNET_h2s (key)); - if (mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET || - mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT) + cls, mtype, s_key); + + if ((mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET || + mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT) && + strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES) monitor_counter++; } @@ -566,6 +574,7 @@ main (int xargc, char *xargv[]) NULL }; + in_test = GNUNET_NO; GNUNET_PROGRAM_run (sizeof (argv) / sizeof (char *) - 1, argv, "test_dht_monitor", gettext_noop ("Test dht monitoring in a small 2D torus."),