• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ergoplatform / sigma-rust / 15667516698

15 Jun 2025 09:22PM UTC coverage: 77.672% (-0.6%) from 78.291%
15667516698

Pull #832

github

web-flow
Merge 39c40f47b into 6f12ef8f2
Pull Request #832: Soft Fork support

298 of 462 new or added lines in 72 files covered. (64.5%)

53 existing lines in 22 files now uncovered.

11765 of 15147 relevant lines covered (77.67%)

2.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/ergotree-interpreter/src/eval/sigma_or.rs
1
use alloc::boxed::Box;
2
use alloc::vec::Vec;
3
use bounded_vec::NonEmptyVec;
4
use ergotree_ir::mir::constant::TryExtractInto;
5
use ergotree_ir::mir::sigma_or::SigmaOr;
6
use ergotree_ir::mir::value::Value;
7
use ergotree_ir::sigma_protocol::sigma_boolean::cor::Cor;
8
use ergotree_ir::sigma_protocol::sigma_boolean::SigmaProp;
9

10
use crate::eval::env::Env;
11
use crate::eval::Context;
12
use crate::eval::EvalError;
13
use crate::eval::Evaluable;
14

15
impl Evaluable for SigmaOr {
16
    fn eval<'ctx>(
4✔
17
        &self,
18
        env: &mut Env<'ctx>,
19
        ctx: &Context<'ctx>,
20
    ) -> Result<Value<'ctx>, EvalError> {
21
        let items_v: NonEmptyVec<_> = self
4✔
NEW
22
            .items
×
23
            .iter()
24
            .map(|it| it.eval(env, ctx))
8✔
25
            .collect::<Result<Vec<_>, _>>()?
26
            .try_into()?;
27
        let items_sigmabool = items_v
8✔
28
            .try_mapped(|it| it.try_extract_into::<SigmaProp>())?
8✔
29
            .mapped(|it| it.value().clone());
12✔
30
        Ok(Value::SigmaProp(Box::new(SigmaProp::new(Cor::normalized(
6✔
31
            items_sigmabool,
3✔
32
        )))))
33
    }
34
}
35

36
#[allow(clippy::unwrap_used)]
37
#[allow(clippy::panic)]
38
#[cfg(test)]
39
#[cfg(feature = "arbitrary")]
40
mod tests {
41
    use ergotree_ir::sigma_protocol::sigma_boolean::SigmaBoolean;
42
    use ergotree_ir::sigma_protocol::sigma_boolean::SigmaConjecture;
43

44
    use crate::eval::test_util::eval_out;
45
    use ergotree_ir::chain::context::Context;
46

47
    use super::*;
48

49
    use ergotree_ir::mir::expr::Expr;
50
    use proptest::collection;
51
    use proptest::prelude::*;
52
    use sigma_test_util::force_any_val;
53

54
    proptest! {
55

56
        #![proptest_config(ProptestConfig::with_cases(8))]
57

58
        #[test]
59
        fn eval(sigmaprops in collection::vec(any::<SigmaProp>(), 2..10)) {
60
            let items = sigmaprops.clone().into_iter().map(|sp| Expr::Const(sp.into())).collect();
61
            let expr: Expr = SigmaOr::new(items).unwrap().into();
62
            let ctx = force_any_val::<Context>();
63
            let res = eval_out::<SigmaProp>(&expr, &ctx);
64
            let expected_sb: Vec<SigmaBoolean> = sigmaprops.into_iter().map(|sp| sp.into()).collect();
65
            prop_assert!(matches!(res.clone().into(), SigmaBoolean::SigmaConjecture(SigmaConjecture::Cor(_))));
66
            if let SigmaBoolean::SigmaConjecture(SigmaConjecture::Cor(Cor {items: actual_sb})) = res.into() {
67
                prop_assert_eq!(actual_sb, expected_sb);
68
            }
69
        }
70
    }
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc