mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-08 14:32:24 -04:00
Execute Alice and Bob state machines concurrently
Previously we were testing the protocol by manually driving Alice and Bob's state machines. This logic has now be moved to an async state transition function that can take any possible state as input. The state transition function is called in a loop until it returns the desired state. This allows use to interrupt midway through the protocol and perform refund and punish tests. This design was chosen over a generator based implementation because the the generator based implementation results in a impure state transition function that is difficult to reason about and prone to bugs. Test related code was extracted into the tests folder. The 2b and 4b states were renamed to be consistent with the rest. Macros were used to reduce code duplication when converting child states to their parent states and vice versa. Todos were added were neccessary.
This commit is contained in:
parent
3d3864807d
commit
8754a9931b
15 changed files with 1211 additions and 503 deletions
|
@ -1,6 +1,4 @@
|
|||
pub mod transactions;
|
||||
#[cfg(test)]
|
||||
pub mod wallet;
|
||||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use async_trait::async_trait;
|
||||
|
@ -28,9 +26,6 @@ pub use crate::bitcoin::transactions::{TxCancel, TxLock, TxPunish, TxRedeem, TxR
|
|||
pub use bitcoin::{Address, Amount, OutPoint, Txid};
|
||||
pub use ecdsa_fun::{adaptor::EncryptedSignature, Signature};
|
||||
|
||||
#[cfg(test)]
|
||||
pub use wallet::{make_wallet, Wallet};
|
||||
|
||||
pub const TX_FEE: u64 = 10_000;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue