Skip to content

Commit 3570108

Browse files
committed
refactor(tests): reorganize test architecture and enhance debugging capabilities
This change restructures the test suite for the person management zome as part of the ongoing Phase 1 completion plan for the Nondominium Holochain hApp. Based on recent development context, this addresses testing infrastructure needs identified during the move toward Alpha testing scheduled for July 29th. The project has been focusing on completing the person management foundation before implementing resource and governance layers. Key structural changes: - Move tests from generic `nondominium/` to domain-specific `person/` directory - Consolidate test utilities into shared `utils.ts` and `types.d.ts` files - Replace general TEST_STRATEGY.md with specialized debug test suite - Enhanced debug logging in zome_person with detailed DHT operation tracking Technical improvements: - Added comprehensive debug test suite covering all person management workflows - Improved error visibility with step-by-step DHT synchronization logging - Enhanced test utilities for multi-agent scenarios and timing analysis - Better separation of concerns between foundation, integration, and scenario tests Debug enhancements in zome_person: - Added detailed logging for person creation and anchor link operations - Enhanced get_all_agents function with comprehensive debug output - Improved error handling and visibility for DHT hash operations This reorganization supports the upcoming capability-based access control migration and prepares the testing infrastructure for resource and governance zome integration in Phase 2.
1 parent 69c00b8 commit 3570108

13 files changed

Lines changed: 2344 additions & 1565 deletions

File tree

dnas/nondominium/zomes/coordinator/zome_person/src/lib.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,28 @@ pub fn create_person(input: CreatePersonInput) -> ExternResult<CreatePersonOutpu
8080

8181
let person = Person {
8282
agent_pub_key: agent_info.agent_initial_pubkey.clone(),
83-
name: input.name,
83+
name: input.name.clone(),
8484
avatar_url: input.avatar_url,
8585
created_at: now,
8686
};
8787

88+
debug!("Creating person: {}", person.name);
8889
let person_hash = create_entry(EntryTypes::Person(person.clone()))?;
90+
debug!("Person entry created with hash: {:?}", person_hash);
8991

9092
// Create an anchor link for discovering all persons
9193
let path = Path::from("all_people");
9294
let anchor_hash = path.path_entry_hash()?;
95+
debug!("Creating link from anchor {:?} to person {:?}", anchor_hash, person_hash);
96+
9397
create_link(
94-
anchor_hash,
98+
anchor_hash.clone(),
9599
person_hash.clone(),
96100
LinkTypes::AllPeople,
97101
LinkTag::new("person"),
98102
)?;
103+
104+
debug!("Link created successfully for person: {}", person.name);
99105

100106
Ok(CreatePersonOutput {
101107
person_hash,
@@ -276,25 +282,38 @@ pub fn get_all_agents(_: ()) -> ExternResult<GetAllAgentsOutput> {
276282
let path = Path::from("all_people");
277283
let anchor_hash = path.path_entry_hash()?;
278284

285+
debug!("Getting all agents - anchor hash: {:?}", anchor_hash);
286+
279287
let links =
280288
get_links(GetLinksInputBuilder::try_new(anchor_hash, LinkTypes::AllPeople)?.build())?;
281289

290+
debug!("Found {} links for all_people anchor", links.len());
291+
282292
let mut agents = Vec::new();
283293

284294
for link in links {
285-
if let Ok(any_dht_hash) = AnyDhtHash::try_from(link.target) {
286-
if let Some(record) = get(any_dht_hash, GetOptions::default())? {
295+
debug!("Processing link: {:?}", link);
296+
if let Ok(any_dht_hash) = AnyDhtHash::try_from(link.target.clone()) {
297+
if let Some(record) = get(any_dht_hash.clone(), GetOptions::default())? {
287298
if let Ok(Some(EntryTypes::Person(person))) =
288299
record.entry().to_app_option::<EntryTypes>().map_err(|_| {
289300
wasm_error!(WasmErrorInner::Guest("Failed to deserialize person".into()))
290301
})
291302
{
303+
debug!("Found person: {}", person.name);
292304
agents.push(person);
305+
} else {
306+
debug!("Failed to deserialize person from record");
293307
}
308+
} else {
309+
debug!("No record found for hash: {:?}", any_dht_hash);
294310
}
311+
} else {
312+
debug!("Failed to convert link target to AnyDhtHash");
295313
}
296314
}
297315

316+
debug!("Returning {} agents", agents.len());
298317
Ok(GetAllAgentsOutput { agents })
299318
}
300319

tests/src/nondominium/TEST_STRATEGY.md

Lines changed: 0 additions & 263 deletions
This file was deleted.

0 commit comments

Comments
 (0)