aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_sendme.c
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2022-02-17 00:26:08 +0000
committerMike Perry <mikeperry-git@torproject.org>2022-02-22 19:28:36 +0000
commit8f4bd8730c1df180e0ef2f5e6565c21b37ae593a (patch)
tree7e76439a56421dcca9223148f65b7052c318b587 /src/test/test_sendme.c
parent5c88bea84c3535ed908d51d2ed2e9beaa58ee607 (diff)
downloadtor-8f4bd8730c1df180e0ef2f5e6565c21b37ae593a.tar.gz
tor-8f4bd8730c1df180e0ef2f5e6565c21b37ae593a.zip
Add test for sendme_cell_is_next with sendme_inc of 31
Diffstat (limited to 'src/test/test_sendme.c')
-rw-r--r--src/test/test_sendme.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test_sendme.c b/src/test/test_sendme.c
index 1a046b5c50..ea7ccd0b3c 100644
--- a/src/test/test_sendme.c
+++ b/src/test/test_sendme.c
@@ -372,6 +372,26 @@ done:
;
}
+/* Check that circuit_sendme_is_next works with a window of 31 */
+static void
+test_sendme_is_next(void *arg)
+{
+ (void)arg;
+ tt_int_op(circuit_sendme_cell_is_next(1000, 31), OP_EQ, 0);
+ tt_int_op(circuit_sendme_cell_is_next(970, 31), OP_EQ, 1);
+ tt_int_op(circuit_sendme_cell_is_next(969, 31), OP_EQ, 0);
+
+ /* deliver_window should never get this low, but test anyway */
+ tt_int_op(circuit_sendme_cell_is_next(9, 31), OP_EQ, 1);
+ tt_int_op(circuit_sendme_cell_is_next(8, 31), OP_EQ, 0);
+ tt_int_op(circuit_sendme_cell_is_next(7, 31), OP_EQ, 0);
+ tt_int_op(circuit_sendme_cell_is_next(1, 31), OP_EQ, 0);
+ tt_int_op(circuit_sendme_cell_is_next(0, 31), OP_EQ, 0);
+
+ done:
+ ;
+}
+
struct testcase_t sendme_tests[] = {
{ "v1_record_digest", test_v1_record_digest, TT_FORK,
NULL, NULL },
@@ -385,6 +405,7 @@ struct testcase_t sendme_tests[] = {
NULL, NULL },
{ "package_payload_len", test_package_payload_len, 0, NULL, NULL },
{ "sendme_is_next1000", test_sendme_is_next1000, 0, NULL, NULL },
+ { "sendme_is_next", test_sendme_is_next, 0, NULL, NULL },
END_OF_TESTCASES
};