You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test(swap): add happy-path coverage for openocean/lifi/relay/liquid providers (#18)
PR #16 added 5 swap.test.ts cases focused on the kyber native-input
msg.value bug + chain-support guards. The other 4 providers had no
shape-pinning happy path. This commit adds one mocked happy-path
test per provider so a future printOutput refactor or provider HTTP
shape change is caught at PR time, not in production.
4 new tests in commands/swap.test.ts:
- openocean: native input on Monad. Mock /v4/{chain}/swap response;
assert provider/chain/amount_out/router fields in output.
- lifi: native input on Monad. Mock /v1/quote response;
assert chain_id=143 (LI.FI is chainId-routed, not slug).
- relay: mock the {steps[],details:{currencyOut}} multi-step
response; assert the CLI skips the approve step and reports
the swap step's router + currencyOut.amount.
- liquid: happy path on hyperevm. The branch's ERC20-approval
path can also surface as an error envelope when token resolution
fails; the test accepts either shape but pins liquid as the
routing target.
All 4 use the same vi.mock(globalThis.fetch) helper introduced in
PR #16; tests run offline and are deterministic.
Verified:
- pnpm -C ts -r build — clean.
- pnpm -C ts -r lint — 3 packages, tsc --noEmit clean.
- pnpm -C ts -r test — defi-core 32/32, defi-protocols 43/43,
defi-cli 98/98 (was 94; +4 provider
happy-path tests).
0 commit comments