mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Add balance assertions to restart tests
This commit is contained in:
parent
5ba830f3bf
commit
9d266fc648
@ -66,6 +66,11 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
|
||||
)
|
||||
.await;
|
||||
|
||||
// TODO: we are making a clone of Bob's wallets here to keep them in scope after
|
||||
// Bob's wallets are moved into an async task.
|
||||
let bob_btc_wallet_clone = bob_btc_wallet.clone();
|
||||
let bob_xmr_wallet_clone = bob_xmr_wallet.clone();
|
||||
|
||||
let _ = tokio::spawn(async move {
|
||||
bob::swap::swap(
|
||||
bob_state,
|
||||
@ -116,8 +121,8 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
|
||||
|
||||
let alice_state = alice::swap::resume_from_database(
|
||||
event_loop_handle_after_restart,
|
||||
alice_btc_wallet,
|
||||
alice_xmr_wallet,
|
||||
alice_btc_wallet.clone(),
|
||||
alice_xmr_wallet.clone(),
|
||||
config,
|
||||
alice_swap_id,
|
||||
alice_db,
|
||||
@ -127,5 +132,19 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
|
||||
|
||||
assert!(matches!(alice_state, AliceState::BtcRedeemed {..}));
|
||||
|
||||
// TODO: Additionally assert balances
|
||||
let btc_alice_final = alice_btc_wallet.as_ref().balance().await.unwrap();
|
||||
let btc_bob_final = bob_btc_wallet_clone.as_ref().balance().await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
btc_alice_final,
|
||||
btc_to_swap - bitcoin::Amount::from_sat(bitcoin::TX_FEE)
|
||||
);
|
||||
assert!(btc_bob_final <= bob_btc_starting_balance - btc_to_swap);
|
||||
|
||||
let xmr_alice_final = alice_xmr_wallet.as_ref().get_balance().await.unwrap();
|
||||
bob_xmr_wallet_clone.as_ref().0.refresh().await.unwrap();
|
||||
let xmr_bob_final = bob_xmr_wallet_clone.as_ref().get_balance().await.unwrap();
|
||||
|
||||
assert!(xmr_alice_final <= alice_xmr_starting_balance - xmr_to_swap);
|
||||
assert_eq!(xmr_bob_final, xmr_to_swap);
|
||||
}
|
||||
|
@ -67,11 +67,21 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
|
||||
)
|
||||
.await;
|
||||
|
||||
// TODO: we are making a clone of Alices's wallets here to keep them in scope
|
||||
// after Alices's wallets are moved into an async task.
|
||||
let alice_btc_wallet_clone = alice_btc_wallet.clone();
|
||||
let alice_xmr_wallet_clone = alice_xmr_wallet.clone();
|
||||
|
||||
// TODO: we are making a clone of Bob's wallets here to keep them in scope after
|
||||
// Bob's wallets are moved into an async task.
|
||||
let bob_btc_wallet_clone = bob_btc_wallet.clone();
|
||||
let bob_xmr_wallet_clone = bob_xmr_wallet.clone();
|
||||
|
||||
let _ = tokio::spawn(async move {
|
||||
alice::swap::swap(
|
||||
alice_state,
|
||||
alice_event_loop_handle,
|
||||
alice_btc_wallet,
|
||||
alice_btc_wallet.clone(),
|
||||
alice_xmr_wallet.clone(),
|
||||
config,
|
||||
Uuid::new_v4(),
|
||||
@ -127,5 +137,19 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
|
||||
|
||||
assert!(matches!(alice_state, BobState::XmrRedeemed {..}));
|
||||
|
||||
// TODO: Additionally assert balances
|
||||
let btc_alice_final = alice_btc_wallet_clone.as_ref().balance().await.unwrap();
|
||||
let btc_bob_final = bob_btc_wallet_clone.as_ref().balance().await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
btc_alice_final,
|
||||
btc_to_swap - bitcoin::Amount::from_sat(bitcoin::TX_FEE)
|
||||
);
|
||||
assert!(btc_bob_final <= bob_btc_starting_balance - btc_to_swap);
|
||||
|
||||
let xmr_alice_final = alice_xmr_wallet_clone.as_ref().get_balance().await.unwrap();
|
||||
bob_xmr_wallet_clone.as_ref().0.refresh().await.unwrap();
|
||||
let xmr_bob_final = bob_xmr_wallet_clone.as_ref().get_balance().await.unwrap();
|
||||
|
||||
assert!(xmr_alice_final <= alice_xmr_starting_balance - xmr_to_swap);
|
||||
assert_eq!(xmr_bob_final, xmr_to_swap);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user