GNUnet 0.21.1
gnunet_core_testing_lib.h File Reference
Include dependency graph for gnunet_core_testing_lib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_TESTING_ConnectPeersState
 API for cmds working with core sub system provided by libgnunetcoretesting. More...
 

Macros

#define GNUNET_CORE_TESTING_SIMPLE_TRAITS(op, prefix)    op (prefix, connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState)
 Call op on all simple traits. More...
 

Functions

struct GNUNET_TESTING_Command GNUNET_CORE_cmd_connect_peers (const char *label, const char *start_peer_label, const char *create_label, uint32_t num, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int additional_connects, unsigned int wait_for_connect, struct GNUNET_MQ_MessageHandler *handlers)
 FIXME: document properly! Create command. More...
 
enum GNUNET_GenericReturnValue GNUNET_CORE_TESTING_get_trait_connect_peer_state (const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_ConnectPeersState **ret)
 
struct GNUNET_TESTING_Trait GNUNET_CORE_TESTING_make_trait_connect_peer_state (const struct GNUNET_TESTING_ConnectPeersState *value)
 

Macro Definition Documentation

◆ GNUNET_CORE_TESTING_SIMPLE_TRAITS

#define GNUNET_CORE_TESTING_SIMPLE_TRAITS (   op,
  prefix 
)     op (prefix, connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState)

Call op on all simple traits.

Definition at line 151 of file gnunet_core_testing_lib.h.

Function Documentation

◆ GNUNET_CORE_cmd_connect_peers()

struct GNUNET_TESTING_Command GNUNET_CORE_cmd_connect_peers ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num,
struct GNUNET_TESTING_NetjailTopology topology,
unsigned int  additional_connects,
unsigned int  wait_for_connect,
struct GNUNET_MQ_MessageHandler handlers 
)

FIXME: document properly! Create command.

Parameters
labelname for command
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
topologyThe topology for the test setup.
additional_connectsNumber of additional connects this cmd will wait for not triggered by this cmd.
Returns
command.

Definition at line 212 of file core_api_cmd_connecting_peers.c.

221{
223 unsigned int node_additional_connects;
224 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
226 unsigned int i;
227
228 node_additional_connects = GNUNET_TESTING_get_additional_connects (num,
229 topology);
230
232 "global: %u and local: %u additional_connects\n",
233 additional_connects,
234 node_additional_connects);
235
236 if (0 != node_additional_connects)
237 additional_connects = node_additional_connects;
238
240 cps->start_peer_label = start_peer_label;
241 cps->num = num;
242 cps->create_label = create_label;
243 cps->topology = topology;
244 cps->additional_connects = additional_connects;
245 cps->wait_for_connect = wait_for_connect;
246 cps->connected_peers_map = connected_peers_map;
247
248 if (NULL != handlers)
249 {
250 for (i = 0; NULL != handlers[i].cb; i++)
251 ;
252 cps->handlers = GNUNET_new_array (i + 1,
255 handlers,
256 i * sizeof(struct GNUNET_MQ_MessageHandler));
257 }
258
259 if (GNUNET_YES == wait_for_connect)
260 return GNUNET_TESTING_command_new (cps,
261 label,
265 &cps->ac);
266 else
267 return GNUNET_TESTING_command_new (cps,
268 label,
272 NULL);
273}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static void connect_peers_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will connect to peers.
#define LOG(kind,...)
Generic logging shortcut.
static void connect_peers_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
enum GNUNET_GenericReturnValue connect_peers_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command.
unsigned int GNUNET_TESTING_get_additional_connects(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get the number of unintentional additional connections the node waits for.
Definition: testing.c:2447
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_DEBUG
#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.
Internal representation of the hash map.
Message handler for a specific message type.
API for cmds working with core sub system provided by libgnunetcoretesting.
uint32_t num
Number globally identifying the node.
unsigned int additional_connects
Number of additional connects this cmd will wait for not triggered by this cmd.
unsigned int wait_for_connect
Flag indicating, whether the command is waiting for peers to connect that are configured to connect.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
A map with struct GNUNET_MQ_Handle values for each peer this peer is connected to.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
const char * start_peer_label
Label of the cmd to start a peer.
struct GNUNET_TESTING_NetjailTopology * topology
The topology of the test setup.

References GNUNET_TESTING_ConnectPeersState::ac, GNUNET_TESTING_ConnectPeersState::additional_connects, connect_peers_cleanup(), connect_peers_run(), connect_peers_traits(), GNUNET_TESTING_ConnectPeersState::connected_peers_map, GNUNET_TESTING_ConnectPeersState::create_label, GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_TESTING_command_new(), GNUNET_TESTING_get_additional_connects(), GNUNET_YES, handlers, GNUNET_TESTING_ConnectPeersState::handlers, LOG, GNUNET_TESTING_ConnectPeersState::num, GNUNET_TESTING_ConnectPeersState::start_peer_label, GNUNET_TESTING_ConnectPeersState::topology, and GNUNET_TESTING_ConnectPeersState::wait_for_connect.

Here is the call graph for this function:

◆ GNUNET_CORE_TESTING_get_trait_connect_peer_state()

enum GNUNET_GenericReturnValue GNUNET_CORE_TESTING_get_trait_connect_peer_state ( const struct GNUNET_TESTING_Command cmd,
const struct GNUNET_TESTING_ConnectPeersState **  ret 
)

◆ GNUNET_CORE_TESTING_make_trait_connect_peer_state()

struct GNUNET_TESTING_Trait GNUNET_CORE_TESTING_make_trait_connect_peer_state ( const struct GNUNET_TESTING_ConnectPeersState value)

Referenced by connect_peers_traits().

Here is the caller graph for this function: