aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/test_testbed_api_2peers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/test_testbed_api_2peers.c')
-rw-r--r--src/testbed/test_testbed_api_2peers.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/testbed/test_testbed_api_2peers.c b/src/testbed/test_testbed_api_2peers.c
index e1445d961..63810187b 100644
--- a/src/testbed/test_testbed_api_2peers.c
+++ b/src/testbed/test_testbed_api_2peers.c
@@ -196,6 +196,30 @@ do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
196 196
197 197
198/** 198/**
199 * Callback to be called when an operation is completed
200 *
201 * @param cls the callback closure from functions generating an operation
202 * @param op the operation that has been finished
203 * @param emsg error message in case the operation has failed; will be NULL if
204 * operation has executed successfully.
205 */
206static void
207op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
208{
209 GNUNET_assert (PEERS_STARTED == result);
210 GNUNET_assert (NULL == peer1.operation);
211 GNUNET_assert (NULL == peer2.operation);
212 GNUNET_assert (NULL != common_operation);
213 GNUNET_TESTBED_operation_done (common_operation);
214 common_operation = NULL;
215 result = PEERS_CONNECTED;
216 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n");
217 peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer);
218 peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer);
219}
220
221
222/**
199 * Signature of the event handler function called by the 223 * Signature of the event handler function called by the
200 * respective event controller. 224 * respective event controller.
201 * 225 *
@@ -211,9 +235,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
211 GNUNET_assert (PEERS_STOPPED == result); 235 GNUNET_assert (PEERS_STOPPED == result);
212 GNUNET_assert (NULL == event->details.operation_finished.op_cls); 236 GNUNET_assert (NULL == event->details.operation_finished.op_cls);
213 GNUNET_assert (NULL == event->details.operation_finished.emsg); 237 GNUNET_assert (NULL == event->details.operation_finished.emsg);
214 GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == 238 GNUNET_assert (NULL == event->details.operation_finished.generic);
215 event->details.operation_finished.pit);
216 GNUNET_assert (NULL == event->details.operation_finished.op_result.generic);
217 if (event->details.operation_finished.operation == peer1.operation) 239 if (event->details.operation_finished.operation == peer1.operation)
218 { 240 {
219 GNUNET_TESTBED_operation_done (peer1.operation); 241 GNUNET_TESTBED_operation_done (peer1.operation);
@@ -255,7 +277,8 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
255 { 277 {
256 result = PEERS_STARTED; 278 result = PEERS_STARTED;
257 common_operation = 279 common_operation =
258 GNUNET_TESTBED_overlay_connect (NULL, peer1.peer, peer2.peer); 280 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer,
281 peer2.peer);
259 } 282 }
260 break; 283 break;
261 case GNUNET_TESTBED_ET_PEER_STOP: 284 case GNUNET_TESTBED_ET_PEER_STOP:
@@ -284,12 +307,6 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
284 GNUNET_assert (NULL != common_operation); 307 GNUNET_assert (NULL != common_operation);
285 GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && 308 GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) &&
286 (event->details.peer_connect.peer2 == peer2.peer)); 309 (event->details.peer_connect.peer2 == peer2.peer));
287 GNUNET_TESTBED_operation_done (common_operation);
288 common_operation = NULL;
289 result = PEERS_CONNECTED;
290 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n");
291 peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer);
292 peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer);
293 break; 310 break;
294 default: 311 default:
295 GNUNET_assert (0); 312 GNUNET_assert (0);