Merge pull request #328 from Cyberking99/feat/181-subscription-quotas… #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Contract Invariant Tests | |
| on: | |
| push: | |
| branches: [main, dev, develop, 'feature/*'] | |
| paths: | |
| - 'contracts/**' | |
| pull_request: | |
| branches: [main, dev, develop, 'feature/*'] | |
| paths: | |
| - 'contracts/**' | |
| env: | |
| RUST_VERSION: '1.85' | |
| # Number of proptest cases per property. Increase for deeper fuzzing. | |
| PROPTEST_CASES: 200 | |
| jobs: | |
| # ───────────────────────────────────────────────────────────────────────── | |
| # Invariant & Property-Based Tests | |
| # ───────────────────────────────────────────────────────────────────────── | |
| contract-invariants: | |
| name: Subscription Contract Invariant Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_VERSION }} | |
| - name: Cache Rust dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './contracts -> target' | |
| # ── Run the full invariant test suite ────────────────────────────── | |
| - name: Run invariant tests (deterministic scenarios) | |
| working-directory: ./contracts | |
| env: | |
| PROPTEST_CASES: ${{ env.PROPTEST_CASES }} | |
| run: | | |
| cargo test --test invariants -- --nocapture 2>&1 | tee invariant-test-results.txt | |
| # ── Run all contract tests to ensure nothing regressed ───────────── | |
| - name: Run full contract test suite | |
| working-directory: ./contracts | |
| run: cargo test --verbose | |
| # ── Upload test results as artifact ─────────────────────────────── | |
| - name: Upload invariant test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: invariant-test-results | |
| path: contracts/invariant-test-results.txt | |
| retention-days: 30 | |
| # ───────────────────────────────────────────────────────────────────────── | |
| # Extended Fuzz Run (only on pushes to main/dev — not every PR) | |
| # ───────────────────────────────────────────────────────────────────────── | |
| contract-invariants-extended: | |
| name: Extended Invariant Fuzz (1000 cases) | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_VERSION }} | |
| - name: Cache Rust dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './contracts -> target' | |
| - name: Run extended invariant fuzz (1000 cases) | |
| working-directory: ./contracts | |
| env: | |
| PROPTEST_CASES: 1000 | |
| run: | | |
| cargo test --test invariants -- --nocapture 2>&1 | tee extended-fuzz-results.txt | |
| - name: Upload extended fuzz results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extended-fuzz-results | |
| path: contracts/extended-fuzz-results.txt | |
| retention-days: 30 |