Skip to content

Commit a17479a

Browse files
committed
test: delete bitcoind tests
Sigh, after all the work I did to get a lockfile for the previous commit, it turns out that all the bitcoind tests were disabled anyway, with the explanation "breaking change in bitcoind". This commit deletes them entirely. We have no plans to fix them. If we ever want to regression test miniscript 9.x, we should do it externally by adding a fuzztest in master which pulls it in and tries to parse stuff. Then it will be actively exercised and maintained and not require ancient broken dependencies. This commit is all red EXCEPT a change to a test in src/miniscript/mod.rs. What's happening here is that we had one test (asserting on the string representation of errors from rust-bitcoin) which fails when the std feature is off. As it turns out, `bitcoind` unconditionally turns on that feature. So by having `bitcoind` as a dev-dependency it was impossible for us to ever test the nostd feature properly. Sigh.
1 parent ac1d9bb commit a17479a

File tree

8 files changed

+10
-1567
lines changed

8 files changed

+10
-1567
lines changed

Cargo-recent.lock

Lines changed: 2 additions & 780 deletions
Large diffs are not rendered by default.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ hashbrown = { version = "0.11", optional = true }
2929
actual-serde = { package = "serde", version = "1.0", optional = true }
3030

3131
[dev-dependencies]
32-
bitcoind = { version = "0.27.0", features=["23_0"] }
3332
actual-rand = { package = "rand", version = "0.8.4"}
3433
secp256k1 = {version = "0.24.0", features = ["rand-std"]}
3534

examples/psbt_sign_finalize.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use std::str::FromStr;
44
use bitcoin::consensus::serialize;
55
use bitcoin::util::sighash::SighashCache;
66
use bitcoin::{PackedLockTime, PrivateKey};
7-
use bitcoind::bitcoincore_rpc::jsonrpc::base64;
8-
use bitcoind::bitcoincore_rpc::RawTx;
7+
use bitcoin::hashes::hex::ToHex as _;
98
use miniscript::bitcoin::consensus::encode::deserialize;
109
use miniscript::bitcoin::hashes::hex::FromHex;
1110
use miniscript::bitcoin::util::psbt;
@@ -158,14 +157,18 @@ fn main() {
158157

159158
println!("{:#?}", psbt);
160159

160+
/*
161+
// In bitcoin 0.29.x there is no base64 encoding of PSBTs, so this line
162+
// would require an entire extra dependency.
161163
let serialized = serialize(&psbt);
162164
println!("{}", base64::encode(&serialized));
165+
*/
163166

164167
psbt.finalize_mut(&secp256k1).unwrap();
165168
println!("{:#?}", psbt);
166169

167170
let tx = psbt.extract_tx();
168-
println!("{}", tx.raw_hex());
171+
println!("{}", serialize(&tx).to_hex());
169172
}
170173

171174
// Find the Outpoint by spk

