upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/common/sync_helpers.rs7
-rw-r--r--tests/purgatory_persistence.rs10
-rw-r--r--tests/purgatory_sync.rs15
-rw-r--r--tests/sync/discovery.rs6
-rw-r--r--tests/sync/maintainer_reprocessing.rs25
-rw-r--r--tests/sync/metrics.rs19
6 files changed, 50 insertions, 32 deletions
diff --git a/tests/common/sync_helpers.rs b/tests/common/sync_helpers.rs
index af51e78..611b1a5 100644
--- a/tests/common/sync_helpers.rs
+++ b/tests/common/sync_helpers.rs
@@ -1240,8 +1240,11 @@ pub async fn push_unique_git_data_to_relay(
1240 git(path, &["config", "commit.gpgsign", "false"]); 1240 git(path, &["config", "commit.gpgsign", "false"]);
1241 1241
1242 // Write a unique file so each maintainer gets a distinct commit hash 1242 // Write a unique file so each maintainer gets a distinct commit hash
1243 std::fs::write(path.join("state_test.txt"), "State test content for purgatory sync") 1243 std::fs::write(
1244 .expect("write state_test.txt"); 1244 path.join("state_test.txt"),
1245 "State test content for purgatory sync",
1246 )
1247 .expect("write state_test.txt");
1245 std::fs::write(path.join(".unique"), unique_seed).expect("write .unique"); 1248 std::fs::write(path.join(".unique"), unique_seed).expect("write .unique");
1246 git(path, &["add", "."]); 1249 git(path, &["add", "."]);
1247 git(path, &["commit", "-m", "State test commit"]); 1250 git(path, &["commit", "-m", "State test commit"]);
diff --git a/tests/purgatory_persistence.rs b/tests/purgatory_persistence.rs
index 655b0d9..0c1de28 100644
--- a/tests/purgatory_persistence.rs
+++ b/tests/purgatory_persistence.rs
@@ -169,7 +169,10 @@ async fn test_full_purgatory_save_restore_cycle() {
169 169
170 // Verify all data was restored 170 // Verify all data was restored
171 let (announcement_count2, state_count2, pr_count2) = purgatory2.count(); 171 let (announcement_count2, state_count2, pr_count2) = purgatory2.count();
172 assert_eq!(announcement_count2, 1, "Should have 1 announcement after restore"); 172 assert_eq!(
173 announcement_count2, 1,
174 "Should have 1 announcement after restore"
175 );
173 assert_eq!(state_count2, 2, "Should have 2 state events after restore"); 176 assert_eq!(state_count2, 2, "Should have 2 state events after restore");
174 assert_eq!( 177 assert_eq!(
175 pr_count2, 3, 178 pr_count2, 3,
@@ -853,7 +856,10 @@ async fn test_announcement_save_restore_cycle() {
853 let purgatory2 = Purgatory::new(&git_data_path); 856 let purgatory2 = Purgatory::new(&git_data_path);
854 purgatory2.restore_from_disk(&state_path).unwrap(); 857 purgatory2.restore_from_disk(&state_path).unwrap();
855 858
856 assert!(!state_path.exists(), "State file should be deleted after restore"); 859 assert!(
860 !state_path.exists(),
861 "State file should be deleted after restore"
862 );
857 863
858 let (ann_count2, _, _) = purgatory2.count(); 864 let (ann_count2, _, _) = purgatory2.count();
859 assert_eq!(ann_count2, 1, "Announcement should be restored"); 865 assert_eq!(ann_count2, 1, "Announcement should be restored");
diff --git a/tests/purgatory_sync.rs b/tests/purgatory_sync.rs
index eefd6bc..ced39ff 100644
--- a/tests/purgatory_sync.rs
+++ b/tests/purgatory_sync.rs
@@ -711,15 +711,10 @@ async fn test_concurrent_state_and_pr_sync() {
711 ); 711 );
712 712
713 // Check refs/nostr/<event-id> points to pr_commit 713 // Check refs/nostr/<event-id> points to pr_commit
714 let pr_ref_correct = check_ref_at_commit( 714 let pr_ref_correct =
715 &syncing_domain, 715 check_ref_at_commit(&syncing_domain, &npub, identifier, &pr_ref_name, &pr_commit)
716 &npub, 716 .await
717 identifier, 717 .expect("Failed to check PR ref");
718 &pr_ref_name,
719 &pr_commit,
720 )
721 .await
722 .expect("Failed to check PR ref");
723 718
724 assert!( 719 assert!(
725 pr_ref_correct, 720 pr_ref_correct,
@@ -993,7 +988,7 @@ async fn test_pr_event_clone_tag_sync_with_partial_oid_aggregation_from_multiple
993 let syncing_relay = TestRelay::start_on_port_with_options( 988 let syncing_relay = TestRelay::start_on_port_with_options(
994 syncing_port, 989 syncing_port,
995 Some(source_grasp.url().to_string()), // Bootstrap from source_grasp 990 Some(source_grasp.url().to_string()), // Bootstrap from source_grasp
996 true, // Disable negentropy - MockRelay doesn't support NIP-77 991 true, // Disable negentropy - MockRelay doesn't support NIP-77
997 ) 992 )
998 .await; 993 .await;
999 994
diff --git a/tests/sync/discovery.rs b/tests/sync/discovery.rs
index d45a290..ee675e6 100644
--- a/tests/sync/discovery.rs
+++ b/tests/sync/discovery.rs
@@ -183,7 +183,10 @@ async fn test_relay_discovery_via_announcements_with_historic_sync() {
183 let (announcement, _git_dir_a) = 183 let (announcement, _git_dir_a) =
184 setup_announcement_on_relay(&relay_a, &keys, &domain_refs, repo_id).await; 184 setup_announcement_on_relay(&relay_a, &keys, &domain_refs, repo_id).await;
185 let announcement_id = announcement.id; 185 let announcement_id = announcement.id;
186 println!("Announcement {} set up on relay_a with git data (Layer 1)", announcement_id); 186 println!(
187 "Announcement {} set up on relay_a with git data (Layer 1)",
188 announcement_id
189 );
187 190
188 // Build repo coordinate for Layer 2 reference 191 // Build repo coordinate for Layer 2 reference
189 let repo_coord = repo_coord(&keys, repo_id); 192 let repo_coord = repo_coord(&keys, repo_id);
@@ -235,4 +238,3 @@ async fn test_relay_discovery_via_announcements_with_historic_sync() {
235 issue_id 238 issue_id
236 ); 239 );
237} 240}
238
diff --git a/tests/sync/maintainer_reprocessing.rs b/tests/sync/maintainer_reprocessing.rs
index ff1eb43..9154ee5 100644
--- a/tests/sync/maintainer_reprocessing.rs
+++ b/tests/sync/maintainer_reprocessing.rs
@@ -70,17 +70,15 @@ async fn test_maintainer_announcement_reprocessed_immediately() {
70 identifier 70 identifier
71 )], 71 )],
72 ), 72 ),
73 Tag::custom( 73 Tag::custom(TagKind::custom("relays"), vec![relay_a.url().to_string()]),
74 TagKind::custom("relays"),
75 vec![relay_a.url().to_string()],
76 ),
77 ]) 74 ])
78 .sign_with_keys(&maintainer_keys) 75 .sign_with_keys(&maintainer_keys)
79 .unwrap(); 76 .unwrap();
80 send_to_relay(&relay_a, &maintainer_announcement).await.unwrap(); 77 send_to_relay(&relay_a, &maintainer_announcement)
78 .await
79 .unwrap();
81 let _git_dir_maintainer = 80 let _git_dir_maintainer =
82 push_git_data_to_relay(&relay_a, &maintainer_keys, identifier, &[&relay_a.domain()]) 81 push_git_data_to_relay(&relay_a, &maintainer_keys, identifier, &[&relay_a.domain()]).await;
83 .await;
84 println!("✓ Maintainer announcement + git data pushed to relay_a"); 82 println!("✓ Maintainer announcement + git data pushed to relay_a");
85 83
86 // Step 2: Start relay_b with relay_a as bootstrap so its SyncManager connects immediately. 84 // Step 2: Start relay_b with relay_a as bootstrap so its SyncManager connects immediately.
@@ -134,7 +132,9 @@ async fn test_maintainer_announcement_reprocessed_immediately() {
134 // re-processing of the maintainer announcement via our new code path. 132 // re-processing of the maintainer announcement via our new code path.
135 let _git_dir_owner = 133 let _git_dir_owner =
136 push_git_data_to_relay(&relay_b, &owner_keys, identifier, &[&relay_b.domain()]).await; 134 push_git_data_to_relay(&relay_b, &owner_keys, identifier, &[&relay_b.domain()]).await;
137 println!("✓ Owner git data pushed to relay_b (owner announcement promoted, hot cache re-processed)"); 135 println!(
136 "✓ Owner git data pushed to relay_b (owner announcement promoted, hot cache re-processed)"
137 );
138 138
139 // Step 5: Wait briefly for async processing to complete. 139 // Step 5: Wait briefly for async processing to complete.
140 tokio::time::sleep(Duration::from_secs(1)).await; 140 tokio::time::sleep(Duration::from_secs(1)).await;
@@ -363,9 +363,12 @@ async fn test_multiple_maintainers_all_reprocessed() {
363 .kind(Kind::GitRepoAnnouncement) 363 .kind(Kind::GitRepoAnnouncement)
364 .author(keys.public_key()) 364 .author(keys.public_key())
365 .identifier(identifier); 365 .identifier(identifier);
366 let found = 366 let found = wait_for_event_on_relay(relay_a.url(), filter, Duration::from_secs(10)).await;
367 wait_for_event_on_relay(relay_a.url(), filter, Duration::from_secs(10)).await; 367 assert!(
368 assert!(found, "{} announcement should be in relay_a before starting relay_b", name); 368 found,
369 "{} announcement should be in relay_a before starting relay_b",
370 name
371 );
369 } 372 }
370 println!("✓ All three maintainer announcements confirmed in relay_a's DB"); 373 println!("✓ All three maintainer announcements confirmed in relay_a's DB");
371 374
diff --git a/tests/sync/metrics.rs b/tests/sync/metrics.rs
index e973bbb..996c8b7 100644
--- a/tests/sync/metrics.rs
+++ b/tests/sync/metrics.rs
@@ -417,9 +417,12 @@ async fn test_live_sync_event_count() {
417 println!("Announcement set up on source relay with git data"); 417 println!("Announcement set up on source relay with git data");
418 418
419 // Start syncing relay with pre-allocated port 419 // Start syncing relay with pre-allocated port
420 let syncing_relay = 420 let syncing_relay = TestRelay::start_on_port_with_options(
421 TestRelay::start_on_port_with_options(sync_port, Some(source_relay.url().to_string()), false) 421 sync_port,
422 .await; 422 Some(source_relay.url().to_string()),
423 false,
424 )
425 .await;
423 println!("Syncing relay started at {}", syncing_relay.url()); 426 println!("Syncing relay started at {}", syncing_relay.url());
424 427
425 // Wait for sync connection to be fully established with EOSE received 428 // Wait for sync connection to be fully established with EOSE received
@@ -458,8 +461,14 @@ async fn test_live_sync_event_count() {
458 let client = TestClient::new(source_relay.url(), keys.clone()) 461 let client = TestClient::new(source_relay.url(), keys.clone())
459 .await 462 .await
460 .expect("Failed to connect to source"); 463 .expect("Failed to connect to source");
461 client.send_event(&patch1).await.expect("Failed to send patch 1"); 464 client
462 client.send_event(&patch2).await.expect("Failed to send patch 2"); 465 .send_event(&patch1)
466 .await
467 .expect("Failed to send patch 1");
468 client
469 .send_event(&patch2)
470 .await
471 .expect("Failed to send patch 2");
463 client.disconnect().await; 472 client.disconnect().await;
464 println!("Two patches sent to source relay (live mode)"); 473 println!("Two patches sent to source relay (live mode)");
465 474