diff --git a/Cargo.lock b/Cargo.lock index 6f78c57..6e247f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -337,7 +337,7 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "core" version = "0.1.0" -source = "git+https://github.com/BlockstreamResearch/simplicity-unchained.git?rev=f9196424bf3fbe5a3da36bd1f1e0bcb488574d2f#f9196424bf3fbe5a3da36bd1f1e0bcb488574d2f" +source = "git+https://github.com/BlockstreamResearch/simplicity-unchained.git?rev=26625522e11e21c441773a347c3546ce1b72397f#26625522e11e21c441773a347c3546ce1b72397f" dependencies = [ "hal-simplicity", "hex 0.4.3", diff --git a/Cargo.toml b/Cargo.toml index 615b761..bd1c44d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } diff --git a/src/lib.rs b/src/lib.rs index 9a1c535..7bfcddb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { @@ -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(|_| ()) @@ -735,4 +741,36 @@ fn main() { .with_witness_values(WitnessValues::::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::>::program_text( + std::borrow::Cow::Borrowed(LOCK_DISTANCE), + ); + distance.sequence = elements::Sequence::from_height(100); + + let mut duration = TestCase::>::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(); + } }