summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2019-02-17 00:00:00 +0000
committerzugz (tox) <mbays+tox@sdf.org>2019-05-19 18:51:28 +0200
commit306dd1f21f25d65ffd1c289d28e4450695c83745 (patch)
tree89d91af3ef10a29ae8a8a9ead0d5d7ea15619389 /auto_tests
parentd26b11d0c263bd796762374154edc7386dd601d4 (diff)
add configurable limit on number of stored frozen peers
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/conference_test.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c
index 5f08b823..ec88c82a 100644
--- a/auto_tests/conference_test.c
+++ b/auto_tests/conference_test.c
@@ -10,6 +10,8 @@
10#include <time.h> 10#include <time.h>
11#include <stdint.h> 11#include <stdint.h>
12 12
13#include "../toxcore/util.h"
14
13#include "check_compat.h" 15#include "check_compat.h"
14 16
15#define NUM_GROUP_TOX 16 17#define NUM_GROUP_TOX 16
@@ -199,6 +201,18 @@ static void run_conference_tests(Tox **toxes, State *state)
199 * fails due to disconnections too short to trigger freezing */ 201 * fails due to disconnections too short to trigger freezing */
200 const bool check_name_change_propagation = false; 202 const bool check_name_change_propagation = false;
201 203
204 /* each peer should freeze at least its two friends, but freezing more
205 * should not be necessary */
206 const uint32_t max_frozen = max_u32(2, NUM_DISCONNECT / 2);
207 printf("restricting number of frozen peers to %u\n", max_frozen);
208
209 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
210 Tox_Err_Conference_Set_Max_Offline err;
211 tox_conference_set_max_offline(toxes[i], 0, max_frozen, &err);
212 ck_assert_msg(err == TOX_ERR_CONFERENCE_SET_MAX_OFFLINE_OK,
213 "tox #%u failed to set max offline: err = %d", state[i].index, err);
214 }
215
202 printf("letting random toxes timeout\n"); 216 printf("letting random toxes timeout\n");
203 bool disconnected[NUM_GROUP_TOX] = {0}; 217 bool disconnected[NUM_GROUP_TOX] = {0};
204 bool restarting[NUM_GROUP_TOX] = {0}; 218 bool restarting[NUM_GROUP_TOX] = {0};
@@ -243,6 +257,7 @@ static void run_conference_tests(Tox **toxes, State *state)
243 free(save[i]); 257 free(save[i]);
244 258
245 set_mono_time_callback(toxes[i], &state[i]); 259 set_mono_time_callback(toxes[i], &state[i]);
260 tox_conference_set_max_offline(toxes[i], 0, max_frozen, nullptr);
246 } 261 }
247 } 262 }
248 263
@@ -256,6 +271,13 @@ static void run_conference_tests(Tox **toxes, State *state)
256 } 271 }
257 } 272 }
258 273
274 for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
275 const uint32_t num_frozen = tox_conference_offline_peer_count(toxes[i], 0, nullptr);
276 ck_assert_msg(num_frozen <= max_frozen,
277 "tox #%u has too many offline peers: %u\n",
278 state[i].index, num_frozen);
279 }
280
259 printf("reconnecting toxes\n"); 281 printf("reconnecting toxes\n");
260 282
261 do { 283 do {