MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / open_array_idempotent_for_same_hash

Function open_array_idempotent_for_same_hash

nodedb/src/engine/array/engine.rs:217–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

215
216 #[test]
217 fn open_array_idempotent_for_same_hash() {
218 use crate::engine::array::wal::ArrayPutCell;
219 use nodedb_array::types::cell_value::value::CellValue;
220 use nodedb_array::types::coord::value::CoordValue;
221 use tempfile::TempDir;
222
223 let dir = TempDir::new().unwrap();
224 let mut e = ArrayEngine::new(ArrayEngineConfig::new(dir.path().to_path_buf())).unwrap();
225 // First open registers the store and a put stamps memtable state.
226 e.open_array(aid(), schema(), 0xC0FFEE).unwrap();
227 e.put_cells(
228 &aid(),
229 vec![ArrayPutCell {
230 coord: vec![CoordValue::Int64(4), CoordValue::Int64(4)],
231 attrs: vec![CellValue::Int64(99)],
232 surrogate: nodedb_types::Surrogate::ZERO,
233 system_from_ms: 0,
234 valid_from_ms: 0,
235 valid_until_ms: i64::MAX,
236 }],
237 1,
238 )
239 .unwrap();
240 // Second open with the same hash must NOT reset state.
241 e.open_array(aid(), schema(), 0xC0FFEE).unwrap();
242 assert_eq!(
243 e.store(&aid()).unwrap().memtable.stats().cell_count,
244 1,
245 "idempotent re-open must preserve memtable contents"
246 );
247 }
248
249 #[test]
250 fn open_array_rejects_different_hash() {

Callers

nothing calls this directly

Calls 5

open_arrayMethod · 0.80
put_cellsMethod · 0.80
aidFunction · 0.70
schemaFunction · 0.70
pathMethod · 0.45

Tested by

no test coverage detected