2 * Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include "internal/quic_fc.h"
11 #include "internal/quic_error.h"
14 static int test_txfc(int is_stream)
17 QUIC_TXFC conn_txfc, stream_txfc, *txfc, *parent_txfc;
19 if (!TEST_true(ossl_quic_txfc_init(&conn_txfc, 0)))
22 if (is_stream && !TEST_true(ossl_quic_txfc_init(&stream_txfc, &conn_txfc)))
25 txfc = is_stream ? &stream_txfc : &conn_txfc;
26 parent_txfc = is_stream ? &conn_txfc : NULL;
28 if (!TEST_true(ossl_quic_txfc_bump_cwm(txfc, 2000)))
31 if (is_stream && !TEST_true(ossl_quic_txfc_bump_cwm(parent_txfc, 2000)))
34 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_swm(txfc), 0))
37 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_cwm(txfc), 2000))
40 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit_local(txfc, 0), 2000))
43 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit_local(txfc, 100), 1900))
47 if ( !TEST_uint64_t_eq(ossl_quic_txfc_get_credit(txfc, 0), 2000))
50 if ( !TEST_uint64_t_eq(ossl_quic_txfc_get_credit(txfc, 100), 1900))
54 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
57 if (!TEST_true(ossl_quic_txfc_consume_credit(txfc, 500)))
60 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit_local(txfc, 0), 1500))
63 if (is_stream && !TEST_uint64_t_eq(ossl_quic_txfc_get_credit(txfc, 0),
67 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
70 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_swm(txfc), 500))
73 if (!TEST_true(ossl_quic_txfc_consume_credit(txfc, 100)))
76 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_swm(txfc), 600))
79 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit_local(txfc, 0), 1400))
82 if (is_stream && !TEST_uint64_t_eq(ossl_quic_txfc_get_credit(txfc, 0),
86 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
89 if (!TEST_true(ossl_quic_txfc_consume_credit(txfc, 1400)))
92 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit_local(txfc, 0), 0))
95 if (is_stream && !TEST_uint64_t_eq(ossl_quic_txfc_get_credit(txfc, 0),
99 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_swm(txfc), 2000))
102 if (!TEST_true(ossl_quic_txfc_has_become_blocked(txfc, 0)))
105 if (!TEST_true(ossl_quic_txfc_has_become_blocked(txfc, 0)))
108 if (!TEST_true(ossl_quic_txfc_has_become_blocked(txfc, 1)))
111 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
114 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
117 if (!TEST_false(ossl_quic_txfc_consume_credit(txfc, 1)))
120 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_cwm(txfc), 2000))
123 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_swm(txfc), 2000))
126 if (!TEST_false(ossl_quic_txfc_bump_cwm(txfc, 2000)))
129 if (!TEST_true(ossl_quic_txfc_bump_cwm(txfc, 2500)))
132 if (is_stream && !TEST_true(ossl_quic_txfc_bump_cwm(parent_txfc, 2400)))
135 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_cwm(txfc), 2500))
138 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_swm(txfc), 2000))
141 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit_local(txfc, 0), 500))
145 ossl_quic_txfc_has_become_blocked(parent_txfc, 1);
148 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit(txfc, 400), 0))
151 if (!TEST_true(ossl_quic_txfc_consume_credit(txfc, 399)))
154 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
157 if (!TEST_uint64_t_eq(ossl_quic_txfc_get_credit(txfc, 0), 1))
160 if (!TEST_true(ossl_quic_txfc_consume_credit(txfc, 1)))
163 if (!TEST_true(ossl_quic_txfc_has_become_blocked(parent_txfc, 0)))
166 if (!TEST_true(ossl_quic_txfc_has_become_blocked(parent_txfc, 1)))
169 if (!TEST_false(ossl_quic_txfc_has_become_blocked(parent_txfc, 0)))
172 if (!TEST_true(ossl_quic_txfc_consume_credit(txfc, 499)))
175 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
178 if (is_stream && !TEST_false(ossl_quic_txfc_has_become_blocked(parent_txfc, 0)))
181 if (!TEST_true(ossl_quic_txfc_consume_credit(txfc, 1)))
184 if (!TEST_true(ossl_quic_txfc_has_become_blocked(txfc, 0)))
187 if (!TEST_true(ossl_quic_txfc_has_become_blocked(txfc, 1)))
190 if (!TEST_false(ossl_quic_txfc_has_become_blocked(txfc, 0)))
199 static OSSL_TIME cur_time;
201 static OSSL_TIME fake_now(void *arg)
207 #define RX_OPC_INIT_CONN 1 /* arg0=initial window, arg1=max window */
208 #define RX_OPC_INIT_STREAM 2 /* arg0=initial window, arg1=max window */
209 #define RX_OPC_RX 3 /* arg0=end, arg1=is_fin */
210 #define RX_OPC_RETIRE 4 /* arg0=num_bytes, arg1=rtt in OSSL_TIME ticks, expect_fail */
211 #define RX_OPC_CHECK_CWM_CONN 5 /* arg0=expected */
212 #define RX_OPC_CHECK_CWM_STREAM 6 /* arg0=expected */
213 #define RX_OPC_CHECK_SWM_CONN 7 /* arg0=expected */
214 #define RX_OPC_CHECK_SWM_STREAM 8 /* arg0=expected */
215 #define RX_OPC_CHECK_RWM_CONN 9 /* arg0=expected */
216 #define RX_OPC_CHECK_RWM_STREAM 10 /* arg0=expected */
217 #define RX_OPC_CHECK_CHANGED_CONN 11 /* arg0=expected, arg1=clear */
218 #define RX_OPC_CHECK_CHANGED_STREAM 12 /* arg0=expected, arg1=clear */
219 #define RX_OPC_CHECK_ERROR_CONN 13 /* arg0=expected, arg1=clear */
220 #define RX_OPC_CHECK_ERROR_STREAM 14 /* arg0=expected, arg1=clear */
221 #define RX_OPC_STEP_TIME 15 /* arg0=OSSL_TIME ticks to advance */
222 #define RX_OPC_MSG 16
228 unsigned char expect_fail;
234 #define RX_OP_INIT_CONN(init_window_size, max_window_size) \
235 { RX_OPC_INIT_CONN, 0, (init_window_size), (max_window_size) },
236 #define RX_OP_INIT_STREAM(stream_idx, init_window_size, max_window_size) \
237 { RX_OPC_INIT_STREAM, (stream_idx), (init_window_size), (max_window_size) },
238 #define RX_OP_RX(stream_idx, end, is_fin) \
239 { RX_OPC_RX, (stream_idx), (end), (is_fin) },
240 #define RX_OP_RETIRE(stream_idx, num_bytes, rtt, expect_fail) \
241 { RX_OPC_RETIRE, (stream_idx), (num_bytes), (rtt), (expect_fail) },
242 #define RX_OP_CHECK_CWM_CONN(expected) \
243 { RX_OPC_CHECK_CWM_CONN, 0, (expected) },
244 #define RX_OP_CHECK_CWM_STREAM(stream_id, expected) \
245 { RX_OPC_CHECK_CWM_STREAM, (stream_id), (expected) },
246 #define RX_OP_CHECK_SWM_CONN(expected) \
247 { RX_OPC_CHECK_SWM_CONN, 0, (expected) },
248 #define RX_OP_CHECK_SWM_STREAM(stream_id, expected) \
249 { RX_OPC_CHECK_SWM_STREAM, (stream_id), (expected) },
250 #define RX_OP_CHECK_RWM_CONN(expected) \
251 { RX_OPC_CHECK_RWM_CONN, 0, (expected) },
252 #define RX_OP_CHECK_RWM_STREAM(stream_id, expected) \
253 { RX_OPC_CHECK_RWM_STREAM, (stream_id), (expected) },
254 #define RX_OP_CHECK_CHANGED_CONN(expected, clear) \
255 { RX_OPC_CHECK_CHANGED_CONN, 0, (expected), (clear) },
256 #define RX_OP_CHECK_CHANGED_STREAM(stream_id, expected, clear) \
257 { RX_OPC_CHECK_CHANGED_STREAM, (stream_id), (expected), (clear) },
258 #define RX_OP_CHECK_ERROR_CONN(expected, clear) \
259 { RX_OPC_CHECK_ERROR_CONN, 0, (expected), (clear) },
260 #define RX_OP_CHECK_ERROR_STREAM(stream_id, expected, clear) \
261 { RX_OPC_CHECK_ERROR_STREAM, (stream_id), (expected), (clear) },
262 #define RX_OP_STEP_TIME(t) \
263 { RX_OPC_STEP_TIME, 0, (t) },
264 #define RX_OP_MSG(msg) \
265 { RX_OPC_MSG, 0, 0, 0, 0, (msg) },
267 #define RX_OP_INIT(init_window_size, max_window_size) \
268 RX_OP_INIT_CONN(init_window_size, max_window_size) \
269 RX_OP_INIT_STREAM(0, init_window_size, max_window_size)
270 #define RX_OP_CHECK_CWM(expected) \
271 RX_OP_CHECK_CWM_CONN(expected) \
272 RX_OP_CHECK_CWM_STREAM(0, expected)
273 #define RX_OP_CHECK_SWM(expected) \
274 RX_OP_CHECK_SWM_CONN(expected) \
275 RX_OP_CHECK_SWM_STREAM(0, expected)
276 #define RX_OP_CHECK_RWM(expected) \
277 RX_OP_CHECK_RWM_CONN(expected) \
278 RX_OP_CHECK_RWM_STREAM(0, expected)
279 #define RX_OP_CHECK_CHANGED(expected, clear) \
280 RX_OP_CHECK_CHANGED_CONN(expected, clear) \
281 RX_OP_CHECK_CHANGED_STREAM(0, expected, clear)
282 #define RX_OP_CHECK_ERROR(expected, clear) \
283 RX_OP_CHECK_ERROR_CONN(expected, clear) \
284 RX_OP_CHECK_ERROR_STREAM(0, expected, clear)
286 #define INIT_WINDOW_SIZE (1 * 1024 * 1024)
287 #define INIT_S_WINDOW_SIZE (384 * 1024)
289 /* 1. Basic RXFC Tests (stream window == connection window) */
290 static const struct rx_test_op rx_script_1[] = {
291 RX_OP_STEP_TIME(1000 * OSSL_TIME_MS)
292 RX_OP_INIT(INIT_WINDOW_SIZE, 10 * INIT_WINDOW_SIZE)
293 /* Check initial state. */
294 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE)
295 RX_OP_CHECK_ERROR(0, 0)
296 RX_OP_CHECK_CHANGED(0, 0)
297 /* We cannot retire what we have not received. */
298 RX_OP_RETIRE(0, 1, 0, 1)
299 /* Zero bytes is a no-op and always valid. */
300 RX_OP_RETIRE(0, 0, 0, 0)
301 /* Consume some window. */
303 /* CWM has not changed. */
304 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE)
307 /* RX, Partial retire */
310 RX_OP_RETIRE(0, 20, 50 * OSSL_TIME_MS, 0)
313 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE)
314 RX_OP_CHECK_CHANGED(0, 0)
315 RX_OP_CHECK_ERROR(0, 0)
318 RX_OP_RETIRE(0, 41, 0, 1)
319 RX_OP_RETIRE(0, 40, 0, 0)
322 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE)
323 RX_OP_CHECK_CHANGED(0, 0)
324 RX_OP_CHECK_ERROR(0, 0)
326 /* Exhaustion of window - we do not enlarge the window this epoch */
327 RX_OP_STEP_TIME(201 * OSSL_TIME_MS)
328 RX_OP_RX(0, INIT_WINDOW_SIZE, 0)
329 RX_OP_RETIRE(0, INIT_WINDOW_SIZE - 60, 50 * OSSL_TIME_MS, 0)
330 RX_OP_CHECK_SWM(INIT_WINDOW_SIZE)
331 RX_OP_CHECK_CHANGED(1, 0)
332 RX_OP_CHECK_CHANGED(1, 1)
333 RX_OP_CHECK_CHANGED(0, 0)
334 RX_OP_CHECK_ERROR(0, 0)
335 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE * 2)
337 /* Second epoch - we still do not enlarge the window this epoch */
338 RX_OP_RX(0, INIT_WINDOW_SIZE + 1, 0)
339 RX_OP_STEP_TIME(201 * OSSL_TIME_MS)
340 RX_OP_RX(0, INIT_WINDOW_SIZE * 2, 0)
341 RX_OP_RETIRE(0, INIT_WINDOW_SIZE, 50 * OSSL_TIME_MS, 0)
342 RX_OP_CHECK_SWM(INIT_WINDOW_SIZE * 2)
343 RX_OP_CHECK_CHANGED(1, 0)
344 RX_OP_CHECK_CHANGED(1, 1)
345 RX_OP_CHECK_CHANGED(0, 0)
346 RX_OP_CHECK_ERROR(0, 0)
347 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE * 3)
349 /* Third epoch - we enlarge the window */
350 RX_OP_RX(0, INIT_WINDOW_SIZE * 2 + 1, 0)
351 RX_OP_STEP_TIME(199 * OSSL_TIME_MS)
352 RX_OP_RX(0, INIT_WINDOW_SIZE * 3, 0)
353 RX_OP_RETIRE(0, INIT_WINDOW_SIZE, 50 * OSSL_TIME_MS, 0)
354 RX_OP_CHECK_SWM(INIT_WINDOW_SIZE * 3)
355 RX_OP_CHECK_CHANGED(1, 0)
356 RX_OP_CHECK_CHANGED(1, 1)
357 RX_OP_CHECK_CHANGED(0, 0)
358 RX_OP_CHECK_ERROR(0, 0)
359 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE * 5)
361 /* Fourth epoch - peer violates flow control */
362 RX_OP_RX(0, INIT_WINDOW_SIZE * 5 - 5, 0)
363 RX_OP_STEP_TIME(250 * OSSL_TIME_MS)
364 RX_OP_RX(0, INIT_WINDOW_SIZE * 5 + 1, 0)
365 RX_OP_CHECK_SWM(INIT_WINDOW_SIZE * 5)
366 RX_OP_CHECK_ERROR(OSSL_QUIC_ERR_FLOW_CONTROL_ERROR, 0)
367 RX_OP_CHECK_ERROR(OSSL_QUIC_ERR_FLOW_CONTROL_ERROR, 1)
368 RX_OP_CHECK_ERROR(0, 0)
369 RX_OP_CHECK_CWM(INIT_WINDOW_SIZE * 5)
371 * No window expansion due to flow control violation; window expansion is
372 * triggered by retirement only.
374 RX_OP_CHECK_CHANGED(0, 0)
379 /* 2. Interaction between connection and stream-level flow control */
380 static const struct rx_test_op rx_script_2[] = {
381 RX_OP_STEP_TIME(1000 * OSSL_TIME_MS)
382 RX_OP_INIT_CONN(INIT_WINDOW_SIZE, 10 * INIT_WINDOW_SIZE)
383 RX_OP_INIT_STREAM(0, INIT_S_WINDOW_SIZE, 30 * INIT_S_WINDOW_SIZE)
384 RX_OP_INIT_STREAM(1, INIT_S_WINDOW_SIZE, 30 * INIT_S_WINDOW_SIZE)
387 RX_OP_CHECK_CWM_CONN(INIT_WINDOW_SIZE)
388 RX_OP_CHECK_CWM_STREAM(0, INIT_S_WINDOW_SIZE)
389 RX_OP_CHECK_CWM_STREAM(1, INIT_S_WINDOW_SIZE)
390 RX_OP_CHECK_SWM_CONN(10)
391 RX_OP_CHECK_SWM_STREAM(0, 10)
392 RX_OP_CHECK_SWM_STREAM(1, 0)
393 RX_OP_CHECK_RWM_CONN(0)
394 RX_OP_CHECK_RWM_STREAM(0, 0)
395 RX_OP_CHECK_RWM_STREAM(1, 0)
398 RX_OP_RX(1, 42, 0) /* monotonic; equal or lower values ignored */
400 RX_OP_CHECK_CWM_CONN(INIT_WINDOW_SIZE)
401 RX_OP_CHECK_CWM_STREAM(0, INIT_S_WINDOW_SIZE)
402 RX_OP_CHECK_CWM_STREAM(1, INIT_S_WINDOW_SIZE)
403 RX_OP_CHECK_SWM_CONN(52)
404 RX_OP_CHECK_SWM_STREAM(0, 10)
405 RX_OP_CHECK_SWM_STREAM(1, 42)
406 RX_OP_CHECK_RWM_CONN(0)
407 RX_OP_CHECK_RWM_STREAM(0, 0)
408 RX_OP_CHECK_RWM_STREAM(1, 0)
410 RX_OP_RETIRE(0, 10, 50 * OSSL_TIME_MS, 0)
411 RX_OP_CHECK_RWM_CONN(10)
412 RX_OP_CHECK_RWM_STREAM(0, 10)
413 RX_OP_CHECK_CWM_CONN(INIT_WINDOW_SIZE)
414 RX_OP_CHECK_CWM_STREAM(0, INIT_S_WINDOW_SIZE)
415 RX_OP_CHECK_CWM_STREAM(1, INIT_S_WINDOW_SIZE)
417 RX_OP_RETIRE(1, 42, 50 * OSSL_TIME_MS, 0)
418 RX_OP_CHECK_RWM_CONN(52)
419 RX_OP_CHECK_RWM_STREAM(1, 42)
420 RX_OP_CHECK_CWM_CONN(INIT_WINDOW_SIZE)
421 RX_OP_CHECK_CWM_STREAM(0, INIT_S_WINDOW_SIZE)
422 RX_OP_CHECK_CWM_STREAM(1, INIT_S_WINDOW_SIZE)
424 RX_OP_CHECK_CHANGED_CONN(0, 0)
426 /* FC limited by stream but not connection */
427 RX_OP_STEP_TIME(1000 * OSSL_TIME_MS)
428 RX_OP_RX(0, INIT_S_WINDOW_SIZE, 0)
429 RX_OP_CHECK_SWM_CONN(INIT_S_WINDOW_SIZE + 42)
430 RX_OP_CHECK_SWM_STREAM(0, INIT_S_WINDOW_SIZE)
431 RX_OP_CHECK_SWM_STREAM(1, 42)
432 RX_OP_CHECK_CWM_CONN(INIT_WINDOW_SIZE)
433 RX_OP_CHECK_CWM_STREAM(0, INIT_S_WINDOW_SIZE)
435 /* We bump CWM when more than 1/4 of the window has been retired */
436 RX_OP_RETIRE(0, INIT_S_WINDOW_SIZE - 10, 50 * OSSL_TIME_MS, 0)
437 RX_OP_CHECK_CWM_STREAM(0, INIT_S_WINDOW_SIZE * 2)
438 RX_OP_CHECK_CHANGED_STREAM(0, 1, 0)
439 RX_OP_CHECK_CHANGED_STREAM(0, 1, 1)
440 RX_OP_CHECK_CHANGED_STREAM(0, 0, 0)
443 * This is more than 1/4 of the connection window, so CWM will
444 * be bumped here too.
446 RX_OP_CHECK_CWM_CONN(INIT_S_WINDOW_SIZE + INIT_WINDOW_SIZE + 42)
447 RX_OP_CHECK_RWM_CONN(INIT_S_WINDOW_SIZE + 42)
448 RX_OP_CHECK_RWM_STREAM(0, INIT_S_WINDOW_SIZE)
449 RX_OP_CHECK_RWM_STREAM(1, 42)
450 RX_OP_CHECK_CHANGED_CONN(1, 0)
451 RX_OP_CHECK_CHANGED_CONN(1, 1)
452 RX_OP_CHECK_CHANGED_CONN(0, 0)
453 RX_OP_CHECK_ERROR_CONN(0, 0)
454 RX_OP_CHECK_ERROR_STREAM(0, 0, 0)
455 RX_OP_CHECK_ERROR_STREAM(1, 0, 0)
457 /* Test exceeding limit at stream level. */
458 RX_OP_RX(0, INIT_S_WINDOW_SIZE * 2 + 1, 0)
459 RX_OP_CHECK_ERROR_STREAM(0, OSSL_QUIC_ERR_FLOW_CONTROL_ERROR, 0)
460 RX_OP_CHECK_ERROR_STREAM(0, OSSL_QUIC_ERR_FLOW_CONTROL_ERROR, 1)
461 RX_OP_CHECK_ERROR_STREAM(0, 0, 0)
462 RX_OP_CHECK_ERROR_CONN(0, 0) /* doesn't affect conn */
464 /* Test exceeding limit at connection level. */
465 RX_OP_RX(0, INIT_WINDOW_SIZE * 2, 0)
466 RX_OP_CHECK_ERROR_CONN(OSSL_QUIC_ERR_FLOW_CONTROL_ERROR, 0)
467 RX_OP_CHECK_ERROR_CONN(OSSL_QUIC_ERR_FLOW_CONTROL_ERROR, 1)
468 RX_OP_CHECK_ERROR_CONN(0, 0)
473 static const struct rx_test_op *rx_scripts[] = {
478 static int run_rxfc_script(const struct rx_test_op *script)
480 #define MAX_STREAMS 3
482 const struct rx_test_op *op = script;
483 QUIC_RXFC conn_rxfc = {0}, stream_rxfc[MAX_STREAMS] = {0}; /* coverity */
484 char stream_init_done[MAX_STREAMS] = {0};
485 int conn_init_done = 0;
487 cur_time = ossl_time_zero();
489 for (; op->op != RX_OPC_END; ++op) {
491 case RX_OPC_INIT_CONN:
492 if (!TEST_true(ossl_quic_rxfc_init(&conn_rxfc, 0,
500 case RX_OPC_INIT_STREAM:
501 if (!TEST_size_t_lt(op->stream_idx, OSSL_NELEM(stream_rxfc))
502 || !TEST_true(conn_init_done))
505 if (!TEST_true(ossl_quic_rxfc_init(&stream_rxfc[op->stream_idx],
511 stream_init_done[op->stream_idx] = 1;
515 if (!TEST_true(conn_init_done && op->stream_idx < OSSL_NELEM(stream_rxfc)
516 && stream_init_done[op->stream_idx]))
519 if (!TEST_true(ossl_quic_rxfc_on_rx_stream_frame(&stream_rxfc[op->stream_idx],
527 if (!TEST_true(conn_init_done && op->stream_idx < OSSL_NELEM(stream_rxfc)
528 && stream_init_done[op->stream_idx]))
531 if (!TEST_int_eq(ossl_quic_rxfc_on_retire(&stream_rxfc[op->stream_idx],
533 ossl_ticks2time(op->arg1)),
538 case RX_OPC_CHECK_CWM_CONN:
539 if (!TEST_true(conn_init_done))
541 if (!TEST_uint64_t_eq(ossl_quic_rxfc_get_cwm(&conn_rxfc),
545 case RX_OPC_CHECK_CWM_STREAM:
546 if (!TEST_true(op->stream_idx < OSSL_NELEM(stream_rxfc)
547 && stream_init_done[op->stream_idx]))
549 if (!TEST_uint64_t_eq(ossl_quic_rxfc_get_cwm(&stream_rxfc[op->stream_idx]),
553 case RX_OPC_CHECK_SWM_CONN:
554 if (!TEST_true(conn_init_done))
556 if (!TEST_uint64_t_eq(ossl_quic_rxfc_get_swm(&conn_rxfc),
560 case RX_OPC_CHECK_SWM_STREAM:
561 if (!TEST_true(op->stream_idx < OSSL_NELEM(stream_rxfc)
562 && stream_init_done[op->stream_idx]))
564 if (!TEST_uint64_t_eq(ossl_quic_rxfc_get_swm(&stream_rxfc[op->stream_idx]),
568 case RX_OPC_CHECK_RWM_CONN:
569 if (!TEST_true(conn_init_done))
571 if (!TEST_uint64_t_eq(ossl_quic_rxfc_get_rwm(&conn_rxfc),
575 case RX_OPC_CHECK_RWM_STREAM:
576 if (!TEST_true(op->stream_idx < OSSL_NELEM(stream_rxfc)
577 && stream_init_done[op->stream_idx]))
579 if (!TEST_uint64_t_eq(ossl_quic_rxfc_get_rwm(&stream_rxfc[op->stream_idx]),
583 case RX_OPC_CHECK_CHANGED_CONN:
584 if (!TEST_true(conn_init_done))
586 if (!TEST_int_eq(ossl_quic_rxfc_has_cwm_changed(&conn_rxfc,
591 case RX_OPC_CHECK_CHANGED_STREAM:
592 if (!TEST_true(op->stream_idx < OSSL_NELEM(stream_rxfc)
593 && stream_init_done[op->stream_idx]))
595 if (!TEST_int_eq(ossl_quic_rxfc_has_cwm_changed(&stream_rxfc[op->stream_idx],
600 case RX_OPC_CHECK_ERROR_CONN:
601 if (!TEST_true(conn_init_done))
603 if (!TEST_int_eq(ossl_quic_rxfc_get_error(&conn_rxfc,
608 case RX_OPC_CHECK_ERROR_STREAM:
609 if (!TEST_true(op->stream_idx < OSSL_NELEM(stream_rxfc)
610 && stream_init_done[op->stream_idx]))
612 if (!TEST_int_eq(ossl_quic_rxfc_get_error(&stream_rxfc[op->stream_idx],
617 case RX_OPC_STEP_TIME:
618 cur_time = ossl_time_add(cur_time, ossl_ticks2time(op->arg0));
621 fprintf(stderr, "# %s\n", op->msg);
633 static int test_rxfc(int idx)
635 return run_rxfc_script(rx_scripts[idx]);
638 int setup_tests(void)
640 ADD_ALL_TESTS(test_txfc, 2);
641 ADD_ALL_TESTS(test_rxfc, OSSL_NELEM(rx_scripts));