From: Vihiga Tyonum Date: Wed, 8 Jul 2026 18:55:23 +0000 (+0100) Subject: test: Add tests for dns payment instn feature X-Git-Url: http://internal-gitweb-vhost/blockdata/script/encode/-script/display/struct.ChainCode.html?a=commitdiff_plain;h=6000dd52a79f04752f758e444925afcdc72b19e5;p=bdk-cli test: Add tests for dns payment instn feature --- diff --git a/src/handlers/online.rs b/src/handlers/online.rs index 2aa2ffc..f2900cb 100644 --- a/src/handlers/online.rs +++ b/src/handlers/online.rs @@ -83,7 +83,7 @@ pub struct FullScanCommand { /// Stop searching addresses for transactions after finding an unused gap of this length. #[arg(env = "STOP_GAP", long = "scan-stop-gap", default_value = "20")] stop_gap: usize, - // #[clap(long, default_value = "5")] + #[clap(long, default_value = "5")] pub parallel_request: usize, } diff --git a/tests/integration/online.rs b/tests/integration/online.rs index 7f37058..0ba166d 100644 --- a/tests/integration/online.rs +++ b/tests/integration/online.rs @@ -917,7 +917,56 @@ mod test_online { "proven_amount should equal the funded UTXO value: {result}" ); } + + // `create_dns_tx` with a plain `--to` recipient + #[cfg(feature = "dns_payment")] + #[test] + fn test_create_dns_tx_plain_recipient() { + use bdk_wallet::bitcoin::Psbt; + let (cli, mut cmd_init, env) = setup_online_wallet(); + cmd_init.assert().success(); + fund_and_sync_wallet(&cli, &env); + + let psbt_b64 = run_wallet_json( + &cli, + &["create_dns_tx", "--to", &format!("{RECIPIENT}:20000")], + )["psbt"] + .as_str() + .expect("create_dns_tx: missing 'psbt'") + .to_string(); + + let psbt: Psbt = psbt_b64 + .parse() + .expect("create_dns_tx returned an invalid PSBT"); + assert!( + psbt.unsigned_tx + .output + .iter() + .any(|o| o.value.to_sat() == 20_000), + "expected the 20_000 sat recipient output" + ); + } + + // With neither `--to` nor `--to_dns`, the command errors. + #[cfg(feature = "dns_payment")] + #[test] + fn test_create_dns_tx_requires_recipient() { + let (cli, mut cmd_init, _env) = setup_online_wallet(); + cmd_init.assert().success(); + + let out = cli + .wallet_cmd(&["--wallet", WALLET_NAME, "create_dns_tx"]) + .output() + .unwrap(); + assert!(!out.status.success(), "should fail with no recipients"); + assert!( + String::from_utf8_lossy(&out.stderr).contains("Either --to or --to_dns"), + "expected recipient-required error, got: {}", + String::from_utf8_lossy(&out.stderr) + ); + } } + #[cfg(feature = "esplora")] mod test_esplora { use crate::common::BdkCli;