aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-01-05 21:16:52 +0000
committerBart Polot <bart@net.in.tum.de>2012-01-05 21:16:52 +0000
commit3c5c48af5d473594a46903d9cba99c5a20fa5d95 (patch)
tree37e2ccb727bec6c405196e7961c04656a1e25ba3 /src/dht
parent70a926d688a41197ef55dbfc874b73539b7b56a1 (diff)
downloadgnunet-3c5c48af5d473594a46903d9cba99c5a20fa5d95.tar.gz
gnunet-3c5c48af5d473594a46903d9cba99c5a20fa5d95.zip
- Improved test to count only relevant messages, completed info transmitted from service
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-dht_clients.c16
-rw-r--r--src/dht/test_dht_monitor.c15
2 files changed, 24 insertions, 7 deletions
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,
1091 mmsg->header.size = htons (msize - sizeof (struct PendingMessage)); 1091 mmsg->header.size = htons (msize - sizeof (struct PendingMessage));
1092 mmsg->header.type = htons (mtype); 1092 mmsg->header.type = htons (mtype);
1093 mmsg->expiration = GNUNET_TIME_absolute_hton(exp); 1093 mmsg->expiration = GNUNET_TIME_absolute_hton(exp);
1094 memcpy (&mmsg->key, key, sizeof (GNUNET_HashCode));
1095 mmsg->put_path_length = htonl(putl);
1096 mmsg->get_path_length = htonl(getl);
1094 path = (struct GNUNET_PeerIdentity *) &mmsg[1]; 1097 path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1095 memcpy (path, put_path, putl * sizeof (struct GNUNET_PeerIdentity)); 1098 if (putl > 0)
1096 path = &path[putl]; 1099 {
1097 memcpy (path, get_path, getl * sizeof (struct GNUNET_PeerIdentity)); 1100 memcpy (path, put_path, putl * sizeof (struct GNUNET_PeerIdentity));
1098 memcpy (&path[getl], data, size); 1101 path = &path[putl];
1102 }
1103 if (getl > 0)
1104 memcpy (path, get_path, getl * sizeof (struct GNUNET_PeerIdentity));
1105 if (size > 0)
1106 memcpy (&path[getl], data, size);
1099 add_pending_message (m->client, pm); 1107 add_pending_message (m->client, pm);
1100 } 1108 }
1101 } 1109 }
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;
130 130
131unsigned int monitor_counter; 131unsigned int monitor_counter;
132 132
133int in_test;
134
133/** 135/**
134 * Check whether peers successfully shut down. 136 * Check whether peers successfully shut down.
135 */ 137 */
@@ -241,6 +243,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
241static void 243static void
242do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 244do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
243{ 245{
246 in_test = GNUNET_YES;
244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n"); 247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n");
245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n", 248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n",
246 GNUNET_h2s_full (&d_far->id.hashPubKey)); 249 GNUNET_h2s_full (&d_far->id.hashPubKey));
@@ -308,11 +311,16 @@ monitor_dht_cb (void *cls,
308 const void *data, 311 const void *data,
309 size_t size) 312 size_t size)
310{ 313{
314 const char *s_key;
315
316 s_key = GNUNET_h2s(key);
311 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 317 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
312 "%u got a message of type %u for key %s\n", 318 "%u got a message of type %u for key %s\n",
313 cls, mtype, GNUNET_h2s (key)); 319 cls, mtype, s_key);
314 if (mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET || 320
315 mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT) 321 if ((mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET ||
322 mtype == GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT) &&
323 strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES)
316 monitor_counter++; 324 monitor_counter++;
317} 325}
318 326
@@ -566,6 +574,7 @@ main (int xargc, char *xargv[])
566 NULL 574 NULL
567 }; 575 };
568 576
577 in_test = GNUNET_NO;
569 GNUNET_PROGRAM_run (sizeof (argv) / sizeof (char *) - 1, argv, 578 GNUNET_PROGRAM_run (sizeof (argv) / sizeof (char *) - 1, argv,
570 "test_dht_monitor", 579 "test_dht_monitor",
571 gettext_noop ("Test dht monitoring in a small 2D torus."), 580 gettext_noop ("Test dht monitoring in a small 2D torus."),