GNUnet 0.21.2
testing_messenger.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2023 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
27#include "messenger-testing.h"
28
29#include "gnunet_util_lib.h"
30
33{
34 struct GNUNET_MESSENGER_TestStage stage;
35 stage.door_id = 0;
37 return stage;
38}
39
40
43{
44 struct GNUNET_MESSENGER_TestStage stage;
45 stage.door_id = 0;
47 return stage;
48}
49
50
53{
54 struct GNUNET_MESSENGER_TestStage stage;
55 stage.door_id = door_id;
57 return stage;
58}
59
60
63 unsigned int stage_amount,
66{
68
73
74 const unsigned int size = tp->peer_amount * tp->stage_amount;
76
77 for (unsigned int i = 0; i < size; i++)
78 tp->peer_stages[i] = peer_stages[i];
79
80 return tp;
81}
82
83
84void
87{
88 GNUNET_assert ((topology) && (topology->peer_stages));
89 GNUNET_free (topology->peer_stages);
90 GNUNET_free (topology);
91}
92
93
97{
101 GNUNET_NO);
102 rs->required_doors = 0;
103 return rs;
104}
105
106
107void
109 GNUNET_MESSENGER_RoomState *room_state)
110{
111 GNUNET_assert ((room_state) && (room_state->doors));
113 GNUNET_free (room_state);
114}
char * door_id
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
Definition: peer.c:68
struct GNUNET_CONTAINER_MultiPeerMap * doors
struct GNUNET_MESSENGER_TestStage * peer_stages
enum GNUNET_MESSENGER_TestStageJoin join
struct GNUNET_MESSENGER_TestStage GNUNET_MESSENGER_create_stage_enter_room(uint32_t door_id)
void GNUNET_MESSENGER_destroy_topo(struct GNUNET_MESSENGER_TestStageTopology *topology)
struct GNUNET_MESSENGER_TestStage GNUNET_MESSENGER_create_stage_skip()
void GNUNET_MESSENGER_destroy_room_state(struct GNUNET_MESSENGER_RoomState *room_state)
struct GNUNET_MESSENGER_TestStage GNUNET_MESSENGER_create_stage_open_room()
struct GNUNET_MESSENGER_TestStageTopology * GNUNET_MESSENGER_create_topo(unsigned int peer_amount, unsigned int stage_amount, const struct GNUNET_MESSENGER_TestStage peer_stages[static peer_amount *stage_amount])
struct GNUNET_MESSENGER_RoomState * GNUNET_MESSENGER_create_room_state(struct GNUNET_MESSENGER_TestStageTopology *topology)
@ GNUNET_MESSENGER_STAGE_JOIN_ENTER_ROOM
@ GNUNET_MESSENGER_STAGE_JOIN_OPEN_ROOM
@ GNUNET_MESSENGER_STAGE_JOIN_NONE