commit d2578e05a36023a2838ea07e27f3e6959bdfcbfc
parent e5bfea811ec6b111500efc31d537ee65de240708
Author: Jacki <jacki@thejackimonster.de>
Date: Sat, 5 Oct 2024 22:48:36 +0200
Fix lobby test cases
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
3 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/tests/handle/test_gnunet_chat_handle_connection.c b/tests/handle/test_gnunet_chat_handle_connection.c
@@ -48,8 +48,6 @@ on_gnunet_chat_handle_connection_msg(void *cls,
connected = GNUNET_CHAT_get_connected(handle);
account = GNUNET_CHAT_message_get_account(message);
- printf("MSG: %d\n", (int) GNUNET_CHAT_message_get_kind(message));
-
switch (GNUNET_CHAT_message_get_kind(message))
{
case GNUNET_CHAT_KIND_WARNING:
@@ -74,7 +72,7 @@ on_gnunet_chat_handle_connection_msg(void *cls,
ck_assert_ptr_nonnull(connected);
ck_assert_ptr_nonnull(account);
ck_assert_ptr_eq(connected, account);
- ck_assert_int_eq(connection_stage, 1);
+ ck_assert_uint_eq(connection_stage, 1);
name = GNUNET_CHAT_account_get_name(account);
@@ -88,7 +86,7 @@ on_gnunet_chat_handle_connection_msg(void *cls,
ck_assert_ptr_nonnull(connected);
ck_assert_ptr_nonnull(account);
ck_assert_ptr_eq(connected, account);
- ck_assert_int_eq(connection_stage, 2);
+ ck_assert_uint_eq(connection_stage, 2);
name = GNUNET_CHAT_account_get_name(account);
diff --git a/tests/lobby/test_gnunet_chat_lobby_join.c b/tests/lobby/test_gnunet_chat_lobby_join.c
@@ -43,6 +43,7 @@ on_gnunet_chat_lobby_join_msg(void *cls,
struct GNUNET_CHAT_Context *context,
struct GNUNET_CHAT_Message *message)
{
+ static unsigned int lobby_stage = 0;
static struct GNUNET_CHAT_Lobby *lobby = NULL;
struct GNUNET_CHAT_Handle *handle = *(
@@ -64,16 +65,22 @@ on_gnunet_chat_lobby_join_msg(void *cls,
ck_assert_ptr_null(context);
ck_assert_ptr_null(account);
- account = GNUNET_CHAT_find_account(handle, TEST_JOIN_ID);
+ if (lobby_stage == 0)
+ {
+ account = GNUNET_CHAT_find_account(handle, TEST_JOIN_ID);
- ck_assert_ptr_nonnull(account);
+ ck_assert_ptr_nonnull(account);
+
+ GNUNET_CHAT_connect(handle, account);
+ lobby_stage = 1;
+ }
- GNUNET_CHAT_connect(handle, account);
break;
case GNUNET_CHAT_KIND_LOGIN:
ck_assert_ptr_null(context);
ck_assert_ptr_nonnull(account);
ck_assert_ptr_null(lobby);
+ ck_assert_uint_eq(lobby_stage, 1);
lobby = GNUNET_CHAT_lobby_open(
handle,
@@ -83,11 +90,13 @@ on_gnunet_chat_lobby_join_msg(void *cls,
);
ck_assert_ptr_nonnull(lobby);
+ lobby_stage = 2;
break;
case GNUNET_CHAT_KIND_LOGOUT:
ck_assert_ptr_null(context);
ck_assert_ptr_nonnull(account);
ck_assert_ptr_null(lobby);
+ ck_assert_uint_eq(lobby_stage, 3);
GNUNET_CHAT_stop(handle);
break;
@@ -102,11 +111,13 @@ on_gnunet_chat_lobby_join_msg(void *cls,
ck_assert_ptr_nonnull(context);
ck_assert_ptr_nonnull(account);
ck_assert_ptr_nonnull(lobby);
+ ck_assert_uint_eq(lobby_stage, 2);
GNUNET_CHAT_lobby_close(lobby);
lobby = NULL;
GNUNET_CHAT_disconnect(handle);
+ lobby_stage = 3;
break;
default:
ck_abort();
diff --git a/tests/lobby/test_gnunet_chat_lobby_open.c b/tests/lobby/test_gnunet_chat_lobby_open.c
@@ -31,6 +31,8 @@ on_gnunet_chat_lobby_open_msg(void *cls,
struct GNUNET_CHAT_Context *context,
struct GNUNET_CHAT_Message *message)
{
+ static unsigned int lobby_stage = 0;
+
struct GNUNET_CHAT_Handle *handle = *(
(struct GNUNET_CHAT_Handle**) cls
);
@@ -53,14 +55,21 @@ on_gnunet_chat_lobby_open_msg(void *cls,
ck_assert_ptr_null(context);
ck_assert_ptr_null(account);
- account = GNUNET_CHAT_find_account(handle, TEST_OPEN_ID);
+ if (lobby_stage == 0)
+ {
+ account = GNUNET_CHAT_find_account(handle, TEST_OPEN_ID);
- ck_assert_ptr_nonnull(account);
+ ck_assert_ptr_nonnull(account);
- GNUNET_CHAT_connect(handle, account);
+ GNUNET_CHAT_connect(handle, account);
+ lobby_stage = 1;
+ }
+
break;
case GNUNET_CHAT_KIND_LOGIN:
+ ck_assert_ptr_null(context);
ck_assert_ptr_nonnull(account);
+ ck_assert_uint_eq(lobby_stage, 1);
lobby = GNUNET_CHAT_lobby_open(
handle,
@@ -73,13 +82,17 @@ on_gnunet_chat_lobby_open_msg(void *cls,
GNUNET_CHAT_lobby_close(lobby);
GNUNET_CHAT_disconnect(handle);
+ lobby_stage = 2;
break;
case GNUNET_CHAT_KIND_LOGOUT:
+ ck_assert_ptr_null(context);
ck_assert_ptr_nonnull(account);
+ ck_assert_uint_eq(lobby_stage, 2);
GNUNET_CHAT_stop(handle);
break;
case GNUNET_CHAT_KIND_UPDATE_ACCOUNT:
+ ck_assert_ptr_null(context);
ck_assert_ptr_nonnull(account);
break;
default: