From fefb37e040eb3cf91093d597737e1431fed38c81 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 18 Feb 2026 22:12:22 +0000 Subject: fix: use unique commit instead of deterministic Owner variant for wrong-commit PR tests PRWrongCommitPushedBeforeEvent and test_push_to_nostr_ref_with_wrong_commit_after_event_received_rejected were calling create_deterministic_commit_with_variant(CommitVariant::Owner) on a clone that already had test.txt with 'Initial commit\n' content from OwnerStateDataPushed. Writing identical content staged nothing so git commit failed silently. Now that ValidRepoServed always depends on OwnerStateDataPushed (git data pushed), the clone is never empty - use create_commit (unique file) instead since the wrong commit only needs to differ from PR_TEST_COMMIT_HASH, not be deterministic. --- grasp-audit/src/fixtures.rs | 10 +++++++--- grasp-audit/src/specs/grasp01/push_authorization.rs | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs index fc6e8cb..45d3094 100644 --- a/grasp-audit/src/fixtures.rs +++ b/grasp-audit/src/fixtures.rs @@ -1579,10 +1579,14 @@ impl<'a> TestContext<'a> { let _ = fs::remove_dir_all(path); }; - // Create a WRONG commit (Owner variant, not PRTestCommit) - // This commit hash will NOT match what's in the PR event's `c` tag + // Create a WRONG commit using a unique file (not PRTestCommit) + // We use create_commit (non-deterministic) so it always succeeds even if the + // repo already has a commit (e.g. from OwnerStateDataPushed) with the same + // deterministic content. The only requirement is that the hash differs from + // PR_TEST_COMMIT_HASH, which is guaranteed since PR_TEST_COMMIT_HASH is a + // deterministic root-commit with specific content and dates. let wrong_commit_hash = - match create_deterministic_commit_with_variant(&clone_path, CommitVariant::Owner) { + match create_commit(&clone_path, "wrong commit - not the PR test commit") { Ok(h) => h, Err(e) => { cleanup(&clone_path); diff --git a/grasp-audit/src/specs/grasp01/push_authorization.rs b/grasp-audit/src/specs/grasp01/push_authorization.rs index 768e8f9..73cbe1f 100644 --- a/grasp-audit/src/specs/grasp01/push_authorization.rs +++ b/grasp-audit/src/specs/grasp01/push_authorization.rs @@ -1231,9 +1231,9 @@ impl PushAuthorizationTests { } }; - // Create a wrong commit (Owner variant, not PRTestCommit) - if let Err(e) = create_deterministic_commit_with_variant(&clone_path, CommitVariant::Owner) - { + // Create a wrong commit (unique, not PRTestCommit) - use create_commit so it always + // succeeds even when the clone already has the Owner deterministic content on disk. + if let Err(e) = create_commit(&clone_path, "wrong commit - not the PR test commit") { let _ = fs::remove_dir_all(&clone_path); return TestResult::new(test_name, SpecRef::GitAcceptRefsNostrEventId, desc).fail(&e); } -- cgit v1.2.3