Skip to main content
This page covers the integration tests for the RubicBridge SDK class, located at /src/tests/bridge/rubic.test.ts. The test file exercises three flows: getTrade, executeTrade with mock data, and executeTrade with real funds. Before running the tests, start the node repository so the bridge RPC is reachable. The first two tests (getTrade and the mock executeTrade) work without any wallet setup — the default test mnemonic is fine. To run executeTrade with real funds:
  1. Remove the skip operator from the test (set it to only if you want to run it in isolation).
  2. Replace the test mnemonic in rubic.test.ts with a wallet that holds funds on the source chain.
Run the suite:
bun test src/tests/bridge/rubic.test.ts

getTrade

Fetches the best cross-chain trade option for the supplied payload. Returns the best trade or an error if no valid route is found.

executeTrade

Submits the trade. Manages allowance, approval, the swap call, and confirmation. Returns the transaction receipt.

Payload shape

import {
    BridgeTradePayload,
    SupportedChains,
} from "@kynesyslabs/demosdk/bridge"

const payload: BridgeTradePayload = {
    fromToken: "USDT",
    toToken: "USDT",
    amount: 1,
    fromChainId: 137,
    toChainId: 1,
}
fromToken / toToken accept "NATIVE" | "USDC" | "USDT". See the crosschain swap recipe for the production-flow example.