mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-15 16:48:58 -05:00
Simplify xmr-btc/tests Monero wallet
- Make it the same for Alice and Bob. - Make it contain a wallet client instead of the `Monero` struct. Also: Remove `Container` from inside `Monero` struct. The caller of `new` can simply ensure that `Container` is not dropped to keep the container alive. This makes the `Monero` struct easier to work with, as it just holds the data necessary to create the different clients created during `init`, and does not have any lifetime restrictions.
This commit is contained in:
parent
55629838f4
commit
50ed74319f
8 changed files with 88 additions and 207 deletions
|
|
@ -5,18 +5,18 @@ use xmr_btc::{alice, bob};
|
|||
|
||||
// TODO: merge this with bob node
|
||||
// This struct is responsible for I/O
|
||||
pub struct AliceNode<'a> {
|
||||
pub struct AliceNode {
|
||||
transport: Transport<alice::Message, bob::Message>,
|
||||
pub bitcoin_wallet: wallet::bitcoin::Wallet,
|
||||
pub monero_wallet: wallet::monero::AliceWallet<'a>,
|
||||
pub monero_wallet: wallet::monero::Wallet,
|
||||
}
|
||||
|
||||
impl<'a> AliceNode<'a> {
|
||||
impl AliceNode {
|
||||
pub fn new(
|
||||
transport: Transport<alice::Message, bob::Message>,
|
||||
bitcoin_wallet: wallet::bitcoin::Wallet,
|
||||
monero_wallet: wallet::monero::AliceWallet<'a>,
|
||||
) -> AliceNode<'a> {
|
||||
monero_wallet: wallet::monero::Wallet,
|
||||
) -> AliceNode {
|
||||
Self {
|
||||
transport,
|
||||
bitcoin_wallet,
|
||||
|
|
@ -25,8 +25,8 @@ impl<'a> AliceNode<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn run_alice_until<'a, R: RngCore + CryptoRng>(
|
||||
alice: &mut AliceNode<'a>,
|
||||
pub async fn run_alice_until<R: RngCore + CryptoRng>(
|
||||
alice: &mut AliceNode,
|
||||
initial_state: alice::State,
|
||||
is_state: fn(&alice::State) -> bool,
|
||||
rng: &mut R,
|
||||
|
|
@ -49,18 +49,18 @@ pub async fn run_alice_until<'a, R: RngCore + CryptoRng>(
|
|||
|
||||
// TODO: merge this with alice node
|
||||
// This struct is responsible for I/O
|
||||
pub struct BobNode<'a> {
|
||||
pub struct BobNode {
|
||||
transport: Transport<bob::Message, alice::Message>,
|
||||
pub bitcoin_wallet: wallet::bitcoin::Wallet,
|
||||
pub monero_wallet: wallet::monero::BobWallet<'a>,
|
||||
pub monero_wallet: wallet::monero::Wallet,
|
||||
}
|
||||
|
||||
impl<'a> BobNode<'a> {
|
||||
impl BobNode {
|
||||
pub fn new(
|
||||
transport: Transport<bob::Message, alice::Message>,
|
||||
bitcoin_wallet: wallet::bitcoin::Wallet,
|
||||
monero_wallet: wallet::monero::BobWallet<'a>,
|
||||
) -> BobNode<'a> {
|
||||
monero_wallet: wallet::monero::Wallet,
|
||||
) -> BobNode {
|
||||
Self {
|
||||
transport,
|
||||
bitcoin_wallet,
|
||||
|
|
@ -69,8 +69,8 @@ impl<'a> BobNode<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn run_bob_until<'a, R: RngCore + CryptoRng>(
|
||||
bob: &mut BobNode<'a>,
|
||||
pub async fn run_bob_until<R: RngCore + CryptoRng>(
|
||||
bob: &mut BobNode,
|
||||
initial_state: bob::State,
|
||||
is_state: fn(&bob::State) -> bool,
|
||||
rng: &mut R,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue