Skip to content

Commit 24f6527

Browse files
committed
wip tests
1 parent b9f990b commit 24f6527

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/descriptor/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,6 @@ mod test {
906906

907907
#[test]
908908
fn test_sh_wsh_sortedmulti_redeemscript() {
909-
use super::DescriptorScripts;
910-
911909
let secp = Secp256k1::new();
912910

913911
let descriptor = "sh(wsh(sortedmulti(3,tpubDEsqS36T4DVsKJd9UH8pAKzrkGBYPLEt9jZMwpKtzh1G6mgYehfHt9WCgk7MJG5QGSFWf176KaBNoXbcuFcuadAFKxDpUdMDKGBha7bY3QM/0/*,tpubDF3cpwfs7fMvXXuoQbohXtLjNM6ehwYT287LWtmLsd4r77YLg6MZg4vTETx5MSJ2zkfigbYWu31VA2Z2Vc1cZugCYXgS7FQu6pE8V6TriEH/0/*,tpubDE1SKfcW76Tb2AASv5bQWMuScYNAdoqLHoexw13sNDXwmUhQDBbCD3QAedKGLhxMrWQdMDKENzYtnXPDRvexQPNuDrLj52wAjHhNEm8sJ4p/0/*,tpubDFLc6oXwJmhm3FGGzXkfJNTh2KitoY3WhmmQvuAjMhD8YbyWn5mAqckbxXfm2etM3p5J6JoTpSrMqRSTfMLtNW46poDaEZJ1kjd3csRSjwH/0/*,tpubDEWD9NBeWP59xXmdqSNt4VYdtTGwbpyP8WS962BuqpQeMZmX9Pur14dhXdZT5a7wR1pK6dPtZ9fP5WR493hPzemnBvkfLLYxnUjAKj1JCQV/0/*,tpubDEHyZkkwd7gZWCTgQuYQ9C4myF2hMEmyHsBCCmLssGqoqUxeT3gzohF5uEVURkf9TtmeepJgkSUmteac38FwZqirjApzNX59XSHLcwaTZCH/0/*,tpubDEqLouCekwnMUWN486kxGzD44qVgeyuqHyxUypNEiQt5RnUZNJe386TKPK99fqRV1vRkZjYAjtXGTECz98MCsdLcnkM67U6KdYRzVubeCgZ/0/*)))";
@@ -918,7 +916,10 @@ mod test {
918916

919917
let script = Script::from_str("5321022f533b667e2ea3b36e21961c9fe9dca340fbe0af5210173a83ae0337ab20a57621026bb53a98e810bd0ee61a0ed1164ba6c024786d76554e793e202dc6ce9c78c4ea2102d5b8a7d66a41ffdb6f4c53d61994022e886b4f45001fb158b95c9164d45f8ca3210324b75eead2c1f9c60e8adeb5e7009fec7a29afcdb30d829d82d09562fe8bae8521032d34f8932200833487bd294aa219dcbe000b9f9b3d824799541430009f0fa55121037468f8ea99b6c64788398b5ad25480cad08f4b0d65be54ce3a55fd206b5ae4722103f72d3d96663b0ea99b0aeb0d7f273cab11a8de37885f1dddc8d9112adb87169357ae").unwrap();
920918

921-
assert_eq!(descriptor.psbt_redeem_script(), Some(script.to_v0_p2wsh()));
922-
assert_eq!(descriptor.psbt_witness_script(), Some(script));
919+
let mut psbt_input = psbt::Input::default();
920+
psbt_input.update_with_descriptor_unchecked(&descriptor).unwrap();
921+
922+
assert_eq!(psbt_input.redeem_script, Some(script.to_v0_p2wsh()));
923+
assert_eq!(psbt_input.witness_script, Some(script));
923924
}
924925
}

src/descriptor/policy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,6 @@ mod test {
11341134
use crate::descriptor::{ExtractPolicy, IntoWalletDescriptor};
11351135

11361136
use super::*;
1137-
use crate::descriptor::derived::AsDerived;
11381137
use crate::descriptor::policy::SatisfiableItem::{EcdsaSignature, Multisig, Thresh};
11391138
use crate::keys::{DescriptorKey, IntoDescriptorKey};
11401139
use crate::wallet::signer::SignersContainer;
@@ -1584,7 +1583,7 @@ mod test {
15841583
.unwrap();
15851584

15861585
let addr = wallet_desc
1587-
.as_derived(0, &secp)
1586+
.at_derivation_index(0)
15881587
.address(Network::Testnet)
15891588
.unwrap();
15901589
assert_eq!(

src/wallet/mod.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,9 @@ where
708708

709709
let n_sequence = match (params.rbf, requirements.csv) {
710710
// No RBF or CSV but there's an nLockTime, so the nSequence cannot be final
711-
(None, None) if lock_time != 0 => 0xFFFFFFFE,
711+
(None, None) if lock_time != 0 => Sequence::ENABLE_LOCKTIME_NO_RBF,
712712
// No RBF, CSV or nLockTime, make the transaction final
713-
(None, None) => 0xFFFFFFFF,
713+
(None, None) => Sequence::MAX,
714714

715715
// No RBF requested, use the value from CSV. Note that this value is by definition
716716
// non-final, so even if a timelock is enabled this nSequence is fine, hence why we
@@ -1850,7 +1850,7 @@ pub fn get_funded_wallet(
18501850

18511851
#[cfg(test)]
18521852
pub(crate) mod test {
1853-
use bitcoin::{util::psbt, Network};
1853+
use bitcoin::{util::psbt, Network, Sequence, PackedLockTime};
18541854

18551855
use crate::database::Database;
18561856
use crate::types::KeychainKind;
@@ -2143,7 +2143,7 @@ pub(crate) mod test {
21432143

21442144
// Since we never synced the wallet we don't have a last_sync_height
21452145
// we could use to try to prevent fee sniping. We default to 0.
2146-
assert_eq!(psbt.unsigned_tx.lock_time, 0);
2146+
assert_eq!(psbt.unsigned_tx.lock_time, PackedLockTime(0));
21472147
}
21482148

21492149
#[test]
@@ -2168,7 +2168,7 @@ pub(crate) mod test {
21682168
let (psbt, _) = builder.finish().unwrap();
21692169

21702170
// current_height will override the last sync height
2171-
assert_eq!(psbt.unsigned_tx.lock_time, current_height);
2171+
assert_eq!(psbt.unsigned_tx.lock_time, PackedLockTime(current_height));
21722172
}
21732173

21742174
#[test]
@@ -2191,7 +2191,7 @@ pub(crate) mod test {
21912191
let (psbt, _) = builder.finish().unwrap();
21922192

21932193
// If there's no current_height we're left with using the last sync height
2194-
assert_eq!(psbt.unsigned_tx.lock_time, sync_time.block_time.height);
2194+
assert_eq!(psbt.unsigned_tx.lock_time, PackedLockTime(sync_time.block_time.height));
21952195
}
21962196

21972197
#[test]
@@ -2202,7 +2202,7 @@ pub(crate) mod test {
22022202
builder.add_recipient(addr.script_pubkey(), 25_000);
22032203
let (psbt, _) = builder.finish().unwrap();
22042204

2205-
assert_eq!(psbt.unsigned_tx.lock_time, 100_000);
2205+
assert_eq!(psbt.unsigned_tx.lock_time, PackedLockTime(100_000));
22062206
}
22072207

22082208
#[test]
@@ -2219,7 +2219,7 @@ pub(crate) mod test {
22192219
// When we explicitly specify a nlocktime
22202220
// we don't try any fee sniping prevention trick
22212221
// (we ignore the current_height)
2222-
assert_eq!(psbt.unsigned_tx.lock_time, 630_000);
2222+
assert_eq!(psbt.unsigned_tx.lock_time, PackedLockTime(630_000));
22232223
}
22242224

22252225
#[test]
@@ -2232,7 +2232,7 @@ pub(crate) mod test {
22322232
.nlocktime(630_000);
22332233
let (psbt, _) = builder.finish().unwrap();
22342234

2235-
assert_eq!(psbt.unsigned_tx.lock_time, 630_000);
2235+
assert_eq!(psbt.unsigned_tx.lock_time, PackedLockTime(630_000));
22362236
}
22372237

22382238
#[test]
@@ -2257,7 +2257,7 @@ pub(crate) mod test {
22572257
builder.add_recipient(addr.script_pubkey(), 25_000);
22582258
let (psbt, _) = builder.finish().unwrap();
22592259

2260-
assert_eq!(psbt.unsigned_tx.input[0].sequence, 6);
2260+
assert_eq!(psbt.unsigned_tx.input[0].sequence, Sequence(6));
22612261
}
22622262

22632263
#[test]
@@ -2271,7 +2271,7 @@ pub(crate) mod test {
22712271
let (psbt, _) = builder.finish().unwrap();
22722272
// When CSV is enabled it takes precedence over the rbf value (unless forced by the user).
22732273
// It will be set to the OP_CSV value, in this case 6
2274-
assert_eq!(psbt.unsigned_tx.input[0].sequence, 6);
2274+
assert_eq!(psbt.unsigned_tx.input[0].sequence, Sequence(6));
22752275
}
22762276

22772277
#[test]
@@ -2296,7 +2296,7 @@ pub(crate) mod test {
22962296
builder.add_recipient(addr.script_pubkey(), 25_000);
22972297
let (psbt, _) = builder.finish().unwrap();
22982298

2299-
assert_eq!(psbt.unsigned_tx.input[0].sequence, 0xFFFFFFFE);
2299+
assert_eq!(psbt.unsigned_tx.input[0].sequence, Sequence(0xFFFFFFFE));
23002300
}
23012301

23022302
#[test]
@@ -2321,7 +2321,7 @@ pub(crate) mod test {
23212321
.enable_rbf_with_sequence(0xDEADBEEF);
23222322
let (psbt, _) = builder.finish().unwrap();
23232323

2324-
assert_eq!(psbt.unsigned_tx.input[0].sequence, 0xDEADBEEF);
2324+
assert_eq!(psbt.unsigned_tx.input[0].sequence, Sequence(0xDEADBEEF));
23252325
}
23262326

23272327
#[test]
@@ -2348,7 +2348,7 @@ pub(crate) mod test {
23482348
builder.add_recipient(addr.script_pubkey(), 25_000);
23492349
let (psbt, _) = builder.finish().unwrap();
23502350

2351-
assert_eq!(psbt.unsigned_tx.input[0].sequence, 0xFFFFFFFF);
2351+
assert_eq!(psbt.unsigned_tx.input[0].sequence, Sequence(0xFFFFFFFF));
23522352
}
23532353

23542354
#[test]
@@ -2869,7 +2869,7 @@ pub(crate) mod test {
28692869
.policy_path(path, KeychainKind::External);
28702870
let (psbt, _) = builder.finish().unwrap();
28712871

2872-
assert_eq!(psbt.unsigned_tx.input[0].sequence, 0xFFFFFFFF);
2872+
assert_eq!(psbt.unsigned_tx.input[0].sequence, Sequence(0xFFFFFFFF));
28732873
}
28742874

28752875
#[test]
@@ -2888,7 +2888,7 @@ pub(crate) mod test {
28882888
.policy_path(path, KeychainKind::External);
28892889
let (psbt, _) = builder.finish().unwrap();
28902890

2891-
assert_eq!(psbt.unsigned_tx.input[0].sequence, 144);
2891+
assert_eq!(psbt.unsigned_tx.input[0].sequence, Sequence(144));
28922892
}
28932893

28942894
#[test]

0 commit comments

Comments
 (0)