]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add test for sendme_cell_is_next with sendme_inc of 31
authorMike Perry <mikeperry-git@torproject.org>
Thu, 17 Feb 2022 00:26:08 +0000 (00:26 +0000)
committerMike Perry <mikeperry-git@torproject.org>
Tue, 22 Feb 2022 19:28:36 +0000 (19:28 +0000)
src/test/test_sendme.c

index 1a046b5c50fa50b51d3fd816f05bd339284cff49..ea7ccd0b3c28ba3f1cd7dcad0fd4a0ed8bc29738 100644 (file)
@@ -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
 };