+ /* Create configuration and call testing lib to modify it */
+ p->cfg = GNUNET_CONFIGURATION_create ();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+ if (GNUNET_SYSERR ==
+ GNUNET_TESTING_configuration_create (tth->tl_system,
+ p->cfg))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Testing library failed to create unique configuration based on `%s'\n",
+ cfgname);
+ GNUNET_CONFIGURATION_destroy (p->cfg);
+ GNUNET_free (p);
+ return NULL;
+ }
+
+ p->no = peer_id;
+ /* Configure peer with configuration */
+ p->peer = GNUNET_TESTING_peer_configure (tth->tl_system,
+ p->cfg,
+ p->no,
+ NULL,
+ &emsg);
+ if (NULL == p->peer)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Testing library failed to create unique configuration based on `%s': `%s'\n",
+ cfgname,
+ emsg);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
+ GNUNET_free_non_null (emsg);
+ return NULL;
+ }
+ GNUNET_free_non_null (emsg);
+ if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Testing library failed to create unique configuration based on `%s'\n",
+ cfgname);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
+ return NULL;
+ }
+
+ memset (&dummy,
+ '\0',
+ sizeof (dummy));
+ GNUNET_TESTING_peer_get_identity (p->peer,
+ &p->id);
+ if (0 == memcmp (&dummy,
+ &p->id,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Testing library failed to obtain peer identity for peer %u\n",
+ p->no);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
+ return NULL;
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u configured with identity `%s'\n",
+ p->no,
+ GNUNET_i2s_full (&p->id));
+ p->tmh = GNUNET_TRANSPORT_manipulation_connect (p->cfg);
+ p->th = GNUNET_TRANSPORT_core_connect (p->cfg,
+ NULL,
+ handlers,
+ p,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ NULL);
+ if ( (NULL == p->th) ||
+ (NULL == p->tmh) )
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to transport service for peer `%s': `%s'\n",
+ cfgname,
+ emsg);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
+ return NULL;
+ }
+ p->ats = GNUNET_ATS_connectivity_init (p->cfg);
+ if (NULL == p->ats)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to connect to ATS service for peer `%s': `%s'\n",
+ cfgname,
+ emsg);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
+ return NULL;
+ }
+ p->ghh = GNUNET_TRANSPORT_hello_get (p->cfg,
+ GNUNET_TRANSPORT_AC_ANY,
+ &get_hello,
+ p);
+ GNUNET_assert (NULL != p->ghh);