Skip to content

Commit de2ff00

Browse files
committed
wip: feat: run_program_with_env
1 parent 2f52e22 commit de2ff00

File tree

1 file changed

+12
-3
lines changed
  • simplicity-sys/src/tests

1 file changed

+12
-3
lines changed

simplicity-sys/src/tests/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::tests::ffi::{
1616
type_inference::simplicity_mallocTypeInference,
1717
SimplicityErr,
1818
};
19+
use crate::CElementsTxEnv;
1920

2021
/// The result of parsing, typechecking, and running a Simplicity program
2122
/// through the C FFI
@@ -107,13 +108,22 @@ impl Drop for FreeOnDrop {
107108
}
108109
}
109110

111+
pub fn run_program(
112+
program: &[u8],
113+
witness: &[u8],
114+
test_up_to: TestUpTo,
115+
) -> Result<TestOutput, SimplicityErr> {
116+
run_program_with_env(program, witness, test_up_to, ptr::null())
117+
}
118+
110119
/// Run a program and return data about it
111120
///
112121
/// This is mostly a direct port of `run_program` in C `tests.c`.
113-
pub fn run_program(
122+
pub fn run_program_with_env(
114123
program: &[u8],
115124
witness: &[u8],
116125
test_up_to: TestUpTo,
126+
env: *const CElementsTxEnv,
117127
) -> Result<TestOutput, SimplicityErr> {
118128
let mut result = TestOutput {
119129
amr: CSha256Midstate::default(),
@@ -266,8 +276,7 @@ pub fn run_program(
266276
}
267277

268278
// 9. Run the program
269-
result.eval_result =
270-
simplicity_evalTCOProgram(dag, type_dag, len, ptr::null(), ptr::null());
279+
result.eval_result = simplicity_evalTCOProgram(dag, type_dag, len, ptr::null(), env);
271280
}
272281

273282
Ok(result)

0 commit comments

Comments
 (0)