summaryrefslogtreecommitdiff
path: root/src/test/test_circuitpadding.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-03-13 13:21:52 +0200
committerGeorge Kadianakis <desnacked@riseup.net>2019-03-13 13:35:52 +0200
commitcdaff26f91ff6e3dceca6054157bbcf976713398 (patch)
tree84e65d0115e0d0afd0c80bbf2c0f260b4f1c18d6 /src/test/test_circuitpadding.c
parent32c821c47b56471802a6c6c0f2286eb41d07238b (diff)
downloadtor-cdaff26f91ff6e3dceca6054157bbcf976713398.tar.gz
tor-cdaff26f91ff6e3dceca6054157bbcf976713398.zip
circpad: Machines MUST have strictly increasing histogram edges.
Add a basic validation function for the histograms. It can be a building block for the future
Diffstat (limited to 'src/test/test_circuitpadding.c')
-rw-r--r--src/test/test_circuitpadding.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index 3570b179bd..a62b2b5164 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -794,7 +794,7 @@ test_circuitpadding_closest_token_removal(void *arg)
tt_int_op(client_side->padding_info[0]->current_state, OP_EQ,
CIRCPAD_STATE_BURST);
circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[0] = 100;
- circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[1] = 100;
+ circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[1] = 101;
circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[2] = 120;
mi->padding_scheduled_at_usec = current_time - 102;
mi->histogram[0] = 0;
@@ -903,7 +903,7 @@ test_circuitpadding_closest_token_removal_usec(void *arg)
tt_int_op(client_side->padding_info[0]->current_state, OP_EQ,
CIRCPAD_STATE_BURST);
circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[0] = 100;
- circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[1] = 100;
+ circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[1] = 101;
circ_client_machine.states[CIRCPAD_STATE_BURST].histogram_edges[2] = 120;
mi->padding_scheduled_at_usec = current_time - 102;
mi->histogram[0] = 0;
@@ -1649,7 +1649,7 @@ helper_create_conditional_machine(void)
ret->states[CIRCPAD_STATE_BURST].histogram_len = 3;
ret->states[CIRCPAD_STATE_BURST].histogram_edges[0] = 0;
- ret->states[CIRCPAD_STATE_BURST].histogram_edges[1] = 0;
+ ret->states[CIRCPAD_STATE_BURST].histogram_edges[1] = 1;
ret->states[CIRCPAD_STATE_BURST].histogram_edges[2] = 1000000;
ret->states[CIRCPAD_STATE_BURST].histogram[0] = 6;
@@ -1686,8 +1686,7 @@ helper_create_conditional_machines(void)
add->conditions.state_mask = CIRCPAD_CIRC_BUILDING|
CIRCPAD_CIRC_NO_STREAMS|CIRCPAD_CIRC_HAS_RELAY_EARLY;
add->conditions.purpose_mask = CIRCPAD_PURPOSE_ALL;
-
- smartlist_add(origin_padding_machines, add);
+ register_padding_machine(add, origin_padding_machines);
add = helper_create_conditional_machine();
add->machine_num = 3;
@@ -1706,15 +1705,15 @@ helper_create_conditional_machines(void)
add->conditions.state_mask = CIRCPAD_CIRC_OPENED|
CIRCPAD_CIRC_STREAMS|CIRCPAD_CIRC_HAS_NO_RELAY_EARLY;
add->conditions.purpose_mask = CIRCPAD_PURPOSE_ALL;
- smartlist_add(origin_padding_machines, add);
+ register_padding_machine(add, origin_padding_machines);
add = helper_create_conditional_machine();
add->machine_num = 2;
- smartlist_add(relay_padding_machines, add);
+ register_padding_machine(add, relay_padding_machines);
add = helper_create_conditional_machine();
add->machine_num = 3;
- smartlist_add(relay_padding_machines, add);
+ register_padding_machine(add, relay_padding_machines);
}
void