Skip to content

test: add deterministic typed event fixture validation - #157

Merged
El-swaggerito merged 1 commit into
Aegis-RWA:mainfrom
EmmyKay0026:test_add_deterministic_fixture_validation
Jul 29, 2026
Merged

test: add deterministic typed event fixture validation#157
El-swaggerito merged 1 commit into
Aegis-RWA:mainfrom
EmmyKay0026:test_add_deterministic_fixture_validation

Conversation

@EmmyKay0026

Copy link
Copy Markdown

Description

This PR strengthens the deterministic event fixture workflow for Aegis Contracts.

Changes

  • Added typed event expectations for every canonical event in fixtures/sdk/04-events.json.
  • Validates the exact contract address, topic, exported payload type, caller, event count, and ordering before JSON/XDR fixtures can be generated or updated.
  • Added reusable Harness::assert_events and Harness::assert_no_events helpers.
  • Ensured reverted compliance-sensitive calls are explicitly verified to emit no durable events.
  • Fixed cross-platform fixture verification by treating Windows CRLF checkout conversion as equivalent to canonical LF while continuing to compare all JSON content and XDR bytes exactly.
  • Added a regression test proving line-ending normalization does not hide fixture content drift.
  • Documented the typed fixture workflow, update-mode review requirements, SDK/dashboard compatibility expectations, and legal/compliance boundaries.
  • Updated the README and testing standards to link contributors to the workflow.

Files Modified

  • tests/sdk_fixtures.rs — adds typed expectations for all canonical event scenarios.
  • tests/support/mod.rs — adds typed event assertions, no-event assertions, and cross-platform comparison handling.
  • docs/sdk-fixtures.md — documents generation, validation, edge cases, and compliance boundaries.
  • docs/testing-standards.md — requires typed expectations for event fixture changes.
  • README.md — describes and links to the deterministic event fixture workflow.

No contract storage, public entrypoints, event schemas, error codes, or roles were changed.

Related Issues

Closes #36

Completion Table

Acceptance Criterion Status Implementation Evidence Test Evidence
AC 1: Deterministic event fixture tests are implemented or clearly specified. Complete typed_events! and Harness::assert_events validate live typed events before 04-events.json verification or regeneration. The workflow is specified in docs/sdk-fixtures.md. fixture_events passes against the committed event fixture.
AC 2: Relevant edge cases and failure states are handled. Complete Reverted calls use Harness::assert_no_events. Fixture comparisons normalize only CRLF/LF differences while preserving exact content and XDR validation. Multi-event compliance ordering is asserted explicitly. fixture_events covers reverted transfer silence; fixture_comparison_normalizes_only_windows_line_endings covers cross-platform determinism and verifies content drift remains detectable.
AC 3: Security and compliance-sensitive assumptions are documented. Complete docs/sdk-fixtures.md states that fixtures validate protocol behavior and wire compatibility, not legal, regulatory, investment, or financial compliance. It links to the Legal Boundary Disclaimer. Documentation review and the existing fixtures_contain_no_real_user_data test cover fixture privacy assumptions.
AC 4: Tests, fixtures, or review checklists are added where practical. Complete All canonical event fixture scenarios now construct exported Rust event payloads. Contributor requirements were added to docs/testing-standards.md. Event fixture test, CRLF regression test, privacy test, determinism test, and 180 contract unit tests were exercised.
AC 5: README/docs link to the guidance and remain compatible with the Aegis ecosystem. Complete README links to the SDK fixture guidance. Fixtures retain their existing JSON envelope and XDR representation for SDK, dashboard, and indexer consumers. The committed 04-events.json remains unchanged because the observed wire behavior did not change.

Incomplete criteria must include a reason and follow-up plan. See Handling Incomplete Criteria in docs/traceability-mapping.md.

Detailed Traceability Mapping

