upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/common/purgatory_helpers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/purgatory_helpers.rs')
-rw-r--r--tests/common/purgatory_helpers.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/common/purgatory_helpers.rs b/tests/common/purgatory_helpers.rs
index 1d06f22..cfcea1c 100644
--- a/tests/common/purgatory_helpers.rs
+++ b/tests/common/purgatory_helpers.rs
@@ -338,6 +338,44 @@ pub fn build_repo_coord(keys: &Keys, identifier: &str) -> String {
338 format!("30617:{}:{}", keys.public_key().to_hex(), identifier) 338 format!("30617:{}:{}", keys.public_key().to_hex(), identifier)
339} 339}
340 340
341/// Create a repository announcement event (kind 30617) for purgatory tests.
342///
343/// Creates a minimal but valid NIP-34 repository announcement with a `d` tag,
344/// optional `clone` URLs, and optional `relays` URLs.
345///
346/// # Arguments
347/// * `keys` - Keys for signing
348/// * `identifier` - Repository identifier (d-tag)
349/// * `clone_urls` - Clone URLs to include (may be empty)
350/// * `relay_urls` - Relay URLs to include (may be empty)
351///
352/// # Returns
353/// * `Ok(Event)` - Signed announcement event
354/// * `Err(String)` - If signing fails
355pub fn create_announcement_event(
356 keys: &Keys,
357 identifier: &str,
358 clone_urls: &[&str],
359 relay_urls: &[&str],
360) -> Result<Event, String> {
361 let mut tags = vec![Tag::identifier(identifier)];
362
363 if !clone_urls.is_empty() {
364 let urls: Vec<String> = clone_urls.iter().map(|s| s.to_string()).collect();
365 tags.push(Tag::custom(TagKind::custom("clone"), urls));
366 }
367
368 if !relay_urls.is_empty() {
369 let urls: Vec<String> = relay_urls.iter().map(|s| s.to_string()).collect();
370 tags.push(Tag::custom(TagKind::custom("relays"), urls));
371 }
372
373 EventBuilder::new(Kind::GitRepoAnnouncement, "")
374 .tags(tags)
375 .sign_with_keys(keys)
376 .map_err(|e| format!("Failed to sign announcement event: {}", e))
377}
378
341/// Wait for an event to be served by a relay (not in purgatory). 379/// Wait for an event to be served by a relay (not in purgatory).
342/// 380///
343/// Polls the relay until the event is queryable, indicating it has 381/// Polls the relay until the event is queryable, indicating it has