Skip to content

feat: add integration tests for stellar contracts#105

Merged
JoE11-y merged 1 commit intomainfrom
stellar-integrations
Apr 11, 2026
Merged

feat: add integration tests for stellar contracts#105
JoE11-y merged 1 commit intomainfrom
stellar-integrations

Conversation

@JoE11-y
Copy link
Copy Markdown
Contributor

@JoE11-y JoE11-y commented Apr 11, 2026

Title: Add Stellar/Soroban contracts with end-to-end integration tests

Summary

  • Implements the full ProofBridge contract suite on Stellar/Soroban: ad-manager, order-portal, merkle-manager, verifier, and a shared proofbridge-core library
  • Adds end-to-end integration tests that deploy all 4 contracts and exercise the complete cross-chain flow: ad creation, order locking, order creation, and ZK proof-based unlocking on both chains
  • Includes a TypeScript fixture generator (generate_fixtures.ts) that produces deterministic UltraHonk ZK proofs, Poseidon2-based MMR roots, and EIP-712 order hashes — all using native Stellar strkey addresses (C... for contracts/tokens, G... for users)

What's tested (5 e2e tests)

  • test_ad_manager_lock_for_order — locks an order on the ad chain, verifies order hash and merkle root match fixtures
  • test_ad_manager_unlock_with_bridger_proof — unlocks with the bridger's ZK proof, verifies order status transitions to Filled
  • test_order_portal_create_and_unlock — creates order on the order chain, unlocks with the ad creator's ZK proof
  • test_full_cross_chain_flow — full round-trip across both chains: lock → create → bridger unlock → ad creator unlock
  • test_nullifier_prevents_double_unlock — verifies nullifier replay protection

Key design decisions

  • Real ed25519 signatures — tests compute request hashes (keccak256) and sign with real ed25519 keys, matching the contract's verify_ed25519_signature (not mockable via mock_all_auths)
  • SAC-convention tokens — uses stellar-tokens crate's FungibleToken trait for test tokens deployed at deterministic addresses
  • Fixture-driven — proof-derived values (order hash, merkle root, nullifiers) are loaded from test_params.json, so regenerating fixtures doesn't require Rust code changes

Test plan

  • All 5 e2e integration tests pass (cargo test --test integration_test)
  • All per-contract unit tests pass (cargo test)
  • Fixture generator runs successfully (npx tsx generate_fixtures.ts)

Summary by CodeRabbit

  • Tests

    • Added comprehensive integration tests covering Stellar contract deployment, order management, and cross-chain flows
    • Added test fixtures and snapshots for multiple verification and proof validation scenarios
  • Chores

    • Updated project dependencies and workspace configuration to support new Stellar contracts module

@JoE11-y JoE11-y merged commit b3a6ea5 into main Apr 11, 2026
1 check was pending
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7550238-c9cd-42e9-b15a-87e4bac0722c

📥 Commits

Reviewing files that changed from the base of the PR and between 1a9d7ab and 779f4da.

⛔ Files ignored due to path filters (3)
  • apps/stellar_contracts/Cargo.lock is excluded by !**/*.lock
  • packages/proofbridge_mmr/package-lock.json is excluded by !**/package-lock.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • apps/stellar_contracts/.gitignore
  • apps/stellar_contracts/Cargo.toml
  • apps/stellar_contracts/src/lib.rs
  • apps/stellar_contracts/test_snapshots/test_ad_manager_lock_for_order.1.json
  • apps/stellar_contracts/test_snapshots/test_ad_manager_unlock_with_bridger_proof.1.json
  • apps/stellar_contracts/test_snapshots/test_end_to_end_merkle_and_verify.1.json
  • apps/stellar_contracts/test_snapshots/test_full_cross_chain_flow.1.json
  • apps/stellar_contracts/test_snapshots/test_merkle_root_matches_fixture.1.json
  • apps/stellar_contracts/test_snapshots/test_nullifier_prevents_double_unlock.1.json
  • apps/stellar_contracts/test_snapshots/test_order_portal_create_and_unlock.1.json
  • apps/stellar_contracts/test_snapshots/test_verifier_accepts_ad_creator_proof.1.json
  • apps/stellar_contracts/test_snapshots/test_verifier_accepts_bridger_proof.1.json
  • apps/stellar_contracts/test_snapshots/test_verifier_rejects_tampered_proof.1.json
  • apps/stellar_contracts/test_snapshots/test_verifier_rejects_wrong_public_inputs.1.json
  • apps/stellar_contracts/tests/fixtures/generate_fixtures.ts
  • apps/stellar_contracts/tests/fixtures/package.json
  • apps/stellar_contracts/tests/integration_test.rs
  • packages/proofbridge_mmr/package.json
  • packages/proofbridge_mmr/tests/test-mmr.ts
  • pnpm-workspace.yaml

