Daniel Karzel
d853b8ec0b
Move tests to bottom of file
3 years ago
Daniel Karzel
6003ad0bc7
Cleanup impl blocks
3 years ago
Daniel Karzel
566aca374b
We can safely assume that creating a timestamp should not fail
Expect instead of returning a `Result`.
3 years ago
bonomat
bf36f290dd
Introduce projection actor
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.
3 years ago
bonomat
1d6b1a49e1
This test did not test much
3 years ago
bonomat
7d98e04686
Move invariant into function
This invariant holds for all CFDs which get inserted into the DB, hence, we can move it inside the insert function.
3 years ago
Thomas Eizinger
07ebb08606
Transition uses of `do_send` to `send`
`do_send` on `MessageChannel` suffers from the same problems as
`Address#do_send` and `Address#do_send_async`.
Our uses only send messages that never fail so we don't need to adjust
anything.
3 years ago
Thomas Eizinger
9811136b05
Remove duplicate message
This is already logged in the connection actor.
3 years ago
Thomas Eizinger
a1dd85f481
Split `Cfd#handle` function into multiple
We always constructed the specific enum variant at the call site.
Might as well call a particular function which is simpler.
3 years ago
Thomas Eizinger
e297a4468a
Simplify invoking `oracle::GetAnnouncement`
Moving the error message into the handler reduces complexity in the
cfd actor.
3 years ago
Thomas Eizinger
211072b9ed
Remove unnecessary indirection of `TakerCommand`
3 years ago
Mariusz Klochowicz
beb10e84fd
Don't use tokio feature from xtra
Prefer using our FutureExt to enforce keeping RemoteHandles to prevent zombie
tasks.
3 years ago
Mariusz Klochowicz
855181f06c
Expand Tasks API for ergonomics
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.
3 years ago
Mariusz Klochowicz
6afe3f8e6c
Disallow calls to tokio::spawn outside dedicated extension trait
Prevent accidentally spawning a task that could outlive the actor system
and become a zombie.
Any long-lived task should be tied to its owner by keeping RemoteHandle around.
3 years ago
Mariusz Klochowicz
bea968d27b
Tie lifetimes of spawned tasks to actors
3 years ago
Thomas Eizinger
30dc9481e4
Ban do_send_async and do_send functions
Both of these discard the return value which can lead to hard to find
bugs if the return value is an `Err`.
3 years ago
Thomas Eizinger
dd69419c4e
Migrate `do_send_async` to `send`
These handlers never fail. Nothing left to do.
3 years ago
Thomas Eizinger
56170250b8
Migrate `do_send_async` to `send`
Broadcasting an order never fails.
3 years ago
Thomas Eizinger
0eaa1ff82e
Migrate `do_send_async` to `send`
These handlers never fail and we are always connected.
3 years ago
Thomas Eizinger
ca36e0b8f4
Migrate `do_send_async` to `send`
We cleaned up our internal state already, hence we can bubble up
the error here.
3 years ago
Thomas Eizinger
e448f37442
Migrate `do_send_async` to `send`
This cannot fail, nothing left to do.
3 years ago
Thomas Eizinger
4e34bbade4
Migrate `do_send_async` to `send`
First log the warning, then attempt to send. This makes sure we always
log the warning, even if we fail to send the message.
3 years ago
Thomas Eizinger
a253a62582
Migrate `do_send_async` to `send`
First clean up state, then attempt to send the message. If it fails,
we bubble up but leave things in a consistent state.
3 years ago
Thomas Eizinger
7f0a218502
Migrate `do_send_async` to `send`
If we fail to deliver `NotifySettlementAccepted`, we just clean-up
our internal state.
3 years ago
Thomas Eizinger
ec8e4d6c6a
Migrate `do_send_async` to `send`
Handling the `Sync` message is quick because we internally use
concurrency to fetch attestations and announcement. This will not
actually block startup.
3 years ago
Thomas Eizinger
8c025d4ed2
Mock handlers for contract setup
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.
3 years ago
Thomas Eizinger
47bfc3a2a9
Replace implementation of TakerId with public key
This is a backwards-incompatible change in regards to the database
because we previously serialized UUIDs and now expect to deserialize
public keys.
It is a first step towards #576 .
3 years ago
Thomas Eizinger
8bda269e7a
Improve variable naming
3 years ago
Thomas Eizinger
0b2d2ec3c2
Prefer tracing fields of stringified log message
3 years ago
Mariusz Klochowicz
342c36ef72
Reduce heartbeat interval in test harness
As a rule of thumb, taker waits twice the amount of HEARTBEAT_INTERVAL until it
assumes that maker disappeared.
3 years ago
Mariusz Klochowicz
e8d2c86182
Add a test for triggering and noticing a maker shutdown
3 years ago
Mariusz Klochowicz
9c4e89325f
Tie tasks spawned inside actor systems to actor system lifetime
When the actor system shuts down, async tasks spawned by it on the tokio runtime
should be stopped too.
3 years ago
Mariusz Klochowicz
143cc09e65
Extend our futures trait for better ergonomics with remote handles
Simplify dealing with spawning a task on a runtime that returns a remote a
handle that can be used to stop it.
3 years ago
Thomas Eizinger
573a950527
Remove left-over dbg!
3 years ago
Thomas Eizinger
05a883297f
Prettify log message for sending message
3 years ago
Thomas Eizinger
900d9560e2
Log readiness of actor systems
3 years ago
Thomas Eizinger
b1f6e9e1db
Generalize logging for received messages
3 years ago
Thomas Eizinger
ca2bd5e291
Statically ensure that our only failure mode is `NoConnection`
By creating a dedicated error type, we can communicate that the only
failure mode of this function is a missing connection.
3 years ago
Thomas Eizinger
561b189de1
Remove unnecessary `Result` return value
3 years ago
Thomas Eizinger
89576974e2
Inline `handle_new_order`
This indirection is unnecessary.
3 years ago
Thomas Eizinger
1e38ec38ac
`unwrap` only in the tests
This makes the stacktrace more useful because it shows us where exactly
it is failing.
3 years ago
Thomas Eizinger
7bdc93c636
Reduce timeout to 10 seconds
With the reduced number of payout curve entries, our tests are
always fast.
3 years ago
Mariusz Klochowicz
6c5e17edad
Use the same actor systems in production and testing
Removes the need to manually align test harness whenever actor systems get
expanded.
3 years ago
Thomas Eizinger
4b85cd5704
Log establishment of connection
3 years ago
Thomas Eizinger
cf5e50029c
Use `TcpStream` to connect to address
Not only this now automatically support IPv6, it is also shorter.
3 years ago
Thomas Eizinger
a4c0b181cf
Allow domains for maker argument
Resolving a DNS entry to a socket address can yield multiple A records.
Thus we need to try all of them.
Resolves #292 .
3 years ago
Thomas Eizinger
97ed7ba54e
Extract connecting into helper function
3 years ago
Thomas Eizinger
b118ffece5
Remove maker default address
This made only sense during local testing.
3 years ago
Thomas Eizinger
b01e3b1dc6
Move handling of bad connection into `send_to_taker` function
This makes sure we notice bad connections upon all messages.
3 years ago
Thomas Eizinger
49d4665fa9
Don't log entire order to avoid log spam
3 years ago