src/miniscript/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,8 @@ mod tests {
996996
"pk(2788ee41e76f4f3af603da5bc8fa22997bc0344bb0f95666ba6aaff0242baa99)"
997997
));
998998
assert_eq!(
999-
ms.unwrap_err().to_string(),
1000-
"unexpected «key hex decoding error»",
999+
&ms.unwrap_err().to_string()[..35],
1000+
"unexpected «key hex decoding error",
10011001
);
10021002
Tapscript::from_str_insane(&format!(
10031003
"pk(2788ee41e76f4f3af603da5bc8fa22997bc0344bb0f95666ba6aaff0242baa99)"

tests/setup/mod.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
11
extern crate miniscript;
22

3-
use bitcoind::bitcoincore_rpc::RpcApi;
4-
use bitcoind::BitcoinD;
5-
use miniscript::bitcoin;
6-
73
pub mod test_util;
84

9-
// Launch an instance of bitcoind with
10-
pub fn setup() -> BitcoinD {
11-
let exe_path = bitcoind::exe_path().unwrap();
12-
let bitcoind = bitcoind::BitcoinD::new(exe_path).unwrap();
13-
let cl = &bitcoind.client;
14-
// generate to an address by the wallet. And wait for funds to mature
15-
let addr = cl.get_new_address(None, None).unwrap();
16-
let blks = cl.generate_to_address(101, &addr).unwrap();
17-
assert_eq!(blks.len(), 101);
18-
19-
assert_eq!(
20-
cl.get_balance(Some(1) /*min conf*/, None).unwrap(),
21-
bitcoin::Amount::from_sat(100_000_000 * 50)
22-
);
23-
bitcoind
24-
}

tests/setup/test_util.rs

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::str::FromStr;
2222
use actual_rand as rand;
2323
use bitcoin::hashes::hex::ToHex;
2424
use bitcoin::hashes::{hash160, ripemd160, sha256, Hash};
25-
use bitcoin::secp256k1;
2625
use miniscript::descriptor::{SinglePub, SinglePubKey};
2726
use miniscript::{
2827
hash256, Descriptor, DescriptorPublicKey, Error, Miniscript, ScriptContext, TranslatePk,
@@ -54,81 +53,6 @@ pub struct TestData {
5453
pub secretdata: SecretData,
5554
}
5655

57-
// Setup (sk, pk) pairs
58-
fn setup_keys(
59-
n: usize,
60-
) -> (
61-
Vec<bitcoin::secp256k1::SecretKey>,
62-
Vec<miniscript::bitcoin::PublicKey>,
63-
Vec<bitcoin::KeyPair>,
64-
Vec<bitcoin::XOnlyPublicKey>,
65-
) {
66-
let secp_sign = secp256k1::Secp256k1::signing_only();
67-
let mut sk = [0; 32];
68-
let mut sks = vec![];
69-
let mut pks = vec![];
70-
for i in 1..n + 1 {
71-
sk[0] = i as u8;
72-
sk[1] = (i >> 8) as u8;
73-
sk[2] = (i >> 16) as u8;
74-
75-
let sk = secp256k1::SecretKey::from_slice(&sk[..]).expect("secret key");
76-
let pk = miniscript::bitcoin::PublicKey {
77-
inner: secp256k1::PublicKey::from_secret_key(&secp_sign, &sk),
78-
compressed: true,
79-
};
80-
pks.push(pk);
81-
sks.push(sk);
82-
}
83-
84-
let mut x_only_keypairs = vec![];
85-
let mut x_only_pks = vec![];
86-
87-
for i in 0..n {
88-
let keypair = bitcoin::KeyPair::from_secret_key(&secp_sign, &sks[i]);
89-
let (xpk, _parity) = bitcoin::XOnlyPublicKey::from_keypair(&keypair);
90-
x_only_keypairs.push(keypair);
91-
x_only_pks.push(xpk);
92-
}
93-
(sks, pks, x_only_keypairs, x_only_pks)
94-
}
95-
96-
impl TestData {
97-
// generate a fixed data for n keys
98-
pub(crate) fn new_fixed_data(n: usize) -> Self {
99-
let (sks, pks, x_only_keypairs, x_only_pks) = setup_keys(n);
100-
let sha256_pre = [0x12 as u8; 32];
101-
let sha256 = sha256::Hash::hash(&sha256_pre);
102-
let hash256_pre = [0x34 as u8; 32];
103-
let hash256 = hash256::Hash::hash(&hash256_pre);
104-
let hash160_pre = [0x56 as u8; 32];
105-
let hash160 = hash160::Hash::hash(&hash160_pre);
106-
let ripemd160_pre = [0x78 as u8; 32];
107-
let ripemd160 = ripemd160::Hash::hash(&ripemd160_pre);
108-
109-
let pubdata = PubData {
110-
pks,
111-
sha256,
112-
hash256,
113-
ripemd160,
114-
hash160,
115-
x_only_pks,
116-
};
117-
let secretdata = SecretData {
118-
sks,
119-
sha256_pre,
120-
hash256_pre,
121-
ripemd160_pre,
122-
hash160_pre,
123-
x_only_keypairs,
124-
};
125-
Self {
126-
pubdata,
127-
secretdata,
128-
}
129-
}
130-
}
131-
13256
/// Obtain an insecure random public key with unknown secret key for testing
13357
pub fn random_pk(mut seed: u8) -> bitcoin::PublicKey {
13458
loop {

0 commit comments

Comments
 (0)