diff options
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.c | 79 |
1 files changed, 42 insertions, 37 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 167120e2b..f1f168102 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c | |||
@@ -65,12 +65,12 @@ struct TestState | |||
65 | */ | 65 | */ |
66 | struct GNUNET_TESTING_NetjailTopology *topology; | 66 | struct GNUNET_TESTING_NetjailTopology *topology; |
67 | 67 | ||
68 | /** | 68 | }; |
69 | |||
70 | /** | ||
69 | * The number of messages received. | 71 | * The number of messages received. |
70 | */ | 72 | */ |
71 | unsigned int number_received; | 73 | static unsigned int number_received; |
72 | |||
73 | }; | ||
74 | 74 | ||
75 | static struct GNUNET_TESTING_Command block_send; | 75 | static struct GNUNET_TESTING_Command block_send; |
76 | 76 | ||
@@ -105,52 +105,61 @@ static void | |||
105 | handle_test (void *cls, | 105 | handle_test (void *cls, |
106 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 106 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
107 | { | 107 | { |
108 | struct TestState *ts = cls; | 108 | struct GNUNET_PeerIdentity *peer = cls; |
109 | const struct GNUNET_TESTING_AsyncContext *ac_block; | 109 | const struct GNUNET_TESTING_AsyncContext *ac_block; |
110 | const struct GNUNET_TESTING_AsyncContext *ac_start; | 110 | const struct GNUNET_TESTING_AsyncContext *ac_start; |
111 | const struct GNUNET_TESTING_Command *cmd; | 111 | const struct GNUNET_TESTING_Command *cmd; |
112 | const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | 112 | const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
113 | unsigned int connected; | 113 | unsigned int connected; |
114 | struct BlockState *bs; | 114 | struct BlockState *bs; |
115 | struct GNUNET_TRANSPORT_CoreHandle *ch; | ||
116 | const struct StartPeerState *sps; | ||
115 | 117 | ||
116 | 118 | ||
117 | 119 | GNUNET_TRANSPORT_get_trait_state (&start_peer, | |
120 | &sps); | ||
121 | ch = sps->th; | ||
118 | GNUNET_TRANSPORT_get_trait_connected_peers_map (&start_peer, | 122 | GNUNET_TRANSPORT_get_trait_connected_peers_map (&start_peer, |
119 | &connected_peers_map); | 123 | &connected_peers_map); |
120 | 124 | ||
121 | connected = GNUNET_CONTAINER_multishortmap_size ( | 125 | if (NULL != connected_peers_map) |
122 | connected_peers_map); | 126 | { |
127 | connected = GNUNET_CONTAINER_multishortmap_size ( | ||
128 | connected_peers_map); | ||
123 | 129 | ||
124 | ts->number_received++; | 130 | number_received++; |
125 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
126 | "Received %u test message(s) from %u connected peer(s)\n", | 132 | "Received %u test message(s) from %s, %u connected peer(s)\n", |
127 | ts->number_received, | 133 | number_received, |
128 | connected); | 134 | GNUNET_i2s (peer), |
135 | connected); | ||
129 | 136 | ||
130 | GNUNET_TESTING_get_trait_async_context (&block_receive, | 137 | GNUNET_TESTING_get_trait_async_context (&block_receive, |
131 | &ac_block); | 138 | &ac_block); |
132 | 139 | ||
133 | if ( connected == ts->number_received) | 140 | if ( connected == number_received) |
134 | { | ||
135 | if (NULL != ac_block->is) | ||
136 | { | 141 | { |
137 | GNUNET_assert (NULL != ac_block); | 142 | if (NULL != ac_block->is) |
138 | if (NULL == ac_block->cont) | 143 | { |
139 | GNUNET_TESTING_async_fail ((struct | 144 | GNUNET_assert (NULL != ac_block); |
140 | GNUNET_TESTING_AsyncContext *) ac_block); | 145 | if (NULL == ac_block->cont) |
141 | else | 146 | GNUNET_TESTING_async_fail ((struct |
142 | GNUNET_TESTING_async_finish ((struct | ||
143 | GNUNET_TESTING_AsyncContext *) ac_block); | 147 | GNUNET_TESTING_AsyncContext *) ac_block); |
144 | } | 148 | else |
145 | else | 149 | GNUNET_TESTING_async_finish ((struct |
146 | { | 150 | GNUNET_TESTING_AsyncContext *) ac_block); |
147 | GNUNET_TESTING_get_trait_block_state ( | 151 | } |
148 | &block_receive, | 152 | else |
149 | (const struct BlockState **) &bs); | 153 | { |
150 | bs->asynchronous_finish = GNUNET_YES; | 154 | GNUNET_TESTING_get_trait_block_state ( |
151 | } | 155 | &block_receive, |
156 | (const struct BlockState **) &bs); | ||
157 | bs->asynchronous_finish = GNUNET_YES; | ||
158 | } | ||
152 | 159 | ||
160 | } | ||
153 | } | 161 | } |
162 | GNUNET_TRANSPORT_core_receive_continue (ch, peer); | ||
154 | } | 163 | } |
155 | 164 | ||
156 | 165 | ||
@@ -284,10 +293,6 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
284 | GNUNET_MQ_handler_end () | 293 | GNUNET_MQ_handler_end () |
285 | }; | 294 | }; |
286 | 295 | ||
287 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
288 | "number_received %u\n", | ||
289 | ts->number_received); | ||
290 | |||
291 | if (GNUNET_YES == *read_file) | 296 | if (GNUNET_YES == *read_file) |
292 | { | 297 | { |
293 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 298 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -347,7 +352,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
347 | handlers, | 352 | handlers, |
348 | ts->cfgname, | 353 | ts->cfgname, |
349 | notify_connect, | 354 | notify_connect, |
350 | GNUNET_YES); | 355 | GNUNET_NO); |
351 | struct GNUNET_TESTING_Command commands[] = { | 356 | struct GNUNET_TESTING_Command commands[] = { |
352 | GNUNET_TESTING_cmd_system_create ("system-create", | 357 | GNUNET_TESTING_cmd_system_create ("system-create", |
353 | ts->testdir), | 358 | ts->testdir), |