Skip to content

Commit 6b27394

Browse files
committed
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.
1 parent 15b6f5b commit 6b27394

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

src/config.rs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,43 @@ mod tests {
169169

170170
#[test]
171171
fn test_wallet_config_inner_to_opts_conversion() {
172+
#[cfg(any(
173+
feature = "electrum",
174+
feature = "esplora",
175+
feature = "rpc",
176+
feature = "cbf"
177+
))]
178+
let client_type = {
179+
if cfg!(feature = "esplora") {
180+
Some("esplora".to_string())
181+
} else if cfg!(feature = "rpc") {
182+
Some("rpc".to_string())
183+
} else if cfg!(feature = "electrum") {
184+
Some("electrum".to_string())
185+
} else if cfg!(feature = "cbf") {
186+
Some("cbf".to_string())
187+
} else {
188+
None
189+
}
190+
};
191+
172192
let wallet_config = WalletConfigInner {
173193
wallet: "test_wallet".to_string(),
174194
network: "testnet4".to_string(),
175195
ext_descriptor: "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg".to_string(),
176196
int_descriptor: Some("wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/1/*)#y7qjdnts".to_string()),
177197
#[cfg(any(feature = "sqlite", feature = "redb"))]
178198
database_type: "sqlite".to_string(),
199+
179200
#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc", feature = "cbf"))]
180-
client_type: Some("esplora".to_string()),
201+
client_type,
202+
181203
#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))]
182-
server_url: Some(" https://blockstream.info/testnet4/api".to_string()),
204+
server_url: Some("https://example.com/testnet/api".to_string()),
183205
#[cfg(feature = "electrum")]
184-
batch_size: None,
206+
batch_size: Some(10),
185207
#[cfg(feature = "esplora")]
186-
parallel_requests: None,
208+
parallel_requests: Some(5),
187209
#[cfg(feature = "rpc")]
188210
rpc_user: None,
189211
#[cfg(feature = "rpc")]
@@ -197,22 +219,18 @@ mod tests {
197219
.expect("Conversion should succeed");
198220

199221
assert_eq!(opts.wallet, Some("test_wallet".to_string()));
200-
assert_eq!(
201-
opts.ext_descriptor,
202-
"wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg"
203-
);
204222

205-
#[cfg(any(
206-
feature = "electrum",
207-
feature = "esplora",
208-
feature = "rpc",
209-
feature = "cbf"
210-
))]
223+
#[cfg(feature = "esplora")]
211224
assert_eq!(opts.client_type, ClientType::Esplora);
212225

213226
#[cfg(feature = "sqlite")]
214227
assert_eq!(opts.database_type, DatabaseType::Sqlite);
215228

229+
assert_eq!(
230+
opts.ext_descriptor,
231+
"wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg"
232+
);
233+
216234
#[cfg(feature = "electrum")]
217235
assert_eq!(opts.batch_size, 10);
218236

0 commit comments

Comments
 (0)