Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mismatch between blank builders and their inputs #289

Merged
merged 1 commit into from
Jan 7, 2025
Merged
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
4 changes: 4 additions & 0 deletions src/containers/partials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@
}

impl TransitionInfo {
/// # Panics
///
/// If the number of provided seals is zero.
pub fn new(
transition: Transition,
seals: impl AsRef<[XOutputSeal]>,
) -> Result<Self, TransitionInfoError> {
let id = transition.id();
let seals = seals.as_ref();
assert!(!seals.is_empty(), "empty seals provided to transition info constructor");

Check warning on line 168 in src/containers/partials.rs

View check run for this annotation

Codecov / codecov/patch

src/containers/partials.rs#L168

Added line #L168 was not covered by tests
let inputs = Confined::<BTreeSet<_>, 1, U24>::try_from_iter(
seals.iter().copied().map(XOutpoint::from),
)
Expand Down
24 changes: 13 additions & 11 deletions src/persistence/stock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,25 +1214,27 @@
.map_err(|_| ComposeError::TooManyBlanks)?;
}

let (first_builder, second_builder) =
let (first_builder, first_inputs, second_builder, second_inputs) =

Check warning on line 1217 in src/persistence/stock.rs

View check run for this annotation

Codecov / codecov/patch

src/persistence/stock.rs#L1217

Added line #L1217 was not covered by tests
match (main_builder.has_inputs(), alt_builder.has_inputs()) {
(true, true) => (main_builder, Some(alt_builder)),
(true, false) => (main_builder, None),
(false, true) => (alt_builder, None),
(true, true) => (main_builder, main_inputs, Some(alt_builder), alt_inputs),
(true, false) => (main_builder, main_inputs, None, alt_inputs),
(false, true) => (alt_builder, alt_inputs, None, main_inputs),

Check warning on line 1221 in src/persistence/stock.rs

View check run for this annotation

Codecov / codecov/patch

src/persistence/stock.rs#L1219-L1221

Added lines #L1219 - L1221 were not covered by tests
(false, false) => return Err(ComposeError::InsufficientState.into()),
};
let first = TransitionInfo::new(first_builder.complete_transition()?, main_inputs)
let first = TransitionInfo::new(first_builder.complete_transition()?, first_inputs)

Check warning on line 1224 in src/persistence/stock.rs

View check run for this annotation

Codecov / codecov/patch

src/persistence/stock.rs#L1224

Added line #L1224 was not covered by tests
.map_err(|e| {
debug_assert!(!matches!(e, TransitionInfoError::CloseMethodDivergence(_)));
ComposeError::TooManyInputs
})?;
let second = if let Some(second_builder) = second_builder {
Some(TransitionInfo::new(second_builder.complete_transition()?, alt_inputs).map_err(
|e| {
debug_assert!(!matches!(e, TransitionInfoError::CloseMethodDivergence(_)));
ComposeError::TooManyInputs
},
)?)
Some(
TransitionInfo::new(second_builder.complete_transition()?, second_inputs).map_err(
|e| {
debug_assert!(!matches!(e, TransitionInfoError::CloseMethodDivergence(_)));
ComposeError::TooManyInputs
},
)?,

Check warning on line 1236 in src/persistence/stock.rs

View check run for this annotation

Codecov / codecov/patch

src/persistence/stock.rs#L1231-L1236

Added lines #L1231 - L1236 were not covered by tests
)
} else {
None
};
Expand Down
Loading