mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Scope alice db
To better match the restart scenario
This commit is contained in:
parent
dc96b3d1e9
commit
edfab58246
@ -84,18 +84,20 @@ async fn given_alice_restarts_after_xmr_is_locked_abort_swap() {
|
|||||||
|
|
||||||
let alice_swap_id = Uuid::new_v4();
|
let alice_swap_id = Uuid::new_v4();
|
||||||
let alice_db_datadir = tempdir().unwrap();
|
let alice_db_datadir = tempdir().unwrap();
|
||||||
let alice_db = Database::open(alice_db_datadir.path()).unwrap();
|
|
||||||
|
|
||||||
let alice_xmr_locked_fut = alice::swap::run_until(
|
let alice_xmr_locked_fut = {
|
||||||
alice_state,
|
let alice_db = Database::open(alice_db_datadir.path()).unwrap();
|
||||||
alice::swap::is_xmr_locked,
|
alice::swap::run_until(
|
||||||
alice_event_loop_handle_1,
|
alice_state,
|
||||||
alice_btc_wallet.clone(),
|
alice::swap::is_xmr_locked,
|
||||||
alice_xmr_wallet.clone(),
|
alice_event_loop_handle_1,
|
||||||
Config::regtest(),
|
alice_btc_wallet.clone(),
|
||||||
alice_swap_id,
|
alice_xmr_wallet.clone(),
|
||||||
alice_db,
|
Config::regtest(),
|
||||||
);
|
alice_swap_id,
|
||||||
|
alice_db,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
tokio::spawn(async move { bob_event_loop.run().await });
|
tokio::spawn(async move { bob_event_loop.run().await });
|
||||||
|
|
||||||
@ -112,21 +114,23 @@ async fn given_alice_restarts_after_xmr_is_locked_abort_swap() {
|
|||||||
panic!("Bob in unexpected state");
|
panic!("Bob in unexpected state");
|
||||||
};
|
};
|
||||||
|
|
||||||
let alice_db = Database::open(alice_db_datadir.path()).unwrap();
|
|
||||||
let (mut alice_event_loop_2, alice_event_loop_handle_2) =
|
let (mut alice_event_loop_2, alice_event_loop_handle_2) =
|
||||||
testutils::init_alice_event_loop(alice_multiaddr);
|
testutils::init_alice_event_loop(alice_multiaddr);
|
||||||
|
|
||||||
let alice_final_state = alice::swap::swap(
|
let alice_final_state = {
|
||||||
alice_restart_state,
|
let alice_db = Database::open(alice_db_datadir.path()).unwrap();
|
||||||
alice_event_loop_handle_2,
|
alice::swap::swap(
|
||||||
alice_btc_wallet.clone(),
|
alice_restart_state,
|
||||||
alice_xmr_wallet.clone(),
|
alice_event_loop_handle_2,
|
||||||
Config::regtest(),
|
alice_btc_wallet.clone(),
|
||||||
alice_swap_id,
|
alice_xmr_wallet.clone(),
|
||||||
alice_db,
|
Config::regtest(),
|
||||||
)
|
alice_swap_id,
|
||||||
.await
|
alice_db,
|
||||||
.unwrap();
|
)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
tokio::spawn(async move { alice_event_loop_2.run().await });
|
tokio::spawn(async move { alice_event_loop_2.run().await });
|
||||||
|
|
||||||
assert!(matches!(alice_final_state, AliceState::XmrRefunded));
|
assert!(matches!(alice_final_state, AliceState::XmrRefunded));
|
||||||
|
Loading…
Reference in New Issue
Block a user