Skip to content

Commit 45983d2

Browse files
committed
Merge commit 'refs/pull/322/head' of github.com:bitcoindevkit/bdk
2 parents 89cb4de + 3ed44ce commit 45983d2

File tree

5 files changed

+21
-54
lines changed

5 files changed

+21
-54
lines changed

.github/workflows/cont_integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Build
4747
run: cargo build --features ${{ matrix.features }} --no-default-features
4848
- name: Clippy
49-
run: cargo clippy --features ${{ matrix.features }} --no-default-features -- -D warnings
49+
run: cargo clippy --all-targets --features ${{ matrix.features }} --no-default-features -- -D warnings
5050
- name: Test
5151
run: cargo test --features ${{ matrix.features }} --no-default-features
5252

@@ -151,7 +151,7 @@ jobs:
151151
run: rustup default 1.51.0 # STABLE
152152
- name: Set profile
153153
run: rustup set profile minimal
154-
- name: Add clippy
154+
- name: Add rustfmt
155155
run: rustup component add rustfmt
156156
- name: Update toolchain
157157
run: rustup update

scripts/cargo-check.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/descriptor/policy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ impl<Ctx: ScriptContext> ExtractPolicy for Miniscript<DescriptorPublicKey, Ctx>
870870
.map(|n| n.extract_policy(signers, secp))
871871
.collect::<Result<Vec<_>, _>>()?
872872
.into_iter()
873-
.filter_map(|x| x)
873+
.flatten()
874874
.collect();
875875

876876
if mapped.len() < nodes.len() {
@@ -1023,8 +1023,8 @@ mod test {
10231023

10241024
assert!(
10251025
matches!(&policy.item, Multisig { keys, threshold } if threshold == &2usize
1026-
&& &keys[0].fingerprint.unwrap() == &fingerprint0
1027-
&& &keys[1].fingerprint.unwrap() == &fingerprint1)
1026+
&& keys[0].fingerprint.unwrap() == fingerprint0
1027+
&& keys[1].fingerprint.unwrap() == fingerprint1)
10281028
);
10291029
// TODO should this be "Satisfaction::None" since we have no prv keys?
10301030
// TODO should items and conditions not be empty?
@@ -1054,8 +1054,8 @@ mod test {
10541054
.unwrap();
10551055
assert!(
10561056
matches!(&policy.item, Multisig { keys, threshold } if threshold == &2usize
1057-
&& &keys[0].fingerprint.unwrap() == &fingerprint0
1058-
&& &keys[1].fingerprint.unwrap() == &fingerprint1)
1057+
&& keys[0].fingerprint.unwrap() == fingerprint0
1058+
&& keys[1].fingerprint.unwrap() == fingerprint1)
10591059
);
10601060

10611061
assert!(
@@ -1429,7 +1429,7 @@ mod test {
14291429
)
14301430
);
14311431

1432-
let mut policy_clone = original_policy.clone();
1432+
let mut policy_clone = original_policy;
14331433
let psbt: PSBT = deserialize(&base64::decode(ALICE_BOB_SIGNED_PSBT).unwrap()).unwrap();
14341434
policy_clone
14351435
.fill_satisfactions(&psbt, &wallet_desc, &secp)

src/wallet/coin_selection.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ mod test {
654654

655655
assert_eq!(result.selected.len(), 3);
656656
assert_eq!(result.selected_amount(), 300_010);
657-
assert_eq!(result.fee_amount, 254.0);
657+
assert!((result.fee_amount - 254.0).abs() < f32::EPSILON);
658658
}
659659

660660
#[test]
@@ -675,7 +675,7 @@ mod test {
675675

676676
assert_eq!(result.selected.len(), 3);
677677
assert_eq!(result.selected_amount(), 300_010);
678-
assert_eq!(result.fee_amount, 254.0);
678+
assert!((result.fee_amount - 254.0).abs() < f32::EPSILON);
679679
}
680680

681681
#[test]
@@ -696,7 +696,7 @@ mod test {
696696

697697
assert_eq!(result.selected.len(), 1);
698698
assert_eq!(result.selected_amount(), 200_000);
699-
assert_eq!(result.fee_amount, 118.0);
699+
assert!((result.fee_amount - 118.0).abs() < f32::EPSILON);
700700
}
701701

702702
#[test]
@@ -756,7 +756,7 @@ mod test {
756756

757757
assert_eq!(result.selected.len(), 3);
758758
assert_eq!(result.selected_amount(), 300_000);
759-
assert_eq!(result.fee_amount, 254.0);
759+
assert!((result.fee_amount - 254.0).abs() < f32::EPSILON);
760760
}
761761

762762
#[test]
@@ -777,7 +777,7 @@ mod test {
777777

778778
assert_eq!(result.selected.len(), 3);
779779
assert_eq!(result.selected_amount(), 300_010);
780-
assert_eq!(result.fee_amount, 254.0);
780+
assert!((result.fee_amount - 254.0).abs() < f32::EPSILON);
781781
}
782782

783783
#[test]
@@ -798,7 +798,7 @@ mod test {
798798

799799
assert_eq!(result.selected.len(), 3);
800800
assert_eq!(result.selected_amount(), 300010);
801-
assert_eq!(result.fee_amount, 254.0);
801+
assert!((result.fee_amount - 254.0).abs() < f32::EPSILON);
802802
}
803803

804804
#[test]
@@ -968,7 +968,7 @@ mod test {
968968
cost_of_change,
969969
)
970970
.unwrap();
971-
assert_eq!(result.fee_amount, 186.0);
971+
assert!((result.fee_amount - 186.0).abs() < f32::EPSILON);
972972
assert_eq!(result.selected_amount(), 100_000);
973973
}
974974

