summaryrefslogtreecommitdiff
path: root/src/transport/transport_api_cmd_connecting_peers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport_api_cmd_connecting_peers.c')
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 34b3d5925..09ca9e54c 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -42,6 +42,15 @@
*/
struct ConnectPeersState
{
+ // Label of the cmd which started the test system.
+ const char *create_label;
+
+ /**
+ * Number globally identifying the node.
+ *
+ */
+ uint32_t num;
+
/**
* Label of the cmd to start a peer.
*
@@ -66,6 +75,13 @@ connect_peers_run (void *cls,
struct GNUNET_TESTING_Interpreter *is)
{
struct ConnectPeersState *cps = cls;
+ const struct GNUNET_TESTING_Command *system_cmd;
+ struct GNUNET_TESTING_System *tl_system;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct
+ GNUNET_CRYPTO_EddsaPrivateKey);
+ struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
+ GNUNET_CRYPTO_EddsaPublicKey);
+ ;
const struct GNUNET_TESTING_Command *peer1_cmd;
// const struct GNUNET_TESTING_Command *peer2_cmd;
struct GNUNET_TRANSPORT_ApplicationHandle *ah;
@@ -77,6 +93,8 @@ connect_peers_run (void *cls,
enum GNUNET_NetworkType nt = 0;
char *peer_id;
struct GNUNET_PeerIdentity *id;
+ struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity);
+ uint32_t num;
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
@@ -88,9 +106,22 @@ connect_peers_run (void *cls,
GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
&id);
- if (strstr (hello, "60002") != NULL)
+ system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label);
+ GNUNET_TESTING_get_trait_test_system (system_cmd,
+ &tl_system);
+
+ if (2 == cps->num)
+ num = 1;
+ else
+ num = 2;
+
+
+
+
+ // if (strstr (hello, "60002") != NULL)
+ if (2 == num)
{
- addr = "tcp-192.168.15.2:60003";
+ addr = "tcp-192.168.15.2:60002";
peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG";
}
else
@@ -99,10 +130,25 @@ connect_peers_run (void *cls,
peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730";
}
+ priv_key = GNUNET_TESTING_hostkey_get (tl_system,
+ num,
+ other);
+
+ GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
+ pub_key);
+
GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
strlen (peer_id),
&peer->public_key);
+ peer->public_key = *pub_key;
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "\nnum: %u\n peer_id: %s\n pub_key %s\n",
+ num,
+ peer_id,
+ GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key));
+
cps->id = peer;
// TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers.
@@ -210,12 +256,16 @@ connect_peers_cleanup (void *cls,
*/
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
- const char *start_peer_label)
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num)
{
struct ConnectPeersState *cps;
cps = GNUNET_new (struct ConnectPeersState);
cps->start_peer_label = start_peer_label;
+ cps->num = num;
+ cps->create_label = create_label;
struct GNUNET_TESTING_Command cmd = {