aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hostlist/Makefile.am1
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c46
2 files changed, 45 insertions, 2 deletions
diff --git a/src/hostlist/Makefile.am b/src/hostlist/Makefile.am
index 0ff4c4d3d..9a01b08da 100644
--- a/src/hostlist/Makefile.am
+++ b/src/hostlist/Makefile.am
@@ -37,6 +37,7 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
37test_gnunet_daemon_hostlist_SOURCES = \ 37test_gnunet_daemon_hostlist_SOURCES = \
38 test_gnunet_daemon_hostlist.c 38 test_gnunet_daemon_hostlist.c
39test_gnunet_daemon_hostlist_LDADD = \ 39test_gnunet_daemon_hostlist_LDADD = \
40 $(top_builddir)/src/transport/libgnunettransport.la \
40 $(top_builddir)/src/arm/libgnunetarm.la \ 41 $(top_builddir)/src/arm/libgnunetarm.la \
41 $(top_builddir)/src/util/libgnunetutil.la 42 $(top_builddir)/src/util/libgnunetutil.la
42 43
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index 443a0d17e..fa333bb91 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -24,12 +24,23 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
27#include "gnunet_arm_lib.h" 27#include "gnunet_arm_service.h"
28#include "gnunet_transport_service.h"
28 29
29#define VERBOSE GNUNET_YES 30#define VERBOSE GNUNET_YES
30 31
31#define START_ARM GNUNET_YES 32#define START_ARM GNUNET_YES
32 33
34
35/**
36 * How long until we give up on transmitting the message?
37 */
38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
39
40static int ok;
41
42static struct GNUNET_SCHEDULER_Handle *sched;
43
33struct PeerContext 44struct PeerContext
34{ 45{
35 struct GNUNET_CONFIGURATION_Handle *cfg; 46 struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -42,6 +53,37 @@ struct PeerContext
42#endif 53#endif
43}; 54};
44 55
56static struct PeerContext p1;
57
58static struct PeerContext p2;
59
60
61
62static void
63process_hello (void *cls,
64 struct GNUNET_TIME_Relative latency,
65 const struct GNUNET_PeerIdentity *peer,
66 const struct GNUNET_MessageHeader *message)
67{
68 struct PeerContext *p = cls;
69
70 GNUNET_assert (peer != NULL);
71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
72 "Received (my) `%s' from transport service of `%4s'\n",
73 "HELLO", GNUNET_i2s (peer));
74 GNUNET_assert (message != NULL);
75 p->hello = GNUNET_malloc (ntohs (message->size));
76 memcpy (p->hello, message, ntohs (message->size));
77 if ((p == &p1) && (p2.th != NULL))
78 GNUNET_TRANSPORT_offer_hello (p2.th, message);
79 if ((p == &p2) && (p1.th != NULL))
80 GNUNET_TRANSPORT_offer_hello (p1.th, message);
81
82 if ((p == &p1) && (p2.hello != NULL))
83 GNUNET_TRANSPORT_offer_hello (p1.th, p2.hello);
84 if ((p == &p2) && (p1.hello != NULL))
85 GNUNET_TRANSPORT_offer_hello (p2.th, p1.hello);
86}
45 87
46 88
47static void 89static void
@@ -72,7 +114,7 @@ run (void *cls,
72 const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) 114 const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg)
73{ 115{
74 GNUNET_assert (ok == 1); 116 GNUNET_assert (ok == 1);
75 OKPP; 117 ok++;
76 sched = s; 118 sched = s;
77 setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); 119 setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf");
78 setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); 120 setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf");