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

Chik-Network / chik_rs / 14565525798

21 Apr 2025 01:39AM UTC coverage: 67.072% (-17.5%) from 84.616%
14565525798

push

github

Chik-Network
update 0.22.0

2 of 2 new or added lines in 1 file covered. (100.0%)

2902 existing lines in 63 files now uncovered.

11097 of 16545 relevant lines covered (67.07%)

799466.45 hits per line

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

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

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

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

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