Harmonize names and structure

Simple renames and structure changes, no logical changes.
This commit is contained in:
Daniel Karzel 2021-01-15 19:34:51 +11:00
parent bede1c13dd
commit 8a2eb07928
3 changed files with 32 additions and 31 deletions

View File

@ -10,7 +10,9 @@ pub mod testutils;
async fn happy_path() {
testutils::test(|alice_harness, bob_harness| async move {
let alice = alice_harness.new_alice().await;
let alice_swap_fut = alice::swap(
let bob = bob_harness.new_bob().await;
let alice_swap = alice::swap(
alice.state,
alice.event_loop_handle,
alice.bitcoin_wallet.clone(),
@ -20,8 +22,7 @@ async fn happy_path() {
alice.db,
);
let bob = bob_harness.new_bob().await;
let bob_swap_fut = bob::swap(
let bob_swap = bob::swap(
bob.state,
bob.event_loop_handle,
bob.db,
@ -30,7 +31,7 @@ async fn happy_path() {
OsRng,
bob.swap_id,
);
let (alice_state, bob_state) = join!(alice_swap_fut, bob_swap_fut);
let (alice_state, bob_state) = join!(alice_swap, bob_swap);
alice_harness.assert_redeemed(alice_state.unwrap()).await;
bob_harness.assert_redeemed(bob_state.unwrap()).await;

View File

@ -9,7 +9,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
let alice = alice_harness.new_alice().await;
let bob = bob_harness.new_bob().await;
let bob_swap_fut = bob::swap(
let bob_swap = bob::swap(
bob.state,
bob.event_loop_handle,
bob.db,
@ -18,7 +18,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
OsRng,
bob.swap_id,
);
let bob_swap_handle = tokio::spawn(bob_swap_fut);
let bob_swap_handle = tokio::spawn(bob_swap);
let alice_state = alice::run_until(
alice.state,

View File

@ -47,8 +47,8 @@ pub struct AliceHarness {
swap_id: Uuid,
swap_amounts: SwapAmounts,
btc_wallet: Arc<bitcoin::Wallet>,
xmr_wallet: Arc<monero::Wallet>,
bitcoin_wallet: Arc<bitcoin::Wallet>,
monero_wallet: Arc<monero::Wallet>,
config: Config,
starting_balances: StartingBalances,
}
@ -65,7 +65,7 @@ impl AliceHarness {
pub async fn assert_redeemed(&self, state: AliceState) {
assert!(matches!(state, AliceState::BtcRedeemed));
let btc_alice_final = self.btc_wallet.as_ref().balance().await.unwrap();
let btc_alice_final = self.bitcoin_wallet.as_ref().balance().await.unwrap();
assert_eq!(
btc_alice_final,
@ -73,7 +73,7 @@ impl AliceHarness {
- bitcoin::Amount::from_sat(bitcoin::TX_FEE)
);
let xmr_alice_final = self.xmr_wallet.as_ref().get_balance().await.unwrap();
let xmr_alice_final = self.monero_wallet.as_ref().get_balance().await.unwrap();
assert!(xmr_alice_final <= self.starting_balances.xmr - self.swap_amounts.xmr);
}
@ -95,7 +95,7 @@ impl AliceHarness {
let db_path = tempdir().unwrap().path().to_path_buf();
let (btc_wallet, xmr_wallet) =
let (bitcoin_wallet, monero_wallet) =
init_wallets("alice", bitcoind, monero, starting_balances.clone(), config).await;
// TODO: This should be done by changing the production code
@ -110,8 +110,8 @@ impl AliceHarness {
peer_id,
swap_id,
swap_amounts,
btc_wallet,
xmr_wallet,
bitcoin_wallet,
monero_wallet,
config,
starting_balances,
}
@ -121,7 +121,7 @@ impl AliceHarness {
let initial_state = init_alice_state(
self.swap_amounts.btc,
self.swap_amounts.xmr,
self.btc_wallet.clone(),
self.bitcoin_wallet.clone(),
self.config,
)
.await;
@ -135,8 +135,8 @@ impl AliceHarness {
Alice {
event_loop_handle,
bitcoin_wallet: self.btc_wallet.clone(),
monero_wallet: self.xmr_wallet.clone(),
bitcoin_wallet: self.bitcoin_wallet.clone(),
monero_wallet: self.monero_wallet.clone(),
config: self.config,
db,
state: initial_state,
@ -168,8 +168,8 @@ impl AliceHarness {
Alice {
state: resume_state,
event_loop_handle,
bitcoin_wallet: self.btc_wallet.clone(),
monero_wallet: self.xmr_wallet.clone(),
bitcoin_wallet: self.bitcoin_wallet.clone(),
monero_wallet: self.monero_wallet.clone(),
config: self.config,
swap_id: self.swap_id,
db,
@ -191,8 +191,8 @@ pub struct BobHarness {
swap_id: Uuid,
swap_amounts: SwapAmounts,
btc_wallet: Arc<bitcoin::Wallet>,
xmr_wallet: Arc<monero::Wallet>,
bitcoin_wallet: Arc<bitcoin::Wallet>,
monero_wallet: Arc<monero::Wallet>,
config: Config,
starting_balances: StartingBalances,
@ -214,15 +214,15 @@ impl BobHarness {
) -> Self {
let db_path = tempdir().unwrap().path().to_path_buf();
let (btc_wallet, xmr_wallet) =
let (bitcoin_wallet, monero_wallet) =
init_wallets("bob", bitcoind, monero, starting_balances.clone(), config).await;
Self {
db_path,
swap_id,
swap_amounts,
btc_wallet,
xmr_wallet,
bitcoin_wallet,
monero_wallet,
config,
starting_balances,
alice_connect_address,
@ -234,7 +234,7 @@ impl BobHarness {
let initial_state = init_bob_state(
self.swap_amounts.btc,
self.swap_amounts.xmr,
self.btc_wallet.clone(),
self.bitcoin_wallet.clone(),
self.config,
)
.await;
@ -252,8 +252,8 @@ impl BobHarness {
state: initial_state,
event_loop_handle,
db,
bitcoin_wallet: self.btc_wallet.clone(),
monero_wallet: self.xmr_wallet.clone(),
bitcoin_wallet: self.bitcoin_wallet.clone(),
monero_wallet: self.monero_wallet.clone(),
swap_id: self.swap_id,
}
}
@ -285,8 +285,8 @@ impl BobHarness {
state: resume_state,
event_loop_handle,
db,
bitcoin_wallet: self.btc_wallet.clone(),
monero_wallet: self.xmr_wallet.clone(),
bitcoin_wallet: self.bitcoin_wallet.clone(),
monero_wallet: self.monero_wallet.clone(),
swap_id: self.swap_id,
}
}
@ -294,9 +294,9 @@ impl BobHarness {
pub async fn assert_redeemed(&self, state: BobState) {
assert!(matches!(state, BobState::XmrRedeemed));
let btc_bob_final = self.btc_wallet.as_ref().balance().await.unwrap();
self.xmr_wallet.as_ref().inner.refresh().await.unwrap();
let xmr_bob_final = self.xmr_wallet.as_ref().get_balance().await.unwrap();
let btc_bob_final = self.bitcoin_wallet.as_ref().balance().await.unwrap();
self.monero_wallet.as_ref().inner.refresh().await.unwrap();
let xmr_bob_final = self.monero_wallet.as_ref().get_balance().await.unwrap();
assert!(btc_bob_final <= self.starting_balances.btc - self.swap_amounts.btc);
assert_eq!(
xmr_bob_final,