diff options
Diffstat (limited to 'src/peerinfo/test_peerinfo_shipped_hellos.c')
-rw-r--r-- | src/peerinfo/test_peerinfo_shipped_hellos.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/src/peerinfo/test_peerinfo_shipped_hellos.c b/src/peerinfo/test_peerinfo_shipped_hellos.c index 36deade1e..24cc26a94 100644 --- a/src/peerinfo/test_peerinfo_shipped_hellos.c +++ b/src/peerinfo/test_peerinfo_shipped_hellos.c | |||
@@ -40,9 +40,9 @@ static int global_ret; | |||
40 | 40 | ||
41 | 41 | ||
42 | static int | 42 | static int |
43 | addr_cb(void *cls, | 43 | addr_cb (void *cls, |
44 | const struct GNUNET_HELLO_Address *address, | 44 | const struct GNUNET_HELLO_Address *address, |
45 | struct GNUNET_TIME_Absolute expiration) | 45 | struct GNUNET_TIME_Absolute expiration) |
46 | { | 46 | { |
47 | unsigned int *addr = cls; | 47 | unsigned int *addr = cls; |
48 | 48 | ||
@@ -52,90 +52,90 @@ addr_cb(void *cls, | |||
52 | 52 | ||
53 | 53 | ||
54 | static void | 54 | static void |
55 | process(void *cls, | 55 | process (void *cls, |
56 | const struct GNUNET_PeerIdentity *peer, | 56 | const struct GNUNET_PeerIdentity *peer, |
57 | const struct GNUNET_HELLO_Message *hello, | 57 | const struct GNUNET_HELLO_Message *hello, |
58 | const char *err_msg) | 58 | const char *err_msg) |
59 | { | 59 | { |
60 | static unsigned int calls = 0; | 60 | static unsigned int calls = 0; |
61 | unsigned int addr; | 61 | unsigned int addr; |
62 | 62 | ||
63 | if (NULL != err_msg) | 63 | if (NULL != err_msg) |
64 | { | ||
65 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
66 | "Error in communication with PEERINFO service: %s\n", | ||
67 | err_msg); | ||
68 | } | ||
69 | if (NULL != peer) | ||
70 | { | ||
71 | addr = 0; | ||
72 | if (NULL != hello) | ||
64 | { | 73 | { |
65 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 74 | GNUNET_HELLO_iterate_addresses (hello, |
66 | "Error in communication with PEERINFO service: %s\n", | 75 | GNUNET_NO, |
67 | err_msg); | 76 | &addr_cb, |
77 | &addr); | ||
78 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
79 | "Got information about peer %s with %u addresses\n", | ||
80 | GNUNET_i2s (peer), | ||
81 | addr); | ||
82 | calls++; | ||
68 | } | 83 | } |
69 | if (NULL != peer) | 84 | else |
70 | { | 85 | { |
71 | addr = 0; | 86 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
72 | if (NULL != hello) | 87 | "Got no HELLP for peer %s\n", |
73 | { | 88 | GNUNET_i2s (peer)); |
74 | GNUNET_HELLO_iterate_addresses(hello, | ||
75 | GNUNET_NO, | ||
76 | &addr_cb, | ||
77 | &addr); | ||
78 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
79 | "Got information about peer %s with %u addresses\n", | ||
80 | GNUNET_i2s(peer), | ||
81 | addr); | ||
82 | calls++; | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
87 | "Got no HELLP for peer %s\n", | ||
88 | GNUNET_i2s(peer)); | ||
89 | } | ||
90 | } | 89 | } |
90 | } | ||
91 | else | 91 | else |
92 | { | ||
93 | if (0 == calls) | ||
94 | { | ||
95 | fprintf (stderr, | ||
96 | "Failed: got no callbacks!\n"); | ||
97 | global_ret = 1; | ||
98 | GNUNET_PEERINFO_disconnect (h); | ||
99 | h = NULL; | ||
100 | } | ||
101 | else | ||
92 | { | 102 | { |
93 | if (0 == calls) | 103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
94 | { | 104 | "Got %u HELLOs in total\n", |
95 | fprintf(stderr, | 105 | calls); |
96 | "Failed: got no callbacks!\n"); | 106 | global_ret = 0; |
97 | global_ret = 1; | 107 | GNUNET_PEERINFO_disconnect (h); |
98 | GNUNET_PEERINFO_disconnect(h); | 108 | h = NULL; |
99 | h = NULL; | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
104 | "Got %u HELLOs in total\n", | ||
105 | calls); | ||
106 | global_ret = 0; | ||
107 | GNUNET_PEERINFO_disconnect(h); | ||
108 | h = NULL; | ||
109 | } | ||
110 | } | 109 | } |
110 | } | ||
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | static void | 114 | static void |
115 | run(void *cls, | 115 | run (void *cls, |
116 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 116 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
117 | struct GNUNET_TESTING_Peer *peer) | 117 | struct GNUNET_TESTING_Peer *peer) |
118 | { | 118 | { |
119 | h = GNUNET_PEERINFO_connect(cfg); | 119 | h = GNUNET_PEERINFO_connect (cfg); |
120 | GNUNET_assert(NULL != h); | 120 | GNUNET_assert (NULL != h); |
121 | ic = GNUNET_PEERINFO_iterate(h, | 121 | ic = GNUNET_PEERINFO_iterate (h, |
122 | GNUNET_YES, | 122 | GNUNET_YES, |
123 | NULL, | 123 | NULL, |
124 | &process, | 124 | &process, |
125 | cls); | 125 | cls); |
126 | GNUNET_assert(NULL != ic); | 126 | GNUNET_assert (NULL != ic); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | int | 130 | int |
131 | main(int argc, | 131 | main (int argc, |
132 | char *argv[]) | 132 | char *argv[]) |
133 | { | 133 | { |
134 | global_ret = 3; | 134 | global_ret = 3; |
135 | if (0 != GNUNET_TESTING_service_run("test_peerinfo_shipped_hellos", | 135 | if (0 != GNUNET_TESTING_service_run ("test_peerinfo_shipped_hellos", |
136 | "peerinfo", | 136 | "peerinfo", |
137 | "test_peerinfo_api_data.conf", | 137 | "test_peerinfo_api_data.conf", |
138 | &run, NULL)) | 138 | &run, NULL)) |
139 | return 1; | 139 | return 1; |
140 | return global_ret; | 140 | return global_ret; |
141 | } | 141 | } |