Skip to content

Commit

Permalink
test: Annotate snippet names with sign-off status
Browse files Browse the repository at this point in the history
Simplify identification of to-be-reviewed snippets.
  • Loading branch information
jan-ferdinand committed Jan 23, 2025
1 parent b856e36 commit e1d1673
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,7 @@ harness = false
name = "consensus"
harness = false
required-features = ["arbitrary-impls"]

[patch.crates-io]
# 04309be3 is tip of “better_snippet_export_pr” on 2025-01-17
tasm-lib = { git = "https://github.com/TritonVM/tasm-lib.git", rev = "04309be3" }
24 changes: 22 additions & 2 deletions src/models/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,30 @@ mod tests {
macro_rules! name_and_lib {
[$($t:expr),* $(,)?] => {[$({
let (library, _) = $t.library_and_code();
(stringify!($t), library)
let snippet_names = library
.get_all_snippet_names()
.into_iter()
.map(annotate_with_sign_off_status)
.collect_vec();
(stringify!($t), snippet_names)
}),*]};
}

/// Annotate a snippet name with a somewhat dramatic visualization of the
/// sign-off status.
fn annotate_with_sign_off_status(name: String) -> String {
let Some(snippet) = tasm_lib::exported_snippets::name_to_snippet(&name) else {
return format!("⚠ {name}");
};

let sign_offs = snippet.sign_offs();
if sign_offs.is_empty() {
return format!("🅾 {name}");
}

format!("{} {name}", sign_offs.len().to_string())
}

let all_consensus_critical_imports = name_and_lib![
block::validity::block_program::BlockProgram,
transaction::validity::collect_lock_scripts::CollectLockScripts,
Expand All @@ -38,7 +58,7 @@ mod tests {
// block_validity::PrincipalBlockValidationLogic,
]
.into_iter()
.flat_map(|(name, lib)| [vec![format!("\n{name}")], lib.get_all_snippet_names()].concat())
.flat_map(|(name, snippet_names)| [vec![format!("\n{name}")], snippet_names].concat())
.unique()
.join("\n");

Expand Down

0 comments on commit e1d1673

Please sign in to comment.