Skip to content

Commit

Permalink
Fix refresh message and attribute sharing test case
Browse files Browse the repository at this point in the history
Signed-off-by: Jacki <jacki@thejackimonster.de>
  • Loading branch information
TheJackiMonster committed Oct 5, 2024
1 parent a2a3cd3 commit 296e5f5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/gnunet_chat_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
handle->accounts_head = NULL;
handle->accounts_tail = NULL;

handle->refreshing = GNUNET_NO;

handle->next = NULL;
handle->current = NULL;
handle->monitor = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/gnunet_chat_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ struct GNUNET_CHAT_Handle
struct GNUNET_CHAT_InternalAccounts *accounts_head;
struct GNUNET_CHAT_InternalAccounts *accounts_tail;

enum GNUNET_GenericReturnValue refreshing;

struct GNUNET_CHAT_Account *next;
struct GNUNET_CHAT_Account *current;
struct GNUNET_NAMESTORE_ZoneMonitor *monitor;
Expand Down
8 changes: 6 additions & 2 deletions src/gnunet_chat_handle_intern.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ on_handle_gnunet_identity (void *cls,
struct GNUNET_CHAT_Handle* handle = cls;

if ((!ctx) || (!ego))
{
handle->refreshing = GNUNET_YES;
goto send_refresh;
}

struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head;

Expand Down Expand Up @@ -372,11 +375,12 @@ on_handle_gnunet_identity (void *cls,
);

send_refresh:
if (handle->refresh)
if ((GNUNET_YES != handle->refreshing) ||
(handle->refresh))
return;

handle->refresh = GNUNET_SCHEDULER_add_with_priority(
GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
GNUNET_SCHEDULER_PRIORITY_IDLE,
on_handle_refresh,
handle
);
Expand Down
16 changes: 10 additions & 6 deletions tests/attribute/test_gnunet_chat_attribute_share.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,19 @@ on_gnunet_chat_attribute_share_msg(void *cls,

ck_assert_ptr_nonnull(name);

if (share_stage < 4)
share_stage = 4;

if (0 == strcmp(name, TEST_SHARE_ID_A))
break;
{
ck_assert_uint_eq(share_stage, 3);

share_stage = 4;
}
else if (0 == strcmp(name, TEST_SHARE_ID_B))
{
ck_assert_uint_eq(share_stage, 7);

ck_assert_uint_eq(share_stage, 7);
GNUNET_CHAT_stop(handle);
}

GNUNET_CHAT_stop(handle);
break;
case GNUNET_CHAT_KIND_UPDATE_ACCOUNT:
ck_assert_ptr_nonnull(account);
Expand Down
6 changes: 6 additions & 0 deletions tests/test_gnunet_chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ on_setup_##test_call (void *cls, \
account = GNUNET_CHAT_message_get_account(message); \
ck_assert_ptr_nonnull(account); \
\
fprintf(stdout, " - Setup account: %s\n", \
GNUNET_CHAT_account_get_name(account)); \
\
const char **accounts; \
for (accounts = test_accounts; *accounts; accounts++) \
if (0 == strcmp(GNUNET_CHAT_account_get_name(account), \
Expand Down Expand Up @@ -116,6 +119,9 @@ on_cleanup_##test_call (void *cls, \
account = GNUNET_CHAT_message_get_account(message); \
ck_assert_ptr_nonnull(account); \
\
fprintf(stdout, " - Cleanup account: %s\n", \
GNUNET_CHAT_account_get_name(account)); \
\
const char **accounts; \
for (accounts = test_accounts; *accounts; accounts++) \
if (0 == strcmp(GNUNET_CHAT_account_get_name(account), \
Expand Down

0 comments on commit 296e5f5

Please sign in to comment.