test contract input features

This commit is contained in:
wiesche
2026-09-04 16:13:32 +02:00
parent 483b29597f
commit b8ede99308
6 changed files with 92 additions and 10 deletions
-2
View File
@@ -39,8 +39,6 @@ Separating side effects until the 'save_step' part would make these functions mu
- Reserve funds across open late-locked contracts, or make the possible signing failure
clearer to callers.
- Handle the coinbase flows. Coinbase inputs are built into the slate, but nothing else
is exercised.
- Keep contracts at two participants until the known multi-party attack is addressed.
- For a payjoin, `--use-inputs any` picks an input for us; naming the commitment would be
clearer, for the API as much as the CLI.
+16 -6
View File
@@ -643,14 +643,24 @@ mod tests {
assert!(check_identifiers(&[], &[own_input], "input").is_err());
assert!(check_identifiers(&[own_input], &[own_output], "output").is_err());
assert!(check_identifiers(&[own_input, own_input], &[own_input], "input").is_err());
assert!(check_identifiers(
&[identifier(1, OutputFeatures::Coinbase)],
&[own_input],
"input"
)
.is_err());
assert!(cached_commitment("01").is_none());
assert!(cached_commitment("not hex").is_none());
assert!(cached_commitment(&"00".repeat(PEDERSEN_COMMITMENT_SIZE)).is_some());
}
#[test]
fn coinbase_features() {
let commit = Commitment::from_vec(vec![1]);
let plain = OutputIdentifier::new(OutputFeatures::Plain, &commit);
let coinbase = OutputIdentifier::new(OutputFeatures::Coinbase, &commit);
for (actual, expected) in [(plain, coinbase), (coinbase, plain)] {
let err = check_identifiers(&[actual], &[expected], "input").unwrap_err();
assert!(matches!(
err,
Error::GenericError(ref message)
if message == "Contract slate changed or duplicated one of our input commitments"
));
}
}
}