Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ itertools = "0.13.0"
arbitrary = { version = "1", optional = true, features = ["derive"] }
clap = "4.5.37"

simplicity-unchained = { git = "https://github.com/BlockstreamResearch/simplicity-unchained.git", rev = "f9196424bf3fbe5a3da36bd1f1e0bcb488574d2f", package = "core"}
simplicity-unchained = { git = "https://github.com/BlockstreamResearch/simplicity-unchained.git", rev = "26625522e11e21c441773a347c3546ce1b72397f", package = "core"}

[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2", features = ["js"] }
Expand Down
40 changes: 39 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ pub(crate) mod tests {
use std::borrow::Cow;
use std::path::Path;

use crate::tracker::{DefaultTracker, TrackerLogLevel};
use crate::*;

pub(crate) struct TestCase<T> {
Expand Down Expand Up @@ -473,7 +474,12 @@ pub(crate) mod tests {

fn run(self) -> Result<(), simplicity::bit_machine::ExecutionError> {
let env = dummy_env::dummy_with(self.lock_time, self.sequence, self.include_fee_output);
let pruned = self.program.redeem().prune(&env)?;
let mut tracker = DefaultTracker::new(self.program.debug_symbols())
.with_log_level(TrackerLogLevel::Trace);
let pruned = self
.program
.redeem()
.prune_with_tracker(&env, &mut tracker)?;
let mut mac = BitMachine::for_program(&pruned)
.expect("program should be within reasonable bounds");
mac.exec(&pruned, &env).map(|_| ())
Expand Down Expand Up @@ -735,4 +741,36 @@ fn main() {
.with_witness_values(WitnessValues::<ElementsExtension>::default())
.assert_run_success();
}

const LOCK_DISTANCE: &str = r#"fn main() {
let _: u16 = jet::tx_lock_distance();
jet::check_lock_distance(10);
}
"#;

const LOCK_DURATION: &str = r#"fn main() {
let _: u16 = jet::tx_lock_duration();
jet::check_lock_duration(10);
}
"#;

#[test]
fn test_timelock_sanity() {
let mut distance = TestCase::<CompiledProgram<ElementsExtension>>::program_text(
std::borrow::Cow::Borrowed(LOCK_DISTANCE),
);
distance.sequence = elements::Sequence::from_height(100);

let mut duration = TestCase::<CompiledProgram<ElementsExtension>>::program_text(
std::borrow::Cow::Borrowed(LOCK_DURATION),
);
duration.sequence = elements::Sequence::from_512_second_intervals(100);

distance
.with_witness_values(WitnessValues::default())
.assert_run_success();
duration
.with_witness_values(WitnessValues::default())
.assert_run_success();
}
}
Loading