2 This file is part of GNUnet.
3 Copyright (C) 2010-2015 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
21 * @file ats/test_ats_reservation_api.c
22 * @brief test ATS bandwidth reservation API
23 * @author Christian Grothoff
26 #include "test_ats_lib.h"
29 * Global timeout for the testcase.
31 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
34 * Definition of the test as a sequence of commands.
36 static struct Command test_commands[] = {
37 /* 0: add initial address */
39 .code = CMD_ADD_ADDRESS,
40 .label = "add-address-0-0",
41 .details.add_address = {
46 /* use network with 65k quota! */
47 .scope = GNUNET_NT_WAN
55 /* 1: some solver still require explicit start */
57 .code = CMD_REQUEST_CONNECTION_START,
59 .details.request_connection_start = {
65 /* 2: check we got an address */
67 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
68 .details.await_address_suggestion = {
69 .add_label = "add-address-0-0"
74 /* 3: sleep 7s, should give us 5s * 64k/s = 320k buffer;
75 Note that this depends on MAX_BANDWIDTH_CARRY_S. We
76 sleep more than 5s to show that only MAX_BANDWIDTH carries. */
80 .details.sleep.delay = { 7 * 1000LL * 1000LL }
82 /* 4: reserve 128k -- should work (5s carry, so we had 320k) */
84 .code = CMD_RESERVE_BANDWIDTH,
85 .details.reserve_bandwidth = {
88 .expected_result = GNUNET_YES
93 /* 5: reserve another 192k -- should just work (now exactly pushing the limit) */
95 .code = CMD_RESERVE_BANDWIDTH,
96 .label = "big reservation",
97 .details.reserve_bandwidth = {
100 .expected_result = GNUNET_YES
105 /* 6: reserve another 32k -- should now fail (if MAX_BANDWIDTH_CARRY_S
106 is precisely observed) */
108 .code = CMD_RESERVE_BANDWIDTH,
109 .label = "failing reservation",
110 .details.reserve_bandwidth = {
113 .expected_result = GNUNET_SYSERR
118 /* 7: sleep 3s, should give us 3s * 64k/s - 32k = 160k buffer */
122 .details.sleep.delay = { 6 * 1000LL * 1000LL }
124 /* 8: reserve another 160k -- should now work */
126 .code = CMD_RESERVE_BANDWIDTH,
127 .label = "successful final reservation",
128 .details.reserve_bandwidth = {
130 .amount = 160 * 1024,
131 .expected_result = GNUNET_YES
136 /* 9: remove address */
138 .code = CMD_DEL_ADDRESS,
139 .details.del_address = {
140 .add_label = "add-address-0-0"
145 /* 10: check we got disconnected */
147 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
148 .details.await_disconnect_suggestion = {
154 /* 11: just for symmetry, also stop asking for the connection */
156 .code = CMD_REQUEST_CONNECTION_STOP,
157 .details.request_connection_stop = {
158 .connect_label = "request-0",
163 /* Test ends successfully */
174 return TEST_ATS_run (argc,
181 /* end of file test_ats_reservation_api.c */