use sqlitegraph::backend::native::graph_file::GraphFile;
use sqlitegraph::backend::native::node_store::NodeStore;
use sqlitegraph::backend::native::v2::node_record_v2::{NodeRecordV2, NodeRecordV2Ext};
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
unsafe {
env::set_var("PHASE75_INSTRUMENTATION", "1");
}
println!("=== Phase 76 Instrumentation Test ===");
let temp_file = tempfile::NamedTempFile::new()?;
let path = temp_file.path();
println!("Creating GraphFile at: {:?}", path);
let mut graph_file = GraphFile::create(path)?;
println!("\n=== Creating Node 1 (Phase 76 instrumentation) ===");
let node1_v2 = NodeRecordV2::new(
1,
"TestNode".to_string(),
"test_node_1".to_string(),
serde_json::json!({"test": true, "node_id": 1}),
);
let mut node_store = NodeStore::new(&mut graph_file);
println!("Writing node 1 (should show [phase76] NODE_WRITE instrumentation)...");
node_store.write_node_v2(&node1_v2)?;
println!("Reading node 1 (should show [phase76] NODE_READ instrumentation)...");
let _read_node = node_store.read_node_v2(1)?;
println!("\n=== Creating Node 2 (Phase 76 instrumentation) ===");
let node2_v2 = NodeRecordV2::new(
2,
"TestNode".to_string(),
"test_node_2".to_string(),
serde_json::json!({"test": true, "node_id": 2}),
);
println!("Writing node 2 (should show [phase76] NODE_WRITE instrumentation)...");
node_store.write_node_v2(&node2_v2)?;
println!("Reading node 2 (should show [phase76] NODE_READ instrumentation)...");
let _read_node = node_store.read_node_v2(2)?;
println!("\n=== Simulating Transaction Write-Set ===");
graph_file.record_node_v2_cluster_modified(1);
graph_file.record_node_v2_cluster_modified(2);
println!("\n=== Simulating Rollback (Phase 76 instrumentation) ===");
println!("This should show [phase76] ROLLBACK_BEFORE and ROLLBACK_AFTER instrumentation...");
graph_file.rollback_transaction()?;
println!("\n=== Phase 76 Instrumentation Test Complete ===");
println!(
"If you saw [phase76] instrumentation messages above, the byte-proof logging is working!"
);
Ok(())
}