Skip to content

test(frontend): cover oisy trade canister wrappers#13341

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-ac06
Draft

test(frontend): cover oisy trade canister wrappers#13341
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-ac06

Conversation

@cursor

@cursor cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Motivation

Recent OISY Trade wrapper changes added retry-aware Result handling across several read and certified write methods, but only getMyOrders had direct canister-wrapper coverage. These wrappers are core trading plumbing: a regression could silently drop arguments, return the wrong Ok payload, or lose retryability/reason metadata that callers use for recovery and UX.

Risky behavior now covered:

  • Ok unwrapping for balances, deposits, withdrawals, order-book reads, and limit-order mutations.
  • Argument forwarding for read wrappers and certified write wrappers.
  • Retry-aware Err mapping for temporary and request failures, including fallback reason discriminants.

Changes

  • Updated src/frontend/src/tests/lib/canisters/oisy-trade.canister.spec.ts with typed fixtures for trading pairs, balances, orders, requests, and responses.
  • Added focused Vitest coverage for getBalances, deposit, withdraw, getOrderBookTicker, getOrderBookDepth, addLimitOrder, and cancelLimitOrder.
  • Replaced the existing partial getMyOrders fixture with a concrete typed UserOrder fixture.

Why these tests materially reduce regression risk:

  • They lock down the boundary between generated canister actors and frontend trading services, where small wrapper mistakes can affect deposits, withdrawals, and order execution flows.
  • They verify both success and error disposition semantics without relying on live canisters or network calls.

Tests

  • Passed: PATH="$HOME/.nvm/versions/node/v24.18.0/bin:$PATH" npx vitest run src/frontend/src/tests/lib/canisters/oisy-trade.canister.spec.ts (17 tests)
  • Passed: PATH="$HOME/.nvm/versions/node/v24.18.0/bin:$PATH" npx prettier --check src/frontend/src/tests/lib/canisters/oisy-trade.canister.spec.ts
  • Passed: PATH="$HOME/.nvm/versions/node/v24.18.0/bin:$PATH" npx eslint src/frontend/src/tests/lib/canisters/oisy-trade.canister.spec.ts
  • Blocked by existing unrelated issue: npm run test -- src/frontend/src/tests/lib/canisters/oisy-trade.canister.spec.ts and npm run check:tests fail before running this spec because src/frontend/src/sol/utils/sol-instructions-system.utils.ts:96 passes SystemInstruction.CreateAccountAllowPrefund to assertNever.
  • Blocked by existing unrelated formatting drift: full npm run lint -- --max-warnings 0 reports Prettier issues in 33 unrelated files; the updated spec passes targeted Prettier and ESLint.
Open in Web View Automation 

cursoragent and others added 2 commits July 2, 2026 10:05
Co-authored-by: Antonio Ventilii <AntonioVentilii@users.noreply.github.com>
Co-authored-by: Antonio Ventilii <AntonioVentilii@users.noreply.github.com>
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