aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo/test_peerinfo_shipped_hellos.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-24 11:54:36 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-24 11:54:36 +0000
commiteafc8188ef6584f77dc4dbc6827210f384986e1a (patch)
tree501f87ddd224b0cbd5aaf9008b57005b129cac24 /src/peerinfo/test_peerinfo_shipped_hellos.c
parent2e95a6961bf57170b215ab28e50dbf2376d46747 (diff)
downloadgnunet-eafc8188ef6584f77dc4dbc6827210f384986e1a.tar.gz
gnunet-eafc8188ef6584f77dc4dbc6827210f384986e1a.zip
update peerinfo API to use MQ
Diffstat (limited to 'src/peerinfo/test_peerinfo_shipped_hellos.c')
-rw-r--r--src/peerinfo/test_peerinfo_shipped_hellos.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/peerinfo/test_peerinfo_shipped_hellos.c b/src/peerinfo/test_peerinfo_shipped_hellos.c
index 7e3ba09d0..dfaac5da9 100644
--- a/src/peerinfo/test_peerinfo_shipped_hellos.c
+++ b/src/peerinfo/test_peerinfo_shipped_hellos.c
@@ -38,12 +38,13 @@ static struct GNUNET_PEERINFO_Handle *h;
38 38
39static int global_ret; 39static int global_ret;
40 40
41
41static int 42static int
42addr_cb (void *cls, 43addr_cb (void *cls,
43 const struct GNUNET_HELLO_Address *address, 44 const struct GNUNET_HELLO_Address *address,
44 struct GNUNET_TIME_Absolute expiration) 45 struct GNUNET_TIME_Absolute expiration)
45{ 46{
46 int *addr = cls; 47 unsigned int *addr = cls;
47 48
48 (*addr) ++; 49 (*addr) ++;
49 return GNUNET_OK; 50 return GNUNET_OK;
@@ -57,28 +58,35 @@ process (void *cls,
57 const char *err_msg) 58 const char *err_msg)
58{ 59{
59 static unsigned int calls = 0; 60 static unsigned int calls = 0;
60 int addr; 61 unsigned int addr;
61 62
62 if (err_msg != NULL) 63 if (NULL != err_msg)
63 { 64 {
64 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 65 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
65 _("Error in communication with PEERINFO service\n")); 66 "Error in communication with PEERINFO service: %s\n",
67 err_msg);
66 } 68 }
67 if (NULL != peer) 69 if (NULL != peer)
68 { 70 {
69 addr = 0; 71 addr = 0;
70 if (NULL != hello) 72 if (NULL != hello)
71 { 73 {
72 GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &addr_cb, &addr); 74 GNUNET_HELLO_iterate_addresses (hello,
75 GNUNET_NO,
76 &addr_cb,
77 &addr);
73 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 78 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
74 "Got information about peer `%s' with %u addresses \n", 79 "Got information about peer %s with %u addresses\n",
75 GNUNET_i2s (peer), addr); 80 GNUNET_i2s (peer),
81 addr);
76 calls++; 82 calls++;
77 } 83 }
78 else 84 else
79 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 85 {
80 "Fail: Got information about peer `%s' without HELLO \n", 86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
87 "Got no HELLP for peer %s\n",
81 GNUNET_i2s (peer)); 88 GNUNET_i2s (peer));
89 }
82 } 90 }
83 else 91 else
84 { 92 {
@@ -87,13 +95,18 @@ process (void *cls,
87 fprintf (stderr, 95 fprintf (stderr,
88 "Failed: got no callbacks!\n"); 96 "Failed: got no callbacks!\n");
89 global_ret = 1; 97 global_ret = 1;
98 GNUNET_PEERINFO_disconnect (h);
99 h = NULL;
90 } 100 }
91 else 101 else
92 { 102 {
93 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
94 "Got %u callbacks\n", calls); 104 "Got %u HELLOs in total\n",
95 global_ret = 0; 105 calls);
96 } 106 global_ret = 0;
107 GNUNET_PEERINFO_disconnect (h);
108 h = NULL;
109 }
97 } 110 }
98} 111}
99 112
@@ -105,14 +118,18 @@ run (void *cls,
105{ 118{
106 h = GNUNET_PEERINFO_connect (cfg); 119 h = GNUNET_PEERINFO_connect (cfg);
107 GNUNET_assert (NULL != h); 120 GNUNET_assert (NULL != h);
108 ic = GNUNET_PEERINFO_iterate (h, GNUNET_YES, NULL, 121 ic = GNUNET_PEERINFO_iterate (h,
109 GNUNET_TIME_relative_multiply 122 GNUNET_YES,
110 (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls); 123 NULL,
124 &process,
125 cls);
126 GNUNET_assert (NULL != ic);
111} 127}
112 128
113 129
114int 130int
115main (int argc, char *argv[]) 131main (int argc,
132 char *argv[])
116{ 133{
117 global_ret = 3; 134 global_ret = 3;
118 if (0 != GNUNET_TESTING_service_run ("test_peerinfo_shipped_hellos", 135 if (0 != GNUNET_TESTING_service_run ("test_peerinfo_shipped_hellos",