• 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

54.55
/ergotree-ir/src/mir/extract_bytes.rs
1
use alloc::boxed::Box;
2

3
use crate::serialization::op_code::OpCode;
4
use crate::types::stype::SType;
5

6
use super::expr::Expr;
7
use super::expr::InvalidArgumentError;
8
use super::unary_op::OneArgOp;
9
use super::unary_op::OneArgOpTryBuild;
10
use crate::has_opcode::HasStaticOpCode;
11

12
/// Serialized box bytes
13
#[derive(PartialEq, Eq, Debug, Clone)]
14
pub struct ExtractBytes {
15
    /// Box, type of SBox
16
    pub input: Box<Expr>,
17
}
18

19
impl ExtractBytes {
20
    /// Type
UNCOV
21
    pub fn tpe(&self) -> SType {
×
UNCOV
22
        SType::SColl(SType::SByte.into())
×
23
    }
24
}
25

26
impl HasStaticOpCode for ExtractBytes {
27
    const OP_CODE: OpCode = OpCode::EXTRACT_BYTES;
28
}
29

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

39
impl OneArgOpTryBuild for ExtractBytes {
UNCOV
40
    fn try_build(input: Expr) -> Result<Self, InvalidArgumentError> {
×
UNCOV
41
        input.check_post_eval_tpe(&SType::SBox)?;
×
NEW
42
        Ok(Self::build_unchecked(input))
×
43
    }
44
    fn build_unchecked(input: Expr) -> Self {
2✔
45
        Self {
46
            input: input.into(),
2✔
47
        }
48
    }
49
}
50

51
#[cfg(test)]
52
#[cfg(feature = "arbitrary")]
53
mod tests {
54
    use super::*;
55
    use crate::mir::global_vars::GlobalVars;
56
    use crate::serialization::sigma_serialize_roundtrip;
57

58
    #[test]
59
    fn ser_roundtrip() {
60
        let e: Expr = ExtractBytes {
61
            input: Box::new(GlobalVars::SelfBox.into()),
62
        }
63
        .into();
64
        assert_eq![sigma_serialize_roundtrip(&e), e];
65
    }
66
}
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