aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_circuitpadding.c
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2019-05-16 19:17:31 +0000
committerMike Perry <mikeperry-git@torproject.org>2019-05-16 19:21:19 +0000
commitbbb974234c67d8d7dc95a760101ca61a9e88d647 (patch)
treed976818ff02c909669557ab7c7c1239f4b4a01b0 /src/test/test_circuitpadding.c
parentf237fed7466e84e6b6399fe5c7cb80bd59e3e2d8 (diff)
downloadtor-bbb974234c67d8d7dc95a760101ca61a9e88d647.tar.gz
tor-bbb974234c67d8d7dc95a760101ca61a9e88d647.zip
Refactor intro machines, stage 2/2: Move histogram code.
The client side had garbage histograms and deadcode here, too. That code has been removed. The tests have also been updated to properly test the intro circ by sending padding from the relay side to the client, and verifying that both shut down when padding was up. (The tests previously erroneously tested only the client side of intro circs, which actually were supposed to be doing nothing).
Diffstat (limited to 'src/test/test_circuitpadding.c')
-rw-r--r--src/test/test_circuitpadding.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index 68d1de91ba..ca65438430 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -3007,10 +3007,10 @@ helper_test_hs_machines(bool test_intro_circs)
relay_side->padding_info[0];
if (test_intro_circs) {
- tt_int_op(client_machine_runtime->state_length, OP_GE,
- INTRO_MACHINE_MINIMUM_PADDING);
- tt_int_op(client_machine_runtime->state_length, OP_LT,
- INTRO_MACHINE_MAXIMUM_PADDING);
+ /* on the client side, we don't send any padding so
+ * state length is not set */
+ tt_int_op(client_machine_runtime->state_length, OP_EQ, -1);
+ /* relay side has state limits. check them */
tt_int_op(relay_machine_runtime->state_length, OP_GE,
INTRO_MACHINE_MINIMUM_PADDING);
tt_int_op(relay_machine_runtime->state_length, OP_LT,
@@ -3020,15 +3020,28 @@ helper_test_hs_machines(bool test_intro_circs)
tt_int_op(relay_machine_runtime->state_length, OP_EQ, 1);
}
- /* Send state_length worth of padding and see that the state goes to END */
- int i;
- for (i = (int) client_machine_runtime->state_length ; i > 0 ; i--) {
- circpad_send_padding_cell_for_callback(client_machine_runtime);
+ if (test_intro_circs) {
+ int i;
+ /* Send state_length worth of padding from the relay and see that the
+ * client state goes to END */
+ for (i = (int) relay_machine_runtime->state_length ; i > 0 ; i--) {
+ circpad_send_padding_cell_for_callback(relay_machine_runtime);
+ }
+ /* See that the machine has been teared down after all the length has been
+ * exhausted (the padding info should now be null on both sides) */
+ tt_ptr_op(relay_side->padding_info[0], OP_EQ, NULL);
+ tt_ptr_op(client_side->padding_info[0], OP_EQ, NULL);
+ } else {
+ int i;
+ /* Send state_length worth of padding and see that the state goes to END */
+ for (i = (int) client_machine_runtime->state_length ; i > 0 ; i--) {
+ circpad_send_padding_cell_for_callback(client_machine_runtime);
+ }
+ /* See that the machine has been teared down after all the length has been
+ * exhausted. */
+ tt_int_op(client_side->padding_info[0]->current_state, OP_EQ,
+ CIRCPAD_STATE_END);
}
- /* See that the machine has been teared down after all the length has been
- * exhausted. */
- tt_int_op(client_side->padding_info[0]->current_state, OP_EQ,
- CIRCPAD_STATE_END);
done:
free_fake_orcirc(relay_side);