- Remove dummy transaction and txid (use the transactions received in the
messages instead
- extract helpers for quote and price to prevent misalignments in tests
- extend contract setup to finish at Open state of the cfd
Contract setup test keeps failing when bors runs it.
Note: contract setup got recently refactored into a dedicated actor, this might
have increased the time it takes to finish the process.
By default tests use the same heartbeat interval as production code.
Allow adjusting the value using builder pattern is tests that otherwise take too
long to complete (as they wait for timeout to trigger).
Disable long-running test to speed up build/test cycle for devs.
This means it is not run by default, in order to run it you have to specify the
test name or run `cargo test -- --ignored`
Originally we thought we need this enum because we would need to use
`MessageChannel`s from the rocket layer. But we can actually fully
qualify the address without issues.
We also introduce `xtra_productivity` to remove some of the indirection
that is happening in this file.
Note: Projection actor is used across both taker and maker, so it really should
publish information about connected counterparty.
Taker should use that channel for deriving maker online status.
Instead of blocking and awaiting for connection to maker before the start, spawn
the connection attempt in a separate task that will also attempt to reconnect if
the maker goes offline.
Extend the unit test to cover the new behaviour.
Do not shutdown the taker upon connection loss anymore.
Co-authored-by: rishflab <rishflab@hotmail.com>
A configurable settlement interval for the maker causes friction when implementing auto-rollover, because the settlement interval is not known to the taker.
The settlement interval should not be configurable, thus the configurable settlement interval is removed on the maker side.
The cfd actors and oracle actor use a global constant to decide the settlement interval and oracle even lookahead.
Not pulling the constant into the actors is a conscious decision, it allows us to set this to a different value in the actor tests.
The fact that we use the same constant for cfd actor and oracle actor is an implementation detail.
The projection actor is responsible in preparing data for the HTTP API and consequently for the UI.
While this is commit provides only the foundation, in the long run we can:
- Reduce the logic happening in the rocket layer. `ToSseEvent` can likely go away.
- Reduce the complexity for other actors in what needs to be updated when. All they should care about is sending updates to the projection actor. (mostly done)
- Improve test coverage. With a dedicated actor that does the projection, we should be able to write assertions in our integration tests that are closer to the UI.
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