diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-10 16:59:09 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-10 16:59:09 +0000 |
| commit | cbed48d5a20b646a5bcc23e907d6163a3a8d36c5 (patch) | |
| tree | d01b4e49e5ffadc8f12f00f44e015531fa2deadb /tests/sync/bootstrap.rs | |
| parent | a958a55196537598492c3935ab46e3b6e23ee44b (diff) | |
refactor(tests): extract shared create_repo_announcement helper
Diffstat (limited to 'tests/sync/bootstrap.rs')
| -rw-r--r-- | tests/sync/bootstrap.rs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/tests/sync/bootstrap.rs b/tests/sync/bootstrap.rs index 4428721..62a8fa5 100644 --- a/tests/sync/bootstrap.rs +++ b/tests/sync/bootstrap.rs | |||
| @@ -14,39 +14,6 @@ use nostr_sdk::prelude::*; | |||
| 14 | 14 | ||
| 15 | use crate::common::{sync_helpers::*, TestRelay}; | 15 | use crate::common::{sync_helpers::*, TestRelay}; |
| 16 | 16 | ||
| 17 | /// Create a valid repository announcement event for testing sync. | ||
| 18 | /// | ||
| 19 | /// This creates a kind 30617 event with required clone and relays tags. | ||
| 20 | /// The event lists all provided domains so it will be accepted by each | ||
| 21 | /// relay's write policy. | ||
| 22 | /// | ||
| 23 | /// # Arguments | ||
| 24 | /// * `keys` - Keys for signing | ||
| 25 | /// * `domains` - Slice of domain strings (e.g., "127.0.0.1:8080") | ||
| 26 | /// * `identifier` - Repository identifier (d-tag) | ||
| 27 | fn create_repo_announcement(keys: &Keys, domains: &[&str], identifier: &str) -> Event { | ||
| 28 | // Build clone URLs for all domains (with .git suffix) | ||
| 29 | let clone_urls: Vec<String> = domains | ||
| 30 | .iter() | ||
| 31 | .map(|d| format!("http://{}/{}.git", d, identifier)) | ||
| 32 | .collect(); | ||
| 33 | |||
| 34 | // Build relay URLs for all domains | ||
| 35 | let relay_urls: Vec<String> = domains.iter().map(|d| format!("ws://{}", d)).collect(); | ||
| 36 | |||
| 37 | // Build tags for repository announcement | ||
| 38 | let tags = vec![ | ||
| 39 | Tag::identifier(identifier), | ||
| 40 | Tag::custom(TagKind::custom("clone"), clone_urls), | ||
| 41 | Tag::custom(TagKind::custom("relays"), relay_urls), | ||
| 42 | ]; | ||
| 43 | |||
| 44 | EventBuilder::new(Kind::Custom(KIND_REPOSITORY_STATE), "Repository state") | ||
| 45 | .tags(tags) | ||
| 46 | .sign_with_keys(keys) | ||
| 47 | .expect("Failed to sign repo announcement") | ||
| 48 | } | ||
| 49 | |||
| 50 | /// Test 1: Bootstrap sync - relay syncs existing events from bootstrap relay on startup | 17 | /// Test 1: Bootstrap sync - relay syncs existing events from bootstrap relay on startup |
| 51 | /// | 18 | /// |
| 52 | /// Scenario: | 19 | /// Scenario: |