static struct GNUNET_CONSENSUS_Handle **consensus_handles;
+static struct GNUNET_TESTBED_Operation **testbed_operations;
+
static unsigned int num_connected_handles;
static struct GNUNET_TESTBED_Peer **peers;
static struct GNUNET_HashCode session_id;
+static unsigned int peers_done = 0;
+
/**
* Signature of the event handler function called by the
GNUNET_assert (0);
}
-
static void
destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *ctx)
{
consensus = cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "destroying consensus\n");
GNUNET_CONSENSUS_destroy (consensus);
+ peers_done++;
+ if (peers_done == num_peers)
+ {
+ int i;
+ for (i = 0; i < num_peers; i++)
+ GNUNET_TESTBED_operation_done (testbed_operations[i]);
+ GNUNET_SCHEDULER_shutdown ();
+ }
}
/**
* Called when a conclusion was successful.
*
- * @param cls
- * @param group
+ * @param cls closure, the consensus handle
* @return GNUNET_YES if more consensus groups should be offered, GNUNET_NO if not
*/
static void
}
-static int
+static void
new_element_cb (void *cls,
const struct GNUNET_CONSENSUS_Element *element)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "received new element\n");
- return GNUNET_YES;
}
num_retrieved_peer_ids++;
if (num_retrieved_peer_ids == num_peers)
for (i = 0; i < num_peers; i++)
- GNUNET_TESTBED_service_connect (NULL, peers[i], "consensus", connect_complete, &consensus_handles[i],
- connect_adapter, disconnect_adapter, NULL);
+ testbed_operations[i] =
+ GNUNET_TESTBED_service_connect (NULL, peers[i], "consensus", connect_complete, &consensus_handles[i],
+ connect_adapter, disconnect_adapter, NULL);
}
else
{
}
+/**
+ * Signature of a main function for a testcase.
+ *
+ * @param cls closure
+ * @param num_peers number of peers in 'peers'
+ * @param started_peers handle to peers run in the testbed. NULL upon timeout (see
+ * GNUNET_TESTBED_test_run()).
+ * @param links_succeeded the number of overlay link connection attempts that
+ * succeeded
+ * @param links_failed the number of overlay link connection attempts that
+ * failed
+ */
static void
test_master (void *cls,
unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **started_peers)
+ struct GNUNET_TESTBED_Peer **started_peers,
+ unsigned int links_succeeded,
+ unsigned int links_failed)
{
int i;
-
GNUNET_log_setup ("gnunet-consensus", "INFO", NULL);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n");
peer_ids = GNUNET_malloc (num_peers * sizeof (struct GNUNET_PeerIdentity));
consensus_handles = GNUNET_malloc (num_peers * sizeof (struct ConsensusHandle *));
+ testbed_operations = GNUNET_malloc (num_peers * sizeof (struct ConsensusHandle *));
for (i = 0; i < num_peers; i++)
GNUNET_TESTBED_peer_get_information (peers[i],