diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-30 17:29:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-30 17:29:00 +0000 |
commit | 24dc89edc8d7f9eb5f23cd3e804fd9732858fbee (patch) | |
tree | 8c2062b0309958537a8e2daca5ce448625250686 /src/core/test_core_quota_compliance.c | |
parent | fc0a7982cd82e6f1915589a89c61dbe9d58aedb3 (diff) | |
download | gnunet-24dc89edc8d7f9eb5f23cd3e804fd9732858fbee.tar.gz gnunet-24dc89edc8d7f9eb5f23cd3e804fd9732858fbee.zip |
converting core tests to hello_get API
Diffstat (limited to 'src/core/test_core_quota_compliance.c')
-rw-r--r-- | src/core/test_core_quota_compliance.c | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 04f79b959..01eafbfe0 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2015 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2015, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -27,6 +27,7 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_ats_service.h" | 28 | #include "gnunet_ats_service.h" |
29 | #include "gnunet_transport_service.h" | 29 | #include "gnunet_transport_service.h" |
30 | #include "gnunet_transport_hello_service.h" | ||
30 | #include "gnunet_statistics_service.h" | 31 | #include "gnunet_statistics_service.h" |
31 | 32 | ||
32 | 33 | ||
@@ -74,7 +75,7 @@ struct PeerContext | |||
74 | struct GNUNET_PeerIdentity id; | 75 | struct GNUNET_PeerIdentity id; |
75 | struct GNUNET_MessageHeader *hello; | 76 | struct GNUNET_MessageHeader *hello; |
76 | struct GNUNET_STATISTICS_Handle *stats; | 77 | struct GNUNET_STATISTICS_Handle *stats; |
77 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | 78 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh; |
78 | struct GNUNET_ATS_ConnectivityHandle *ats; | 79 | struct GNUNET_ATS_ConnectivityHandle *ats; |
79 | struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; | 80 | struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; |
80 | int connect_status; | 81 | int connect_status; |
@@ -124,7 +125,7 @@ terminate_peer (struct PeerContext *p) | |||
124 | } | 125 | } |
125 | if (NULL != p->ghh) | 126 | if (NULL != p->ghh) |
126 | { | 127 | { |
127 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 128 | GNUNET_TRANSPORT_hello_get_cancel (p->ghh); |
128 | p->ghh = NULL; | 129 | p->ghh = NULL; |
129 | } | 130 | } |
130 | if (NULL != p->oh) | 131 | if (NULL != p->oh) |
@@ -677,17 +678,26 @@ setup_peer (struct PeerContext *p, | |||
677 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); | 678 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); |
678 | p->cfg = GNUNET_CONFIGURATION_create (); | 679 | p->cfg = GNUNET_CONFIGURATION_create (); |
679 | p->arm_proc = | 680 | p->arm_proc = |
680 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 681 | GNUNET_OS_start_process (GNUNET_YES, |
682 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
681 | NULL, NULL, NULL, | 683 | NULL, NULL, NULL, |
682 | binary, | 684 | binary, |
683 | "gnunet-service-arm", | 685 | "gnunet-service-arm", |
684 | "-c", cfgname, NULL); | 686 | "-c", |
685 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 687 | cfgname, |
686 | p->stats = GNUNET_STATISTICS_create ("core", p->cfg); | 688 | NULL); |
687 | GNUNET_assert (p->stats != NULL); | 689 | GNUNET_assert (GNUNET_OK == |
690 | GNUNET_CONFIGURATION_load (p->cfg, | ||
691 | cfgname)); | ||
692 | p->stats = GNUNET_STATISTICS_create ("core", | ||
693 | p->cfg); | ||
694 | GNUNET_assert (NULL != p->stats); | ||
688 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); | 695 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); |
689 | GNUNET_assert (NULL != p->ats); | 696 | GNUNET_assert (NULL != p->ats); |
690 | p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, &process_hello, p); | 697 | p->ghh = GNUNET_TRANSPORT_hello_get (p->cfg, |
698 | GNUNET_TRANSPORT_AC_ANY, | ||
699 | &process_hello, | ||
700 | p); | ||
691 | GNUNET_free (binary); | 701 | GNUNET_free (binary); |
692 | } | 702 | } |
693 | 703 | ||
@@ -708,42 +718,59 @@ run (void *cls, | |||
708 | NULL); | 718 | NULL); |
709 | if (test == SYMMETRIC) | 719 | if (test == SYMMETRIC) |
710 | { | 720 | { |
711 | setup_peer (&p1, "test_core_quota_peer1.conf"); | 721 | setup_peer (&p1, |
712 | setup_peer (&p2, "test_core_quota_peer2.conf"); | 722 | "test_core_quota_peer1.conf"); |
723 | setup_peer (&p2, | ||
724 | "test_core_quota_peer2.conf"); | ||
713 | } | 725 | } |
714 | else if (test == ASYMMETRIC_SEND_LIMITED) | 726 | else if (test == ASYMMETRIC_SEND_LIMITED) |
715 | { | 727 | { |
716 | setup_peer (&p1, "test_core_quota_asymmetric_send_limit_peer1.conf"); | 728 | setup_peer (&p1, |
717 | setup_peer (&p2, "test_core_quota_asymmetric_send_limit_peer2.conf"); | 729 | "test_core_quota_asymmetric_send_limit_peer1.conf"); |
730 | setup_peer (&p2, | ||
731 | "test_core_quota_asymmetric_send_limit_peer2.conf"); | ||
718 | } | 732 | } |
719 | else if (test == ASYMMETRIC_RECV_LIMITED) | 733 | else if (test == ASYMMETRIC_RECV_LIMITED) |
720 | { | 734 | { |
721 | setup_peer (&p1, "test_core_quota_asymmetric_recv_limited_peer1.conf"); | 735 | setup_peer (&p1, |
722 | setup_peer (&p2, "test_core_quota_asymmetric_recv_limited_peer2.conf"); | 736 | "test_core_quota_asymmetric_recv_limited_peer1.conf"); |
737 | setup_peer (&p2, | ||
738 | "test_core_quota_asymmetric_recv_limited_peer2.conf"); | ||
723 | } | 739 | } |
724 | 740 | ||
725 | GNUNET_assert (test != -1); | 741 | GNUNET_assert (test != -1); |
726 | GNUNET_assert (GNUNET_SYSERR != | 742 | GNUNET_assert (GNUNET_SYSERR != |
727 | GNUNET_CONFIGURATION_get_value_size (p1.cfg, "ATS", | 743 | GNUNET_CONFIGURATION_get_value_size (p1.cfg, |
744 | "ATS", | ||
728 | "WAN_QUOTA_IN", | 745 | "WAN_QUOTA_IN", |
729 | ¤t_quota_p1_in)); | 746 | ¤t_quota_p1_in)); |
730 | GNUNET_assert (GNUNET_SYSERR != | 747 | GNUNET_assert (GNUNET_SYSERR != |
731 | GNUNET_CONFIGURATION_get_value_size (p2.cfg, "ATS", | 748 | GNUNET_CONFIGURATION_get_value_size (p2.cfg, |
749 | "ATS", | ||
732 | "WAN_QUOTA_IN", | 750 | "WAN_QUOTA_IN", |
733 | ¤t_quota_p2_in)); | 751 | ¤t_quota_p2_in)); |
734 | GNUNET_assert (GNUNET_SYSERR != | 752 | GNUNET_assert (GNUNET_SYSERR != |
735 | GNUNET_CONFIGURATION_get_value_size (p1.cfg, "ATS", | 753 | GNUNET_CONFIGURATION_get_value_size (p1.cfg, |
754 | "ATS", | ||
736 | "WAN_QUOTA_OUT", | 755 | "WAN_QUOTA_OUT", |
737 | ¤t_quota_p1_out)); | 756 | ¤t_quota_p1_out)); |
738 | GNUNET_assert (GNUNET_SYSERR != | 757 | GNUNET_assert (GNUNET_SYSERR != |
739 | GNUNET_CONFIGURATION_get_value_size (p2.cfg, "ATS", | 758 | GNUNET_CONFIGURATION_get_value_size (p2.cfg, |
759 | "ATS", | ||
740 | "WAN_QUOTA_OUT", | 760 | "WAN_QUOTA_OUT", |
741 | ¤t_quota_p2_out)); | 761 | ¤t_quota_p2_out)); |
742 | 762 | ||
743 | p1.ch = | 763 | p1.ch = |
744 | GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, | 764 | GNUNET_CORE_connect (p1.cfg, |
745 | &disconnect_notify, &inbound_notify, GNUNET_YES, | 765 | &p1, |
746 | &outbound_notify, GNUNET_YES, handlers); | 766 | &init_notify, |
767 | &connect_notify, | ||
768 | &disconnect_notify, | ||
769 | &inbound_notify, | ||
770 | GNUNET_YES, | ||
771 | &outbound_notify, | ||
772 | GNUNET_YES, | ||
773 | handlers); | ||
747 | } | 774 | } |
748 | 775 | ||
749 | 776 | ||