From 247b59cf97ce541f8d39543407ab1ab74f3bd8e9 Mon Sep 17 00:00:00 2001 From: nic <139033898+dicnunz@users.noreply.github.com> Date: Fri, 8 May 2026 21:31:55 -0400 Subject: [PATCH] Fix swap-core unit tests --- bitcoin-wallet/src/wallet.rs | 24 ++++++++++++------------ swap-core/src/monero/primitives.rs | 5 +---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/bitcoin-wallet/src/wallet.rs b/bitcoin-wallet/src/wallet.rs index 033b0cc79..25b1536fb 100644 --- a/bitcoin-wallet/src/wallet.rs +++ b/bitcoin-wallet/src/wallet.rs @@ -2921,7 +2921,7 @@ impl TestWalletBuilder { } } -/// Implement BitcoinWallet trait for a stub wallet and panic when the function is not implemented +/// Implement the wallet trait for the in-memory static-fee wallet used by tests. #[async_trait::async_trait] #[allow(unused)] impl BitcoinWallet for Wallet { @@ -2934,15 +2934,15 @@ impl BitcoinWallet for Wallet { } async fn balance(&self) -> Result { - unimplemented!("stub method called erroneously") + Wallet::balance(self).await } async fn balance_info(&self) -> Result { - unimplemented!("stub method called erroneously") + Wallet::balance_info(self).await } async fn new_address(&self) -> Result
{ - unimplemented!("stub method called erroneously") + Wallet::new_address(self).await } async fn send_to_address( @@ -2952,7 +2952,7 @@ impl BitcoinWallet for Wallet { spending_fee: Amount, change_override: Option
, ) -> Result { - unimplemented!("stub method called erroneously") + Wallet::send_to_address(self, address, amount, spending_fee, change_override).await } async fn send_to_address_dynamic_fee( @@ -2961,15 +2961,15 @@ impl BitcoinWallet for Wallet { amount: Amount, change_override: Option
, ) -> Result { - unimplemented!("stub method called erroneously") + Wallet::send_to_address_dynamic_fee(self, address, amount, change_override).await } async fn sweep_balance_to_address_dynamic_fee(&self, address: Address) -> Result { - unimplemented!("stub method called erroneously") + Wallet::sweep_balance_to_address_dynamic_fee(self, address).await } async fn sign_and_finalize(&self, psbt: Psbt) -> Result { - unimplemented!("stub method called erroneously") + Wallet::sign_and_finalize(self, psbt).await } async fn sync(&self) -> Result<()> { @@ -2992,7 +2992,7 @@ impl BitcoinWallet for Wallet { } async fn max_giveable(&self, locking_script_size: usize) -> Result<(Amount, Amount)> { - unimplemented!("stub method called erroneously") + Wallet::max_giveable(self, locking_script_size).await } async fn estimate_fee( @@ -3000,15 +3000,15 @@ impl BitcoinWallet for Wallet { weight: Weight, transfer_amount: Option, ) -> Result { - unimplemented!("stub method called erroneously") + Wallet::estimate_fee(self, weight, transfer_amount).await } fn network(&self) -> Network { - unimplemented!("stub method called erroneously") + Wallet::network(self) } fn finality_confirmations(&self) -> u32 { - unimplemented!("stub method called erroneously") + Wallet::finality_confirmations(self) } async fn wallet_export(&self, role: &str) -> Result { diff --git a/swap-core/src/monero/primitives.rs b/swap-core/src/monero/primitives.rs index 90d97c197..12220f1c7 100644 --- a/swap-core/src/monero/primitives.rs +++ b/swap-core/src/monero/primitives.rs @@ -506,10 +506,7 @@ mod tests { fn parse_monero_overflows() { let overflow_pics = "18446744.073709551616"; let error = Amount::parse_monero(overflow_pics).unwrap_err(); - assert_eq!( - error.downcast_ref::().unwrap(), - &OverflowError(overflow_pics.to_owned()) - ); + assert_eq!(error.to_string(), format!("{overflow_pics} too big")); } #[test]