add tests for timestamp validity windows

This commit is contained in:
Sergio Chouhy
2026-03-31 13:49:37 +02:00
committed by Moudy
parent 9aa7caf3bf
commit 27b0ba7592
3 changed files with 142 additions and 26 deletions
@@ -1,14 +1,15 @@
use nssa_core::program::{
AccountPostState, BlockId, ProgramInput, ProgramOutput, ValidityWindow, read_nssa_inputs,
AccountPostState, BlockId, ProgramInput, ProgramOutput, Timestamp, ValidityWindow,
read_nssa_inputs,
};
type Instruction = ValidityWindow<BlockId>;
type Instruction = (ValidityWindow<BlockId>, ValidityWindow<Timestamp>);
fn main() {
let (
ProgramInput {
pre_states,
instruction: block_validity_window,
instruction: (block_validity_window, timestamp_validity_window),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
@@ -25,5 +26,6 @@ fn main() {
vec![AccountPostState::new(post)],
)
.with_block_validity_window(block_validity_window)
.with_timestamp_validity_window(timestamp_validity_window)
.write();
}
@@ -1,6 +1,6 @@
use nssa_core::program::{
AccountPostState, BlockId, ChainedCall, ProgramId, ProgramInput, ProgramOutput, ValidityWindow,
read_nssa_inputs,
AccountPostState, BlockId, ChainedCall, ProgramId, ProgramInput, ProgramOutput, Timestamp,
ValidityWindow, read_nssa_inputs,
};
use risc0_zkvm::serde::to_vec;
@@ -9,6 +9,8 @@ use risc0_zkvm::serde::to_vec;
///
/// Instruction: (`window`, `chained_program_id`, `chained_window`)
/// The initial output uses `window` and chains to `chained_program_id` with `chained_window`.
/// The chained program (validity_window) expects `(ValidityWindow<BlockId>, ValidityWindow<Timestamp>)`
/// so an unbounded timestamp window is appended automatically.
type Instruction = (ValidityWindow<BlockId>, ProgramId, ValidityWindow<BlockId>);
fn main() {
@@ -23,7 +25,11 @@ fn main() {
let [pre] = <[_; 1]>::try_from(pre_states.clone()).expect("Expected exactly one pre state");
let post = pre.account.clone();
let chained_instruction = to_vec(&chained_block_validity_window).unwrap();
let chained_instruction = to_vec(&(
chained_block_validity_window,
ValidityWindow::<Timestamp>::new_unbounded(),
))
.unwrap();
let chained_call = ChainedCall {
program_id: chained_program_id,
instruction_data: chained_instruction,