Skip to content

Commit b03b571

Browse files
committed
fix: flaky tcp test
This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
1 parent 32e67ab commit b03b571

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

auto_tests/TCP_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,9 @@ static void test_client(void)
525525
ip_port_tcp_s.ip = get_loopback();
526526

527527
TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr);
528-
do_tcp_connection(logger, mono_time, conn, nullptr);
528+
// TCP sockets might need a moment before they can be written to.
529529
c_sleep(50);
530+
do_tcp_connection(logger, mono_time, conn, nullptr);
530531

531532
// The connection status should be unconfirmed here because we have finished
532533
// sending our data and are awaiting a response.
@@ -560,6 +561,7 @@ static void test_client(void)
560561
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
561562
TCP_Client_Connection *conn2 = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f2_public_key,
562563
f2_secret_key, nullptr);
564+
c_sleep(50);
563565

564566
// The client should call this function (defined earlier) during the routing process.
565567
routing_response_handler(conn, response_callback, (char *)conn + 2);

0 commit comments

Comments
 (0)