Skip to content

Final Integration Testing for Stellar Wallet Service [wallet - service]Β #143

@salazarsebas

Description

@salazarsebas

πŸ”‘ Final Integration Testing for Stellar Wallet Service πŸ› οΈ

πŸ“ Description

Implement integration tests to verify the end-to-end functionality of the Stellar wallet service, ensuring all components (authentication, KYC, wallet operations, and Soroban interactions) work together seamlessly. These tests will simulate real-world user flows, such as registering biometric credentials, submitting KYC data, creating accounts, sending transactions, and querying statuses, to validate the system’s reliability and correctness.

🎯 Objective

Create integration tests in services/stellar-wallet/tests/integration to cover key user flows, mocking external dependencies (e.g., Stellar testnet, Soroban RPC) to ensure reliable test execution.

πŸ—‚ Structure

  • Directory: services/stellar-wallet
  • Files:
    • tests/integration/auth.test.js
    • tests/integration/kyc.test.js
    • tests/integration/wallet.test.js
  • Expected structure:
    services/stellar-wallet
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ index.js
    β”‚   β”œβ”€β”€ stellar
    β”‚   β”‚   β”œβ”€β”€ client.js
    β”‚   β”‚   β”œβ”€β”€ keys.js
    β”‚   β”‚   β”œβ”€β”€ fund.js
    β”‚   β”‚   └── sign.js
    β”‚   β”œβ”€β”€ db
    β”‚   β”‚   └── kyc.js
    β”‚   β”œβ”€β”€ routes
    β”‚   β”‚   β”œβ”€β”€ kyc.js
    β”‚   β”‚   β”œβ”€β”€ kyc-verify.js
    β”‚   β”‚   β”œβ”€β”€ kyc-status.js
    β”‚   β”‚   β”œβ”€β”€ auth-register.js
    β”‚   β”‚   β”œβ”€β”€ auth-verify.js
    β”‚   β”‚   β”œβ”€β”€ auth-login.js
    β”‚   β”‚   β”œβ”€β”€ wallet.js
    β”‚   β”‚   └── docs.js
    β”‚   β”œβ”€β”€ kyc
    β”‚   β”‚   └── validate.js
    β”‚   β”œβ”€β”€ soroban
    β”‚   β”‚   β”œβ”€β”€ client.js
    β”‚   β”‚   β”œβ”€β”€ kyc-contract.rs
    β”‚   β”‚   └── deploy.js
    β”‚   β”œβ”€β”€ auth
    β”‚   β”‚   β”œβ”€β”€ webauthn.js
    β”‚   β”‚   └── jwt.js
    β”‚   └── middleware
    β”‚       β”œβ”€β”€ rate-limit.js
    β”‚       └── logger.js
    β”œβ”€β”€ config
    β”‚   └── db.sqlite
    β”œβ”€β”€ docs
    β”‚   └── api.yaml
    β”œβ”€β”€ tests
    β”‚   β”œβ”€β”€ integration
    β”‚   β”‚   β”œβ”€β”€ auth.test.js
    β”‚   β”‚   β”œβ”€β”€ kyc.test.js
    β”‚   β”‚   └── wallet.test.js
    β”‚   β”œβ”€β”€ stellar
    β”‚   β”‚   β”œβ”€β”€ client.test.js
    β”‚   β”‚   β”œβ”€β”€ keys.test.js
    β”‚   β”‚   β”œβ”€β”€ fund.test.js
    β”‚   β”‚   └── sign.test.js
    β”‚   β”œβ”€β”€ db
    β”‚   β”‚   └── kyc.test.js
    β”‚   β”œβ”€β”€ routes
    β”‚   β”‚   β”œβ”€β”€ kyc.test.js
    β”‚   β”‚   β”œβ”€β”€ kyc-verify.test.js
    β”‚   β”‚   β”œβ”€β”€ kyc-status.test.js
    β”‚   β”‚   β”œβ”€β”€ auth-register.test.js
    β”‚   β”‚   β”œβ”€β”€ auth-verify.test.js
    β”‚   β”‚   β”œβ”€β”€ auth-login.test.js
    β”‚   β”‚   β”œβ”€β”€ wallet.test.js
    β”‚   β”‚   └── docs.test.js
    β”‚   β”œβ”€β”€ kyc
    β”‚   β”‚   └── validate.test.js
    β”‚   β”œβ”€β”€ soroban
    β”‚   β”‚   β”œβ”€β”€ client.test.js
    β”‚   β”‚   └── deploy.test.js
    β”‚   β”œβ”€β”€ auth
    β”‚   β”‚   └── jwt.test.js
    β”‚   └── middleware
    β”‚       β”œβ”€β”€ rate-limit.test.js
    β”‚       └── logger.test.js
    β”œβ”€β”€ package.json
    β”œβ”€β”€ .env.example
    β”œβ”€β”€ .eslintrc.json
    β”œβ”€β”€ .eslintignore
    β”œβ”€β”€ .prettierrc.json
    β”œβ”€β”€ .prettierignore
    β”œβ”€β”€ .gitignore
    

