summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxrs <xrs@mail36.net>2020-06-17 20:08:47 +0200
committerxrs <xrs@mail36.net>2020-06-17 20:08:47 +0200
commit97f951473b1581eca61c769c12b9d794df98bf6e (patch)
tree741ecb1d541232bffce515cba511f8aaae02c181
parentcdea4f7ba00100c83b41d4820588e375b1bb996c (diff)
add logic for sending multiple messages and linklayer manipulation
-rw-r--r--src/cadet/test_cadeT.c48
-rw-r--r--src/cadet/test_cadeT_util.c13
2 files changed, 38 insertions, 23 deletions
diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c
index 5e92084a6..97f315167 100644
--- a/src/cadet/test_cadeT.c
+++ b/src/cadet/test_cadeT.c
@@ -45,7 +45,6 @@
* - GNUNET_TESTBED_underlay_configure_link not implemented
* - GNUNET_TESTBED_underlaylinkmodel_set_link not usable
* - GNUNET_TESTBED_peer_stop evokes standard service disconnect
- * - GNUNET_TESTBED_peer_destroy and GNUNET_TESTBED_peer_create
* - how can we test the sublayers of CADET, e.g. connection, tunnel, channel?
*
* Development
@@ -63,29 +62,50 @@
/****************************** TEST LOGIC ********************************/
static int kx_initiator;
-
-void
-handle_message (void *cls,
- const struct GNUNET_MessageHeader *msg)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
-}
+static struct GNUNET_TESTBED_UnderlayLinkModel *model;
static void
send_message ()
{
struct GNUNET_MQ_Envelope *envelope;
struct GNUNET_MessageHeader *msg;
+ int *data;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
- envelope = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_DUMMY);
+ envelope = GNUNET_MQ_msg_extra (msg, 10000,
+ GNUNET_MESSAGE_TYPE_DUMMY);
+ data = (int *) &msg[1];
+ *data = 1000;
GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel),
envelope);
}
+int
+check_message (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ return GNUNET_OK; /* all is well-formed */
+}
+
+void
+handle_message (void *cls,
+ const struct GNUNET_MessageHeader *msg)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
+
+/*
+ model = GNUNET_TESTBED_underlaylinkmodel_create (test_peers[1].testbed_peer,
+ GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST);
+ GNUNET_TESTBED_underlaylinkmodel_set_link (model,
+ test_peers[0].testbed_peer,
+ 0, 100, 0);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s: Modified link model.\n", __func__);
+*/
+ send_message();
+}
+
/**
* This function is called after all testbed management is done and the
* testbed peers are ready for the actual test logic.
@@ -99,10 +119,12 @@ run_test ()
kx_initiator = (0 < GNUNET_memcmp (&test_peers[0].id, &test_peers[1].id)) ? 1 : 0;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "KX initiator is peer %s\n",
- GNUNET_i2s (&test_peers[kx_initiator].id));
+ "KX initiator is peer %s (idx:%i)\n",
+ GNUNET_i2s (&test_peers[kx_initiator].id),
+ kx_initiator);
- send_message();
+ for (int i=0; i<10; i++)
+ send_message();
}
diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c
index bc66adbdc..f2082a006 100644
--- a/src/cadet/test_cadeT_util.c
+++ b/src/cadet/test_cadeT_util.c
@@ -41,11 +41,6 @@ static struct GNUNET_TESTBED_Operation *testbed_info_req[REQUESTED_PEERS];
static struct GNUNET_HashCode hashed_portname;
/**
- * Port handle.
- */
-struct GNUNET_CADET_Port *port;
-
-/**
* Result of the test.
*/
int test_result = 0;
@@ -83,9 +78,6 @@ disconnect_from_peer (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
- if (0 == strncmp ("listening_peer", cls, sizeof (cls)))
- GNUNET_CADET_close_port (port);
-
GNUNET_CADET_disconnect (cadet);
}
@@ -142,6 +134,7 @@ setup_listening_peer (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_CADET_Handle *cadet;
+ struct GNUNET_CADET_Port *port;
struct GNUNET_MQ_MessageHandler msg_handlers[] = {
GNUNET_MQ_hd_fixed_size (message,
GNUNET_MESSAGE_TYPE_DUMMY,
@@ -205,13 +198,13 @@ connect_to_service (void *cb_cls,
"cadet",
&check_test_readyness, NULL,
&setup_listening_peer,
- &disconnect_from_peer, "listening_peer");
+ &disconnect_from_peer, NULL);
testbed_to_svc[0] =
GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer,
"cadet",
&check_test_readyness, NULL,
&setup_initiating_peer,
- &disconnect_from_peer, "initiating_peer");
+ &disconnect_from_peer, NULL);
}
}