Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
cargo update -p "hyper-rustls" --precise "0.27.7"
cargo update -p openssl --precise "0.10.78"
cargo update -p openssl-sys --precise "0.9.114"
cargo update -p zeroize --precise "1.8.2"
- name: Pin dependencies for MSRV
if: matrix.rust.version == '1.63.0'
run: ./ci/pin-msrv.sh
Expand Down
1 change: 1 addition & 0 deletions ci/pin-msrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ cargo update -p base58ck --precise "0.1.1"
cargo update -p bitcoin-io --precise "0.1.4"
cargo update -p bitcoin-units --precise "0.1.4"
cargo update -p filetime --precise "0.2.27"
cargo update -p zeroize --precise "1.8.2"

# all pinning required due to `clap` usage in `example_cli`
cargo update -p "clap@4.6.1" --precise "4.5.17"
Expand Down
31 changes: 29 additions & 2 deletions crates/chain/src/spk_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ where
{
let start = match range.start_bound() {
Bound::Included(start) => *start,
Bound::Excluded(start) => *start + 1,
Bound::Excluded(start) => start.saturating_add(1),
Bound::Unbounded => u32::MIN,
};

let mut end = match range.end_bound() {
Bound::Included(end) => *end + 1,
Bound::Included(end) => end.saturating_add(1),
Bound::Excluded(end) => *end,
Bound::Unbounded => u32::MAX,
};
Expand Down Expand Up @@ -136,6 +136,8 @@ where
#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use core::ops::Bound;

use crate::{
bitcoin::secp256k1::Secp256k1,
indexer::keychain_txout::KeychainTxOutIndex,
Expand Down Expand Up @@ -264,6 +266,31 @@ mod test {
None
);
}

#[test]
fn test_spkiterator_no_overflow_on_u32_max_range() {
let (_, external_desc, _) = init_txout_index();

// Inclusive range up to u32::MAX should not overflow and should produce items
// (clamped to BIP32_MAX_INDEX).
let mut iter = SpkIterator::new_with_range(&external_desc, 0..=u32::MAX);
assert!(
iter.next().is_some(),
"0..=u32::MAX range should produce items, not overflow to empty"
);

// Exclusive start at u32::MAX should not overflow and should produce an empty iterator
// (start saturates to u32::MAX which is beyond BIP32_MAX_INDEX).
let mut iter = SpkIterator::new_with_range(
&external_desc,
(Bound::Excluded(u32::MAX), Bound::Included(u32::MAX)),
);
assert_eq!(
iter.next(),
None,
"range starting after u32::MAX should be empty"
);
}
}

#[test]
Expand Down
Loading