Commit Graph

32 Commits

Author SHA1 Message Date
Daniel Karzel
83ce6f2c85 Ensure that Bob can cancel correctly if T1 expired and Alice did not move
Bob has to check for the possibility to cancel in every state after he locked the BTC.
Otherwise Bob will try to perform actions that don't have any point.
2020-12-22 16:27:25 +11:00
bors[bot]
3db71997d3
Merge #99
99: Cleanup resume_from_database functions only used in tests r=da-kami a=da-kami

Follow up of https://github.com/comit-network/xmr-btc-swap/pull/88

Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-18 03:01:18 +00:00
Daniel Karzel
773eebc723 Cleanup resume_from_database functions only used in tests 2020-12-18 10:50:32 +11:00
Franck Royer
84bec0631b
Rename alice::negotiate to steps
This module includes helper function for each state.
2020-12-15 16:49:38 +11:00
Franck Royer
5ba830f3bf
Replace swap recover terminology with resume 2020-12-15 11:52:00 +11:00
Franck Royer
8cc470a80e
Use -ed terminology for cancel state 2020-12-15 11:47:05 +11:00
Daniel Karzel
91d4d5da25
Cleanup swap execution to not return EventLoopHandle, refactor both_refund test 2020-12-15 11:43:28 +11:00
rishflab
143d8bc07d
Move message0 response handler out of NB 2020-12-15 11:43:24 +11:00
Daniel Karzel
4143394767
Add recovery function for Alice 2020-12-15 11:40:40 +11:00
rishflab
4b00141c29
Fix happy path test 2020-12-15 11:40:36 +11:00
Franck Royer
4ce8695dfc
Align with origin/database 2020-12-15 11:29:38 +11:00
Franck Royer
1a5b9f9fa9
Update tests after rebase 2020-12-15 10:19:45 +11:00
Franck Royer
c4cdd098fd
Use from instead of try_from for Alice state conversion 2020-12-15 10:19:03 +11:00
Franck Royer
64b021daf4
Save Alice states in db 2020-12-15 10:10:40 +11:00
Franck Royer
238f6a989d
Extract spend key as soon as possible 2020-12-15 09:18:23 +11:00
Franck Royer
c095693a5f
Refund swap if resumed from a step that requires further communication 2020-12-15 09:17:12 +11:00
rishflab
d8d6477ee9 Remove and fix comments 2020-12-14 11:56:14 +11:00
rishflab
7af4b6980a Test Alice refunds after Bob refund
Reworked Alice XmrLocked state transition handler to handle the
scenario when Alice received the encsig but Bob refunds.
Previously Alice was trying to redeem after receiving the encsig
without checking if t1 had elapsed.
2020-12-11 17:05:34 +11:00
Franck Royer
2c9fb7b1da
Rename var to match type name 2020-12-10 14:03:45 +11:00
rishflab
9ba89194b0 Rename swarm driver to event loop 2020-12-10 13:29:53 +11:00
rishflab
27d1334726 Init Alice behaviour with state0
Previously state0 had to be set after creating Alice's behaviour.
With the event loop we no longer has access to the swarm so
set_state0() has to be called indirectly through a channel. This
means it is difficult to guarantee state0 is being set due to the
asynchronous nature of channels. This was solved by initialising
Alice with state0.
2020-12-10 13:29:53 +11:00
rishflab
58da1df9dc Create SwarmDriverHandle to resolve ownership issues 2020-12-10 11:24:08 +11:00
rishflab
6f7408ecce Drive swarm in seperate async task
Previously the libp2p swarm had to be manually polled within the
protocol execution code to execute actions such as sending a
message. The swarm is now wrapped in SwarmDriver which polls the
swarm in a seperate task
2020-12-10 11:24:05 +11:00
rishflab
8592ef5f79 Address PR feedback
Add context to logging statements. Use amount type for monero in tests. Remove stale
code and comments.
2020-12-07 13:55:13 +11:00
rishflab
c91e9652aa Add alice punish test
Use reusable test init functions for happy path test

Extract tracing setup to reusable function

Move test initialization to seperate functions

Increase stack size in CI

Fix monero max finality time

Force Bob swarm polling to send message 2

Run Bob state to xmr_locked in punish test to force the sending of
message2. Previously Bob state was run until btc_locked. Although
this was the right thing to do, message2 was not being sent as the
swarm was not polled in btc_locked. Alice punish test passes.

Add info logging to executor
2020-12-04 17:23:37 +11:00
rishflab
5fef68322a Allow Alice to exit execution at a specified state 2020-12-04 17:16:03 +11:00
Franck Royer
624716d8a7
Upgrade rust-bitcoin to 0.25 2020-12-04 08:11:55 +11:00
Franck Royer
765482b0aa
Implement wait_for_transaction_finality 2020-12-02 10:02:20 +11:00
rishflab
1c401aad31 Fix clippy warnings and formatting 2020-12-01 15:38:24 +11:00
Franck Royer
9e13034e54 Extract execution details from driving loop 2020-11-30 15:13:20 +11:00
rishflab
24631d464d Add test for recursive executor 2020-11-30 15:13:20 +11:00
rishflab
3b005bd15c Resolve rebase issues, restructure code and fix warnings 2020-11-30 15:13:20 +11:00