• 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

56.25
/ergotree-ir/src/mir/decode_point.rs
1
//! Decode byte array to EC point
2

3
use alloc::boxed::Box;
4
use alloc::sync::Arc;
5

6
use crate::serialization::op_code::OpCode;
7
use crate::types::stype::SType;
8

9
use super::expr::Expr;
10
use super::expr::InvalidArgumentError;
11
use super::unary_op::OneArgOp;
12
use super::unary_op::OneArgOpTryBuild;
13
use crate::has_opcode::HasStaticOpCode;
14

15
/// Decode byte array to EC point
16
#[derive(PartialEq, Eq, Debug, Clone)]
17
pub struct DecodePoint {
18
    /// Byte array to be decoded
19
    pub input: Box<Expr>,
20
}
21

22
impl DecodePoint {
23
    /// Type
UNCOV
24
    pub fn tpe(&self) -> SType {
×
UNCOV
25
        SType::SGroupElement
×
26
    }
27
}
28

29
impl HasStaticOpCode for DecodePoint {
30
    const OP_CODE: OpCode = OpCode::DECODE_POINT;
31
}
32

33
impl OneArgOp for DecodePoint {
34
    fn input(&self) -> &Expr {
2✔
35
        &self.input
2✔
36
    }
37
    fn input_mut(&mut self) -> &mut Expr {
×
38
        &mut self.input
×
39
    }
40
}
41

42
impl OneArgOpTryBuild for DecodePoint {
UNCOV
43
    fn try_build(input: Expr) -> Result<Self, InvalidArgumentError> {
×
UNCOV
44
        input.check_post_eval_tpe(&SType::SColl(Arc::new(SType::SByte)))?;
×
NEW
45
        Ok(Self::build_unchecked(input))
×
46
    }
47
    fn build_unchecked(input: Expr) -> Self {
2✔
48
        Self {
49
            input: input.into(),
2✔
50
        }
51
    }
52
}
53

54
/// Arbitrary impl
55
#[cfg(feature = "arbitrary")]
56
mod arbitrary {
57
    use super::*;
58
    use crate::mir::expr::arbitrary::ArbExprParams;
59
    use proptest::prelude::*;
60

61
    impl Arbitrary for DecodePoint {
62
        type Strategy = BoxedStrategy<Self>;
63
        type Parameters = usize;
64

65
        fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
1✔
66
            any_with::<Expr>(ArbExprParams {
1✔
67
                tpe: SType::SColl(SType::SByte.into()),
1✔
68
                depth: args,
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::mir::expr::Expr;
84
    use crate::serialization::sigma_serialize_roundtrip;
85

86
    use proptest::prelude::*;
87

88
    proptest! {
89

90
        #[test]
91
        fn ser_roundtrip(v in any_with::<DecodePoint>(1)) {
92
            let expr: Expr = v.into();
93
            prop_assert_eq![sigma_serialize_roundtrip(&expr), expr];
94
        }
95

96
    }
97
}
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