@@ -1031,9 +1031,8 @@ mod test {
10311031
);
10321032

10331033
assert!(result.selected_amount() > target_amount);
1034-
assert_eq!(
1035-
result.fee_amount,
1036-
50.0 + result.selected.len() as f32 * 68.0
1034+
assert!(
1035+
(result.fee_amount - (50.0 + result.selected.len() as f32 * 68.0)).abs() < f32::EPSILON
10371036
);
10381037
}
10391038
}

src/wallet/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub enum AddressIndex {
190190
/// then the returned address and subsequent addresses returned by calls to `AddressIndex::New`
191191
/// and `AddressIndex::LastUsed` may have already been used. Also if the index is reset to a
192192
/// value earlier than the [`crate::blockchain::Blockchain`] stop_gap (default is 20) then a
193-
/// larger stop_gap should be used to monitor for all possibly used addresses.
193+
/// larger stop_gap should be used to monitor for all possibly used addresses.
194194
Reset(u32),
195195
}
196196

@@ -1633,7 +1633,7 @@ mod test {
16331633
.database
16341634
.borrow_mut()
16351635
.set_script_pubkey(
1636-
&bitcoin::Address::from_str(&tx_meta.output.iter().next().unwrap().to_address)
1636+
&bitcoin::Address::from_str(&tx_meta.output.get(0).unwrap().to_address)
16371637
.unwrap()
16381638
.script_pubkey(),
16391639
KeychainKind::External,
@@ -2431,8 +2431,7 @@ mod test {
24312431
.unsigned_tx
24322432
.input
24332433
.iter()
2434-
.find(|input| input.previous_output == utxo.outpoint)
2435-
.is_some(),
2434+
.any(|input| input.previous_output == utxo.outpoint),
24362435
"foreign_utxo should be in there"
24372436
);
24382437

@@ -3616,7 +3615,7 @@ mod test {
36163615
#[test]
36173616
fn test_unused_address() {
36183617
let db = MemoryDatabase::new();
3619-
let wallet = Wallet::new_offline("wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)",
3618+
let wallet = Wallet::new_offline("wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)",
36203619
None, Network::Testnet, db).unwrap();
36213620

36223621
assert_eq!(

0 commit comments

Comments
 (0)