Skip to content

Commit 4311760

Browse files
committed
Move bitcoind tests to inner crate
This will allow us to have separate test dependacies and test CI only on stable. Ideally, we would want to have to a conditional dev dependancy but that is not possible currently
1 parent 1781af3 commit 4311760

File tree

10 files changed

+29
-10
lines changed

10 files changed

+29
-10
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ hashbrown = { version = "0.11", optional = true }
3030
actual-serde = { package = "serde", version = "1.0", optional = true }
3131

3232
[dev-dependencies]
33-
bitcoind = { version = "0.27.0", features=["23_0"] }
34-
actual-rand = { package = "rand", version = "0.8.4"}
35-
secp256k1 = {version = "0.24.0", features = ["rand-std"]}
3633
serde_test = "1.0.147"
34+
bitcoin = { version = "0.29.2", features = ["base64"] }
35+
secp256k1 = {version = "0.24.0", features = ["rand-std"]}
36+
actual-base64 = { package = "base64", version = "0.13.0" }
3737

3838
[[example]]
3939
name = "htlc"
@@ -65,4 +65,4 @@ required-features = ["compiler","std"]
6565

6666
[[example]]
6767
name = "psbt_sign_finalize"
68-
required-features = ["std"]
68+
required-features = ["std", "base64"]

bitcoind-tests/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "bitcoind-tests"
3+
version = "0.1.0"
4+
authors = ["sanket1729 <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
miniscript = {path = "../"}
11+
bitcoind = { version = "0.29.3", features=["23_0"] }
12+
actual-rand = { package = "rand", version = "0.8.4"}
13+
secp256k1 = {version = "0.24.0", features = ["rand-std"]}

bitcoind-tests/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}
File renamed without changes.
File renamed without changes.

tests/setup/test_util.rs renamed to bitcoind-tests/tests/setup/test_util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
2020
use std::str::FromStr;
2121

22+
use miniscript::bitcoin;
2223
use actual_rand as rand;
2324
use bitcoin::hashes::hex::ToHex;
2425
use bitcoin::hashes::{hash160, ripemd160, sha256, Hash};
@@ -29,6 +30,7 @@ use miniscript::{
2930
Translator,
3031
};
3132
use rand::RngCore;
33+
3234
#[derive(Clone, Debug)]
3335
pub struct PubData {
3436
pub pks: Vec<bitcoin::PublicKey>,

tests/test_cpp.rs renamed to bitcoind-tests/tests/test_cpp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use bitcoin::hashes::{sha256d, Hash};
1313
use bitcoin::secp256k1::{self, Secp256k1};
1414
use bitcoin::util::psbt;
1515
use bitcoin::util::psbt::PartiallySignedTransaction as Psbt;
16-
use bitcoin::{self, Amount, LockTime, OutPoint, Sequence, Transaction, TxIn, TxOut, Txid};
16+
use bitcoin::{Amount, LockTime, OutPoint, Sequence, Transaction, TxIn, TxOut, Txid};
1717
use bitcoind::bitcoincore_rpc::{json, Client, RpcApi};
18+
use miniscript::bitcoin;
1819
use miniscript::psbt::PsbtExt;
1920
use miniscript::Descriptor;
2021

tests/test_desc.rs renamed to bitcoind-tests/tests/test_desc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use std::collections::BTreeMap;
88
use std::{error, fmt};
99

10+
use miniscript::bitcoin;
1011
use actual_rand as rand;
1112
use bitcoin::blockdata::witness::Witness;
1213
use bitcoin::hashes::{sha256d, Hash};
@@ -15,7 +16,7 @@ use bitcoin::util::sighash::SighashCache;
1516
use bitcoin::util::taproot::{LeafVersion, TapLeafHash};
1617
use bitcoin::util::{psbt, sighash};
1718
use bitcoin::{
18-
self, secp256k1, Amount, LockTime, OutPoint, SchnorrSig, Script, Sequence, Transaction, TxIn,
19+
secp256k1, Amount, LockTime, OutPoint, SchnorrSig, Script, Sequence, Transaction, TxIn,
1920
TxOut, Txid,
2021
};
2122
use bitcoind::bitcoincore_rpc::{json, Client, RpcApi};

examples/psbt_sign_finalize.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use std::collections::BTreeMap;
22
use std::str::FromStr;
33

4+
use actual_base64 as base64;
45
use bitcoin::consensus::serialize;
56
use bitcoin::util::sighash::SighashCache;
67
use bitcoin::{PackedLockTime, PrivateKey};
7-
use bitcoind::bitcoincore_rpc::jsonrpc::base64;
8-
use bitcoind::bitcoincore_rpc::RawTx;
98
use miniscript::bitcoin::consensus::encode::deserialize;
109
use miniscript::bitcoin::hashes::hex::FromHex;
1110
use miniscript::bitcoin::util::psbt;
@@ -165,7 +164,7 @@ fn main() {
165164
println!("{:#?}", psbt);
166165

167166
let tx = psbt.extract_tx();
168-
println!("{}", tx.raw_hex());
167+
println!("{}", bitcoin::consensus::encode::serialize_hex(&tx));
169168
}
170169

171170
// Find the Outpoint by spk

examples/taproot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::collections::HashMap;
22
use std::str::FromStr;
33

4+
use bitcoin::secp256k1::{rand, KeyPair};
45
use bitcoin::util::address::WitnessVersion;
56
use bitcoin::Network;
67
use miniscript::descriptor::DescriptorType;
78
use miniscript::policy::Concrete;
89
use miniscript::{translate_hash_fail, Descriptor, Miniscript, Tap, TranslatePk, Translator};
9-
use secp256k1::{rand, KeyPair};
1010

1111
// Refer to https://github.com/sanket1729/adv_btc_workshop/blob/master/workshop.md#creating-a-taproot-descriptor
1212
// for a detailed explanation of the policy and it's compilation

0 commit comments

Comments
 (0)