upleb.uk

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

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/specs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-23 16:20:24 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-23 16:20:24 +0000
commitf8c3e3920ed2a1bdaab30be912276993449a5476 (patch)
tree793181955620cd61475d9ea81ea316a6d6c0bdb9 /grasp-audit/src/specs
parent2f4da43c5b90597ba671986d15c9227ebbfc84ce (diff)
test: add purgatory to PR push test
commented out so it currently passes
Diffstat (limited to 'grasp-audit/src/specs')
-rw-r--r--grasp-audit/src/specs/grasp01/push_authorization.rs41
1 files changed, 38 insertions, 3 deletions
diff --git a/grasp-audit/src/specs/grasp01/push_authorization.rs b/grasp-audit/src/specs/grasp01/push_authorization.rs
index 0ba5b5d..e076bee 100644
--- a/grasp-audit/src/specs/grasp01/push_authorization.rs
+++ b/grasp-audit/src/specs/grasp01/push_authorization.rs
@@ -39,6 +39,7 @@ use nostr_sdk::prelude::*;
39use std::fs; 39use std::fs;
40use std::path::{Path, PathBuf}; 40use std::path::{Path, PathBuf};
41use std::process::Command; 41use std::process::Command;
42use std::time::Duration;
42 43
43// ============================================================ 44// ============================================================
44// PR Event Test Helper Functions 45// PR Event Test Helper Functions
@@ -382,7 +383,7 @@ impl PushAuthorizationTests {
382 .await, 383 .await,
383 ); 384 );
384 results.add( 385 results.add(
385 Self::test_push_to_nostr_ref_with_correct_commit_after_event_received_accepted( 386 Self::test_push_to_nostr_ref_with_correct_commit_after_event_received_accepted_and_event_served(
386 client, 387 client,
387 relay_domain, 388 relay_domain,
388 ) 389 )
@@ -1289,10 +1290,10 @@ impl PushAuthorizationTests {
1289 /// 1290 ///
1290 /// This test verifies that the relay accepts pushes to refs/nostr/<event-id> 1291 /// This test verifies that the relay accepts pushes to refs/nostr/<event-id>
1291 /// when a corresponding event exists AND the pushed commit matches 1292 /// when a corresponding event exists AND the pushed commit matches
1292 /// the commit in the PR event's `c` tag. 1293 /// the commit in the PR event's `c` tag AND the PR event is served on relay.
1293 /// 1294 ///
1294 /// Uses `PREventSentAfterWrongPush` fixture, then creates correct commit and pushes. 1295 /// Uses `PREventSentAfterWrongPush` fixture, then creates correct commit and pushes.
1295 pub async fn test_push_to_nostr_ref_with_correct_commit_after_event_received_accepted( 1296 pub async fn test_push_to_nostr_ref_with_correct_commit_after_event_received_accepted_and_event_served(
1296 client: &AuditClient, 1297 client: &AuditClient,
1297 relay_domain: &str, 1298 relay_domain: &str,
1298 ) -> TestResult { 1299 ) -> TestResult {
@@ -1353,6 +1354,21 @@ impl PushAuthorizationTests {
1353 return TestResult::new(test_name, "GRASP-01:git-http:40", desc).fail(&e); 1354 return TestResult::new(test_name, "GRASP-01:git-http:40", desc).fail(&e);
1354 } 1355 }
1355 1356
1357 // TODO - uncomment this when purgatory feature added
1358 // // Check event is not yet served by relay (still in purgatory)
1359 // match client.is_event_on_relay(pr_event.id).await {
1360 // Ok(on_relay) => {
1361 // if !on_relay {
1362 // return TestResult::new(test_name, "GRASP-01:git-http:40", desc)
1363 // .fail("PR event not in purgatory before correct commit pushed to refs/nostr/<event-id> (the relay serve the PR event)");
1364 // }
1365 // }
1366 // Err(_) => {
1367 // return TestResult::new(test_name, "GRASP-01:git-http:40", desc)
1368 // .fail("failed to query relay");
1369 // }
1370 // }
1371
1356 // Push correct commit (should succeed) 1372 // Push correct commit (should succeed)
1357 let push_succeeded = match push_to_pr_ref(&clone_path, &pr_event_id) { 1373 let push_succeeded = match push_to_pr_ref(&clone_path, &pr_event_id) {
1358 Ok(success) => success, 1374 Ok(success) => success,
@@ -1370,6 +1386,25 @@ impl PushAuthorizationTests {
1370 .fail("Push rejected (expected acceptance since commit matches PR event)"); 1386 .fail("Push rejected (expected acceptance since commit matches PR event)");
1371 } 1387 }
1372 1388
1389 // ============================================================
1390 // Stage 5: Verify PR event is on relay
1391 // ============================================================
1392
1393 tokio::time::sleep(Duration::from_millis(200)).await;
1394
1395 match client.is_event_on_relay(pr_event.id).await {
1396 Ok(on_relay) => {
1397 if !on_relay {
1398 return TestResult::new(test_name, "GRASP-01:git-http:40", desc)
1399 .fail("PR event not served after correct commit at refs/nostr/<event-id>");
1400 }
1401 }
1402 Err(_) => {
1403 return TestResult::new(test_name, "GRASP-01:git-http:40", desc)
1404 .fail("failed to query relay");
1405 }
1406 }
1407
1373 TestResult::new(test_name, "GRASP-01:git-http:40", desc).pass() 1408 TestResult::new(test_name, "GRASP-01:git-http:40", desc).pass()
1374 } 1409 }
1375 1410