From: Vihiga Tyonum Date: Fri, 21 Feb 2025 03:16:26 +0000 (+0100) Subject: feat: add ci test for features X-Git-Tag: v1.0.0~7^2~10 X-Git-Url: http://internal-gitweb-vhost/?a=commitdiff_plain;h=a2ad6b3b72b2377036c3ba761befc0cc7418b23b;p=bdk-cli feat: add ci test for features - add ci test for features - add "compiler" feature to bdk_wallet dependency - remove duplicate fn in utils.rs - replace "possible_values" with "value_parser" as it is deprecated in clap 4.5 [Ticket: X] --- diff --git a/Cargo.toml b/Cargo.toml index 04aa35f..81c06cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" license = "MIT" [dependencies] -bdk_wallet = { version = "1.0.0", features = ["rusqlite", "keys-bip39"] } +bdk_wallet = { version = "1.0.0", features = ["rusqlite", "keys-bip39", "compiler"] } clap = { version = "4.5", features = ["derive","env"] } dirs = { version = "6.0.0" } env_logger = "0.11.6" diff --git a/ci/test_features.sh b/ci/test_features.sh new file mode 100755 index 0000000..826a8d6 --- /dev/null +++ b/ci/test_features.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +feature_combinations=( + "default" + "repl" + "sqlite" + "electrum" + "esplora" + "verify" + "compiler" + "repl sqlite" + "repl electrum" + "repl esplora" + "repl verify" + "repl compiler" + "sqlite electrum" + "sqlite esplora" + "sqlite verify" + "sqlite compiler" +) + +for features in "${feature_combinations[@]}"; do + echo "Testing with features: $features" + + if ! cargo build --features "$features"; then + echo "Build failed with features: $features" + exit 1 + fi + + if ! cargo test --features "$features"; then + echo "Tests failed with features: $features" + exit 1 + fi + + echo "Tests passed with features: $features" + echo "----------------------------------------" +done + +echo "All feature combinations tested successfully!" diff --git a/src/commands.rs b/src/commands.rs index f8754a8..7659d2c 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -96,7 +96,7 @@ pub enum CliSubCommand { #[arg(env = "POLICY", required = true, index = 1)] policy: String, /// Sets the script type used to embed the compiled policy. - #[arg(env = "TYPE", short = 't', long = "type", default_value = "wsh", possible_values = &["sh","wsh", "sh-wsh"] + #[arg(env = "TYPE", short = 't', long = "type", default_value = "wsh", value_parser = ["sh","wsh", "sh-wsh"] )] script_type: String, }, diff --git a/src/handlers.rs b/src/handlers.rs index ae88d3c..fb318bb 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -30,7 +30,7 @@ use bdk_wallet::bitcoin::{secp256k1::Secp256k1, Transaction, Txid}; use bdk_wallet::bitcoin::{Amount, FeeRate, Psbt, Sequence}; use bdk_wallet::descriptor::Segwitv0; #[cfg(feature = "compiler")] -use bdk_wallet::descriptor::{Descriptor, Legacy, Miniscript}; +use bdk_wallet::{descriptor::{Descriptor, Legacy, Miniscript}, miniscript::policy::Concrete}; use bdk_wallet::keys::bip39::WordCount; #[cfg(feature = "sqlite")] use bdk_wallet::rusqlite::Connection; @@ -42,18 +42,15 @@ use bdk_wallet::miniscript::miniscript; use std::collections::{BTreeMap, HashSet}; use std::convert::TryFrom; use std::io::Write; - -#[cfg(feature = "compiler")] -use bdk_wallet::miniscript::policy::Concrete; use serde_json::json; use std::str::FromStr; #[cfg(feature = "electrum")] use crate::utils::BlockchainClient::Electrum; #[cfg(feature = "esplora")] -use crate::utils::BlockchainClient::Esplora; -#[cfg(feature = "esplora")] -use bdk_esplora::EsploraAsyncExt; +use {crate::utils::BlockchainClient::Esplora, + bdk_esplora::EsploraAsyncExt +}; use bdk_wallet::bitcoin::base64::prelude::*; use bdk_wallet::bitcoin::consensus::Decodable; use bdk_wallet::bitcoin::hex::FromHex; diff --git a/src/utils.rs b/src/utils.rs index 6fd83be..795ebaf 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -117,20 +117,6 @@ pub(crate) fn prepare_wallet_db_dir( Ok(dir) } -#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc",))] -pub(crate) enum BlockchainClient { - #[cfg(feature = "electrum")] - Electrum { - client: bdk_electrum::BdkElectrumClient, - batch_size: usize, - }, - #[cfg(feature = "esplora")] - Esplora { - client: bdk_esplora::esplora_client::AsyncClient, - parallel_requests: usize, - }, -} - #[cfg(any( feature = "electrum", feature = "esplora", @@ -155,7 +141,7 @@ pub(crate) enum BlockchainClient { #[cfg(any( feature = "electrum", feature = "esplora", - feature = "rpc", + // feature = "rpc", feature = "cbf", ))] /// Create a new blockchain from the wallet configuration options. diff --git a/tests/integration.rs b/tests/integration.rs index 3faaf1f..2a8b60c 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -11,7 +11,7 @@ //! This modules performs the necessary integration test for bdk-cli //! The tests can be run using `cargo test` -#[cfg(feature = "regtest-node")] +#[cfg(feature = "rpc")] mod test { use electrsd::bitcoind::tempfile::TempDir; use serde_json::{json, Value};