#include "gnunet_server_lib.h"
#include "gnunet_transport_service.h"
#include "transport.h"
+#include "transport-testing.h"
#define VERBOSE GNUNET_NO
#define MTYPE 11111
-struct PeerContext
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- struct GNUNET_TRANSPORT_Handle *th;
- struct GNUNET_PeerIdentity id;
-#if START_ARM
- struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
/**
* Handle for a transmission-ready request.
*/
{
const struct TestMessage *hdr;
+ GNUNET_assert (message != NULL);
hdr = (const struct TestMessage*) message;
if (measurement_running == GNUNET_NO)
return;
memset (&cbuf[ret], last_msg_sent, s - sizeof (struct TestMessage));
ret += s - sizeof (struct TestMessage);
#if DEBUG_MEASUREMENT
- if (n % 5000 == 0)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending message %u\n",n);
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending message %u\n",
+ last_msg_sent);
#endif
-
- /* GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending message %u\n",last_msg_sent);*/
-
s = get_size ();
if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
break; /* sometimes pack buffer full, sometimes not */
{
struct PeerContext *me = cls;
+ GNUNET_assert (message != NULL);
+#if DEBUG_CONNECTIONS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Exchanging HELLO of size %d with peer (%s)!\n",
(int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
GNUNET_i2s (&me->id));
- GNUNET_assert (message != NULL);
+#endif
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
message, &me->id));
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
message, &me->id));
+#if DEBUG_CONNECTIONS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Exchanging HELLO of size %d from peer %s!\n",
(int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
GNUNET_i2s (&me->id));
+#endif
GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
}
}
if (connected == 2)
{
- GNUNET_SCHEDULER_cancel (tct);
- tct = GNUNET_SCHEDULER_NO_TASK;
+ if (GNUNET_SCHEDULER_NO_TASK != tct)
+ {
+ GNUNET_SCHEDULER_cancel (tct);
+ tct = GNUNET_SCHEDULER_NO_TASK;
+ }
GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
if (is_asymmetric_send_constant == GNUNET_YES)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
+ if (cls == &p2)
+ {
+ if (NULL != transmit_handle)
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle);
+ transmit_handle = NULL;
+ }
+ }
connected--;
#if DEBUG_CONNECTIONS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
setup_peer (struct PeerContext *p, const char *cfgname)
{
p->cfg = GNUNET_CONFIGURATION_create ();
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+ {
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
+ GNUNET_DISK_directory_remove (p->servicehome);
+ }
+
#if START_ARM
p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
"gnunet-service-arm",
"-c", cfgname, NULL);
#endif
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
p,
¬ify_receive_new,
try_connect (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+#if DEBUG_CONNECTIONS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking peers to connect...\n");
+#endif
GNUNET_TRANSPORT_try_connect (p2.th,
&p1.id);
GNUNET_TRANSPORT_try_connect (p1.th,
main (int argc, char *argv[])
{
int ret = 0;
-#ifdef MINGW
- return GNUNET_SYSERR;
-#endif
if (strstr(argv[0], "tcp_nat") != NULL)
{
is_tcp_nat = GNUNET_YES;
GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none");
}
- GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
- GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
-
fprintf(stderr, "Running `%s'\n", logger);
GNUNET_log_setup ("test-quota-compliance",
#if VERBOSE
ret = ok;
stop_arm (&p1);
stop_arm (&p2);
+
+ if (p1.servicehome != NULL)
+ {
+ GNUNET_DISK_directory_remove (p1.servicehome);
+ GNUNET_free(p1.servicehome);
+ }
+ if (p2.servicehome != NULL)
+ {
+ GNUNET_DISK_directory_remove (p2.servicehome);
+ GNUNET_free(p2.servicehome);
+ }
GNUNET_free(logger);
- GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
- GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
return ret;
}