diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-30 10:36:00 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-30 10:36:00 -0400 |
commit | d1a0534649be02e37668073279664f513f4dc7d7 (patch) | |
tree | 62fc513c567f0e4d21ed7c3cc1fd390469e22887 /src/test/test_periodic_event.c | |
parent | 3800d5916f90b11df433c885fae94f1dc7edca5c (diff) | |
download | tor-d1a0534649be02e37668073279664f513f4dc7d7.tar.gz tor-d1a0534649be02e37668073279664f513f4dc7d7.zip |
Make unit tests pass with new dirserver role.
Diffstat (limited to 'src/test/test_periodic_event.c')
-rw-r--r-- | src/test/test_periodic_event.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/test/test_periodic_event.c b/src/test/test_periodic_event.c index 74e799360e..34689b64f4 100644 --- a/src/test/test_periodic_event.c +++ b/src/test/test_periodic_event.c @@ -118,6 +118,10 @@ test_pe_launch(void *arg) options->ORPort_set = 1; periodic_events_on_new_options(options); + unsigned roles = get_my_roles(options); + tt_uint_op(roles, OP_EQ, + PERIODIC_EVENT_ROLE_RELAY|PERIODIC_EVENT_ROLE_DIRSERVER); + for (int i = 0; periodic_events[i].name; ++i) { periodic_event_item_t *item = &periodic_events[i]; /* Only Client role should be disabled. */ @@ -130,8 +134,8 @@ test_pe_launch(void *arg) tt_int_op(periodic_event_is_enabled(item), OP_EQ, 1); tt_u64_op(item->last_action_time, OP_NE, 0); } - /* Non Relay role should be disabled! */ - if (!(item->roles & PERIODIC_EVENT_ROLE_RELAY)) { + /* Non Relay role should be disabled, except for Dirserver. */ + if (!(item->roles & roles)) { tt_int_op(periodic_event_is_enabled(item), OP_EQ, 0); } } @@ -196,19 +200,21 @@ test_pe_get_roles(void *arg) options->ORPort_set = 1; roles = get_my_roles(options); tt_int_op(roles, OP_EQ, - (PERIODIC_EVENT_ROLE_CLIENT | PERIODIC_EVENT_ROLE_RELAY)); + (PERIODIC_EVENT_ROLE_CLIENT | PERIODIC_EVENT_ROLE_RELAY | + PERIODIC_EVENT_ROLE_DIRSERVER)); /* Now add a Bridge. */ options->BridgeRelay = 1; roles = get_my_roles(options); tt_int_op(roles, OP_EQ, (PERIODIC_EVENT_ROLE_CLIENT | PERIODIC_EVENT_ROLE_RELAY | - PERIODIC_EVENT_ROLE_BRIDGE)); + PERIODIC_EVENT_ROLE_BRIDGE | PERIODIC_EVENT_ROLE_DIRSERVER)); tt_assert(roles & PERIODIC_EVENT_ROLE_ROUTER); /* Unset client so we can solely test Router role. */ options->SocksPort_set = 0; roles = get_my_roles(options); - tt_int_op(roles, OP_EQ, PERIODIC_EVENT_ROLE_ROUTER); + tt_int_op(roles, OP_EQ, + PERIODIC_EVENT_ROLE_ROUTER | PERIODIC_EVENT_ROLE_DIRSERVER); /* Reset options so we can test authorities. */ options->SocksPort_set = 0; @@ -218,24 +224,28 @@ test_pe_get_roles(void *arg) tt_int_op(roles, OP_EQ, 0); /* Now upgrade to Dirauth. */ + options->DirPort_set = 1; options->AuthoritativeDir = 1; options->V3AuthoritativeDir = 1; roles = get_my_roles(options); - tt_int_op(roles, OP_EQ, PERIODIC_EVENT_ROLE_DIRAUTH); + tt_int_op(roles, OP_EQ, + PERIODIC_EVENT_ROLE_DIRAUTH|PERIODIC_EVENT_ROLE_DIRSERVER); tt_assert(roles & PERIODIC_EVENT_ROLE_AUTHORITIES); /* Now Bridge Authority. */ options->V3AuthoritativeDir = 0; options->BridgeAuthoritativeDir = 1; roles = get_my_roles(options); - tt_int_op(roles, OP_EQ, PERIODIC_EVENT_ROLE_BRIDGEAUTH); + tt_int_op(roles, OP_EQ, + PERIODIC_EVENT_ROLE_BRIDGEAUTH|PERIODIC_EVENT_ROLE_DIRSERVER); tt_assert(roles & PERIODIC_EVENT_ROLE_AUTHORITIES); /* Move that bridge auth to become a relay. */ options->ORPort_set = 1; roles = get_my_roles(options); tt_int_op(roles, OP_EQ, - (PERIODIC_EVENT_ROLE_BRIDGEAUTH | PERIODIC_EVENT_ROLE_RELAY)); + (PERIODIC_EVENT_ROLE_BRIDGEAUTH | PERIODIC_EVENT_ROLE_RELAY + | PERIODIC_EVENT_ROLE_DIRSERVER)); tt_assert(roles & PERIODIC_EVENT_ROLE_AUTHORITIES); /* And now an Hidden service. */ @@ -246,7 +256,7 @@ test_pe_get_roles(void *arg) remove_service(get_hs_service_map(), &service); tt_int_op(roles, OP_EQ, (PERIODIC_EVENT_ROLE_BRIDGEAUTH | PERIODIC_EVENT_ROLE_RELAY | - PERIODIC_EVENT_ROLE_HS_SERVICE)); + PERIODIC_EVENT_ROLE_HS_SERVICE | PERIODIC_EVENT_ROLE_DIRSERVER)); tt_assert(roles & PERIODIC_EVENT_ROLE_AUTHORITIES); done: |