mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-17 20:04:25 -05:00
Remove Alice restarts tests
Current focus is on CLI UX. Fair amount of change needs to happen to cater for Alice (nectar) restart scenarios.
This commit is contained in:
parent
bfc19d5628
commit
fd9f633a77
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -127,13 +127,10 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
test_name: [
|
test_name: [
|
||||||
happy_path,
|
happy_path,
|
||||||
happy_path_restart_alice,
|
|
||||||
happy_path_restart_bob_after_comm,
|
happy_path_restart_bob_after_comm,
|
||||||
happy_path_restart_bob_after_lock_proof_received,
|
happy_path_restart_bob_after_lock_proof_received,
|
||||||
happy_path_restart_bob_before_comm,
|
happy_path_restart_bob_before_comm,
|
||||||
punish,
|
punish,
|
||||||
refund_restart_alice_cancelled,
|
|
||||||
refund_restart_alice,
|
|
||||||
bob_refunds_using_cancel_and_refund_command,
|
bob_refunds_using_cancel_and_refund_command,
|
||||||
bob_refunds_using_cancel_and_refund_command_timelock_not_exired,
|
bob_refunds_using_cancel_and_refund_command_timelock_not_exired,
|
||||||
bob_refunds_using_cancel_and_refund_command_timelock_not_exired_force,
|
bob_refunds_using_cancel_and_refund_command_timelock_not_exired_force,
|
||||||
|
@ -3,11 +3,8 @@ status = [
|
|||||||
"build_test (x86_64-unknown-linux-gnu)",
|
"build_test (x86_64-unknown-linux-gnu)",
|
||||||
"build_test (x86_64-apple-darwin)",
|
"build_test (x86_64-apple-darwin)",
|
||||||
"docker_tests (happy_path)",
|
"docker_tests (happy_path)",
|
||||||
"docker_tests (happy_path_restart_alice)",
|
|
||||||
"docker_tests (happy_path_restart_bob_after_comm)",
|
"docker_tests (happy_path_restart_bob_after_comm)",
|
||||||
"docker_tests (happy_path_restart_bob_after_lock_proof_received)",
|
"docker_tests (happy_path_restart_bob_after_lock_proof_received)",
|
||||||
"docker_tests (happy_path_restart_bob_before_comm)",
|
"docker_tests (happy_path_restart_bob_before_comm)",
|
||||||
"docker_tests (punish)",
|
"docker_tests (punish)",
|
||||||
"docker_tests (refund_restart_alice_cancelled)",
|
|
||||||
"docker_tests (refund_restart_alice)",
|
|
||||||
]
|
]
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
pub mod testutils;
|
|
||||||
|
|
||||||
use swap::protocol::{alice, alice::AliceState, bob};
|
|
||||||
use testutils::{alice_run_until::is_encsig_learned, SlowCancelConfig};
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
|
|
||||||
testutils::setup_test(SlowCancelConfig, |mut ctx| async move {
|
|
||||||
let (alice_swap, alice_join_handle) = ctx.new_swap_as_alice().await;
|
|
||||||
let (bob_swap, _) = ctx.new_swap_as_bob().await;
|
|
||||||
|
|
||||||
let bob = bob::run(bob_swap);
|
|
||||||
let bob_handle = tokio::spawn(bob);
|
|
||||||
|
|
||||||
let alice_state = alice::run_until(alice_swap, is_encsig_learned)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert!(matches!(alice_state, AliceState::EncSigLearned { .. }));
|
|
||||||
|
|
||||||
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
|
||||||
assert!(matches!(alice_swap.state, AliceState::EncSigLearned { .. }));
|
|
||||||
|
|
||||||
let alice_state = alice::run(alice_swap).await.unwrap();
|
|
||||||
|
|
||||||
ctx.assert_alice_redeemed(alice_state).await;
|
|
||||||
|
|
||||||
let bob_state = bob_handle.await.unwrap();
|
|
||||||
ctx.assert_bob_redeemed(bob_state.unwrap()).await
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
pub mod testutils;
|
|
||||||
|
|
||||||
use swap::protocol::{alice, alice::AliceState, bob};
|
|
||||||
use testutils::{alice_run_until::is_xmr_locked, FastCancelConfig};
|
|
||||||
|
|
||||||
/// Bob locks btc and Alice locks xmr. Alice fails to act so Bob refunds. Alice
|
|
||||||
/// then also refunds.
|
|
||||||
#[tokio::test]
|
|
||||||
async fn given_alice_restarts_after_xmr_is_locked_refund_swap() {
|
|
||||||
testutils::setup_test(FastCancelConfig, |mut ctx| async move {
|
|
||||||
let (alice_swap, alice_join_handle) = ctx.new_swap_as_alice().await;
|
|
||||||
let (bob_swap, _) = ctx.new_swap_as_bob().await;
|
|
||||||
|
|
||||||
let bob = bob::run(bob_swap);
|
|
||||||
let bob_handle = tokio::spawn(bob);
|
|
||||||
|
|
||||||
let alice_state = alice::run_until(alice_swap, is_xmr_locked).await.unwrap();
|
|
||||||
assert!(matches!(alice_state, AliceState::XmrLocked { .. }));
|
|
||||||
|
|
||||||
// Alice does not act, Bob refunds
|
|
||||||
let bob_state = bob_handle.await.unwrap();
|
|
||||||
ctx.assert_bob_refunded(bob_state.unwrap()).await;
|
|
||||||
|
|
||||||
// Once bob has finished Alice is restarted and refunds as well
|
|
||||||
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
|
||||||
assert!(matches!(alice_swap.state, AliceState::XmrLocked { .. }));
|
|
||||||
|
|
||||||
let alice_state = alice::run(alice_swap).await.unwrap();
|
|
||||||
|
|
||||||
ctx.assert_alice_refunded(alice_state).await;
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
pub mod testutils;
|
|
||||||
|
|
||||||
use swap::{
|
|
||||||
execution_params,
|
|
||||||
protocol::{alice, alice::AliceState, bob},
|
|
||||||
};
|
|
||||||
use testutils::alice_run_until::is_encsig_learned;
|
|
||||||
|
|
||||||
/// Bob locks btc and Alice locks xmr. Alice fails to act so Bob refunds. Alice
|
|
||||||
/// is forced to refund even though she learned the secret and would be able to
|
|
||||||
/// redeem had the timelock not expired.
|
|
||||||
#[tokio::test]
|
|
||||||
async fn given_alice_restarts_after_enc_sig_learned_and_bob_already_cancelled_refund_swap() {
|
|
||||||
testutils::setup_test(execution_params::Regtest, |mut ctx| async move {
|
|
||||||
let (alice_swap, alice_join_handle) = ctx.new_swap_as_alice().await;
|
|
||||||
let (bob_swap, _) = ctx.new_swap_as_bob().await;
|
|
||||||
|
|
||||||
let bob = bob::run(bob_swap);
|
|
||||||
let bob_handle = tokio::spawn(bob);
|
|
||||||
|
|
||||||
let alice_state = alice::run_until(alice_swap, is_encsig_learned)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert!(
|
|
||||||
matches!(alice_state, AliceState::EncSigLearned { .. }),
|
|
||||||
"Alice state is not EncSigLearned: {:?}",
|
|
||||||
alice_state
|
|
||||||
);
|
|
||||||
|
|
||||||
// Wait for Bob to refund, because Alice does not act
|
|
||||||
let bob_state = bob_handle.await.unwrap();
|
|
||||||
ctx.assert_bob_refunded(bob_state.unwrap()).await;
|
|
||||||
|
|
||||||
// Once bob has finished Alice is restarted and refunds as well
|
|
||||||
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
|
||||||
assert!(
|
|
||||||
matches!(alice_swap.state, AliceState::EncSigLearned { .. }),
|
|
||||||
"Alice state is not EncSigLearned: {:?}",
|
|
||||||
alice_state
|
|
||||||
);
|
|
||||||
|
|
||||||
let alice_state = alice::run(alice_swap).await.unwrap();
|
|
||||||
|
|
||||||
ctx.assert_alice_refunded(alice_state).await;
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user