Commit Graph

66 Commits

Author SHA1 Message Date
Nick Mathewson 9737580402 Add a few more clippy warnings 2021-05-03 16:10:39 -04:00
Nick Mathewson 615e2ed31a Split mocking parts of rtcompat into new rtmock crate.
Since these parts are testing-only, let's take steps to make sure we
don't ship them in production by accident.
2021-05-03 09:10:33 -04:00
Nick Mathewson 098cd61409 bump to latest async_io 2021-05-03 08:42:08 -04:00
Nick Mathewson c372671b5a Note a limitation in MockSleepProvider::advance 2021-04-28 13:47:01 -04:00
Nick Mathewson 64e32b8199 Remove most pin_project usage in tor_rtcompat. 2021-04-28 11:51:59 -04:00
Nick Mathewson 95671bd71d Define a runtime wrapper to override the network. 2021-04-28 11:08:37 -04:00
Nick Mathewson d3380877cc Add a mock TLS provider. 2021-04-28 10:00:43 -04:00
Nick Mathewson 202096e98a Add a MockNetwork structure for testing.
This isn't a shadow replacement: it's just a testing fixture that we
can use to try out code that wants to connect and/or listen.
2021-04-28 08:51:49 -04:00
Nick Mathewson 94c93c9121 Add some more clippy warnings to our list. 2021-04-27 14:51:04 -04:00
Nick Mathewson 2e3780affb Enforce (and obey) clippy lints about exhaustive enums, structs.
These lints force us to declare our exported enums and
exhaustive-looking structs as non-exhaustive (so that we can add to
them in the future without breaking our API) or to explicitly
disable the warning for a given enum/struct (to say that we _intend_
for additions to be a breaking change).
2021-04-27 14:17:49 -04:00
Nick Mathewson 4306a28ddd cargo fix --edition-idioms 2021-04-26 11:11:05 -04:00
Nick Mathewson 27097c24c4 Small doc fix. 2021-04-24 11:01:55 -04:00
Nick Mathewson acc4e09d60 Define a helper for replacing the sleep functionality of a runtime. 2021-04-22 17:05:37 -04:00
Nick Mathewson 2e34a53f9b Add a yield_now() call to MockSleepProvider::advance()
This is almost always what we want for testing: the task that is
advancing time wants to give the other tasks a chance to run.

