Skip to content

Commit bd3a22a

Browse files
committed
compiler: test the number of witness elements standard limit
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
1 parent 4501216 commit bd3a22a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/policy/compiler.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,25 @@ mod tests {
14691469
};
14701470
}
14711471
}
1472+
1473+
#[test]
1474+
fn segwit_limits() {
1475+
// Hit the maximum witness stack elements limit
1476+
let (keys, _) = pubkeys_and_a_sig(100);
1477+
let keys: Vec<Concrete<bitcoin::PublicKey>> =
1478+
keys.iter().map(|pubkey| Concrete::Key(*pubkey)).collect();
1479+
let thresh_res: Result<SegwitMiniScript, _> =
1480+
Concrete::Threshold(keys.len(), keys).compile();
1481+
let n_elements = thresh_res
1482+
.clone()
1483+
.and_then(|m| Ok(m.max_satisfaction_witness_elements()));
1484+
assert_eq!(
1485+
thresh_res,
1486+
Err(CompilerError::LimitsExceeded),
1487+
"Compilation succeeded with '{:?}' elements",
1488+
n_elements,
1489+
);
1490+
}
14721491
}
14731492

14741493
#[cfg(all(test, feature = "unstable"))]

0 commit comments

Comments
 (0)