use libveritas::msg::QueryContext;
use libveritas_testutil::fixture::{ChainState, FixtureRunner, single_commit_finalized};
use std::fs;
fn main() {
let dir = std::path::Path::new("examples/fixture");
fs::create_dir_all(dir).unwrap();
let mut state = ChainState::new();
let fixture = single_commit_finalized();
let mut runner = FixtureRunner::new(&mut state, fixture);
runner.run(&mut state);
state.anchors.push(state.chain.current_root_anchor());
let bundle = runner.build_bundle();
let msg = state.message(vec![bundle]);
let mut anchors = state.anchors.clone();
anchors.reverse();
let anchors_json = serde_json::to_string_pretty(&anchors).unwrap();
fs::write(dir.join("anchors.json"), &anchors_json).unwrap();
println!("wrote anchors.json ({} anchors)", anchors.len());
let msg_bytes = msg.to_bytes();
fs::write(dir.join("message.bin"), &msg_bytes).unwrap();
println!("wrote message.bin ({} bytes)", msg_bytes.len());
let veritas = state.veritas();
let ctx = QueryContext::new();
let result = veritas
.verify_with_options(&ctx, msg, libveritas::VERIFY_DEV_MODE)
.unwrap();
println!("\nnative verify OK: {} zones", result.zones.len());
for z in &result.zones {
println!(" {} -> {}", z.handle, z.sovereignty);
}
}