Acceptance Criteria Implementation Storage & State Changes Events Emitted Test Coverage Security/Safety Controls
AC 1: Deterministic typed fixtures typed_events! constructs exported payload types and calls Harness::assert_events before serialization. None. Test-only behavior. No new events. Existing event sequences are validated exactly. fixture_events Update mode cannot silently bless an unexpected topic, payload, caller, count, or ordering change.
AC 2: Edge cases and failures Added Harness::assert_no_events and canonical CRLF/LF comparison. None. Reverted transfer is required to emit no durable event. fixture_events; fixture_comparison_normalizes_only_windows_line_endings Failed compliance-sensitive operations remain event-free, and line-ending normalization cannot hide content drift.
AC 3: Compliance assumptions Added explicit protocol/legal boundary language to docs/sdk-fixtures.md. None. None. Existing privacy and fixture tests. No personal data, KYC evidence, legal determinations, or financial claims are represented by fixtures.
AC 4: Contributor workflow Updated docs/testing-standards.md with typed-event and no-event requirements. None. None. Targeted fixture tests and contract unit suite. Intentional event changes require typed expectation, documentation, compatibility review, and fixture diff review.
AC 5: Ecosystem compatibility Preserved existing JSON envelope, scenario IDs, lossless integer encoding, synthetic addresses, and raw XDR fields. None. Existing schemas remain unchanged. Committed event fixture verification passes without regeneration. SDKs, dashboards, and indexers retain the existing consumer boundary.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Chore (refactoring, build tools, etc.)

PR Evidence Checklist

Before opening this PR, complete every applicable item in the evidence
checklist below. See PR Evidence Checklist
for detailed guidance.

1. Issue Reference

  • The PR description links to the issue being addressed (replace #<issue-number> above).

2. Implementation Summary

  • A concise summary of what was implemented, changed, or fixed is provided above in the Description section.
  • Key files modified are listed with brief descriptions of each change.
  • New public functions, events, error codes, or roles are documented. No new contract-level public functions, events, error codes, or roles were introduced.

3. Tests Added or Justification

  • New or updated tests cover the change, including successful typed event sequences and failure paths.
  • Test names and locations are listed:
    • fixture_events in tests/sdk_fixtures.rs
    • fixture_comparison_normalizes_only_windows_line_endings in tests/support/mod.rs
    • fixtures_are_deterministic in tests/sdk_fixtures.rs
    • fixtures_contain_no_real_user_data in tests/sdk_fixtures.rs
  • OR a No-Test Justification is provided. Not applicable because tests were added and updated.

4. Commands Run

  • make verify passes locally. See Additional Context for the targeted results and existing unrelated repository failures.
  • Relevant command output is included in the Additional Context section.

5. CI Status

  • All GitHub Actions checks pass on the PR branch. Update this after CI runs.
  • If CI is failing, add the CI link and corresponding follow-up issue.

6. Acceptance Criteria Coverage

  • Every acceptance criterion from the issue is addressed in the Completion Table above.
  • No acceptance criteria are marked Partial or Not Met.

Policy & Standards

  • I have read the Contributor Evaluation Policy and understand that merge does not guarantee payment.
  • I have read the CONTRIBUTING.md guidelines.
  • Modified Rust files pass targeted rustfmt --check.
  • My changes generate no new warnings (cargo clippy should be confirmed after existing repository warnings are resolved).
  • All repository tests pass. Targeted event tests and all 180 contract unit tests pass; two unrelated stale SDK fixtures remain, as documented below.
  • Traceability Mapping: I have filled out the detailed mapping table for the event and security-related changes.
  • Reviewer Guidance: The changes were reviewed against the event compatibility, deterministic output, privacy, and failure-state requirements.
  • Compliance & Legal Check: Documentation does not present protocol-level controls or fixture results as legal, regulatory, investment, or financial advice.

Additional Context

Verification Results

cargo test --lib
result: 180 passed; 0 failed

cargo test --test sdk_fixtures fixture_events
result: 1 passed; 0 failed

cargo test --test sdk_fixtures fixture_comparison_normalizes_only_windows_line_endings
result: 1 passed; 0 failed

rustfmt --edition 2021 --check tests/sdk_fixtures.rs tests/support/mod.rs
result: passed

git diff --check
result: passed

@El-swaggerito
El-swaggerito merged commit dbdab87 into Aegis-RWA:main Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add deterministic event fixture tests

2 participants