Skip to content

Extract and expand integration tests for swap tools #9

@ongrid

Description

@ongrid

Background

The estimate_same_chain_swap tests currently live inside tests/server.test.ts alongside general server tests (initialization, tool listing, search_tokens, get_supported_chains). They already use mocked fetch with JSON fixtures from tests/fixtures/live-api/. However, create_tx (cross-chain swaps) has no test coverage at all.

Goals

  1. Add create_tx integration tests — cover the cross-chain swap tool with mocked fixtures, similar to how estimate_same_chain_swap is tested today:
    - ETH→USDC cross-chain (e.g. Ethereum → Arbitrum)
    - Stablecoin cross-chain (e.g. USDC on Polygon → USDC on BNB Chain)
    - Solana as source or destination chain
    - Error case: invalid/missing required params
    - Error case: unsupported chain pair
  2. Extract tool-specific tests to separate files:
    - tests/estimate-same-chain-swap.test.ts — all estimate_same_chain_swap tests (currently in server.test.ts)
    - tests/create-tx.test.ts — new create_tx tests
    - tests/server.test.ts — keep only general/clean server tests (init, tool listing, get_instructions, search_tokens, get_supported_chains)
  3. Re-organize fixtures for clarity:
    - tests/fixtures/live-api/estimation/ — same-chain estimation fixtures
    - tests/fixtures/live-api/create-tx/ — cross-chain create-tx fixtures
  4. Extract shared setupClient helper to a reusable module (e.g. tests/setup-client.ts) to avoid duplication across test files.

Acceptance criteria

  • create_tx tool has integration tests with mocked fetch and fixture files captured from live API
  • estimate_same_chain_swap tests moved out of server.test.ts into their own file
  • Fixture files reorganized into subdirectories by tool
  • setupClient extracted and shared across test files
  • All existing tests continue to pass
  • npm test runs without network calls (except tests explicitly opted in via env var)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions