The fact that we're storing a Vec<RemoteHandle<()>) internally is an
implementation detail.
Calling `spawn_with_handle` is done internally now, guarded by a `debug_assert!`
macro discouraging from doing it twice.
Running this test with `--nocapture` reveals that we have unmocked
handlers. Adding these mocks fixes those panics (which are being
captured by tokio and hence did not abort the test).
Additionally we specialize the `mock_common_handlers` function to just
deal with the two `Sync` messages to make it clear that no more mocks
should be added to this function.
Connection actor takes care of establishing a connection to the maker and is
monitoring its status.
The connection actor:
- listens for periodically sent heartbeat messages from the maker,
- publish the maker status on a watch::channel feed outside TakerActorSystem,
- observe changes on the watch channel and shut down Rocket if maker goes offline
Note: this is a stepping stone resulting in temporary behaviour. Eventually,
we'd want to support reconnecting to the maker as well as operating the
taker without the maker being online (with a limited set of actions).
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
`do_send` did not inspect any errors, while Cfd actors support returning errors
if an action performed on them failed.
This matches the code used in production in HTTP requests.
Slight changes in the test were required as the test failed
otherwise (particularly, on unhandled monitoring of oracle attestation).
Cfd protocol got moved into a separate repository.
All references of `cfd_protocol` were renamed to `maia`.
Patch cargo.toml with a fixed git revision until it gets a public release.
Invoke user actions (cfd actions & posting a new sell order) synchronously in
order to be able to communicate the results.
Use HttpApiProblem to send error details to the frontend in a standard way.
This allows opting-in for longer-running tests by enabling "expensive_tests"
feature, instead of waiting for a few minutes after starting `cargo test`.
Amend the CI to run all the tests (including expensive ones) on every run.
Mockall is a mocking framework that removes the need for writing more actors,
making tests easier to write.
Summary:
- add one more layer of indirection (a trait per actor type: Wallet, Oracle, Monitor)
- Mocks implementing the actor traits (with default stubbed implementations if no extra
behaviour needed)
- references to the mocks are being passed into the tests (via Arc<Mutex>>), allowing
for dynamically changing the behaviour and adding assertions. This also
aids readability, as the mock setup can be collocated with a particular
test, if the test needs something extra
Fixes#450
The which do not fit into the 65535 byte message size
limit of the noise protocol are chunked before
encryption. This feature was introduced to handle the
very large messages which contained the CET's.
More research is required into the NOISE_PARAMS and
whether they can be used to configure snow elegantly
handle authentication.
Created new Timestamp struct that only uses seconds (as i64 in order
to play nice with both sqlx and chrono) and removed use of SytemTime::now()
throughout in the process.
This PR addresses #352 but also had the effect of doing a better job of
addressing #434, making #435 pointless.
Addresses #357 and #365. Although not a very large change, this PR ends up touching rather a lot of code.
* Converted types `Usd`, `Leverage` and `Percent` to something that is appropriate to this application
* Created new types `Price` and `InversePrice` to use for BTC/USD exchange rate with appropriate algebraic ops implemented as well.
* Added new positive tests
* The function `daemon::model::calculate_profit()` has been changed substantially as the updated types make the existing workflow needlessly complex
* Some tests (mostly in `cfd.rs` required updating) in order to make use of the new types.
* Minor edit to `.gitignore` to avoid accidental pushing of DB to repository--should have been it's own item, added here to fix a problem that arose during this work.
NOTE:
* There may be an excess of algebraic ops implemented, some pruning may be appropriate.
Fetching new events all over the place is cumbersome and it is likely that we will forget about doing so (e.g. atm we forgot doing this when receiving a roll-over request at the maker). Hence, we now fetch on a regular interval for a fixed timespan:
When starting up we fetch oracle events for the next 24h. Afterwards we check every 5 minutes again if there is a new event to check. This should ensure that we always know about needed events.