diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-01 23:21:20 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-01 23:21:20 +0000 |
| commit | e6c056023bac4a83930b9c40f4a9513c3680cb67 (patch) | |
| tree | cda3e46881309a0503f1ee57883a50fbb82689d1 /grasp-audit | |
| parent | 9a2e127663d8b3d776241472f4d769fb5d0ee27b (diff) | |
better fixtures: update readme
Diffstat (limited to 'grasp-audit')
| -rw-r--r-- | grasp-audit/README.md | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/grasp-audit/README.md b/grasp-audit/README.md index 2f4387c..2f07326 100644 --- a/grasp-audit/README.md +++ b/grasp-audit/README.md | |||
| @@ -242,7 +242,7 @@ pub async fn test_something(client: &AuditClient) -> TestResult { | |||
| 242 | │ Create TestContext, get fixtures, build scenarios, verify │ | 242 | │ Create TestContext, get fixtures, build scenarios, verify │ |
| 243 | ├─────────────────────────────────────────────────────────────────┤ | 243 | ├─────────────────────────────────────────────────────────────────┤ |
| 244 | │ Layer 2: FixtureKind + TestContext │ | 244 | │ Layer 2: FixtureKind + TestContext │ |
| 245 | │ ValidRepo, RepoState, MaintainerState, etc. │ | 245 | │ ValidRepo, RepoState, OwnerStateDataPushed, etc. │ |
| 246 | │ Mode-aware caching within TestContext │ | 246 | │ Mode-aware caching within TestContext │ |
| 247 | ├─────────────────────────────────────────────────────────────────┤ | 247 | ├─────────────────────────────────────────────────────────────────┤ |
| 248 | │ Layer 1: AuditClient │ | 248 | │ Layer 1: AuditClient │ |
| @@ -252,24 +252,60 @@ pub async fn test_something(client: &AuditClient) -> TestResult { | |||
| 252 | 252 | ||
| 253 | ### Available Fixtures | 253 | ### Available Fixtures |
| 254 | 254 | ||
| 255 | | FixtureKind | Provides | Use When | | 255 | | FixtureKind | Provides | Use When | |
| 256 | | ------------------------------------ | --------------------------------------- | ------------------------------------- | | 256 | | ----------- | -------- | -------- | |
| 257 | | `ValidRepo` | Accepted repo announcement (kind 30617) | Need a repo as prerequisite | | 257 | | `ValidRepo` | Accepted repo announcement (kind 30617). Signed by owner keys, lists maintainer in maintainers tag. | Need a repo as prerequisite | |
| 258 | | `RepoState` | Repo + state event (kind 30618) | Testing owner push authorization | | 258 | | `RepoWithIssue` | Repo + accepted issue (kind 1621) | Testing issue-dependent events | |
| 259 | | `RepoWithIssue` | Repo + accepted issue (kind 1621) | Testing issue-dependent events | | 259 | | `RepoWithComment` | Repo + issue + comment (kind 1111) | Testing comment-dependent events | |
| 260 | | `RepoWithComment` | Repo + issue + comment | Testing comment-dependent events | | 260 | | `RepoState` | Repo + state event (kind 30618). Signed by owner, points to `DETERMINISTIC_COMMIT_HASH`. | Testing owner state events | |
| 261 | | `MaintainerStateDataPushed` | Full maintainer push with git data | Testing maintainer push authorization | | 261 | | `PREvent` | Repo + PR event (kind 1618). Signed by PR author, points to `PR_TEST_COMMIT_HASH`. | Testing PR-dependent events | |
| 262 | | `RecursiveMaintainerStateDataPushed` | Full recursive maintainer push | Testing recursive maintainer chain | | 262 | | `PREventGenerated` | PR event built but NOT sent to relay. | Need PR event ID before publishing | |
| 263 | | `PRWrongCommitPushedBeforeEvent` | Wrong commit pushed to `refs/nostr/<pr-event-id>` before PR event sent. Returns unsent PR event. | Testing pre-event ref cleanup | | ||
| 264 | | `PREventSentAfterWrongPush` | PR event sent after wrong commit was pushed. Tests cleanup behavior. | Testing post-event ref cleanup | | ||
| 265 | | `OwnerStateDataPushed` | Full owner push flow: state event + git data pushed. Points to `DETERMINISTIC_COMMIT_HASH`. | Testing owner push authorization | | ||
| 266 | | `MaintainerStateDataPushed` | Full maintainer push flow: force-pushes over owner's data. Points to `MAINTAINER_DETERMINISTIC_COMMIT_HASH`. | Testing maintainer push authorization | | ||
| 267 | | `RecursiveMaintainerStateDataPushed` | Full recursive maintainer push flow: Owner → Maintainer → RecursiveMaintainer chain. Points to `RECURSIVE_MAINTAINER_DETERMINISTIC_COMMIT_HASH`. | Testing recursive maintainer authorization | | ||
| 268 | | `HeadSetToDevelopBranch` | State event with HEAD=refs/heads/develop. Depends on RecursiveMaintainerStateDataPushed. | Testing HEAD branch switching | | ||
| 263 | 269 | ||
| 264 | ### Fixture Lifecycle: Generate → Send → Verify | 270 | ### Deterministic Commit Hashes |
| 265 | 271 | ||
| 266 | Every fixture follows a 3-step lifecycle: | 272 | Fixtures use deterministic commit hashes for reproducible testing: |
| 273 | |||
| 274 | | Constant | Hash | Used By | | ||
| 275 | | -------- | ---- | ------- | | ||
| 276 | | `DETERMINISTIC_COMMIT_HASH` | `64ea71d79a57a7acb334cd9651f8aec067c0ce5d` | Owner fixtures (RepoState, OwnerStateDataPushed) | | ||
| 277 | | `MAINTAINER_DETERMINISTIC_COMMIT_HASH` | `1c2d472c9b71ed51968a66500281a3c4a6840464` | MaintainerStateDataPushed | | ||
| 278 | | `RECURSIVE_MAINTAINER_DETERMINISTIC_COMMIT_HASH` | `05939b82de66fbdb9c077d0a64fc68522f3cb8e0` | RecursiveMaintainerStateDataPushed | | ||
| 279 | | `PR_TEST_COMMIT_HASH` | `5d40fb1555a0c28bf4d650515a73aaa54d4d9bfb` | PR fixtures (PREvent, PREventGenerated) | | ||
| 280 | |||
| 281 | ### Fixture Dependencies | ||
| 282 | |||
| 283 | Fixtures automatically resolve their dependencies: | ||
| 284 | |||
| 285 | ``` | ||
| 286 | ValidRepo (base) | ||
| 287 | ├── RepoWithIssue → RepoWithComment | ||
| 288 | ├── RepoState | ||
| 289 | ├── PREventGenerated → PRWrongCommitPushedBeforeEvent → PREventSentAfterWrongPush | ||
| 290 | ├── PREvent | ||
| 291 | └── OwnerStateDataPushed | ||
| 292 | └── MaintainerStateDataPushed | ||
| 293 | └── RecursiveMaintainerStateDataPushed | ||
| 294 | └── HeadSetToDevelopBranch | ||
| 295 | ``` | ||
| 296 | |||
| 297 | ### Fixture Lifecycle: Generate → Send → Verify → DataPushed | ||
| 298 | |||
| 299 | Every fixture follows a lifecycle (some stop earlier): | ||
| 267 | 300 | ||
| 268 | 1. **GENERATE**: Build event via `AuditClient.event_builder()` (in memory only) | 301 | 1. **GENERATE**: Build event via `AuditClient.event_builder()` (in memory only) |
| 269 | 2. **SEND**: `client.send_event(event)` transmits to relay (rate-limited operation) | 302 | 2. **SEND**: `client.send_event(event)` transmits to relay (rate-limited operation) |
| 270 | 3. **VERIFY**: Query relay to confirm acceptance/rejection | 303 | 3. **VERIFY**: Query relay to confirm acceptance/rejection |
| 304 | 4. **DATA_PUSHED**: (DataPushed variants only) Clone repo, create commit, push to git server | ||
| 305 | |||
| 306 | Caching happens after the fixture completes - same fixture request returns cached Event. | ||
| 271 | 307 | ||
| 272 | Caching happens after SEND succeeds - same fixture request returns cached Event. | 308 | **Note:** Some fixtures handle their own event sending (e.g., `OwnerStateDataPushed`, `MaintainerStateDataPushed`). These are marked with `sends_own_events() -> true`. |
| 273 | 309 | ||
| 274 | ### How TestContext Correlates Events | 310 | ### How TestContext Correlates Events |
| 275 | 311 | ||