diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-11-13 15:33:46 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-11-15 11:17:22 -0500 |
commit | 2c15b6538123047c258987b00475fa658ca14878 (patch) | |
tree | 6a01a36619cd1df7228b9a50e20a15087d3e014e /src/test/test_periodic_event.c | |
parent | ccbb36048f5167b9d5011b7c8b0d2c346ce567e8 (diff) | |
download | tor-2c15b6538123047c258987b00475fa658ca14878.tar.gz tor-2c15b6538123047c258987b00475fa658ca14878.zip |
Make the NET_PARTICIPANT role dependent on user activity
This patch implements all of 28337, except for the part where we
turn off the role if we've been idle for a long time.
Diffstat (limited to 'src/test/test_periodic_event.c')
-rw-r--r-- | src/test/test_periodic_event.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/test/test_periodic_event.c b/src/test/test_periodic_event.c index 6a3e320b2e..f3d518eb7b 100644 --- a/src/test/test_periodic_event.c +++ b/src/test/test_periodic_event.c @@ -51,6 +51,8 @@ test_pe_initialize(void *arg) * need to run the main loop and then wait for a second delaying the unit * tests. Instead, we'll test the callback work indepedently elsewhere. */ initialize_periodic_events(); + set_network_participation(false); + rescan_periodic_events(get_options()); /* Validate that all events have been set up. */ for (int i = 0; periodic_events[i].name; ++i) { @@ -82,6 +84,8 @@ test_pe_launch(void *arg) * network gets enabled. */ consider_hibernation(time(NULL)); + set_network_participation(true); + /* Hack: We'll set a dumb fn() of each events so they don't get called when * dispatching them. We just want to test the state of the callbacks, not * the whole code path. */ @@ -93,6 +97,7 @@ test_pe_launch(void *arg) options = get_options_mutable(); options->SocksPort_set = 1; periodic_events_on_new_options(options); + #if 0 /* Lets make sure that before intialization, we can't scan the periodic * events list and launch them. Lets try by being a Client. */ @@ -148,6 +153,7 @@ test_pe_launch(void *arg) options->SocksPort_set = 0; options->ORPort_set = 0; options->DisableNetwork = 1; + set_network_participation(false); periodic_events_on_new_options(options); for (int i = 0; periodic_events[i].name; ++i) { @@ -162,6 +168,7 @@ test_pe_launch(void *arg) options->BridgeRelay = 1; options->AuthoritativeDir = 1; options->V3AuthoritativeDir = 1; options->BridgeAuthoritativeDir = 1; options->DisableNetwork = 0; + set_network_participation(true); register_dummy_hidden_service(&service); periodic_events_on_new_options(options); /* Note down the reference because we need to remove this service from the @@ -195,8 +202,10 @@ test_pe_get_roles(void *arg) or_options_t *options = get_options_mutable(); tt_assert(options); + set_network_participation(true); - const int ALL = PERIODIC_EVENT_ROLE_ALL; + const int ALL = PERIODIC_EVENT_ROLE_ALL | + PERIODIC_EVENT_ROLE_NET_PARTICIPANT; /* Nothing configured, should be no roles. */ tt_assert(net_is_disabled()); |