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

Chik-Network / chik_rs / 9888528887

11 Jul 2024 08:59AM UTC coverage: 74.442% (-8.4%) from 82.844%
9888528887

push

github

Chik-Network
update 0.10.0

27 of 163 new or added lines in 10 files covered. (16.56%)

1047 existing lines in 32 files now uncovered.

10404 of 13976 relevant lines covered (74.44%)

273788.23 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 super::adapt_response::eval_err_to_pyresult;
2
use chik_consensus::allocator::make_allocator;
3
use chik_consensus::gen::flags::ALLOW_BACKREFS;
4
use chik_protocol::LazyNode;
5
use klvmr::chik_dialect::ChikDialect;
6
use klvmr::cost::Cost;
7
use klvmr::reduction::Response;
8
use klvmr::run_program::run_program;
9
use klvmr::serde::{node_from_bytes, node_from_bytes_backrefs, serialized_length_from_bytes};
10
use pyo3::buffer::PyBuffer;
11
use pyo3::prelude::*;
12
use std::rc::Rc;
13

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

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

UNCOV
34
    let r: Response = (|| -> PyResult<Response> {
×
UNCOV
35
        let deserialize = if (flags & ALLOW_BACKREFS) != 0 {
×
UNCOV
36
            node_from_bytes_backrefs
×
UNCOV
37
        } else {
×
UNCOV
38
            node_from_bytes
×
UNCOV
39
        };
×
UNCOV
40
        let program = deserialize(&mut allocator, program)?;
×
UNCOV
41
        let args = deserialize(&mut allocator, args)?;
×
UNCOV
42
        let dialect = ChikDialect::new(flags);
×
UNCOV
43

×
UNCOV
44
        Ok(py.allow_threads(|| run_program(&mut allocator, &dialect, program, args, max_cost)))
×
UNCOV
45
    })()?;
×
UNCOV
46
    match r {
×
UNCOV
47
        Ok(reduction) => {
×
UNCOV
48
            let val = LazyNode::new(Rc::new(allocator), reduction.1);
×
UNCOV
49
            Ok((reduction.0, val))
×
50
        }
UNCOV
51
        Err(eval_err) => eval_err_to_pyresult(eval_err, &allocator),
×
52
    }
UNCOV
53
}
×
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