mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Remove StartingBalances
from release code
This commit is contained in:
parent
181999e04f
commit
9e3ef7ea24
@ -67,7 +67,7 @@ async fn main() -> Result<()> {
|
||||
btc: receive_bitcoin,
|
||||
};
|
||||
|
||||
let (bitcoin_wallet, monero_wallet, starting_balances) = setup_wallets(
|
||||
let (bitcoin_wallet, monero_wallet) = setup_wallets(
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name.as_str(),
|
||||
monero_wallet_rpc_url,
|
||||
@ -88,7 +88,6 @@ async fn main() -> Result<()> {
|
||||
swap_id,
|
||||
bitcoin_wallet,
|
||||
monero_wallet,
|
||||
starting_balances,
|
||||
db_path,
|
||||
listen_addr,
|
||||
)
|
||||
@ -112,7 +111,7 @@ async fn main() -> Result<()> {
|
||||
xmr: receive_monero,
|
||||
};
|
||||
|
||||
let (bitcoin_wallet, monero_wallet, _starting_balances) = setup_wallets(
|
||||
let (bitcoin_wallet, monero_wallet) = setup_wallets(
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name.as_str(),
|
||||
monero_wallet_rpc_url,
|
||||
@ -162,7 +161,7 @@ async fn main() -> Result<()> {
|
||||
monero_wallet_rpc_url,
|
||||
listen_addr,
|
||||
}) => {
|
||||
let (bitcoin_wallet, monero_wallet, starting_balances) = setup_wallets(
|
||||
let (bitcoin_wallet, monero_wallet) = setup_wallets(
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name.as_str(),
|
||||
monero_wallet_rpc_url,
|
||||
@ -176,7 +175,6 @@ async fn main() -> Result<()> {
|
||||
swap_id,
|
||||
bitcoin_wallet,
|
||||
monero_wallet,
|
||||
starting_balances,
|
||||
db_path,
|
||||
listen_addr,
|
||||
)
|
||||
@ -194,7 +192,7 @@ async fn main() -> Result<()> {
|
||||
alice_peer_id,
|
||||
alice_addr,
|
||||
}) => {
|
||||
let (bitcoin_wallet, monero_wallet, _starting_balances) = setup_wallets(
|
||||
let (bitcoin_wallet, monero_wallet) = setup_wallets(
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name.as_str(),
|
||||
monero_wallet_rpc_url,
|
||||
@ -226,11 +224,7 @@ async fn setup_wallets(
|
||||
bitcoin_wallet_name: &str,
|
||||
monero_wallet_rpc_url: url::Url,
|
||||
config: Config,
|
||||
) -> Result<(
|
||||
Arc<swap::bitcoin::Wallet>,
|
||||
Arc<swap::monero::Wallet>,
|
||||
StartingBalances,
|
||||
)> {
|
||||
) -> Result<(Arc<swap::bitcoin::Wallet>, Arc<swap::monero::Wallet>)> {
|
||||
let bitcoin_wallet =
|
||||
swap::bitcoin::Wallet::new(bitcoin_wallet_name, bitcoind_url, config.bitcoin_network)
|
||||
.await?;
|
||||
@ -249,10 +243,5 @@ async fn setup_wallets(
|
||||
);
|
||||
let monero_wallet = Arc::new(monero_wallet);
|
||||
|
||||
let starting_balances = StartingBalances {
|
||||
btc: bitcoin_balance,
|
||||
xmr: monero_balance,
|
||||
};
|
||||
|
||||
Ok((bitcoin_wallet, monero_wallet, starting_balances))
|
||||
Ok((bitcoin_wallet, monero_wallet))
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ pub struct SwapFactory {
|
||||
|
||||
pub bitcoin_wallet: Arc<bitcoin::Wallet>,
|
||||
pub monero_wallet: Arc<monero::Wallet>,
|
||||
pub starting_balances: StartingBalances,
|
||||
}
|
||||
|
||||
impl SwapFactory {
|
||||
@ -75,7 +74,6 @@ impl SwapFactory {
|
||||
swap_id: Uuid,
|
||||
bitcoin_wallet: Arc<bitcoin::Wallet>,
|
||||
monero_wallet: Arc<monero::Wallet>,
|
||||
starting_balances: StartingBalances,
|
||||
db_path: PathBuf,
|
||||
listen_address: Multiaddr,
|
||||
) -> Self {
|
||||
@ -92,7 +90,6 @@ impl SwapFactory {
|
||||
listen_address,
|
||||
bitcoin_wallet,
|
||||
monero_wallet,
|
||||
starting_balances,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,16 @@ use tracing_core::dispatcher::DefaultGuard;
|
||||
use tracing_log::LogTracer;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StartingBalances {
|
||||
pub xmr: monero::Amount,
|
||||
pub btc: bitcoin::Amount,
|
||||
}
|
||||
|
||||
pub struct TestContext {
|
||||
swap_amounts: SwapAmounts,
|
||||
alice_swap_factory: alice::SwapFactory,
|
||||
alice_starting_balances: StartingBalances,
|
||||
bob_swap_factory: bob::SwapFactory,
|
||||
bob_starting_balances: StartingBalances,
|
||||
}
|
||||
@ -79,7 +86,7 @@ impl TestContext {
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
btc_balance_after_swap,
|
||||
self.alice_swap_factory.starting_balances.btc + self.swap_amounts.btc
|
||||
self.alice_starting_balances.btc + self.swap_amounts.btc
|
||||
- bitcoin::Amount::from_sat(bitcoin::TX_FEE)
|
||||
);
|
||||
|
||||
@ -90,10 +97,7 @@ impl TestContext {
|
||||
.get_balance()
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(
|
||||
xmr_balance_after_swap
|
||||
<= self.alice_swap_factory.starting_balances.xmr - self.swap_amounts.xmr
|
||||
);
|
||||
assert!(xmr_balance_after_swap <= self.alice_starting_balances.xmr - self.swap_amounts.xmr);
|
||||
}
|
||||
|
||||
pub async fn assert_alice_refunded(&self, state: AliceState) {
|
||||
@ -106,10 +110,7 @@ impl TestContext {
|
||||
.balance()
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
btc_balance_after_swap,
|
||||
self.alice_swap_factory.starting_balances.btc
|
||||
);
|
||||
assert_eq!(btc_balance_after_swap, self.alice_starting_balances.btc);
|
||||
|
||||
// Ensure that Alice's balance is refreshed as we use a newly created wallet
|
||||
self.alice_swap_factory
|
||||
@ -141,7 +142,7 @@ impl TestContext {
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
btc_balance_after_swap,
|
||||
self.alice_swap_factory.starting_balances.btc + self.swap_amounts.btc
|
||||
self.alice_starting_balances.btc + self.swap_amounts.btc
|
||||
- bitcoin::Amount::from_sat(2 * bitcoin::TX_FEE)
|
||||
);
|
||||
|
||||
@ -152,10 +153,7 @@ impl TestContext {
|
||||
.get_balance()
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(
|
||||
xmr_balance_after_swap
|
||||
<= self.alice_swap_factory.starting_balances.xmr - self.swap_amounts.xmr
|
||||
);
|
||||
assert!(xmr_balance_after_swap <= self.alice_starting_balances.xmr - self.swap_amounts.xmr);
|
||||
}
|
||||
|
||||
pub async fn assert_bob_redeemed(&self, state: BobState) {
|
||||
@ -331,7 +329,6 @@ where
|
||||
Uuid::new_v4(),
|
||||
alice_bitcoin_wallet,
|
||||
alice_monero_wallet,
|
||||
alice_starting_balances,
|
||||
tempdir().unwrap().path().to_path_buf(),
|
||||
listen_address,
|
||||
)
|
||||
@ -364,6 +361,7 @@ where
|
||||
let test = TestContext {
|
||||
swap_amounts,
|
||||
alice_swap_factory,
|
||||
alice_starting_balances,
|
||||
bob_swap_factory,
|
||||
bob_starting_balances,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user