2024-12-01 automated rustfmt nightly

This commit is contained in:
Fmt Bot 2024-12-01 01:41:12 +00:00 committed by github-actions[bot]
parent 230b9e5ca0
commit 0990b30035
5 changed files with 15 additions and 26 deletions

View File

@ -1133,9 +1133,7 @@ impl InputWeightPrediction {
/// Computes the **signature weight** added to a transaction by an input with this weight prediction, /// Computes the **signature weight** added to a transaction by an input with this weight prediction,
/// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count varint. /// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count varint.
#[deprecated(since = "TBD", note = "use `InputWeightPrediction::witness_weight()` instead")] #[deprecated(since = "TBD", note = "use `InputWeightPrediction::witness_weight()` instead")]
pub const fn weight(&self) -> Weight { pub const fn weight(&self) -> Weight { Self::witness_weight(self) }
Self::witness_weight(self)
}
/// Computes the signature, prevout (txid, index), and sequence weights of this weight /// Computes the signature, prevout (txid, index), and sequence weights of this weight
/// prediction. /// prediction.
@ -1972,7 +1970,7 @@ mod tests {
InputWeightPrediction::P2PKH_COMPRESSED_MAX, InputWeightPrediction::P2PKH_COMPRESSED_MAX,
InputWeightPrediction::P2PKH_UNCOMPRESSED_MAX, InputWeightPrediction::P2PKH_UNCOMPRESSED_MAX,
InputWeightPrediction::P2TR_KEY_DEFAULT_SIGHASH, InputWeightPrediction::P2TR_KEY_DEFAULT_SIGHASH,
InputWeightPrediction::P2TR_KEY_NON_DEFAULT_SIGHASH InputWeightPrediction::P2TR_KEY_NON_DEFAULT_SIGHASH,
]; ];
let weight = predict_weight_from_slices(&predict, &[1]); let weight = predict_weight_from_slices(&predict, &[1]);

View File

@ -237,8 +237,8 @@ pub mod parse {
#[doc(inline)] #[doc(inline)]
pub use units::parse::{ pub use units::parse::{
hex_check_unprefixed, hex_remove_prefix, hex_u128, hex_u128_unchecked, hex_u128_unprefixed, hex_check_unprefixed, hex_remove_prefix, hex_u128, hex_u128_unchecked, hex_u128_unprefixed,
hex_u32, hex_u32_unchecked, hex_u32_unprefixed, int, hex_u32, hex_u32_unchecked, hex_u32_unprefixed, int, ParseIntError, PrefixedHexError,
ParseIntError, PrefixedHexError, UnprefixedHexError, UnprefixedHexError,
}; };
} }

View File

@ -256,8 +256,7 @@ impl Psbt {
{ {
continue; continue;
} else if derivation2.len() <= derivation1.len() } else if derivation2.len() <= derivation1.len()
&& derivation2[..] && derivation2[..] == derivation1[derivation1.len() - derivation2.len()..]
== derivation1[derivation1.len() - derivation2.len()..]
{ {
entry.insert((fingerprint1, derivation1)); entry.insert((fingerprint1, derivation1));
continue; continue;
@ -2117,14 +2116,16 @@ mod tests {
assert_eq!(psbt1, psbt2); assert_eq!(psbt1, psbt2);
} }
// https://github.com/rust-bitcoin/rust-bitcoin/issues/3628 // https://github.com/rust-bitcoin/rust-bitcoin/issues/3628
#[test] #[test]
fn test_combine_psbt_fuzz_3628() { fn test_combine_psbt_fuzz_3628() {
let mut psbt1 = hex_psbt(include_str!("../../tests/data/psbt_fuzz1.hex")).unwrap(); let mut psbt1 = hex_psbt(include_str!("../../tests/data/psbt_fuzz1.hex")).unwrap();
let psbt2 = hex_psbt(include_str!("../../tests/data/psbt_fuzz2.hex")).unwrap(); let psbt2 = hex_psbt(include_str!("../../tests/data/psbt_fuzz2.hex")).unwrap();
assert!(matches!(psbt1.combine(psbt2).unwrap_err(), Error::CombineInconsistentKeySources(_))); assert!(matches!(
psbt1.combine(psbt2).unwrap_err(),
Error::CombineInconsistentKeySources(_)
));
} }
#[cfg(feature = "rand-std")] #[cfg(feature = "rand-std")]

View File

@ -331,15 +331,11 @@ impl std::error::Error for PrefixedHexError {
} }
impl From<MissingPrefixError> for PrefixedHexError { impl From<MissingPrefixError> for PrefixedHexError {
fn from(e: MissingPrefixError) -> Self { fn from(e: MissingPrefixError) -> Self { Self(PrefixedHexErrorInner::MissingPrefix(e)) }
Self(PrefixedHexErrorInner::MissingPrefix(e))
}
} }
impl From<ParseIntError> for PrefixedHexError { impl From<ParseIntError> for PrefixedHexError {
fn from(e: ParseIntError) -> Self { fn from(e: ParseIntError) -> Self { Self(PrefixedHexErrorInner::ParseInt(e)) }
Self(PrefixedHexErrorInner::ParseInt(e))
}
} }
/// Error returned when parsing an integer from a hex string that is not supposed to contain a prefix. /// Error returned when parsing an integer from a hex string that is not supposed to contain a prefix.
@ -381,15 +377,11 @@ impl std::error::Error for UnprefixedHexError {
} }
impl From<ContainsPrefixError> for UnprefixedHexError { impl From<ContainsPrefixError> for UnprefixedHexError {
fn from(e: ContainsPrefixError) -> Self { fn from(e: ContainsPrefixError) -> Self { Self(UnprefixedHexErrorInner::ContainsPrefix(e)) }
Self(UnprefixedHexErrorInner::ContainsPrefix(e))
}
} }
impl From<ParseIntError> for UnprefixedHexError { impl From<ParseIntError> for UnprefixedHexError {
fn from(e: ParseIntError) -> Self { fn from(e: ParseIntError) -> Self { Self(UnprefixedHexErrorInner::ParseInt(e)) }
Self(UnprefixedHexErrorInner::ParseInt(e))
}
} }
/// Error returned when a hex string is missing a prefix (e.g. `0x`). /// Error returned when a hex string is missing a prefix (e.g. `0x`).

View File

@ -98,7 +98,7 @@ struct CommonTraits {
} }
/// A struct that includes all types that implement `Default`. /// A struct that includes all types that implement `Default`.
#[derive(Default)] // C-COMMON-TRAITS: `Default` #[derive(Default)] // C-COMMON-TRAITS: `Default`
struct Default { struct Default {
a: Amount, a: Amount,
b: SignedAmount, b: SignedAmount,
@ -196,9 +196,7 @@ fn api_can_use_all_types_from_module_locktime_relative() {
#[test] #[test]
fn api_can_use_all_types_from_module_parse() { fn api_can_use_all_types_from_module_parse() {
use bitcoin_units::parse::{ use bitcoin_units::parse::{ParseIntError, PrefixedHexError, UnprefixedHexError};
ParseIntError, PrefixedHexError, UnprefixedHexError,
};
} }
#[test] #[test]