βœ… Requirements

  • Create a branch named feat/integration-testing for this task.
  • Create integration tests in tests/integration to cover the following user flows:
    • Authentication Flow (auth.test.js):
      • Register biometric credentials (POST /auth/register, Issue 17).
      • Verify credentials and obtain a JWT (POST /auth/verify, POST /auth/login, Issues 18, 20).
    • KYC Flow (kyc.test.js):
      • Submit KYC data (POST /kyc/submit, Issue 9).
      • Register KYC data in Soroban (POST /kyc/verify, Issue 14).
      • Query KYC status (GET /kyc/status/:id, Issue 15).
    • Wallet Flow (wallet.test.js):
      • Create a Stellar account (POST /wallet/create, Issue 19).
      • Send a transaction (POST /wallet/send, Issue 23).
      • Query transaction history (GET /wallet/transactions/:user_id, Issue 24).
  • Mock external dependencies:
    • Stellar SDK for testnet interactions (Horizon, Friendbot).
    • Soroban client for contract calls.
    • WebAuthn server for biometric authentication.
  • Use an in-memory SQLite database (e.g., sqlite3 with :memory:) for tests to avoid file system dependencies.
  • Verify that:
    • Each flow completes successfully with expected HTTP status codes (e.g., 200, 201).
    • Protected endpoints require valid JWTs (Issue 21).
    • Rate limiting is enforced (Issue 25).
    • Logs are generated for requests and operations (Issue 27).
  • Handle errors (e.g., invalid inputs, unauthorized access) and verify correct error responses.
  • Update the CI pipeline configuration (from Issue 1) to include integration tests in the test job.
  • Ensure the code adheres to ESLint and Prettier rules (from Issue 3).
  • Commit changes to the feat/integration-testing branch with a message like feat: final integration testing.
  • Verify that the CI pipeline passes, with linting and test jobs (including integration tests) succeeding.

πŸ† Expected Outcomes

  • Integration tests in tests/integration/auth.test.js, kyc.test.js, and wallet.test.js cover key user flows.
  • Tests mock external dependencies (Stellar SDK, Soroban, WebAuthn) and use an in-memory SQLite database.
  • All flows complete successfully with expected HTTP status codes and responses.
  • Protected endpoints enforce JWT authentication and rate limiting.
  • Logs are generated for requests and critical operations.
  • CI pipeline includes integration tests and passes successfully.
  • Code passes ESLint and Prettier checks.
  • Changes are committed to the feat/integration-testing branch with a descriptive lowercase commit message.
  • CI pipeline runs successfully, with linting passing for new test files and the integration tests passing.

πŸ”— References

πŸ“‹ Notes

  • Integration tests should simulate real-world scenarios, chaining API calls to mimic user behavior.
  • Mock external services to ensure tests are fast and reliable in CI.
  • Use an in-memory SQLite database to reset state between tests.
  • Ensure tests cover error cases (e.g., invalid JWT, rate limit exceeded, missing KYC data).
  • Commit messages must be in lowercase and start with feat, change, fix, chore, or refactor.
  • The CI pipeline should validate the new code, ensuring ESLint passes and integration tests execute successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    onlydust-waveContribute to awesome OSS repos during OnlyDust's open source week

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions