• 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

68.75
/ergotree-ir/src/mir/calc_blake2b256.rs
1
use alloc::boxed::Box;
2
use alloc::sync::Arc;
3

4
use crate::has_opcode::HasStaticOpCode;
5
use crate::serialization::op_code::OpCode;
6
use crate::types::stype::SType;
7

8
use super::expr::Expr;
9
use super::expr::InvalidArgumentError;
10
use super::unary_op::OneArgOp;
11
use super::unary_op::OneArgOpTryBuild;
12

13
/// Calc Blake2b 256-bit hash
14
#[derive(PartialEq, Eq, Debug, Clone)]
15
pub struct CalcBlake2b256 {
16
    /// Byte array with SColl(SByte) expr type
17
    pub input: Box<Expr>,
18
}
19

20
impl CalcBlake2b256 {
21
    /// Type
22
    pub fn tpe(&self) -> SType {
×
23
        SType::SColl(Arc::new(SType::SByte))
×
24
    }
25
}
26

27
impl HasStaticOpCode for CalcBlake2b256 {
28
    const OP_CODE: OpCode = OpCode::CALC_BLAKE2B256;
29
}
30

31
impl OneArgOp for CalcBlake2b256 {
32
    fn input(&self) -> &Expr {
2✔
33
        &self.input
2✔
34
    }
35
    fn input_mut(&mut self) -> &mut Expr {
2✔
36
        &mut self.input
2✔
37
    }
38
}
39

40
impl OneArgOpTryBuild for CalcBlake2b256 {
UNCOV
41
    fn try_build(input: Expr) -> Result<Self, InvalidArgumentError> {
×
UNCOV
42
        input.check_post_eval_tpe(&SType::SColl(Arc::new(SType::SByte)))?;
×
NEW
43
        Ok(Self::build_unchecked(input))
×
44
    }
45

46
    fn build_unchecked(input: Expr) -> Self {
3✔
47
        Self {
48
            input: input.into(),
3✔
49
        }
50
    }
51
}
52

53
#[cfg(feature = "arbitrary")]
54
/// Arbitrary impl
55
mod arbitrary {
56
    use crate::mir::expr::arbitrary::ArbExprParams;
57

58
    use super::*;
59
    use proptest::prelude::*;
60

61
    impl Arbitrary for CalcBlake2b256 {
62
        type Strategy = BoxedStrategy<Self>;
63
        type Parameters = ();
64

65
        fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
1✔
66
            any_with::<Expr>(ArbExprParams {
1✔
67
                tpe: SType::SColl(Arc::new(SType::SByte)),
1✔
68
                depth: 0,
69
            })
70
            .prop_map(|input| Self {
1✔
71
                input: input.into(),
1✔
72
            })
73
            .boxed()
74
        }
75
    }
76
}
77

78
#[cfg(test)]
79
#[cfg(feature = "arbitrary")]
80
#[allow(clippy::panic)]
81
mod tests {
82
    use super::*;
83
    use crate::serialization::sigma_serialize_roundtrip;
84

85
    use proptest::prelude::*;
86

87
    proptest! {
88

89
        #[test]
90
        fn ser_roundtrip(v in any::<CalcBlake2b256>()) {
91
            let expr: Expr = v.into();
92
            prop_assert_eq![sigma_serialize_roundtrip(&expr), expr];
93
        }
94
    }
95
}
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