aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_plugin_cmd_simple_send_dv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_plugin_cmd_simple_send_dv.c')
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_dv.c109
1 files changed, 78 insertions, 31 deletions
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
index e73e5a0b2..167120e2b 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -64,6 +64,12 @@ struct TestState
64 * The complete topology information. 64 * The complete topology information.
65 */ 65 */
66 struct GNUNET_TESTING_NetjailTopology *topology; 66 struct GNUNET_TESTING_NetjailTopology *topology;
67
68 /**
69 * The number of messages received.
70 */
71 unsigned int number_received;
72
67}; 73};
68 74
69static struct GNUNET_TESTING_Command block_send; 75static struct GNUNET_TESTING_Command block_send;
@@ -74,6 +80,8 @@ static struct GNUNET_TESTING_Command connect_peers;
74 80
75static struct GNUNET_TESTING_Command local_prepared; 81static struct GNUNET_TESTING_Command local_prepared;
76 82
83static struct GNUNET_TESTING_Command start_peer;
84
77/** 85/**
78 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being 86 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
79 * received. 87 * received.
@@ -83,6 +91,7 @@ static int
83check_test (void *cls, 91check_test (void *cls,
84 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) 92 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
85{ 93{
94 GNUNET_assert (NULL != cls);
86 return GNUNET_OK; 95 return GNUNET_OK;
87} 96}
88 97
@@ -96,17 +105,52 @@ static void
96handle_test (void *cls, 105handle_test (void *cls,
97 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) 106 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
98{ 107{
99 const struct GNUNET_TESTING_AsyncContext *ac; 108 struct TestState *ts = cls;
109 const struct GNUNET_TESTING_AsyncContext *ac_block;
110 const struct GNUNET_TESTING_AsyncContext *ac_start;
111 const struct GNUNET_TESTING_Command *cmd;
112 const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
113 unsigned int connected;
114 struct BlockState *bs;
115
116
100 117
118 GNUNET_TRANSPORT_get_trait_connected_peers_map (&start_peer,
119 &connected_peers_map);
120
121 connected = GNUNET_CONTAINER_multishortmap_size (
122 connected_peers_map);
123
124 ts->number_received++;
101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
102 "Received test message\n"); 126 "Received %u test message(s) from %u connected peer(s)\n",
127 ts->number_received,
128 connected);
129
103 GNUNET_TESTING_get_trait_async_context (&block_receive, 130 GNUNET_TESTING_get_trait_async_context (&block_receive,
104 &ac); 131 &ac_block);
105 GNUNET_assert (NULL != ac); 132
106 if (NULL == ac->cont) 133 if ( connected == ts->number_received)
107 GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac); 134 {
108 else 135 if (NULL != ac_block->is)
109 GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac); 136 {
137 GNUNET_assert (NULL != ac_block);
138 if (NULL == ac_block->cont)
139 GNUNET_TESTING_async_fail ((struct
140 GNUNET_TESTING_AsyncContext *) ac_block);
141 else
142 GNUNET_TESTING_async_finish ((struct
143 GNUNET_TESTING_AsyncContext *) ac_block);
144 }
145 else
146 {
147 GNUNET_TESTING_get_trait_block_state (
148 &block_receive,
149 (const struct BlockState **) &bs);
150 bs->asynchronous_finish = GNUNET_YES;
151 }
152
153 }
110} 154}
111 155
112 156
@@ -232,8 +276,17 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
232 unsigned int num; 276 unsigned int num;
233 struct TestState *ts = GNUNET_new (struct TestState); 277 struct TestState *ts = GNUNET_new (struct TestState);
234 struct GNUNET_TESTING_NetjailTopology *topology; 278 struct GNUNET_TESTING_NetjailTopology *topology;
279 struct GNUNET_MQ_MessageHandler handlers[] = {
280 GNUNET_MQ_hd_var_size (test,
281 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
282 struct GNUNET_TRANSPORT_TESTING_TestMessage,
283 ts),
284 GNUNET_MQ_handler_end ()
285 };
235 286
236 287 LOG (GNUNET_ERROR_TYPE_DEBUG,
288 "number_received %u\n",
289 ts->number_received);
237 290
238 if (GNUNET_YES == *read_file) 291 if (GNUNET_YES == *read_file)
239 { 292 {
@@ -258,12 +311,13 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
258 block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); 311 block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block");
259 block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( 312 block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
260 "block-receive"); 313 "block-receive");
261 connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", 314 connect_peers = GNUNET_TRANSPORT_cmd_connect_peers (
262 "start-peer", 315 "connect-peers",
263 "system-create", 316 "start-peer",
264 num, 317 "system-create",
265 topology, 318 num,
266 8); 319 topology,
320 topology->additional_connects);
267 local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( 321 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
268 "local-test-prepared", 322 "local-test-prepared",
269 write_message); 323 write_message);
@@ -286,25 +340,18 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
286 m, 340 m,
287 n); 341 n);
288 342
289 struct GNUNET_MQ_MessageHandler handlers[] = { 343 start_peer = GNUNET_TRANSPORT_cmd_start_peer ("start-peer",
290 GNUNET_MQ_hd_var_size (test, 344 "system-create",
291 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, 345 num,
292 struct GNUNET_TRANSPORT_TESTING_TestMessage, 346 node_ip,
293 ts), 347 handlers,
294 GNUNET_MQ_handler_end () 348 ts->cfgname,
295 }; 349 notify_connect,
296 350 GNUNET_YES);
297 struct GNUNET_TESTING_Command commands[] = { 351 struct GNUNET_TESTING_Command commands[] = {
298 GNUNET_TESTING_cmd_system_create ("system-create", 352 GNUNET_TESTING_cmd_system_create ("system-create",
299 ts->testdir), 353 ts->testdir),
300 GNUNET_TRANSPORT_cmd_start_peer ("start-peer", 354 start_peer,
301 "system-create",
302 num,
303 node_ip,
304 handlers,
305 ts->cfgname,
306 notify_connect,
307 GNUNET_YES),
308 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", 355 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
309 write_message), 356 write_message),
310 block_send, 357 block_send,