From fd9f633a7736ae0adee816b209a3d4c47636b6e8 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Wed, 10 Feb 2021 09:40:16 +1100 Subject: [PATCH] Remove Alice restarts tests Current focus is on CLI UX. Fair amount of change needs to happen to cater for Alice (nectar) restart scenarios. --- .github/workflows/ci.yml | 3 -- bors.toml | 3 -- swap/tests/happy_path_restart_alice.rs | 31 ------------- swap/tests/refund_restart_alice.rs | 33 -------------- swap/tests/refund_restart_alice_cancelled.rs | 47 -------------------- 5 files changed, 117 deletions(-) delete mode 100644 swap/tests/happy_path_restart_alice.rs delete mode 100644 swap/tests/refund_restart_alice.rs delete mode 100644 swap/tests/refund_restart_alice_cancelled.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a46ef1f9..1c4aecb4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,13 +127,10 @@ jobs: matrix: test_name: [ happy_path, - happy_path_restart_alice, happy_path_restart_bob_after_comm, happy_path_restart_bob_after_lock_proof_received, happy_path_restart_bob_before_comm, punish, - refund_restart_alice_cancelled, - refund_restart_alice, 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_force, diff --git a/bors.toml b/bors.toml index 8b82cb8c..929e07ea 100644 --- a/bors.toml +++ b/bors.toml @@ -3,11 +3,8 @@ status = [ "build_test (x86_64-unknown-linux-gnu)", "build_test (x86_64-apple-darwin)", "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_lock_proof_received)", "docker_tests (happy_path_restart_bob_before_comm)", "docker_tests (punish)", - "docker_tests (refund_restart_alice_cancelled)", - "docker_tests (refund_restart_alice)", ] diff --git a/swap/tests/happy_path_restart_alice.rs b/swap/tests/happy_path_restart_alice.rs deleted file mode 100644 index fbf2515c..00000000 --- a/swap/tests/happy_path_restart_alice.rs +++ /dev/null @@ -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; -} diff --git a/swap/tests/refund_restart_alice.rs b/swap/tests/refund_restart_alice.rs deleted file mode 100644 index 5af2c7a0..00000000 --- a/swap/tests/refund_restart_alice.rs +++ /dev/null @@ -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; -} diff --git a/swap/tests/refund_restart_alice_cancelled.rs b/swap/tests/refund_restart_alice_cancelled.rs deleted file mode 100644 index 129887a1..00000000 --- a/swap/tests/refund_restart_alice_cancelled.rs +++ /dev/null @@ -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; -}