fix(tests): harness (#781)

This commit is contained in:
Mohan 2025-12-01 18:37:18 +01:00 committed by GitHub
parent c25d851187
commit 2edf6ac229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 18 deletions

View file

@ -10,18 +10,13 @@ chrono = { version = "0.4", features = ["serde"] }
cxx = "1.0.137" cxx = "1.0.137"
monero = { workspace = true } monero = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
sqlx = { version = "0.8", features = [ sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio-rustls", "macros", "chrono"] }
"sqlite", thiserror = "2.0.17"
"runtime-tokio-rustls",
"macros",
"chrono",
] }
tokio = { workspace = true, features = ["sync", "time", "rt"] } tokio = { workspace = true, features = ["sync", "time", "rt"] }
tracing = { workspace = true } tracing = { workspace = true }
typeshare = { workspace = true } typeshare = { workspace = true }
url = { workspace = true } url = { workspace = true }
uuid = { workspace = true } uuid = { workspace = true }
thiserror = "2.0.17"
# Our crates # Our crates
swap-serde = { path = "../swap-serde" } swap-serde = { path = "../swap-serde" }

View file

@ -1,15 +1,15 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use crate::defaults::{ use crate::defaults::{
DEFAULT_MAX_BUY_AMOUNT, DEFAULT_MIN_BUY_AMOUNT, DEFAULT_SPREAD, default_rendezvous_points, default_rendezvous_points, DEFAULT_MAX_BUY_AMOUNT, DEFAULT_MIN_BUY_AMOUNT, DEFAULT_SPREAD,
}; };
use anyhow::{Context, Result, bail}; use anyhow::{bail, Context, Result};
use console::Style; use console::Style;
use dialoguer::Confirm; use dialoguer::Confirm;
use dialoguer::{Input, Select, theme::ColorfulTheme}; use dialoguer::{theme::ColorfulTheme, Input, Select};
use libp2p::Multiaddr; use libp2p::Multiaddr;
use rust_decimal::Decimal;
use rust_decimal::prelude::FromPrimitive; use rust_decimal::prelude::FromPrimitive;
use rust_decimal::Decimal;
use url::Url; use url::Url;
/// Prompt user for data directory /// Prompt user for data directory

View file

@ -1,4 +1,4 @@
use crate::behaviour_util::{AddressTracker}; use crate::behaviour_util::AddressTracker;
use crate::futures_util::FuturesHashSet; use crate::futures_util::FuturesHashSet;
use crate::out_event; use crate::out_event;
use crate::protocols::quote::BidQuote; use crate::protocols::quote::BidQuote;

View file

@ -79,7 +79,7 @@ mod tests {
registrar.listen_on_random_memory_address().await; registrar.listen_on_random_memory_address().await;
let registrar_id = *registrar.local_peer_id(); let registrar_id = *registrar.local_peer_id();
// Create peer that discovers the // Create peer that discovers the
let mut discoverer = new_swarm(|identity| { let mut discoverer = new_swarm(|identity| {
discovery::Behaviour::new( discovery::Behaviour::new(
identity, identity,

View file

@ -1,6 +1,6 @@
use crate::cli::api::request::{ use crate::cli::api::request::{
BalanceArgs, CancelAndRefundArgs, ExportBitcoinWalletArgs, GetConfigArgs, BalanceArgs, CancelAndRefundArgs, ExportBitcoinWalletArgs, GetConfigArgs, GetHistoryArgs,
GetHistoryArgs, MoneroRecoveryArgs, Request, ResumeSwapArgs, WithdrawBtcArgs, MoneroRecoveryArgs, Request, ResumeSwapArgs, WithdrawBtcArgs,
}; };
use crate::cli::api::Context; use crate::cli::api::Context;
use crate::monero::{self, MoneroAddressPool}; use crate::monero::{self, MoneroAddressPool};

View file

@ -103,6 +103,7 @@ pub async fn setup_test<T, F, C>(
.await .await
.main_address() .main_address()
.await .await
.unwrap()
.into(); .into();
let developer_tip_monero_wallet_subaddress = developer_tip_monero_wallet let developer_tip_monero_wallet_subaddress = developer_tip_monero_wallet
@ -384,7 +385,7 @@ async fn init_test_wallets(
let xmr_wallet = wallets.main_wallet().await; let xmr_wallet = wallets.main_wallet().await;
tracing::info!( tracing::info!(
address = %xmr_wallet.main_address().await, address = %xmr_wallet.main_address().await.unwrap(),
"Initialized monero wallet" "Initialized monero wallet"
); );
@ -534,7 +535,12 @@ impl BobParams {
pub async fn get_change_receive_addresses(&self) -> (bitcoin::Address, monero::Address) { pub async fn get_change_receive_addresses(&self) -> (bitcoin::Address, monero::Address) {
( (
self.bitcoin_wallet.new_address().await.unwrap(), self.bitcoin_wallet.new_address().await.unwrap(),
self.monero_wallet.main_wallet().await.main_address().await, self.monero_wallet
.main_wallet()
.await
.main_address()
.await
.unwrap(),
) )
} }
@ -563,6 +569,7 @@ impl BobParams {
.await .await
.main_address() .main_address()
.await .await
.unwrap()
.into(), .into(),
) )
.await .await
@ -603,6 +610,7 @@ impl BobParams {
.await .await
.main_address() .main_address()
.await .await
.unwrap()
.into(), .into(),
self.bitcoin_wallet.new_address().await?, self.bitcoin_wallet.new_address().await?,
btc_amount, btc_amount,
@ -628,7 +636,7 @@ impl BobParams {
let mut swarm = swarm::cli(identity.clone(), None, behaviour).await?; let mut swarm = swarm::cli(identity.clone(), None, behaviour).await?;
swarm.add_peer_address(self.alice_peer_id, self.alice_address.clone()); swarm.add_peer_address(self.alice_peer_id, self.alice_address.clone());
cli::EventLoop::new(swarm, db.clone()) cli::EventLoop::new(swarm, db.clone(), None)
} }
} }