• 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/byte_array_to_long.rs
1
//! Convert byte array to SLong
2
use alloc::boxed::Box;
3
use alloc::sync::Arc;
4

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
use crate::has_opcode::HasStaticOpCode;
13

14
/// Convert byte array to SLong
15
#[derive(PartialEq, Eq, Debug, Clone)]
16
pub struct ByteArrayToLong {
17
    /// Byte array with SColl(SByte) expr type
18
    pub input: Box<Expr>,
19
}
20

21
impl ByteArrayToLong {
22
    /// Type
23
    pub fn tpe(&self) -> SType {
1✔
24
        SType::SLong
1✔
25
    }
26
}
27

28
impl HasStaticOpCode for ByteArrayToLong {
29
    const OP_CODE: OpCode = OpCode::BYTE_ARRAY_TO_LONG;
30
}
31

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

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

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

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

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

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

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

79
#[cfg(test)]
80
#[cfg(feature = "arbitrary")]
81
#[allow(clippy::panic)]
82
mod tests {
83
    use super::*;
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::<ByteArrayToLong>()) {
92
            let expr: Expr = v.into();
93
            prop_assert_eq![sigma_serialize_roundtrip(&expr), expr];
94
        }
95
    }
96
}
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