📝 Walkthrough

Walkthrough

This pull request introduces Stellar/Soroban integration test infrastructure for ProofBridge, including fixture generation for cryptographic proofs, test snapshots, comprehensive integration tests across four smart contracts, and supporting configuration updates.

Changes

Cohort / File(s) Summary
Configuration & Setup
apps/stellar_contracts/.gitignore, apps/stellar_contracts/Cargo.toml, apps/stellar_contracts/src/lib.rs, pnpm-workspace.yaml
Added workspace root declaration, Cargo crate definition (proofbridge-stellar v0.1.0), dev dependencies (serde, soroban-sdk, ed25519-dalek, stellar-tokens), and gitignore patterns for build artifacts.
Test Snapshots
apps/stellar_contracts/test_snapshots/*
Added five JSON snapshot fixtures capturing expected ledger states for merkle root validation, verifier acceptance (ad-creator and bridger proofs), tampered proof rejection, and wrong public input rejection scenarios.
Fixture Generation
apps/stellar_contracts/tests/fixtures/generate_fixtures.ts, apps/stellar_contracts/tests/fixtures/package.json
Created TypeScript script that loads deposit circuit, derives test secrets, computes Stellar-compatible EIP-712 order hashes, builds MMR proofs, executes Noir circuit, generates UltraHonk proofs, and outputs binary proof fixtures and JSON parameters; includes npm script and dependencies (barretenberg, noir_js, poseidon2, ethers, proofbridge-mmr).
Integration Tests
apps/stellar_contracts/tests/integration_test.rs
Comprehensive Rust integration test suite (890 lines) covering end-to-end contract flow with TokenContract (SAC fungible token), deterministic contract deployments, initialization across merkle-manager/ad-manager/order-portal/verifier contracts, ed25519 request signing, proof verification, and test cases for lock/unlock operations, cross-chain consistency, and double-unlock prevention.
MMR Proof Updates
packages/proofbridge_mmr/package.json, packages/proofbridge_mmr/tests/test-mmr.ts
Updated test to reference proof.peaks instead of proof.peakBagging in logging and verification; added @types/crypto-js dev dependency.

Sequence Diagram

sequenceDiagram
    participant FG as Fixture Generator
    participant CC as Noir Circuit
    participant PM as Proof Manager
    participant IT as Integration Test
    participant SC as Stellar Contracts
    participant PV as Proof Verifier

    FG->>FG: Load deposit circuit & init Barretenberg
    FG->>FG: Derive test secrets & compute order hashes
    FG->>PM: Build MMR & compute proofs
    FG->>CC: Execute circuit (bridger & ad-creator variants)
    FG->>PM: Generate UltraHonk proofs
    FG->>FG: Write proof/params binaries & JSON fixtures
    
    IT->>SC: Deploy TokenContract (deterministic address)
    IT->>SC: Deploy & register merkle-manager
    IT->>SC: Deploy & initialize ad-manager
    IT->>SC: Deploy & initialize order-portal
    
    IT->>SC: Lock order in ad-manager
    IT->>SC: Retrieve Merkle root & order hash
    
    IT->>PV: Submit bridger proof + public inputs
    PV->>PV: Verify proof signature & nullifier
    PV-->>IT: Proof valid
    IT->>SC: Unlock order with bridger proof
    SC-->>IT: Order status = Filled
    
    IT->>PV: Submit ad-creator proof + public inputs
    PV->>PV: Verify proof signature & nullifier
    PV-->>IT: Proof valid
    IT->>SC: Unlock order in order-portal
    SC-->>IT: Order status = Filled
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • Ugo-X

Poem

🐰 With fixtures fresh and proofs so bright,
Stellar contracts stand in test's light,
MMR roots and nullifiers aligned,
Integration flows now well-designed,
ProofBridge leaps with cryptographic might!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stellar-integrations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant