MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / insert_test_data

Function insert_test_data

ipld/resolver/tests/smoke.rs:390–400  ·  view source on GitHub ↗

Insert a HAMT into the block store of an agent.

(agent: &mut Agent)

Source from the content-addressed store, hash-verified

388
389/// Insert a HAMT into the block store of an agent.
390fn insert_test_data(agent: &mut Agent) -> anyhow::Result<Cid> {
391 let mut hamt: Hamt<_, String, u32> = Hamt::new_with_bit_width(&agent.store, BIT_WIDTH);
392
393 // Insert enough data into the HAMT to make sure it grows from a single `Node`.
394 for i in 0..KEY_COUNT {
395 hamt.set(i, format!("value {i}"))?;
396 }
397 let cid = hamt.flush()?;
398
399 Ok(cid)
400}
401
402fn check_test_data(agent: &mut Agent, cid: &Cid) -> anyhow::Result<()> {
403 let hamt: Hamt<_, String, u32> = Hamt::load_with_bit_width(cid, &agent.store, BIT_WIDTH)?;

Calls 1

flushMethod · 0.45

Tested by

no test coverage detected