Skip to content

Commit

Permalink
wip: Set array_width to 80
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharding committed Jul 27, 2023
1 parent 8dc5012 commit 93e7c3a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 69 deletions.
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn_call_width = 80
attr_fn_like_width = 70
struct_lit_width = 80
struct_variant_width = 35
array_width = 60
array_width = 80
chain_width = 60
single_line_if_else_max_width = 50
wrap_comments = false
Expand Down
36 changes: 12 additions & 24 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,8 @@ mod tests {

//Check Pkh
let pk_bytes = pks[1].to_public_key().to_bytes();
let stack = Stack::from(vec![
stack::Element::Push(&der_sigs[1]),
stack::Element::Push(&pk_bytes),
]);
let stack =
Stack::from(vec![stack::Element::Push(&der_sigs[1]), stack::Element::Push(&pk_bytes)]);
let constraints = from_stack(Box::new(vfyfn), stack, &pkh);
let pkh_satisfied: Result<Vec<SatisfiedConstraint>, Error> = constraints.collect();
assert_eq!(
Expand Down Expand Up @@ -1267,10 +1265,8 @@ mod tests {
);

//Check AndB
let stack = Stack::from(vec![
stack::Element::Push(&preimage),
stack::Element::Push(&der_sigs[0]),
]);
let stack =
Stack::from(vec![stack::Element::Push(&preimage), stack::Element::Push(&der_sigs[0])]);
let elem = no_checks_ms(&format!("and_b(c:pk_k({}),sjtv:sha256({}))", pks[0], sha256_hash));
let constraints = from_stack(Box::new(vfyfn), stack, &elem);

Expand All @@ -1286,10 +1282,8 @@ mod tests {
);

//Check AndOr
let stack = Stack::from(vec![
stack::Element::Push(&preimage),
stack::Element::Push(&der_sigs[0]),
]);
let stack =
Stack::from(vec![stack::Element::Push(&preimage), stack::Element::Push(&der_sigs[0])]);
let elem = no_checks_ms(&format!(
"andor(c:pk_k({}),jtv:sha256({}),c:pk_h({}))",
pks[0], sha256_hash, pks[1],
Expand Down Expand Up @@ -1326,10 +1320,8 @@ mod tests {
);

//Check OrB
let stack = Stack::from(vec![
stack::Element::Push(&preimage),
stack::Element::Dissatisfied,
]);
let stack =
Stack::from(vec![stack::Element::Push(&preimage), stack::Element::Dissatisfied]);
let elem = no_checks_ms(&format!("or_b(c:pk_k({}),sjtv:sha256({}))", pks[0], sha256_hash));
let constraints = from_stack(Box::new(vfyfn), stack, &elem);

Expand All @@ -1356,10 +1348,8 @@ mod tests {
);

//Check OrC
let stack = Stack::from(vec![
stack::Element::Push(&der_sigs[0]),
stack::Element::Dissatisfied,
]);
let stack =
Stack::from(vec![stack::Element::Push(&der_sigs[0]), stack::Element::Dissatisfied]);
let elem =
no_checks_ms(&format!("t:or_c(jtv:sha256({}),vc:pk_k({}))", sha256_hash, pks[0]));
let constraints = from_stack(Box::new(vfyfn), stack, &elem);
Expand All @@ -1373,10 +1363,8 @@ mod tests {
);

//Check OrI
let stack = Stack::from(vec![
stack::Element::Push(&der_sigs[0]),
stack::Element::Dissatisfied,
]);
let stack =
Stack::from(vec![stack::Element::Push(&der_sigs[0]), stack::Element::Dissatisfied]);
let elem = no_checks_ms(&format!("or_i(jtv:sha256({}),c:pk_k({}))", sha256_hash, pks[0]));
let constraints = from_stack(Box::new(vfyfn), stack, &elem);

Expand Down
52 changes: 20 additions & 32 deletions src/policy/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,38 +1249,26 @@ mod compiler_tests {

let combinations = generate_combination(&policy_vec, 1.0, 2);

let comb_a: Vec<Arc<PolicyArc<String>>> = vec![
policy_str!("pk(B)"),
policy_str!("pk(C)"),
policy_str!("pk(D)"),
]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let comb_b: Vec<Arc<PolicyArc<String>>> = vec![
policy_str!("pk(A)"),
policy_str!("pk(C)"),
policy_str!("pk(D)"),
]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let comb_c: Vec<Arc<PolicyArc<String>>> = vec![
policy_str!("pk(A)"),
policy_str!("pk(B)"),
policy_str!("pk(D)"),
]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let comb_d: Vec<Arc<PolicyArc<String>>> = vec![
policy_str!("pk(A)"),
policy_str!("pk(B)"),
policy_str!("pk(C)"),
]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let comb_a: Vec<Arc<PolicyArc<String>>> =
vec![policy_str!("pk(B)"), policy_str!("pk(C)"), policy_str!("pk(D)")]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let comb_b: Vec<Arc<PolicyArc<String>>> =
vec![policy_str!("pk(A)"), policy_str!("pk(C)"), policy_str!("pk(D)")]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let comb_c: Vec<Arc<PolicyArc<String>>> =
vec![policy_str!("pk(A)"), policy_str!("pk(B)"), policy_str!("pk(D)")]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let comb_d: Vec<Arc<PolicyArc<String>>> =
vec![policy_str!("pk(A)"), policy_str!("pk(B)"), policy_str!("pk(C)")]
.into_iter()
.map(|pol| Arc::new(PolicyArc::from(pol)))
.collect();
let expected_comb = vec![comb_a, comb_b, comb_c, comb_d]
.into_iter()
.map(|sub_pol| (0.25, Arc::new(PolicyArc::Threshold(2, sub_pol))))
Expand Down
10 changes: 2 additions & 8 deletions src/policy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Liftable<Pk> for Terminal<Pk, Ctx> {
}
Terminal::AndOr(ref a, ref b, ref c) => Semantic::Threshold(
1,
vec![
Semantic::Threshold(2, vec![a.node.lift()?, b.node.lift()?]),
c.node.lift()?,
],
vec![Semantic::Threshold(2, vec![a.node.lift()?, b.node.lift()?]), c.node.lift()?],
),
Terminal::OrB(ref left, ref right)
| Terminal::OrD(ref left, ref right)
Expand Down Expand Up @@ -347,10 +344,7 @@ mod tests {
vec![
Semantic::Threshold(
2,
vec![
Semantic::Key(key_a),
Semantic::Older(Sequence::from_height(42))
]
vec![Semantic::Key(key_a), Semantic::Older(Sequence::from_height(42))]
),
Semantic::Key(key_b)
]
Expand Down
5 changes: 1 addition & 4 deletions src/policy/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,7 @@ mod tests {
policy,
Policy::Threshold(
1,
vec![
Policy::Key("".to_owned()),
Policy::Older(Sequence::from_height(1000)),
]
vec![Policy::Key("".to_owned()), Policy::Older(Sequence::from_height(1000)),]
)
);
assert_eq!(policy.relative_timelocks(), vec![1000]);
Expand Down

0 comments on commit 93e7c3a

Please sign in to comment.