use sqlitegraph::{GraphConfig, NodeSpec, SnapshotId, open_graph};
#[test]
fn test_v2_node_creation_beyond_256() {
let temp_dir = tempfile::tempdir().unwrap();
let db_path = temp_dir.path().join("test.db");
let graph = open_graph(&db_path, &GraphConfig::native()).unwrap();
let mut node_ids = Vec::new();
println!("Creating nodes 1..300 to test boundary at 256...");
for i in 1..=300 {
let node_id = graph
.insert_node(NodeSpec {
kind: "Node".to_string(),
name: format!("node_{}", i),
file_path: None,
data: serde_json::json!({"id": i}),
})
.expect(&format!("Failed to insert node {}", i));
node_ids.push(node_id);
if i >= 250 && i <= 260 {
println!("Created node {} with ID {}", i, node_id);
}
}
println!("Total nodes created: {}", node_ids.len());
assert_eq!(node_ids.len(), 300, "Should have created 300 nodes");
for node_id in 250..=260 {
match graph.get_node(SnapshotId::current(), node_id) {
Ok(node) => {
println!(
"SUCCESS: Node {} exists: {} (ID: {})",
node_id, node.name, node.id
);
assert_eq!(node.id, node_id);
}
Err(e) => {
panic!("ERROR: Cannot read node {}: {:?}", node_id, e);
}
}
}
match graph.get_node(SnapshotId::current(), 257) {
Ok(node) => {
println!("SUCCESS: Node 257 exists: {} (ID: {})", node.name, node.id);
assert_eq!(node.id, 257);
assert_eq!(node.name, "node_257");
}
Err(e) => {
panic!("CRITICAL: Node 257 cannot be read: {:?}", e);
}
}
for i in 0..299 {
let from_id = node_ids[i];
let to_id = node_ids[i + 1];
graph
.insert_edge(sqlitegraph::EdgeSpec {
from: from_id,
to: to_id,
edge_type: "test".to_string(),
data: serde_json::json!({"index": i}),
})
.expect(&format!("Failed to insert edge {}->{}", from_id, to_id));
}
println!("Successfully created {} edges across 256 boundary", 299);
}