Skip to content

Commit c74934b

Browse files
committed
Fix compiler test cases for new typing rules
1 parent 9766e30 commit c74934b

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

integration_test/random_ms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ j:and_v(v:ripemd160(H),or_d(sha256(H),older(16)))
1313
and_b(hash256(H),a:and_b(hash256(H),a:older(1)))
1414
thresh(2,multi(2,03a0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7,036d2b085e9e382ed10b69fc311a03f8641ccfff21574de0927513a49d9a688a00),a:multi(1,036d2b085e9e382ed10b69fc311a03f8641ccfff21574de0927513a49d9a688a00),ac:pk_k(022f01e5e15cca351daff3843fb70f3c2f0a1bdd05e5af888a67784ef3e10a2a01))
1515
and_n(sha256(H),t:or_i(v:older(4252898),v:older(16)))
16-
or_d(d:and_v(v:older(4252898),v:older(4252898)),sha256(H))
16+
or_d(nd:and_v(v:older(4252898),v:older(4252898)),sha256(H))
1717
c:and_v(or_c(sha256(H),v:multi(1,02c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db)),pk_k(03acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe))
1818
c:and_v(or_c(multi(2,036d2b085e9e382ed10b69fc311a03f8641ccfff21574de0927513a49d9a688a00,02352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5),v:ripemd160(H)),pk_k(03fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556))
1919
and_v(andor(hash256(H),v:hash256(H),v:older(50000)),after(1231488000))

src/policy/compiler.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,13 +1166,13 @@ mod tests {
11661166
use std::str::FromStr;
11671167
use std::string::String;
11681168

1169-
use miniscript::{satisfy, Legacy, Segwitv0};
1169+
use miniscript::{satisfy, Legacy, Segwitv0, Tap};
11701170
use policy::Liftable;
11711171
use script_num_size;
11721172

11731173
type SPolicy = Concrete<String>;
11741174
type BPolicy = Concrete<bitcoin::PublicKey>;
1175-
type DummySegwitAstElemExt = policy::compiler::AstElemExt<String, Segwitv0>;
1175+
type DummyTapAstElemExt = policy::compiler::AstElemExt<String, Tap>;
11761176
type SegwitMiniScript = Miniscript<bitcoin::PublicKey, Segwitv0>;
11771177

11781178
fn pubkeys_and_a_sig(n: usize) -> (Vec<bitcoin::PublicKey>, secp256k1::ecdsa::Signature) {
@@ -1262,7 +1262,7 @@ mod tests {
12621262
#[test]
12631263
fn compile_q() {
12641264
let policy = SPolicy::from_str("or(1@and(pk(A),pk(B)),127@pk(C))").expect("parsing");
1265-
let compilation: DummySegwitAstElemExt =
1265+
let compilation: DummyTapAstElemExt =
12661266
best_t(&mut BTreeMap::new(), &policy, 1.0, None).unwrap();
12671267

12681268
assert_eq!(compilation.cost_1d(1.0, None), 88.0 + 74.109375);
@@ -1271,13 +1271,14 @@ mod tests {
12711271
compilation.ms.lift().unwrap().sorted()
12721272
);
12731273

1274+
// compile into taproot context to avoid limit errors
12741275
let policy = SPolicy::from_str(
12751276
"and(and(and(or(127@thresh(2,pk(A),pk(B),thresh(2,or(127@pk(A),1@pk(B)),after(100),or(and(pk(C),after(200)),and(pk(D),sha256(66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925))),pk(E))),1@pk(F)),sha256(66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925)),or(127@pk(G),1@after(300))),or(127@after(400),pk(H)))"
12761277
).expect("parsing");
1277-
let compilation: DummySegwitAstElemExt =
1278+
let compilation: DummyTapAstElemExt =
12781279
best_t(&mut BTreeMap::new(), &policy, 1.0, None).unwrap();
12791280

1280-
assert_eq!(compilation.cost_1d(1.0, None), 437.0 + 299.4003295898438);
1281+
assert_eq!(compilation.cost_1d(1.0, None), 438.0 + 299.4003295898438);
12811282
assert_eq!(
12821283
policy.lift().unwrap().sorted(),
12831284
compilation.ms.lift().unwrap().sorted()
@@ -1563,9 +1564,9 @@ mod benches {
15631564
use test::{black_box, Bencher};
15641565

15651566
use super::{CompilerError, Concrete};
1566-
use miniscript::Segwitv0;
1567+
use miniscript::Tap;
15671568
use Miniscript;
1568-
type SegwitMsRes = Result<Miniscript<String, Segwitv0>, CompilerError>;
1569+
type TapMsRes = Result<Miniscript<String, Tap>, CompilerError>;
15691570
#[bench]
15701571
pub fn compile_basic(bh: &mut Bencher) {
15711572
let h = (0..64).map(|_| "a").collect::<String>();
@@ -1575,7 +1576,7 @@ mod benches {
15751576
))
15761577
.expect("parsing");
15771578
bh.iter(|| {
1578-
let pt: SegwitMsRes = pol.compile();
1579+
let pt: TapMsRes = pol.compile();
15791580
black_box(pt).unwrap();
15801581
});
15811582
}
@@ -1587,7 +1588,7 @@ mod benches {
15871588
&format!("or(pk(L),thresh(9,sha256({}),pk(A),pk(B),and(or(pk(C),pk(D)),pk(E)),after(100),pk(F),pk(G),pk(H),pk(I),and(pk(J),pk(K))))", h)
15881589
).expect("parsing");
15891590
bh.iter(|| {
1590-
let pt: SegwitMsRes = pol.compile();
1591+
let pt: TapMsRes = pol.compile();
15911592
black_box(pt).unwrap();
15921593
});
15931594
}
@@ -1598,7 +1599,7 @@ mod benches {
15981599
"or(pk(A),thresh(4,pk(B),older(100),pk(C),and(after(100),or(pk(D),or(pk(E),and(pk(F),thresh(2,pk(G),or(pk(H),and(thresh(5,pk(I),or(pk(J),pk(K)),pk(L),pk(M),pk(N),pk(O),pk(P),pk(Q),pk(R),pk(S),pk(T)),pk(U))),pk(V),or(and(pk(W),pk(X)),pk(Y)),after(100)))))),pk(Z)))"
15991600
).expect("parsing");
16001601
bh.iter(|| {
1601-
let pt: SegwitMsRes = pol.compile();
1602+
let pt: TapMsRes = pol.compile();
16021603
black_box(pt).unwrap();
16031604
});
16041605
}

0 commit comments

Comments
 (0)