diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-22 22:11:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-22 22:11:56 +0000 |
commit | 2e30802278646e10b20f9fd89dadb7c74d4a4496 (patch) | |
tree | cdd39e877b9b92b6e83f7383c36ca2462abbeed9 /src/transport/test_transport_api_blacklisting.c | |
parent | 8a732552157d565ff2a0636121e1f9fd93804c64 (diff) | |
download | gnunet-2e30802278646e10b20f9fd89dadb7c74d4a4496.tar.gz gnunet-2e30802278646e10b20f9fd89dadb7c74d4a4496.zip |
migrate more tests to new transmission API
Diffstat (limited to 'src/transport/test_transport_api_blacklisting.c')
-rw-r--r-- | src/transport/test_transport_api_blacklisting.c | 63 |
1 files changed, 9 insertions, 54 deletions
diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c index 72f8a71a3..a2add5957 100644 --- a/src/transport/test_transport_api_blacklisting.c +++ b/src/transport/test_transport_api_blacklisting.c | |||
@@ -117,42 +117,9 @@ notify_receive (void *cls, | |||
117 | { | 117 | { |
118 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 118 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
119 | "Unexpectedly even received the message despite blacklist\n"); | 119 | "Unexpectedly even received the message despite blacklist\n"); |
120 | GNUNET_SCHEDULER_shutdown (); | 120 | connected = GNUNET_YES; |
121 | } | 121 | GNUNET_SCHEDULER_cancel (shutdown_task); |
122 | 122 | end (NULL); | |
123 | |||
124 | static size_t | ||
125 | notify_ready (void *cls, | ||
126 | size_t size, | ||
127 | void *buf) | ||
128 | { | ||
129 | struct GNUNET_MessageHeader *hdr; | ||
130 | |||
131 | th = NULL; | ||
132 | if (NULL == buf) | ||
133 | { | ||
134 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
135 | "Timeout occurred while waiting for transmit_ready\n"); | ||
136 | GNUNET_SCHEDULER_shutdown (); | ||
137 | return 0; | ||
138 | } | ||
139 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | ||
140 | hdr = buf; | ||
141 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
142 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
143 | return TEST_MESSAGE_SIZE; | ||
144 | } | ||
145 | |||
146 | |||
147 | static void | ||
148 | sendtask (void *cls) | ||
149 | { | ||
150 | th = GNUNET_TRANSPORT_notify_transmit_ready (ccc->p[1]->th, | ||
151 | &ccc->p[0]->id, | ||
152 | TEST_MESSAGE_SIZE, | ||
153 | TIMEOUT, | ||
154 | ¬ify_ready, | ||
155 | ccc->p[0]); | ||
156 | } | 123 | } |
157 | 124 | ||
158 | 125 | ||
@@ -172,22 +139,6 @@ notify_connect (void *cls, | |||
172 | } | 139 | } |
173 | 140 | ||
174 | 141 | ||
175 | static void | ||
176 | notify_disconnect (void *cls, | ||
177 | struct GNUNET_TRANSPORT_TESTING_PeerContext *me, | ||
178 | const struct GNUNET_PeerIdentity *other) | ||
179 | { | ||
180 | GNUNET_TRANSPORT_TESTING_log_disconnect (cls, | ||
181 | me, | ||
182 | other); | ||
183 | if (NULL != th) | ||
184 | { | ||
185 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | ||
186 | th = NULL; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | |||
191 | static int | 142 | static int |
192 | blacklist_cb (void *cls, | 143 | blacklist_cb (void *cls, |
193 | const struct GNUNET_PeerIdentity *pid) | 144 | const struct GNUNET_PeerIdentity *pid) |
@@ -244,13 +195,17 @@ int | |||
244 | main (int argc, | 195 | main (int argc, |
245 | char *argv[]) | 196 | char *argv[]) |
246 | { | 197 | { |
198 | struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { | ||
199 | .num_messages = 1 | ||
200 | }; | ||
247 | struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { | 201 | struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { |
248 | .pre_connect_task = &start_blacklist, | 202 | .pre_connect_task = &start_blacklist, |
249 | .connect_continuation = &sendtask, | 203 | .connect_continuation = &GNUNET_TRANSPORT_TESTING_simple_send, |
204 | .connect_continuation_cls = &sc, | ||
250 | .config_file = "test_transport_api_data.conf", | 205 | .config_file = "test_transport_api_data.conf", |
251 | .rec = ¬ify_receive, | 206 | .rec = ¬ify_receive, |
252 | .nc = ¬ify_connect, | 207 | .nc = ¬ify_connect, |
253 | .nd = ¬ify_disconnect, | 208 | .nd = &GNUNET_TRANSPORT_TESTING_log_disconnect, |
254 | .shutdown_task = &custom_shutdown, | 209 | .shutdown_task = &custom_shutdown, |
255 | .timeout = TIMEOUT, | 210 | .timeout = TIMEOUT, |
256 | .bi_directional = GNUNET_YES | 211 | .bi_directional = GNUNET_YES |