[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6871 - GNUnet/src/applications/dht/tools
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6871 - GNUnet/src/applications/dht/tools |
Date: |
Fri, 23 May 2008 23:16:40 -0600 (MDT) |
Author: grothoff
Date: 2008-05-23 23:16:40 -0600 (Fri, 23 May 2008)
New Revision: 6871
Modified:
GNUnet/src/applications/dht/tools/dht_api.c
GNUnet/src/applications/dht/tools/dht_loopback_test.c
GNUnet/src/applications/dht/tools/dht_multipeer_test.c
GNUnet/src/applications/dht/tools/dht_twopeer_test.c
Log:
fixing loopback test and passing type
Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2008-05-23 23:07:41 UTC (rev
6870)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2008-05-24 05:16:40 UTC (rev
6871)
@@ -100,7 +100,8 @@
size = ntohs (reply->size) - sizeof (CS_dht_request_put_MESSAGE);
put = (CS_dht_request_put_MESSAGE *) reply;
if ((info->processor != NULL) &&
- (GNUNET_OK != info->processor (&put->key, 0 /* unknown! */ ,
+ (GNUNET_OK != info->processor (&put->key,
+ ntohl(put->type),
size,
(const char *) &put[1],
info->closure)))
Modified: GNUnet/src/applications/dht/tools/dht_loopback_test.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_loopback_test.c 2008-05-23
23:07:41 UTC (rev 6870)
+++ GNUnet/src/applications/dht/tools/dht_loopback_test.c 2008-05-24
05:16:40 UTC (rev 6871)
@@ -34,6 +34,37 @@
#define START_PEERS 1
+static int err;
+
+static int
+result_callback(const GNUNET_HashCode * key,
+ unsigned int type,
+ unsigned int size,
+ const char * data,
+ void * cls)
+{
+ int * i = cls;
+ char expect[8];
+
+#if 0
+ fprintf(stderr,
+ "Got %u %u `%.*s'\n",
+ type,
+ size,
+ size,
+ data);
+#endif
+ memset(expect, (*i), sizeof(expect));
+ if ( (8 != size) ||
+ (0 != memcmp(expect, data, size) ) ||
+ (type != GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING) )
+ {
+ err = 1;
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
#define CHECK(a) do { if (!(a)) { ret = 1; GNUNET_GE_BREAK(ectx, 0); goto
FAILURE; } } while(0)
/**
@@ -53,6 +84,7 @@
struct GNUNET_GC_Configuration *cfg;
struct GNUNET_ClientServerConnection *sock;
int left;
+ int i;
ectx = NULL;
cfg = GNUNET_GC_create ();
@@ -80,47 +112,49 @@
/* actual test code */
GNUNET_hash ("key2", 4, &key);
value = GNUNET_malloc (8);
- memset (&value[1], 'A', 8);
- printf ("Storing key2\n");
+ memset (value, 'A', 8);
CHECK (GNUNET_OK == GNUNET_DHT_put (cfg,
ectx,
&key,
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
8, value));
- printf ("Getting key2\n");
+ i = 'A';
CHECK (1 == GNUNET_DHT_get (cfg,
ectx,
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
- &key, 10 * GNUNET_CRON_SECONDS, NULL, NULL));
+ &key, 2 * GNUNET_CRON_SECONDS, &result_callback,
&i));
+ CHECK (err == 0);
GNUNET_hash ("key", 3, &key);
value = GNUNET_malloc (8);
- memset (&value[1], 'B', 8);
- printf ("Storing key.\n");
+ memset (value, 'B', 8);
CHECK (GNUNET_OK == GNUNET_DHT_put (cfg,
ectx,
&key,
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
8, value));
- printf ("Getting key.\n");
+ CHECK (err == 0);
+ i = 'B';
CHECK (1 == GNUNET_DHT_get (cfg,
ectx,
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
- &key, 10 * GNUNET_CRON_SECONDS, NULL, NULL));
+ &key, 2 * GNUNET_CRON_SECONDS, &result_callback,
&i));
GNUNET_hash ("key2", 4, &key);
- printf ("Getting key2");
+ CHECK (err == 0);
left = 10;
do
{
fprintf (stderr, ".");
+ i = 'A';
if (1 == GNUNET_DHT_get (cfg,
ectx,
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
- &key, 15 * GNUNET_CRON_SECONDS, NULL, NULL))
+ &key, 2 * GNUNET_CRON_SECONDS,
&result_callback, &i))
break;
+ CHECK (err == 0);
left--;
}
while (left > 0);
- printf (left > 0 ? "!\n" : "?\n");
+ CHECK (left > 0);
/* end of actual test code */
FAILURE:
Modified: GNUnet/src/applications/dht/tools/dht_multipeer_test.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_multipeer_test.c 2008-05-23
23:07:41 UTC (rev 6870)
+++ GNUnet/src/applications/dht/tools/dht_multipeer_test.c 2008-05-24
05:16:40 UTC (rev 6871)
@@ -140,7 +140,7 @@
GNUNET_hash (buf, 4, &key);
value = GNUNET_malloc (8);
- memset (&value[1], 'A' + i, 8);
+ memset (value, 'A' + i, 8);
CHECK (GNUNET_OK == GNUNET_DHT_put (cfg,
ectx,
&key,
Modified: GNUnet/src/applications/dht/tools/dht_twopeer_test.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_twopeer_test.c 2008-05-23
23:07:41 UTC (rev 6870)
+++ GNUnet/src/applications/dht/tools/dht_twopeer_test.c 2008-05-24
05:16:40 UTC (rev 6871)
@@ -154,7 +154,7 @@
/* actual test code */
GNUNET_hash ("key2", 4, &key);
value = GNUNET_malloc (8);
- memset (&value[1], 'A', 8);
+ memset (value, 'A', 8);
printf ("Peer1 stores key2\n");
CHECK (GNUNET_OK == GNUNET_DHT_put (cfg,
ectx,
@@ -173,7 +173,7 @@
"localhost:12087");
GNUNET_hash ("key", 3, &key);
value = GNUNET_malloc (8);
- memset (&value[1], 'B', 8);
+ memset (value, 'B', 8);
printf ("Peer2 stores key.\n");
CHECK (GNUNET_OK == GNUNET_DHT_put (cfg,
ectx,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6871 - GNUnet/src/applications/dht/tools,
gnunet <=