Skip to content

Commit a501434

Browse files
committed
Merge #256: fix(test): Enable using any client in config test
af0d98e fix(test): Enable any client type in config test (Vihiga Tyonum) Pull request description: ### Description As pointed out in issue #255, whenever Esplora was configured 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. <!-- You can erase any parts of this template not applicable to your Pull Request. --> Fixes #255 ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: * [ ] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR ACKs for top commit: notmandatory: cACK af0d98e Tree-SHA512: f1eecabd0d1dc9fc6e005655ffd158d5ed1e1021156ae2ce96195f78fcab35a13380269dd019157da34a8cd28308525d3ef4e1b08a0b6dec2e217a5782052f02
2 parents f1bab08 + af0d98e commit a501434

File tree

1 file changed

+53
-13
lines changed

1 file changed

+53
-13
lines changed

src/config.rs

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,49 @@ impl TryFrom<&WalletConfigInner> for WalletOpts {
166166
mod tests {
167167
use super::*;
168168
use std::convert::TryInto;
169+
const EXT_DESCRIPTOR: &str = "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg";
170+
const INT_DESCRIPTOR: &str = "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/1/*)#y7qjdnts";
169171

170172
#[test]
171173
fn test_wallet_config_inner_to_opts_conversion() {
174+
#[cfg(any(
175+
feature = "electrum",
176+
feature = "esplora",
177+
feature = "rpc",
178+
feature = "cbf"
179+
))]
180+
let client_type = {
181+
if cfg!(feature = "esplora") {
182+
Some("esplora".to_string())
183+
} else if cfg!(feature = "rpc") {
184+
Some("rpc".to_string())
185+
} else if cfg!(feature = "electrum") {
186+
Some("electrum".to_string())
187+
} else if cfg!(feature = "cbf") {
188+
Some("cbf".to_string())
189+
} else {
190+
None
191+
}
192+
};
193+
172194
let wallet_config = WalletConfigInner {
173195
wallet: "test_wallet".to_string(),
174196
network: "testnet4".to_string(),
175-
ext_descriptor: "wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/0/*)#429nsxmg".to_string(),
176-
int_descriptor: Some("wpkh([07234a14/84'/1'/0']tpubDCSgT6PaVLQH9h2TAxKryhvkEurUBcYRJc9dhTcMDyahhWiMWfEWvQQX89yaw7w7XU8bcVujoALfxq59VkFATri3Cxm5mkp9kfHfRFDckEh/1/*)#y7qjdnts".to_string()),
197+
ext_descriptor: EXT_DESCRIPTOR.to_string(),
198+
int_descriptor: Some(INT_DESCRIPTOR.to_string()),
177199
#[cfg(any(feature = "sqlite", feature = "redb"))]
178200
database_type: "sqlite".to_string(),
179-
#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc", feature = "cbf"))]
180-
client_type: Some("esplora".to_string()),
201+
202+
#[cfg(any(
203+
feature = "electrum",
204+
feature = "esplora",
205+
feature = "rpc",
206+
feature = "cbf"
207+
))]
208+
client_type,
209+
181210
#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))]
182-
server_url: Some(" https://blockstream.info/testnet4/api".to_string()),
211+
server_url: Some("https://example.com/testnet/api".to_string()),
183212
#[cfg(feature = "electrum")]
184213
batch_size: None,
185214
#[cfg(feature = "esplora")]
@@ -197,22 +226,33 @@ mod tests {
197226
.expect("Conversion should succeed");
198227

199228
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-
);
204229

205-
#[cfg(any(
206-
feature = "electrum",
230+
#[cfg(all(
207231
feature = "esplora",
208-
feature = "rpc",
209-
feature = "cbf"
232+
not(any(feature = "electrum", feature = "rpc", feature = "cbf"))
210233
))]
211234
assert_eq!(opts.client_type, ClientType::Esplora);
212235

236+
#[cfg(all(
237+
feature = "rpc",
238+
not(any(feature = "esplora", feature = "electrum", feature = "cbf"))
239+
))]
240+
assert_eq!(opts.client_type, ClientType::Rpc);
241+
242+
#[cfg(all(feature = "electrum", not(any(feature = "esplora", feature = "rpc"))))]
243+
assert_eq!(opts.client_type, ClientType::Electrum);
244+
245+
#[cfg(all(
246+
feature = "cbf",
247+
not(any(feature = "esplora", feature = "rpc", feature = "electrum"))
248+
))]
249+
assert_eq!(opts.client_type, ClientType::Cbf);
250+
213251
#[cfg(feature = "sqlite")]
214252
assert_eq!(opts.database_type, DatabaseType::Sqlite);
215253

254+
assert_eq!(opts.ext_descriptor, EXT_DESCRIPTOR);
255+
216256
#[cfg(feature = "electrum")]
217257
assert_eq!(opts.batch_size, 10);
218258

0 commit comments

Comments
 (0)