upleb.uk

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

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/fixtures.rs
AgeCommit message (Collapse)Author
2025-12-24feat(purgatory): add broken purgatory implementationDanConwayDev
2025-12-23test: prepare other state tests for purgatory featureDanConwayDev
2025-12-23test: prepare OwnerStateDataPushed fixture for purgatoryDanConwayDev
This is the model for how to prepare all push tests for purgatory
2025-12-22chore: bump rust-nostr to latest masterDanConwayDev
so we can more easily support grasp purgatory feature
2025-12-11fix: resolve all fmt and clippy warningsDanConwayDev
Main lib (src/): - Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration) - Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting) - Replace .or_insert_with(RelaySyncNeeds::default) with .or_default() - Replace manual div_ceil implementations with .div_ceil(100) Test code (tests/): - Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...)) - Remove needless borrows in fetch_metrics() calls - Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module grasp-audit: - Apply cargo fmt to fix formatting
2025-12-02fix: tests using gpg signerDanConwayDev
2025-12-02refactor: rename AuditMode variants and change CLI default to sharedDanConwayDev
Breaking change: Renamed AuditMode enum variants for clarity: - AuditMode::CI -> AuditMode::Isolated (fresh fixtures per test) - AuditMode::Production -> AuditMode::Shared (reuse fixtures across tests) Config constructors renamed (with deprecated aliases): - AuditConfig::ci() -> AuditConfig::isolated() - AuditConfig::production() -> AuditConfig::shared() CLI default changed from 'ci' to 'shared' mode, which enables fixture caching across tests. This fixes the issue where fixtures were being re-created for every test in CLI mode. Fixture caching behavior: - Shared mode (CLI default): Uses client's cache, fixtures reused - Isolated mode (for cargo test): Local cache per TestContext
2025-12-02refactor: fix fmt and clippyDanConwayDev
2025-12-01better fixtures: clean upDanConwayDev
2025-12-01better fixtures: test_head_set_after_state_event_with_existing_commitDanConwayDev
2025-12-01better fixtures: refs/nostr testsDanConwayDev
2025-12-01better fixtures: MaintainerStateDataPushedDanConwayDev
2025-12-01fixtures dependancy overhaulDanConwayDev
2025-12-01better fixtures: MaintainerStateDataPushedDanConwayDev
2025-12-01begin implementing better fixturesDanConwayDev
2025-12-01reject push when refs/nostr/<event-id> doesnt match known event and delete ↵DanConwayDev
incorrect ref on event receive
2025-11-28test: added checks that refs/nostr/<event-id> match commit in PR / updateDanConwayDev
2025-11-28allow push to ref/nostr/<event-id>DanConwayDev
2025-11-28audit: fix push test when not isolatedDanConwayDev
2025-11-28audit: future test shared / isolation fixesDanConwayDev
2025-11-28fix: respect Isolated mode in TestContext fixture helpersDanConwayDev
Previously get_or_create_repo() and get_or_create_issue() always checked the client cache first, bypassing the mode-based caching logic. This caused fixture leaking across test suites when using the same AuditClient. With this fix: - In Isolated mode: helpers skip the cache, creating fresh fixtures - In Shared mode: helpers use the cache for fixture reuse (unchanged) This restores proper test isolation for push authorization tests that were failing because they shared the same ValidRepo fixture.
2025-11-28audit: fix shared test context to minimise events sent to production relaysDanConwayDev
2025-11-27remove depricated codeDanConwayDev
2025-11-27Task 4: Refactor recursive maintainer push test to fixture-first patternDanConwayDev
- Deprecated setup_repo_for_recursive_maintainer helper in fixtures.rs - test_push_authorized_by_recursive_maintainer_state now creates own TestContext - Uses FixtureKind chain: RepoState, MaintainerAnnouncement, MaintainerState, RecursiveMaintainerRepoAndState - Uses git helpers from fixtures.rs (clone_repo, create_deterministic_commit_with_variant, try_push) - Updated imports to include RECURSIVE_MAINTAINER_DETERMINISTIC_COMMIT_HASH - All unit tests pass: cargo test --lib
2025-11-27Task 3: Refactor maintainer push authorization test to fixture-first patternDanConwayDev
- Deprecated setup_repo_for_maintainer helper - test_push_authorized_by_maintainer_state_only now creates own TestContext - Uses FixtureKind::RepoState and FixtureKind::MaintainerState - Uses git helpers from fixtures.rs (clone_repo, create_deterministic_commit_with_variant, try_push) - Uses CommitVariant::Maintainer and MAINTAINER_DETERMINISTIC_COMMIT_HASH - Test compiles and passes: cargo test --lib (25 passed, 0 failed)
2025-11-27Task 2: Refactor owner push authorization test to fixture-first patternDanConwayDev
- Refactored test_push_authorized_by_owner_state to use fixture-first pattern - Test now creates its own TestContext and uses FixtureKind::RepoState - Uses git helper functions from fixtures.rs (clone_repo, create_deterministic_commit, try_push) - Follows the 3-step pattern: Generate fixtures → Send to relay → Verify behavior - Deprecated setup_repo_with_deterministic_commit with migration guide - Test passes: cargo test --test push_authorization test_push_authorized_by_owner_state - No API changes required for main project tests
2025-11-27fix(auth): accept state announcements from maintainersDanConwayDev
Updated get_maintainers_recursive() to properly handle maintainers listed in accepted repository announcements: 1. Separated 'visited' set (cycle prevention) from 'maintainers' set (result) 2. Maintainers listed in an announcement's 'maintainers' tag are now added to the maintainer set immediately, even without their own announcement 3. Recursively traverse maintainer chains to handle multi-level delegation Also fixed RecursiveMaintainerRepoAndState fixture to publish the maintainer's announcement (which lists the recursive maintainer) before publishing the recursive maintainer's announcement, establishing the proper trust chain: Owner -> Maintainer -> RecursiveMaintainer Test results: 7/7 push authorization tests passing
2025-11-27fix(tests): update main project tests for grasp-audit API changesDanConwayDev
2025-11-26test: use fixtures in push testsDanConwayDev
2025-11-26feat(fixtures): reuse prerequisite fixtures in production modeDanConwayDev
Fixtures now reuse their prerequisites in Shared (production) mode, significantly reducing events published to production relays: Before: Each fixture created its own prerequisite events - ValidRepo: 1 event - RepoWithIssue: 2 events (repo + issue) - RepoWithComment: 3 events (repo + issue + comment) - RepoState: 2 events (repo + state) After: Fixtures share prerequisites via caching - ValidRepo: 1 event - RepoWithIssue: 1 new event (issue), reuses cached repo - RepoWithComment: 1 new event (comment), reuses cached repo+issue - RepoState: 1 new event (state), reuses cached repo Total for all 4 fixtures: 8 events → 4 events (50% reduction) In CI/Isolated mode, each test still gets fresh fixtures for test isolation - behavior unchanged. Implemented via get_or_create_repo() and get_or_create_issue() helpers that handle mode-aware caching without async recursion.
2025-11-26feat: push authorization from state eventDanConwayDev
2025-11-19fix some clippy fmt warningsDanConwayDev
2025-11-11Fixed the RepoWithIssue fixture implementationDanConwayDev
in grasp-audit/src/fixtures.rs Changes Made: Updated the RepoWithIssue fixture to return the issue event directly instead of a problematic marker event The fixture now properly creates a repo, sends it, creates an issue referencing it, and returns the issue for the caller to send Fixed the test in event_acceptance_policy.rs:700-711 to work with the new fixture structure Test Results: ✓ accept_issue_quoting_issue_via_q now passes (uses RepoWithIssue fixture) ✗ accept_comment_via_E_tag still fails with "Failed to build RepoWithIssue fixture" The fixture structure is now correct (proven by the passing test). The remaining failure in accept_comment_via_E_tag appears to be a relay timing/state issue rather than a code problem, since: Same fixture kind works for one test but not the other Failure is very fast (2.7ms), suggesting early bail-out May be related to test execution order or relay capacity
2025-11-06fix cli runs to prevent rate limitingDanConwayDev