Doing this turns MockSleepProvider::advance() into an async
function.
2021-04-21 14:05:49 -04:00
Nick Mathewson b40a1edc54 tor_rtcompat: add a yield_now() function. 2021-04-21 13:48:18 -04:00
Nick Mathewson d19ed533d2 Add a "socketpair"-style linked-reader/writer implementation for testing 2021-04-21 08:40:50 -04:00
Nick Mathewson f6ca37cbe1 Disable a test on OSX; see arti#111 2021-04-20 15:40:36 -04:00
Nick Mathewson 3fc66306c5 Tests for sleep_until_wallclock. 2021-04-20 09:34:34 -04:00
Nick Mathewson 4a761f55ea A little more testing for tor_rtcompat::mock::time. 2021-04-20 08:26:41 -04:00
Nick Mathewson a910627e92 Add support for simulating the passage of time. 2021-04-19 20:13:12 -04:00
Nick Mathewson 5f850fad1f Add "now" functions to SleepProvider. 2021-04-19 20:03:27 -04:00
Nick Mathewson ec6dc417b9 rtcompat: remove an unused conversion function. 2021-04-19 10:28:41 -04:00
Nick Mathewson fe22c329c6 Simple unit tests for tor_rtcompat: at last! 2021-04-19 10:24:13 -04:00
Nick Mathewson a271faca3a rtcompat: mark some outputs as must-use. 2021-04-19 10:08:18 -04:00
Nick Mathewson b8e1234a4c Clarify what TlsConnector doesn't validate. 2021-04-19 08:24:22 -04:00
Nick Mathewson 50f5ad9850 Flatten async_std impl module slightly. 2021-04-19 08:20:20 -04:00
Nick Mathewson e3c51519e8 Flatten tokio TcpProvider implementation a bit. 2021-04-19 08:15:12 -04:00
Nick Mathewson 065162aff2 Add a local_addr() function for TcpListener. 2021-04-18 18:02:30 -04:00
Nick Mathewson 975374beb5 Fix some broken rustdoc links. 2021-04-18 17:55:43 -04:00
Nick Mathewson 342a98dccd tor_rtcompat: Documentation and cleanups 2021-04-17 17:09:20 -04:00
Nick Mathewson a774cdde80 Remove the no-longer-needed "global runtime" code. 2021-04-17 17:09:20 -04:00
Nick Mathewson ee556eb714 Remove some cruft in tor_rtcompat::impls 2021-04-17 17:09:20 -04:00
Nick Mathewson 745a7a89f5 Remove need for async_trait in SleepProviderExt 2021-04-17 17:09:20 -04:00
Nick Mathewson 92de7c58f0 Move timer functions into an extension trait. 2021-04-17 09:37:46 -04:00
Nick Mathewson 6878fe8336 Move around the public modules in tor_rtcompat. 2021-04-17 09:21:09 -04:00
Nick Mathewson 1d07132787 Remove all non-runtime methods in tor_rtcompat. 2021-04-16 17:15:55 -04:00
Nick Mathewson 8532cef9aa Add a "Runtime" parameter to all the manager types.
This is a big change, but it is a step towards our goal of removing
tor_rtcompat:: calls directly.
2021-04-16 16:12:08 -04:00
Nick Mathewson ebcfd38b48 rtcompat: Make TLS functionality use Runtime traits.
Now there is nothing in principle that you couldn't access from a
Runtime implementation.
2021-04-16 15:44:36 -04:00
Nick Mathewson e0f4c222dd Move the "sleep()" function from task to timer. 2021-04-16 15:44:36 -04:00
Nick Mathewson 6821211e1e Make incoming Streams of TcpStream a real type for each backend.
This makes things a little more complicated for AsyncStd, and a
little simpler for Tokio.
2021-04-16 15:44:20 -04:00
Nick Mathewson 5a587a55b4 Port tor_rtcompat::net to use Runtime objects. 2021-04-16 15:44:20 -04:00
Nick Mathewson 459a884f94 Port tor_rtcompat::timer to use Runtime objects. 2021-04-16 13:20:56 -04:00
Nick Mathewson f3505cad49 Begin a refactoring of tor-rtcompat to use runtime objects.
So far, all traits are defined (I hope) and the task api is ported.

With time I want to have none of the current "global runtime" APIs
exposed, and just use Runtime objects instead.  But that isn't just
yet.
2021-04-16 11:25:50 -04:00
Nick Mathewson d18013c03a rtcompat: rename traits module to impl_traits. 2021-04-16 09:47:15 -04:00
Nick Mathewson 1da7fccfc0 rtcompat: Add a cancellable-task-handle type.
The API is a bit yucky, since it has to be compatible with tokio and
async_std.

(Also, this patch fixes some async_std clippy warnings)
2021-04-09 08:01:38 -04:00
Nick Mathewson d073f24138 Move responsibility for knowing about TLS into tor_rtcompat.
Now we don't need runtime-specific stuff in tor-chanmgr.
2021-03-23 15:59:39 -04:00
Nick Mathewson 68f18d4fe3 Refactor tokio implpementation in tor-rtcompat.
Now other crates don't need any 'ifdef tokio' code, since there
are wrappers that implement 'futures' right.

Technically, the 'futures' traits are in some ways less good than
the tokio ones, but we need a consistent API if we want to support
WASM someday and keep support for async_std.  I'd rather hold out
hope for a future version of futures::io working like tokio than to
fix ourselves into the tokioverse forever.
2021-03-23 11:00:09 -04:00
Nick Mathewson a4e0dde4da Add appropriate categories to some Cargo.toml files. 2021-03-17 14:51:18 -04:00
Nick Mathewson 6daf57957d Add the tor project as an author. 2021-03-17 14:43:40 -04:00
Nick Mathewson ba14d43be4 Add keywords to each Cargo.toml 2021-03-17 14:41:02 -04:00