+ abort_task = NULL;
+ do_shutdown (cls);
+}
+
+
+/**
+ * Adapter function called to establish a connection to
+ * a service.
+ *
+ * @param cls closure
+ * @param cfg configuration of the peer to connect to; will be available until
+ * GNUNET_TESTBED_operation_done() is called on the operation returned
+ * from GNUNET_TESTBED_service_connect()
+ * @return service handle to return in 'op_result', NULL on error
+ */
+static void *
+arm_connect_adapter (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ FAIL_TEST (NULL == cls, return NULL);
+ FAIL_TEST (OTHER == sub_test, return NULL);
+ sub_test = PEER_SERVICE_CONNECT;
+ arm_handle = GNUNET_ARM_connect (cfg, NULL, NULL);
+ return arm_handle;
+}
+
+
+/**
+ * Adapter function called to destroy a connection to
+ * a service.
+ *
+ * @param cls closure
+ * @param op_result service handle returned from the connect adapter
+ */
+static void
+arm_disconnect_adapter (void *cls,
+ void *op_result)
+{
+ FAIL_TEST (NULL != op_result, return );
+ FAIL_TEST (op_result == arm_handle, return );
+ GNUNET_ARM_disconnect (arm_handle);
+ arm_handle = NULL;
+ FAIL_TEST (PEER_SERVICE_CONNECT == sub_test, return );
+ FAIL_TEST (NULL != operation, return );
+ operation = GNUNET_TESTBED_peer_stop (NULL, peer, NULL, NULL);
+ FAIL_TEST (NULL != operation, return );
+}
+
+
+/**
+ * Callback to be called when a service connect operation is completed
+ *
+ * @param cls the callback closure from functions generating an operation
+ * @param op the operation that has been finished
+ * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
+ * @param emsg error message in case the operation has failed; will be NULL if
+ * operation has executed successfully.
+ */
+static void
+service_connect_comp_cb (void *cls,
+ struct GNUNET_TESTBED_Operation *op,
+ void *ca_result,
+ const char *emsg)
+{
+ switch (sub_test)
+ {
+ case PEER_SERVICE_CONNECT:
+ FAIL_TEST (operation == op, return );
+ FAIL_TEST (NULL == emsg, return );
+ FAIL_TEST (NULL == cls, return );
+ FAIL_TEST (ca_result == arm_handle, return );
+ GNUNET_TESTBED_operation_done (operation); /* This results in call to
+ * disconnect adapter */
+ break;
+
+ default:
+ FAIL_TEST (0, return );
+ }
+}
+
+
+/**
+ * Callback to be called when the requested peer information is available
+ *
+ * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
+ * @param op the operation this callback corresponds to
+ * @param pinfo the result; will be NULL if the operation has failed
+ * @param emsg error message if the operation has failed; will be NULL if the
+ * operation is successfull
+ */
+static void
+peerinfo_cb (void *cb_cls,
+ struct GNUNET_TESTBED_Operation *op,
+ const struct GNUNET_TESTBED_PeerInformation *pinfo,
+ const char *emsg)
+{
+ switch (sub_test)
+ {
+ case PEER_GETCONFIG:
+ FAIL_TEST (NULL != pinfo, return );
+ FAIL_TEST (NULL == emsg, return );
+ FAIL_TEST (NULL == cb_cls, return );
+ FAIL_TEST (operation == op, return );
+ FAIL_TEST (GNUNET_TESTBED_PIT_CONFIGURATION == pinfo->pit, return );
+ FAIL_TEST (NULL != pinfo->result.cfg, return );
+ sub_test = PEER_DESTROY;
+ GNUNET_TESTBED_operation_done (operation);
+ operation = GNUNET_TESTBED_peer_destroy (peer);
+ break;
+
+ default:
+ FAIL_TEST (0, return );
+ }