Adds Anvil-based deposit E2E tests#1066
Conversation
🦋 Changeset detectedLatest commit: 2d7c37e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Someone is attempting to deploy a commit to the Status Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Adds Anvil-backed E2E coverage for full deposit flows (funding → MetaMask approvals → on-chain confirmation) by introducing an Anvil fixture/infrastructure layer and expanding MetaMask automation to handle more real-world confirmation edge cases.
Changes:
- Add Anvil fork infrastructure (docker-compose, Anvil RPC helper, MetaMask SW/STX patching) and a dedicated Playwright project/tag (
@anvil). - Add new deposit E2E specs (WETH/SNT/LINEA/GUSD + below-minimum + exceed-balance + network switch).
- Update CI to lint/typecheck E2E, cache MetaMask by version, and start/stop Anvil forks.
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| e2e/tsconfig.json | Adds @helpers/* path alias used by new Anvil helpers. |
| e2e/tests/hub/pre-deposits/weth-deposit.spec.ts | Adds WETH deposit flows including wrap + deposit scenarios on Anvil. |
| e2e/tests/hub/pre-deposits/snt-deposit.spec.ts | Adds SNT happy-path deposit E2E on Anvil. |
| e2e/tests/hub/pre-deposits/linea-deposit.spec.ts | Adds LINEA deposit E2E including network switch to Linea. |
| e2e/tests/hub/pre-deposits/gusd-deposit.spec.ts | Adds parameterized GUSD deposit E2Es via multiple stablecoins. |
| e2e/tests/hub/pre-deposits/deposit-validation.spec.ts | Adds exceed-balance validation coverage across vaults. |
| e2e/tests/hub/pre-deposits/deposit-network-switch.spec.ts | Adds network switching test coverage across vaults. |
| e2e/tests/hub/pre-deposits/below-minimum-validation.spec.ts | Adds below-minimum validation tests on Anvil for selected vaults. |
| e2e/src/types/env.d.ts | Updates E2E env typings for Anvil RPCs + wallet address. |
| e2e/src/pages/metamask/notification.page.ts | Major robustness upgrades for MetaMask confirmation handling + queued popups. |
| e2e/src/pages/metamask/metamask.page.ts | Adjusts MetaMask page façade to updated notification APIs (and adds add-network dismissal). |
| e2e/src/pages/metamask/home.page.ts | Removes standalone home page helper (logic moved into NotificationPage). |
| e2e/src/pages/hub/components/pre-deposit-modal.component.ts | Introduces deposit modal page-object used by new deposit specs. |
| e2e/src/helpers/stx-patcher.ts | Adds file-level STX-disabling patcher for MetaMask extension JS bundles. |
| e2e/src/helpers/service-worker-patch.ts | Adds pre-LavaMoat SW fetch patch to redirect RPC + handle STX relay behavior. |
| e2e/src/helpers/hub-test-helpers.ts | Adds reusable helpers for network switching and SIWE modal dismissal. |
| e2e/src/helpers/anvil-rpc.ts | Adds Anvil JSON-RPC helper for funding, storage manipulation, snapshots, and health checks. |
| e2e/src/fixtures/metamask.fixture.ts | Extracts reusable MetaMask launcher with before/after hooks and extra args. |
| e2e/src/fixtures/index.ts | Removes unused fixture barrel exports. |
| e2e/src/fixtures/anvil.fixture.ts | Adds core Anvil fixture: SW patching, STX disable, RPC routing, snapshot/revert, and page objects. |
| e2e/src/constants/viewport.ts | Moves viewport constants out of timeouts to a dedicated module. |
| e2e/src/constants/timeouts.ts | Expands MetaMask notification timing constants + adds deposit timeouts. |
| e2e/src/constants/rpc-hosts.ts | Centralizes known RPC hostnames for chain detection (SW patch + routing). |
| e2e/src/constants/hub/vaults.ts | Expands vault constants for deposits/validation and references Anvil contract constants. |
| e2e/src/constants/hub/chains.ts | Adds MetaMask default chain + Status Sepolia chain id hex constant. |
| e2e/src/config/env.ts | Derives wallet address, builds default Anvil RPC URLs, and centralizes MetaMask version source. |
| e2e/playwright.config.ts | Adds anvil-deposits project bound to @anvil tag with extended timeout. |
| e2e/package.json | Adds Anvil lifecycle scripts, lint/typecheck, and MetaMask version config; adds deps (viem/typescript). |
| e2e/eslint.config.mjs | Tightens lint rules by removing the global no-explicit-any override. |
| e2e/download-metamask-extension.ts | Uses package.json config as MetaMask version source for downloads. |
| e2e/docker-compose.anvil.yml | Adds dockerized Anvil mainnet + Linea forks with healthchecks. |
| e2e/README.md | Documents Anvil architecture, setup, tags/projects, and CI expectations. |
| e2e/.env.example | Updates env template for Anvil forks and MetaMask version override. |
| apps/hub/src/app/_constants/env.client.mjs | Adds optional public env vars for mainnet/linea RPC URLs. |
| apps/hub/src/app/_constants/chain.ts | Switches wagmi transports to direct RPCs with env overrides (and a hard-coded mainnet fallback). |
| .github/workflows/e2e.yml | Adds lint/typecheck + MetaMask cache by version + Anvil up/down around test run. |
| .changeset/bold-candies-clap.md | Adds an (currently empty/invalid) changeset file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| - name: Read MetaMask version | ||
| id: metamask | ||
| run: echo "version=$(node -p "require('./e2e/package.json').config.metamaskVersion")" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
The Read MetaMask version step has nested double-quotes inside a double-quoted echo, which will break YAML/shell parsing and prevent $GITHUB_OUTPUT from being written. Use single quotes around the Node expression (or escape the inner quotes), e.g. node -p 'require("./e2e/package.json").config.metamaskVersion', or write the output via a heredoc.
| run: echo "version=$(node -p "require('./e2e/package.json').config.metamaskVersion")" >> $GITHUB_OUTPUT | |
| run: | | |
| echo "version=$(node -p 'require("./e2e/package.json").config.metamaskVersion')" >> "$GITHUB_OUTPUT" |
| --- | ||
| --- |
There was a problem hiding this comment.
This changeset file contains only empty frontmatter (--- / ---) and no release entries, which is not a valid Changesets file and can break changeset tooling in CI/release workflows. Either remove the file (if no package version bump is intended) or add the required frontmatter with at least one package + bump type.
| --- | |
| --- | |
| This changeset file previously contained empty frontmatter and has been cleared. | |
| No release changes are defined here. |
| [statusSepolia.id]: http(statusSepolia.rpcUrls.default.http[0]), | ||
| [mainnet.id]: http( | ||
| `${clientEnv.NEXT_PUBLIC_STATUS_API_URL}/api/trpc/rpc.proxy?chainId=${mainnet.id}` | ||
| clientEnv.NEXT_PUBLIC_MAINNET_RPC_URL || | ||
| 'https://mainnet.infura.io/v3/6291a6aa45c94fd79bda6770b58153dd' | ||
| ), | ||
| [linea.id]: http( | ||
| `${clientEnv.NEXT_PUBLIC_STATUS_API_URL}/api/trpc/rpc.proxy?chainId=${linea.id}` | ||
| clientEnv.NEXT_PUBLIC_LINEA_RPC_URL || linea.rpcUrls.default.http[0] | ||
| ), |
There was a problem hiding this comment.
This change switches wagmi transports from the existing .../api/trpc/rpc.proxy?chainId=... endpoints to direct public RPCs and introduces a hard-coded Infura URL (including a project id) as the mainnet fallback. This is a behavior/operational change for production builds (rate limits, analytics, outage domain, and potentially unintended key exposure). Consider keeping the previous proxy URLs as the default fallback when NEXT_PUBLIC_*_RPC_URL is unset, and avoid hard-coding a specific Infura project id in source (prefer env-only).
…posits functionalities
…vConfig`, and reduce workflow timeout to 15 mins
- Implement comprehensive Pre-Deposit tests for network switching and balance validation. - Enhance MetaMask handling with dismissPendingAddNetwork and popup detection improvements. - Extend constants and page objects to support new test cases.
…ize and replace hardcoded values with constants.
… unused env vars, and streamline process
…d MetaMask handling
…emove redundant steps
…ate Node.js version in workflow
…alog dismissal logic into reusable helpers.
…E fixtures, and introduce custom RPC configuration with snapshot isolation.
…osits and extend Anvil functionality with storage-based token funding
…including network-switching flows, partial wrap scenarios, and MetaMask interaction enhancements. Extend Anvil and MetaMask utilities to support advanced queue handling and transaction flows.
…d chain discovery with hostname-based lookup, and add fallback retry for eth_chainId.
…ve retry logic for STX endpoints, optimize hostname-based chain detection, and extend STX patching for MetaMask v13 compatibility.
@JulesFiliot Pushed a Hub-side fix for the G-1 USDT failure. |
|
@at0m1x19 I ran two times the test suite, the first time all passed, the second time one failed. Is it something on my side only? |
…ability - Add mocked `eth_estimateGas` responses to prevent stalling in MetaMask's confirmation UI during slow Anvil states. - Update service-worker-patch and Anvil fixtures for consistent handling of `eth_estimateGas` RPC calls.
@JulesFiliot No, it's not on your side, I think it was a flaky gas estimation issue in a bit slower environments Fixed by mocking eth_estimateGas in both the SW patch and the context route, same approach as the existing linea_estimateGas mock. Ran 3 consecutive times locally, all 11 passed each time (about 5 min per run). |
|
@at0m1x19, looks like it did the trick. I ran the suite two times and all passed both times.
|
JulesFiliot
left a comment
There was a problem hiding this comment.
@at0m1x19 thank you for the continuous and hard work 🙏 🙏 🙏
…ants for improved readability
… module-level snapshot state races
Hub's production RPC proxy (snt.eth-rpc.status.im) serves mainnet and linea under different paths on a single host, so hostname-only chain detection in the fixture and service-worker interceptors fell through to the eth_chainId probe. The probe hit the URL without a Puzzle-auth token, got back 401 HTML, failed JSON parsing, and requests leaked to the real RPC — making anvil-funded balances read as 0 and breaking all deposit tests with "Insufficient balance. Max: 0.00" and disabled submit buttons. Add path-based detection (KNOWN_MAINNET_PATHS, KNOWN_LINEA_PATHS) mirroring Hub's rpcProxyPaths, checked before hostname in both the context-level route and the service-worker patch. /status/hoodi is intentionally omitted — hoodi has no Anvil fork.
@jinhojang6 Thanks for catching this! Root cause found and fixed in 2d7c37e. What was happening: Hub's production deploy now uses the puzzle-auth RPC proxy at snt.eth-rpc.status.im, which serves mainnet, linea, and hoodi under different URL paths on a single host. The Anvil fixture only did hostname-based chain detection, so requests fell through to the eth_chainId probe — which hit the URL without a puzzle-auth token, got 401 HTML back, failed JSON parsing ("Probe failed permanently" in the log), and the requests leaked through to the real RPC. That's why the Anvil-funded balances read as 0, you saw Insufficient balance. Max: 0.00, and the submit buttons stayed disabled. Fix: Added KNOWN_MAINNET_PATHS / KNOWN_LINEA_PATHS mirroring Hub's rpcProxyPaths, and check path before hostname in both the context-level route and the service-worker patch. /status/hoodi is intentionally omitted — no Anvil fork for hoodi, those pass through. |
Part 3 of the E2E testing project. Builds on #1032 (framework + smoke tests, merged) and #1043 (network switch + validation tests).
Adds Anvil-based deposit E2E tests that run full deposit flows against local Ethereum/Linea forks — from wallet funding through MetaMask approval to on-chain confirmation.
Anvil infrastructure:
Deposit test specs (11 tests):
CI: