From: Vihiga Tyonum Date: Wed, 18 Mar 2026 12:22:52 +0000 (+0100) Subject: fix(test): Enable any client type in config test X-Git-Tag: v3.0.0~3^2 X-Git-Url: http://internal-gitweb-vhost/parse/src/example_cli/base64/-script-hash.html?a=commitdiff_plain;h=af0d98e16f8fc6d8e9bdf431d0d39e23b5d51d6a;p=bdk-cli fix(test): Enable any client type in config test As pointed out in the issue #255, whenever Esplora was compiled out, the config test will fail because Esplora was used as the client. This fix addresses the above issue by adding other client types in the test. --- diff --git a/src/config.rs b/src/config.rs index 69c0238..197dc07 100644 --- a/src/config.rs +++ b/src/config.rs @@ -166,20 +166,49 @@ impl TryFrom<&WalletConfigInner> for WalletOpts { mod tests { use super::*; use std::convert::TryInto; + const EXT_DESCRIPTOR: &str = "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg"; + const INT_DESCRIPTOR: &str = "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/1/*)#y7qjdnts"; #[test] fn test_wallet_config_inner_to_opts_conversion() { + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "rpc", + feature = "cbf" + ))] + let client_type = { + if cfg!(feature = "esplora") { + Some("esplora".to_string()) + } else if cfg!(feature = "rpc") { + Some("rpc".to_string()) + } else if cfg!(feature = "electrum") { + Some("electrum".to_string()) + } else if cfg!(feature = "cbf") { + Some("cbf".to_string()) + } else { + None + } + }; + let wallet_config = WalletConfigInner { wallet: "test_wallet".to_string(), network: "testnet4".to_string(), - ext_descriptor: "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg".to_string(), - int_descriptor: Some("wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/1/*)#y7qjdnts".to_string()), + ext_descriptor: EXT_DESCRIPTOR.to_string(), + int_descriptor: Some(INT_DESCRIPTOR.to_string()), #[cfg(any(feature = "sqlite", feature = "redb"))] database_type: "sqlite".to_string(), - #[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc", feature = "cbf"))] - client_type: Some("esplora".to_string()), + + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "rpc", + feature = "cbf" + ))] + client_type, + #[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))] - server_url: Some(" https://blockstream.info/testnet4/api".to_string()), + server_url: Some("https://example.com/testnet/api".to_string()), #[cfg(feature = "electrum")] batch_size: None, #[cfg(feature = "esplora")] @@ -197,22 +226,33 @@ mod tests { .expect("Conversion should succeed"); assert_eq!(opts.wallet, Some("test_wallet".to_string())); - assert_eq!( - opts.ext_descriptor, - "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg" - ); - #[cfg(any( - feature = "electrum", + #[cfg(all( feature = "esplora", - feature = "rpc", - feature = "cbf" + not(any(feature = "electrum", feature = "rpc", feature = "cbf")) ))] assert_eq!(opts.client_type, ClientType::Esplora); + #[cfg(all( + feature = "rpc", + not(any(feature = "esplora", feature = "electrum", feature = "cbf")) + ))] + assert_eq!(opts.client_type, ClientType::Rpc); + + #[cfg(all(feature = "electrum", not(any(feature = "esplora", feature = "rpc"))))] + assert_eq!(opts.client_type, ClientType::Electrum); + + #[cfg(all( + feature = "cbf", + not(any(feature = "esplora", feature = "rpc", feature = "electrum")) + ))] + assert_eq!(opts.client_type, ClientType::Cbf); + #[cfg(feature = "sqlite")] assert_eq!(opts.database_type, DatabaseType::Sqlite); + assert_eq!(opts.ext_descriptor, EXT_DESCRIPTOR); + #[cfg(feature = "electrum")] assert_eq!(opts.batch_size, 10);