Move queue management into mbedtls_test_ssl_dtls_join_endpoints

This allows mbedtls_test_ssl_endpoint_init() to no longer interact with the
other endpoint.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/tests/include/test/ssl_helpers.h b/tests/include/test/ssl_helpers.h
index ca43663..d98f48e 100644
--- a/tests/include/test/ssl_helpers.h
+++ b/tests/include/test/ssl_helpers.h
@@ -205,6 +205,7 @@
 
     /* Objects owned by the endpoint */
     int *ciphersuites;
+    mbedtls_test_ssl_message_queue queue_input;
     mbedtls_x509_crt *ca_chain;
     mbedtls_x509_crt *cert;
     mbedtls_pk_context *pkey;
diff --git a/tests/src/test_helpers/ssl_helpers.c b/tests/src/test_helpers/ssl_helpers.c
index f917acc..453e8e7 100644
--- a/tests/src/test_helpers/ssl_helpers.c
+++ b/tests/src/test_helpers/ssl_helpers.c
@@ -742,16 +742,12 @@
     mbedtls_test_ssl_message_queue *output_queue)
 {
     (void) dtls_context; // no longer used
+    (void) input_queue; // no longer used
+    (void) output_queue; // no longer used
 
     int ret = -1;
     uintptr_t user_data_n;
 
-    if (options->dtls &&
-        (input_queue == NULL || output_queue == NULL)) {
-        return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
-
-    }
-
     if (ep == NULL) {
         return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
     }
@@ -775,13 +771,7 @@
     mbedtls_ssl_conf_set_user_data_n(&ep->conf, user_data_n);
     mbedtls_ssl_set_user_data_n(&ep->ssl, user_data_n);
 
-    if (options->dtls) {
-        TEST_EQUAL(mbedtls_test_message_socket_setup(input_queue, output_queue,
-                                                     100, &(ep->socket),
-                                                     &ep->dtls_context), 0);
-    } else {
-        mbedtls_test_mock_socket_init(&(ep->socket));
-    }
+    mbedtls_test_mock_socket_init(&(ep->socket));
 
     /* Non-blocking callbacks without timeout */
     if (options->dtls) {
@@ -938,11 +928,19 @@
 {
     int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
 
-    /* Nothing to do yet. */
-    (void) client;
-    (void) server;
-    ret = 0;
+    ret = mbedtls_test_message_socket_setup(&client->queue_input,
+                                            &server->queue_input,
+                                            100, &(client->socket),
+                                            &client->dtls_context);
+    TEST_EQUAL(ret, 0);
 
+    ret = mbedtls_test_message_socket_setup(&server->queue_input,
+                                            &client->queue_input,
+                                            100, &(server->socket),
+                                            &server->dtls_context);
+    TEST_EQUAL(ret, 0);
+
+exit:
     return ret;
 }
 
@@ -2142,7 +2140,6 @@
     MD_OR_USE_PSA_INIT();
     mbedtls_platform_zeroize(&client, sizeof(client));
     mbedtls_platform_zeroize(&server, sizeof(server));
-    mbedtls_test_ssl_message_queue server_queue, client_queue;
 
 #if defined(MBEDTLS_DEBUG_C)
     if (options->cli_log_fun || options->srv_log_fun) {
@@ -2154,9 +2151,8 @@
     if (options->dtls != 0) {
         TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&client,
                                                   MBEDTLS_SSL_IS_CLIENT,
-                                                  options, NULL,
-                                                  &client_queue,
-                                                  &server_queue), 0);
+                                                  options, NULL, NULL,
+                                                  NULL), 0);
     } else {
         TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&client,
                                                   MBEDTLS_SSL_IS_CLIENT,
@@ -2170,9 +2166,8 @@
     if (options->dtls != 0) {
         TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&server,
                                                   MBEDTLS_SSL_IS_SERVER,
-                                                  options, NULL,
-                                                  &server_queue,
-                                                  &client_queue), 0);
+                                                  options, NULL, NULL,
+                                                  NULL), 0);
     } else {
         TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&server,
                                                   MBEDTLS_SSL_IS_SERVER,