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

Chik-Network / chik_rs / 14076764197

26 Mar 2025 06:14AM UTC coverage: 84.616% (+0.1%) from 84.516%
14076764197

push

github

Chik-Network
update 0.21.2

287 of 310 new or added lines in 4 files covered. (92.58%)

77 existing lines in 3 files now uncovered.

14004 of 16550 relevant lines covered (84.62%)

1160098.34 hits per line

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

76.67
/wheel/src/run_program.rs
1
use chik_consensus::allocator::make_allocator;
2
use chik_protocol::LazyNode;
3
use klvmr::chik_dialect::ChikDialect;
4
use klvmr::cost::Cost;
5
use klvmr::reduction::Response;
6
use klvmr::run_program::run_program;
7
use klvmr::serde::{node_from_bytes_backrefs, node_to_bytes, serialized_length_from_bytes};
8
use pyo3::buffer::PyBuffer;
9
use pyo3::exceptions::PyValueError;
10
use pyo3::prelude::*;
11
use std::rc::Rc;
12

13
#[allow(clippy::borrow_deref_ref)]
UNCOV
14
#[pyfunction]
×
UNCOV
15
pub fn serialized_length(program: PyBuffer<u8>) -> PyResult<u64> {
×
UNCOV
16
    assert!(program.is_c_contiguous(), "program must be contiguous");
×
UNCOV
17
    let program =
×
UNCOV
18
        unsafe { std::slice::from_raw_parts(program.buf_ptr() as *const u8, program.len_bytes()) };
×
UNCOV
19
    Ok(serialized_length_from_bytes(program)?)
×
UNCOV
20
}
×
21

22
#[allow(clippy::borrow_deref_ref)]
23
#[pyfunction]
5,610✔
24
pub fn run_chik_program(
5,610✔
25
    py: Python<'_>,
5,610✔
26
    program: &[u8],
5,610✔
27
    args: &[u8],
5,610✔
28
    max_cost: Cost,
5,610✔
29
    flags: u32,
5,610✔
30
) -> PyResult<(Cost, LazyNode)> {
5,610✔
31
    let mut allocator = make_allocator(flags);
5,610✔
32

33
    let reduction = (|| -> PyResult<Response> {
5,610✔
34
        let program = node_from_bytes_backrefs(&mut allocator, program)?;
5,610✔
35
        let args = node_from_bytes_backrefs(&mut allocator, args)?;
5,610✔
36
        let dialect = ChikDialect::new(flags);
5,610✔
37

5,610✔
38
        Ok(py.allow_threads(|| run_program(&mut allocator, &dialect, program, args, max_cost)))
5,610✔
39
    })()?
5,610✔
40
    .map_err(|e| {
5,610✔
41
        let blob = node_to_bytes(&allocator, e.0).ok().map(hex::encode);
4✔
42
        PyValueError::new_err((e.1, blob))
4✔
43
    })?;
5,610✔
44
    let val = LazyNode::new(Rc::new(allocator), reduction.1);
5,606✔
45
    Ok((reduction.0, val))
5,606✔
46
}
5,610✔
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

© 2026 Coveralls, Inc