aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-08-07 15:02:38 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-08-07 15:02:38 +0000
commit962e3ae31715ab780f57d1392f8c730808a96155 (patch)
tree7228a80fd8f405027f85d850c62a81c6a8e560c2 /src/testbed
parenta0ebfc6a72f42eab9ce0859e0f2e565424cf2118 (diff)
downloadgnunet-962e3ae31715ab780f57d1392f8c730808a96155.tar.gz
gnunet-962e3ae31715ab780f57d1392f8c730808a96155.zip
working version of peer connect
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/Makefile.am1
-rw-r--r--src/testbed/gnunet-service-testbed.c289
-rw-r--r--src/testbed/test_testbed_api.conf3
-rw-r--r--src/testbed/test_testbed_api_2peers.c10
-rw-r--r--src/testbed/testbed_api.c2
5 files changed, 175 insertions, 130 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index 36ef3cae8..85e60dc59 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -23,6 +23,7 @@ gnunet_service_testbed_SOURCES = \
23gnunet_service_testbed_LDADD = $(XLIB) \ 23gnunet_service_testbed_LDADD = $(XLIB) \
24 $(top_builddir)/src/util/libgnunetutil.la \ 24 $(top_builddir)/src/util/libgnunetutil.la \
25 $(top_builddir)/src/core/libgnunetcore.la \ 25 $(top_builddir)/src/core/libgnunetcore.la \
26 $(top_builddir)/src/hello/libgnunethello.la \
26 $(top_builddir)/src/transport/libgnunettransport.la \ 27 $(top_builddir)/src/transport/libgnunettransport.la \
27 $(top_builddir)/src/testing/libgnunettesting.la \ 28 $(top_builddir)/src/testing/libgnunettesting.la \
28 $(top_builddir)/src/testbed/libgnunettestbed.la \ 29 $(top_builddir)/src/testbed/libgnunettestbed.la \
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 2aa22d213..4ca2c25ac 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -29,6 +29,7 @@
29#include "gnunet_server_lib.h" 29#include "gnunet_server_lib.h"
30#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
31#include "gnunet_core_service.h" 31#include "gnunet_core_service.h"
32#include "gnunet_hello_lib.h"
32#include <zlib.h> 33#include <zlib.h>
33 34
34#include "gnunet_testbed_service.h" 35#include "gnunet_testbed_service.h"
@@ -330,34 +331,49 @@ struct OverlayConnectContext
330 struct GNUNET_SERVER_Client *client; 331 struct GNUNET_SERVER_Client *client;
331 332
332 /** 333 /**
333 * peer 1 and peer2 334 * the peer which has to connect to the other peer
334 */ 335 */
335 struct Peer * peers[2]; 336 struct Peer *peer;
337
338 /**
339 * The other peer
340 */
341 struct Peer *other_peer;
336 342
337 /** 343 /**
338 * Transport handle of peers 344 * Transport handle of the first peer to offer second peer's HELLO
345 */
346 struct GNUNET_TRANSPORT_Handle *p1th;
347
348 /**
349 * Transport handle of other peer to get its HELLO
339 */ 350 */
340 struct GNUNET_TRANSPORT_Handle *peers_transport[2]; 351 struct GNUNET_TRANSPORT_Handle *p2th;
341 352
342 /** 353 /**
343 * Core handles of peers 354 * Core handles of the peer which has to connect to other peer
344 */ 355 */
345 struct GNUNET_CORE_Handle *peers_core[2]; 356 struct GNUNET_CORE_Handle *ch;
346 357
347 /** 358 /**
348 * HELLO of peers 359 * HELLO of the other peer
349 */ 360 */
350 struct GNUNET_MessageHeader *peers_hello[2]; 361 struct GNUNET_MessageHeader *hello;
351 362
352 /** 363 /**
353 * Get hello handle for peers 364 * Get hello handle for the other peer
354 */ 365 */
355 struct GNUNET_TRANSPORT_GetHelloHandle *peers_ghh[2]; 366 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
356 367
357 /** 368 /**
358 * The peer identity of peers 369 * The peer identity of the first peer
359 */ 370 */
360 struct GNUNET_PeerIdentity peers_identity[2]; 371 struct GNUNET_PeerIdentity peer_identity;
372
373 /**
374 * The peer identity of the other peer
375 */
376 struct GNUNET_PeerIdentity other_peer_identity;
361 377
362 /** 378 /**
363 * The id of the operation responsible for creating this context 379 * The id of the operation responsible for creating this context
@@ -365,6 +381,12 @@ struct OverlayConnectContext
365 uint64_t op_id; 381 uint64_t op_id;
366 382
367 /** 383 /**
384 * The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to
385 * connect to peer 2
386 */
387 GNUNET_SCHEDULER_TaskIdentifier send_hello_task;
388
389 /**
368 * State information for determining whose HELLOs have been successfully 390 * State information for determining whose HELLOs have been successfully
369 * exchanged 391 * exchanged
370 */ 392 */
@@ -374,23 +396,6 @@ struct OverlayConnectContext
374 396
375 397
376/** 398/**
377 * Wrapper around OverlayConnectContext
378 */
379struct OverlayConnectContextWrapper
380{
381 /**
382 * The overlay connect context
383 */
384 struct OverlayConnectContext *occ;
385
386 /**
387 * The peer number in reference; should be 0 or 1
388 */
389 unsigned int peer;
390};
391
392
393/**
394 * The master context; generated with the first INIT message 399 * The master context; generated with the first INIT message
395 */ 400 */
396static struct Context *master_context; 401static struct Context *master_context;
@@ -1543,7 +1548,27 @@ handle_peer_get_config (void *cls,
1543} 1548}
1544 1549
1545 1550
1551/**
1552 * Task for cleaing up overlay connect context structure
1553 *
1554 * @param cls the overlay connect context
1555 * @param tc the task context
1556 */
1557static void
1558occ_cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1559{
1560 struct OverlayConnectContext *occ = cls;
1546 1561
1562 if (NULL != occ->ch)
1563 GNUNET_CORE_disconnect (occ->ch);
1564 if (NULL != occ->ghh)
1565 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
1566 if (NULL != occ->p1th)
1567 GNUNET_TRANSPORT_disconnect (occ->p1th);
1568 if (NULL != occ->p2th)
1569 GNUNET_TRANSPORT_disconnect (occ->p2th);
1570 GNUNET_free (occ);
1571}
1547 1572
1548 1573
1549/** 1574/**
@@ -1561,22 +1586,18 @@ overlay_connect_notify (void *cls,
1561 const struct GNUNET_ATS_Information * ats, 1586 const struct GNUNET_ATS_Information * ats,
1562 unsigned int ats_count) 1587 unsigned int ats_count)
1563{ 1588{
1564 struct OverlayConnectContextWrapper *occw = cls; 1589 struct OverlayConnectContext *occ = cls;
1565 struct OverlayConnectContext *occ;
1566 struct GNUNET_TESTBED_ConnectionEventMessage *msg; 1590 struct GNUNET_TESTBED_ConnectionEventMessage *msg;
1567 char *new_peer_str; 1591 char *new_peer_str;
1568 char *other_peer_str; 1592 char *other_peer_str;
1569 unsigned int peer;
1570 1593
1571 LOG_DEBUG ("Overlay connect notify\n"); 1594 LOG_DEBUG ("Overlay connect notify\n");
1572 peer = occw->peer; 1595 if (0 == memcmp (new_peer, &occ->peer_identity,
1573 occ = occw->occ;
1574 if (0 == memcmp (new_peer, &occ->peers_identity[peer],
1575 sizeof (struct GNUNET_PeerIdentity))) 1596 sizeof (struct GNUNET_PeerIdentity)))
1576 return; 1597 return;
1577 new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer)); 1598 new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer));
1578 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->peers_identity[peer ^ 1])); 1599 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
1579 if (0 != memcmp (new_peer, &occ->peers_identity[peer ^ 1], 1600 if (0 != memcmp (new_peer, &occ->other_peer_identity,
1580 sizeof (struct GNUNET_PeerIdentity))) 1601 sizeof (struct GNUNET_PeerIdentity)))
1581 { 1602 {
1582 LOG_DEBUG ("Unexpected peer %4s connected to peer %4s\n", 1603 LOG_DEBUG ("Unexpected peer %4s connected to peer %4s\n",
@@ -1585,85 +1606,67 @@ overlay_connect_notify (void *cls,
1585 GNUNET_free (other_peer_str); 1606 GNUNET_free (other_peer_str);
1586 return; 1607 return;
1587 } 1608 }
1588 GNUNET_free (occw);
1589 LOG_DEBUG ("Peer %4s connected to peer %4s\n", new_peer_str, other_peer_str); 1609 LOG_DEBUG ("Peer %4s connected to peer %4s\n", new_peer_str, other_peer_str);
1590 GNUNET_free (new_peer_str); 1610 GNUNET_free (new_peer_str);
1591 GNUNET_free (other_peer_str); 1611 GNUNET_free (other_peer_str);
1592 GNUNET_TRANSPORT_disconnect (occ->peers_transport[peer]); 1612 if (GNUNET_SCHEDULER_NO_TASK != occ->send_hello_task)
1593 occ->peers_transport[peer] = NULL; 1613 {
1594 if (NULL != occ->peers_transport[peer ^ 1]) 1614 GNUNET_SCHEDULER_cancel (occ->send_hello_task);
1595 return; 1615 occ->send_hello_task = GNUNET_SCHEDULER_NO_TASK;
1596 /* Peers are connected - now send overlay connect success message */ 1616 }
1617 GNUNET_TRANSPORT_disconnect (occ->p1th);
1618 occ->p1th = NULL;
1619 /* Peer 1 has connected connect to peer2 - now send overlay connect success message */
1597 LOG_DEBUG ("Peers connected - Sending overlay connect success\n"); 1620 LOG_DEBUG ("Peers connected - Sending overlay connect success\n");
1598 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); 1621 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage));
1599 msg->header.size = htons (sizeof (struct 1622 msg->header.size = htons (sizeof (struct
1600 GNUNET_TESTBED_ConnectionEventMessage)); 1623 GNUNET_TESTBED_ConnectionEventMessage));
1601 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT); 1624 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT);
1602 msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); 1625 msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
1603 msg->peer1 = occ->peers[0]->id; 1626 msg->peer1 = htonl (occ->peer->id);
1604 msg->peer2 = occ->peers[1]->id; 1627 msg->peer2 = htonl (occ->other_peer->id);
1605 msg->operation_id = GNUNET_htonll (occ->op_id); 1628 msg->operation_id = GNUNET_htonll (occ->op_id);
1606 queue_message (occ->client, &msg->header); 1629 queue_message (occ->client, &msg->header);
1607 GNUNET_SERVER_client_drop (occ->client); 1630 GNUNET_SERVER_client_drop (occ->client);
1608 GNUNET_free (occ); 1631 GNUNET_SCHEDULER_add_now (&occ_cleanup, occ);
1609} 1632}
1610 1633
1611 1634
1612/**
1613 * For peers that haven't yet connected, send
1614 * CORE connect requests.
1615 *
1616 * @param cls the 'struct SendHelloContext *'
1617 * @param tc scheduler context
1618 */
1619static void 1635static void
1620send_core_connect_requests (void *cls, 1636send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1621 const struct GNUNET_SCHEDULER_TaskContext *tc)
1622{ 1637{
1623 struct OverlayConnectContext *occ = cls; 1638 struct OverlayConnectContext *occ = cls;
1624 unsigned int peer; 1639 char *other_peer_str;
1625 1640
1626 LOG_DEBUG ("Sending connect requests to transport\n"); 1641 occ->send_hello_task = GNUNET_SCHEDULER_NO_TASK;
1627 for (peer = 0; peer < 2; peer++) 1642 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1628 GNUNET_TRANSPORT_try_connect (occ->peers_transport[peer], 1643 return;
1629 &occ->peers_identity[peer ^ 1]); 1644 GNUNET_assert (NULL != occ->hello);
1645 other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
1646 LOG_DEBUG ("Offering HELLO of %s to %s\n", other_peer_str, GNUNET_i2s (&occ->peer_identity));
1647 GNUNET_free (other_peer_str);
1648 GNUNET_TRANSPORT_offer_hello (occ->p1th, occ->hello, NULL, NULL);
1649 GNUNET_TRANSPORT_try_connect (occ->p1th, &occ->other_peer_identity);
1650 occ->send_hello_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
1651 &send_hello, occ);
1630} 1652}
1631 1653
1632
1633/** 1654/**
1634 * Exchanges HELLO of peers among them 1655 * Test for checking whether HELLO message is empty
1635 * 1656 *
1636 * @param occ the OverlayConnectContext to look into for HELLO messages 1657 * @param cls empty flag to set
1658 * @param address the HELLO
1659 * @param expiration expiration of the HELLO
1660 * @return
1637 */ 1661 */
1638static void 1662static int
1639exchange_hellos (struct OverlayConnectContext *occ) 1663test_address (void *cls, const struct GNUNET_HELLO_Address *address,
1664 struct GNUNET_TIME_Absolute expiration)
1640{ 1665{
1641 struct GNUNET_CORE_MessageHandler no_handlers[] = { 1666 int *empty = cls;
1642 {NULL, 0, 0}
1643 };
1644 struct OverlayConnectContextWrapper *occw;
1645 unsigned int peer;
1646 1667
1647 GNUNET_assert (NULL != occ->peers_hello[0]); 1668 *empty = GNUNET_NO;
1648 GNUNET_assert (NULL != occ->peers_hello[1]); 1669 return GNUNET_OK;
1649 LOG_DEBUG ("Exchanging hellos\n");
1650 for (peer = 0; peer < 2; peer++)
1651 {
1652 GNUNET_TRANSPORT_offer_hello (occ->peers_transport[peer],
1653 occ->peers_hello[peer ^ 1],
1654 NULL, NULL);
1655 GNUNET_free (occ->peers_hello[peer ^ 1]);
1656 occ->peers_hello[peer ^ 1] = NULL;
1657 occw = GNUNET_malloc (sizeof (struct OverlayConnectContextWrapper));
1658 occw->occ = occ;
1659 occw->peer = peer;
1660 occ->peers_core[peer] =
1661 GNUNET_CORE_connect (occ->peers[peer]->cfg,
1662 occw, NULL, &overlay_connect_notify, NULL,
1663 NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers);
1664 }
1665 if ((NULL == occ->peers_hello[peer]) && (NULL == occ->peers_hello[peer ^ 1]))
1666 GNUNET_SCHEDULER_add_now (&send_core_connect_requests, occ);
1667} 1670}
1668 1671
1669 1672
@@ -1677,22 +1680,67 @@ exchange_hellos (struct OverlayConnectContext *occ)
1677static void 1680static void
1678hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) 1681hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
1679{ 1682{
1680 struct OverlayConnectContextWrapper *occw = cls; 1683 struct OverlayConnectContext *occ = cls;
1681 struct OverlayConnectContext *occ; 1684 int empty;
1682 unsigned int peer;
1683 uint16_t msize; 1685 uint16_t msize;
1684 1686
1685 msize = ntohs (hello->size); 1687 msize = ntohs (hello->size);
1686 peer = occw->peer; 1688 if (msize < 0)
1687 GNUNET_assert (peer <= 1); 1689 {
1688 occ = occw->occ; 1690 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1689 GNUNET_free (occw); 1691 "HELLO message of peer %s is of size 0\n",
1690 occ->peers_hello[peer] = GNUNET_malloc (msize); 1692 &occ->other_peer_identity);
1691 memcpy (occ->peers_hello[peer], hello, msize); 1693 return;
1692 GNUNET_TRANSPORT_get_hello_cancel (occ->peers_ghh[peer]); 1694 }
1693 occ->peers_ghh[peer] = NULL; 1695 empty = GNUNET_YES;
1694 if (NULL != occ->peers_hello[peer ^ 1]) 1696 (void)
1695 exchange_hellos (occ); 1697 GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *) hello,
1698 GNUNET_NO, &test_address, &empty);
1699 if (GNUNET_YES == empty)
1700 {
1701 LOG_DEBUG ("HELLO of %s is empty\n", GNUNET_i2s (&occ->other_peer_identity));
1702 return;
1703 }
1704 LOG_DEBUG ("Received HELLO of %s\n", GNUNET_i2s (&occ->other_peer_identity));
1705 occ->hello = GNUNET_malloc (msize);
1706 memcpy (occ->hello, hello, msize);
1707 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
1708 occ->ghh = NULL;
1709 GNUNET_TRANSPORT_disconnect (occ->p2th);
1710 occ->p2th = NULL;
1711 occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ);
1712}
1713
1714
1715/**
1716 * Function called after GNUNET_CORE_connect has succeeded (or failed
1717 * for good). Note that the private key of the peer is intentionally
1718 * not exposed here; if you need it, your process should try to read
1719 * the private key file directly (which should work if you are
1720 * authorized...).
1721 *
1722 * @param cls closure
1723 * @param server handle to the server, NULL if we failed
1724 * @param my_identity ID of this peer, NULL if we failed
1725 */
1726static void
1727core_startup_cb (void *cls, struct GNUNET_CORE_Handle * server,
1728 const struct GNUNET_PeerIdentity *my_identity)
1729{
1730 struct OverlayConnectContext *occ = cls;
1731
1732 memcpy (&occ->peer_identity, my_identity, sizeof (struct GNUNET_PeerIdentity));
1733 occ->p1th =
1734 GNUNET_TRANSPORT_connect (occ->peer->cfg, &occ->peer_identity, NULL, NULL,
1735 NULL, NULL);
1736 /* Connect to the transport of 2nd peer and get its HELLO message */
1737 GNUNET_TESTING_peer_get_identity (occ->other_peer->peer,
1738 &occ->other_peer_identity);
1739 occ->p2th =
1740 GNUNET_TRANSPORT_connect (occ->other_peer->cfg, &occ->other_peer_identity,
1741 NULL, NULL, NULL, NULL);
1742 LOG_DEBUG ("Acquiring HELLO of peer %s\n", GNUNET_i2s (&occ->other_peer_identity));
1743 occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p2th, &hello_update_cb, occ);
1696} 1744}
1697 1745
1698 1746
@@ -1710,8 +1758,9 @@ handle_overlay_connect (void *cls,
1710{ 1758{
1711 const struct GNUNET_TESTBED_OverlayConnectMessage *msg; 1759 const struct GNUNET_TESTBED_OverlayConnectMessage *msg;
1712 struct OverlayConnectContext *occ; 1760 struct OverlayConnectContext *occ;
1713 struct OverlayConnectContextWrapper *occw; 1761 struct GNUNET_CORE_MessageHandler no_handlers[] = {
1714 unsigned int peer; 1762 {NULL, 0, 0}
1763 };
1715 uint32_t p1; 1764 uint32_t p1;
1716 uint32_t p2; 1765 uint32_t p2;
1717 1766
@@ -1726,24 +1775,14 @@ handle_overlay_connect (void *cls,
1726 GNUNET_SERVER_client_keep (client); 1775 GNUNET_SERVER_client_keep (client);
1727 occ->client = client; 1776 occ->client = client;
1728 occ->state = OCC_STATE_INIT; 1777 occ->state = OCC_STATE_INIT;
1729 occ->peers[0] = peer_list[p1]; 1778 occ->peer = peer_list[p1];
1730 occ->peers[1] = peer_list[p2]; 1779 occ->other_peer = peer_list[p2];
1731 occ->op_id = GNUNET_ntohll (msg->operation_id); 1780 occ->op_id = GNUNET_ntohll (msg->operation_id);
1732 for (peer = 0; peer < 2; peer++) 1781 /* Connect to the core of 1st peer and wait for the 2nd peer to connect */
1733 { 1782 occ->ch =
1734 GNUNET_TESTING_peer_get_identity (occ->peers[peer]->peer, 1783 GNUNET_CORE_connect (occ->peer->cfg, occ, &core_startup_cb,
1735 &occ->peers_identity[peer]); 1784 &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL,
1736 occ->peers_transport[peer] = 1785 GNUNET_NO, no_handlers);
1737 GNUNET_TRANSPORT_connect (occ->peers[peer]->cfg,
1738 &occ->peers_identity[peer],
1739 NULL, NULL, NULL, NULL);
1740 occw = GNUNET_malloc (sizeof (struct OverlayConnectContextWrapper));
1741 occw->occ = occ;
1742 occw->peer = peer;
1743 occ->peers_ghh[peer] =
1744 GNUNET_TRANSPORT_get_hello (occ->peers_transport[peer],
1745 &hello_update_cb, occw);
1746 }
1747 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1786 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1748} 1787}
1749 1788
@@ -1926,7 +1965,7 @@ testbed_run (void *cls,
1926 */ 1965 */
1927int main (int argc, char *const *argv) 1966int main (int argc, char *const *argv)
1928{ 1967{
1929 //sleep (60); /* Debugging */ 1968 //sleep (30); /* Debugging */
1930 return 1969 return
1931 (GNUNET_OK == 1970 (GNUNET_OK ==
1932 GNUNET_SERVICE_run (argc, 1971 GNUNET_SERVICE_run (argc,
diff --git a/src/testbed/test_testbed_api.conf b/src/testbed/test_testbed_api.conf
index bf6c414b8..00b482d7c 100644
--- a/src/testbed/test_testbed_api.conf
+++ b/src/testbed/test_testbed_api.conf
@@ -38,9 +38,10 @@ WAN_QUOTA_IN = 3932160
38 38
39[core] 39[core]
40PORT = 12092 40PORT = 12092
41AUTOSTART = YES
41 42
42[arm] 43[arm]
43DEFAULTSERVICES = 44DEFAULTSERVICES = core
44PORT = 12366 45PORT = 12366
45DEBUG = NO 46DEBUG = NO
46 47
diff --git a/src/testbed/test_testbed_api_2peers.c b/src/testbed/test_testbed_api_2peers.c
index 781194bf4..0893afcfb 100644
--- a/src/testbed/test_testbed_api_2peers.c
+++ b/src/testbed/test_testbed_api_2peers.c
@@ -207,7 +207,7 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
207{ 207{
208 switch (event->type) 208 switch (event->type)
209 { 209 {
210 case GNUNET_TESTBED_ET_OPERATION_FINISHED: 210 case GNUNET_TESTBED_ET_OPERATION_FINISHED: /* Will be reached when we destroy peers */
211 GNUNET_assert (PEERS_STOPPED == result); 211 GNUNET_assert (PEERS_STOPPED == result);
212 GNUNET_assert (NULL == event->details.operation_finished.op_cls); 212 GNUNET_assert (NULL == event->details.operation_finished.op_cls);
213 GNUNET_assert (NULL == event->details.operation_finished.emsg); 213 GNUNET_assert (NULL == event->details.operation_finished.emsg);
@@ -229,8 +229,11 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
229 } 229 }
230 else 230 else
231 GNUNET_assert (0); 231 GNUNET_assert (0);
232 result = GNUNET_YES; 232 if ((NULL == peer1.peer) && (NULL == peer2.peer))
233 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 233 {
234 result = SUCCESS;
235 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
236 }
234 break; 237 break;
235 case GNUNET_TESTBED_ET_PEER_START: 238 case GNUNET_TESTBED_ET_PEER_START:
236 GNUNET_assert (INIT == result); 239 GNUNET_assert (INIT == result);
@@ -285,6 +288,7 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
285 GNUNET_TESTBED_operation_done (common_operation); 288 GNUNET_TESTBED_operation_done (common_operation);
286 common_operation = NULL; 289 common_operation = NULL;
287 result = PEERS_CONNECTED; 290 result = PEERS_CONNECTED;
291 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n");
288 peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer); 292 peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer);
289 peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer); 293 peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer);
290 break; 294 break;
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 7ca86ac8d..c8bab21cd 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -427,7 +427,7 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c,
427 data = opc->data; 427 data = opc->data;
428 GNUNET_assert (NULL != data); 428 GNUNET_assert (NULL != data);
429 GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id) 429 GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id)
430 && (ntohl (msg->peer2) == data->p2->unique_id)); 430 && (ntohl (msg->peer2) == data->p2->unique_id));
431 event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type); 431 event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type);
432 switch (event.type) 432 switch (event.type)
433 { 433 {