From 707430f4369246cbf54b61ca2ba7ff82bf192629 Mon Sep 17 00:00:00 2001
From: Timidan
- Live app · How every PR is tested + Live app · How every PR is tested
--- @@ -119,9 +119,19 @@ Full Solidity step-through debugger powered by the local EDB engine: ## Testing with TestSprite -Every pull request is tested before it can merge. Vercel builds a preview of the PR. When that deployment completes, the [TestSprite](https://www.testsprite.com) GitHub App runs the suite against the preview, posts the results on the PR, and reports a status check that blocks the merge while tests fail. Nobody has to remember to run it. +Nobody has to remember to run the tests. [TestSprite](https://www.testsprite.com) runs them at three points: -The suite is 20 browser tests, generated in the TestSprite portal from a short product scope and tightened by hand to assert exact values from one real mainnet USDC transfer. +| When | What runs | Against | What happens on failure | +|---|---|---|---| +| Every pull request | 20 browser tests + 20 API tests | The PR's Vercel preview | The `TestSprite V3` check fails. It is required on `master`, so the PR cannot merge | +| Every merge to `master` | Both suites | Production, https://hexkit.app | The run fails in the TestSprite portal | +| Every night, 12:00 AM PT | 8 core flows (decode, replay, bad-hash message, explorer, signatures, LI.FI vaults) | Production | The run fails, and the result is emailed | + +The PR and merge runs start from Vercel's own deployment events, through the TestSprite GitHub App. The nightly run catches what no pull request changes: a public RPC or an upstream API changing under the app. + +Both suites were generated in the TestSprite portal, from a short product scope and an [OpenAPI description](api/openapi.yaml), then tightened by hand. The browser tests assert exact values from one real mainnet USDC transfer, which lives in the production environment's variables. + +**Browser suite (20)** | Area | Tests | What they check | |---|---|---| @@ -133,6 +143,15 @@ The suite is 20 browser tests, generated in the TestSprite portal from a short p | Local storage | 3 | Storage inventory, simulation history surviving a reload, clearing history | | Navigation | 3 | Source Tools and Integrations from home, Contract Explorer from the command palette | +**API suite (20)** + +| Area | Tests | What they check | +|---|---|---| +| Simulator bridge | 4 | Health returns `status: ok` with its concurrency limits, with and without a same-origin request; PUT is refused with 405; CORS never grants a wildcard origin | +| Path guard | 4 | Encoded traversal, double-encoded traversal and illegal characters return 400 `invalid_path`; an unknown safe path returns 404 | +| LI.FI Earn proxy | 8 | Chains, vaults (with chain filter and limit), protocols and positions return the expected shapes; a bad address returns 400; POST returns 405; CORS never grants a wildcard origin | +| Sourcify proxy | 4 | USDC's source on Ethereum is a runtime `match`; a short address and an unknown chain return 400; same-origin lookups work | + Not covered: anything that needs a wallet signature (deposits, withdrawals, Live Interaction writes), the AI recommendation features, and the step debugger. Keep branch names to 19 characters or fewer. Vercel shortens longer branch names in preview URLs with a hash, and the check then cannot find the preview. diff --git a/api/openapi.yaml b/api/openapi.yaml new file mode 100644 index 0000000..dfbc084 --- /dev/null +++ b/api/openapi.yaml @@ -0,0 +1,151 @@ +openapi: 3.0.3 +info: + title: HexKit serverless API + version: "1.0" + description: | + The Vercel serverless functions behind https://www.hexkit.app. They proxy HexKit's EVM simulator bridge (EDB) + and LI.FI Earn, and they guard both with an origin allowlist, a method allowlist and path validation. + No authentication: same-origin browser calls carry no Origin header; any foreign Origin is refused. + Out of scope: /api/llm-recommend (paid model calls) and /api/lifi-composer (builds deposit transactions). +servers: + - url: https://www.hexkit.app +paths: + /api/edb/health: + get: + summary: Simulator bridge health + description: Proxied to the EDB simulator bridge. Must return JSON with status "ok" and a concurrency object. + responses: + "200": + description: Bridge reachable + content: + application/json: + schema: + type: object + required: [status, concurrency] + properties: + status: { type: string, enum: [ok] } + edbServerRunning: { type: boolean } + activeSessions: { type: integer, minimum: 0 } + concurrency: + type: object + properties: + maxConcurrent: { type: integer, minimum: 1 } + maxQueue: { type: integer, minimum: 1 } + "403": + description: Sent with a foreign Origin header (for example Origin https://evil.example). Body {"error":"origin_required"}. + put: + summary: Disallowed method + description: Only GET, POST and OPTIONS are allowed through the bridge proxy. + responses: + "405": + description: Body {"error":"method_not_allowed"} + /api/edb/{segment}: + get: + summary: Path validation on the bridge proxy + description: Each path segment must match [a-zA-Z0-9_\-:.] and must not be "." or "..". An encoded traversal such as "..%2Fsecret" is refused before anything reaches the bridge. + parameters: + - in: path + name: segment + required: true + schema: { type: string } + example: "..%2Fsecret" + responses: + "400": + description: Body {"error":"invalid_path"} + /api/lifi-earn/v1/chains: + get: + summary: Chains supported by LI.FI Earn + responses: + "200": + description: A non-empty array that includes chainId 1 (Ethereum) and 42161 (Arbitrum) + content: + application/json: + schema: + type: array + minItems: 1 + items: + type: object + required: [chainId, name] + properties: + chainId: { type: integer } + name: { type: string } + networkCaip: { type: string } + "403": + description: Sent with a foreign Origin header. Body {"error":"Origin not allowed"}. + /api/lifi-earn/v1/vaults: + get: + summary: Yield vaults, filterable by chain + parameters: + - in: query + name: chainId + schema: { type: integer } + example: 42161 + - in: query + name: limit + schema: { type: integer } + example: 2 + responses: + "200": + description: Object with a data array of vaults; with chainId=42161 every returned vault is on chain 42161, and limit caps the count + content: + application/json: + schema: + type: object + required: [data] + properties: + data: + type: array + items: + type: object + required: [name, slug] + properties: + name: { type: string } + slug: { type: string } + post: + summary: Disallowed method + responses: + "405": + description: Body {"error":"Method not allowed"} + /api/lifi-earn/v1/protocols: + get: + summary: Protocols with vaults on LI.FI Earn + responses: + "200": + description: A non-empty array of {id, name, url}; includes id "aave" + /api/lifi-earn/v1/portfolio/{address}/positions: + get: + summary: Earn positions for any address + parameters: + - in: path + name: address + required: true + schema: { type: string, pattern: "^0x[0-9a-fA-F]{40}$" } + example: "0x5A61acE11A12d2F661cE18d22F823C111aC87b77" + responses: + "200": + description: Object with a data array (possibly empty) and a numeric limit + /api/sourcify/server/v2/contract/{chainId}/{address}: + get: + summary: Verified-contract lookup through the Sourcify rewrite + parameters: + - in: path + name: chainId + required: true + schema: { type: integer } + example: 1 + - in: path + name: address + required: true + schema: { type: string } + example: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" + responses: + "200": + description: The USDC proxy on Ethereum is verified; runtimeMatch is "match" + content: + application/json: + schema: + type: object + required: [runtimeMatch] + properties: + runtimeMatch: { type: string } + creationMatch: { type: string } From e6b50282831b6e3535bbc2065f6b68eeb43e8638 Mon Sep 17 00:00:00 2001 From: Timidan