Browse Source

Merge #440

440: Only transition maker to `ContractSetup` if we succeed to contract taker r=da-kami a=da-kami

Stumbled on this when writing actor tests.
We cannot create a failing test for this code at the moment, because our current test framework does not allow us to test at this granulairty level.
Nevertheless, we should fix this.

Rational:

If the maker is unable to contact the taker about the contract setup we fail now (previously we tried to continue).
This means, that we should only transition the maker's cfd to the new state if we are able to contact the maker.

Co-authored-by: Daniel Karzel <daniel@comit.network>
contact-taker-before-changing-cfd-state
bors[bot] 3 years ago
committed by GitHub
parent
commit
ed50140afc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      daemon/src/maker_cfd.rs

11
daemon/src/maker_cfd.rs

@ -574,12 +574,7 @@ where
.await?
.with_context(|| format!("Announcement {} not found", cfd.order.oracle_event_id))?;
// 3. Insert that we are in contract setup and refresh our own feed
cfd.state = CfdState::contract_setup();
append_cfd_state(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
// 4. Notify the taker that we are ready for contract setup
// 3. Notify the taker that we are ready for contract setup
// Use `.send` here to ensure we only continue once the message has been sent
// Nothing done after this call should be able to fail, otherwise we notified the taker, but
// might not transition to `Active` ourselves!
@ -590,6 +585,10 @@ where
})
.await??;
// 4. Insert that we are in contract setup and refresh our own feed
cfd.state = CfdState::contract_setup();
append_cfd_state(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
// 5. Spawn away the contract setup
let (sender, receiver) = mpsc::unbounded();
let contract_future = setup_contract::new(

Loading…
Cancel
Save