Skip to content

Adds Anvil-based deposit E2E tests#1066

Open
at0m1x19 wants to merge 75 commits intostatus-im:mainfrom
at0m1x19:933-ui-tests-for-SN-Hub_anvil_tests
Open

Adds Anvil-based deposit E2E tests#1066
at0m1x19 wants to merge 75 commits intostatus-im:mainfrom
at0m1x19:933-ui-tests-for-SN-Hub_anvil_tests

Conversation

@at0m1x19
Copy link
Copy Markdown
Contributor

@at0m1x19 at0m1x19 commented Mar 1, 2026

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:

  • Dockerized Anvil setup (docker-compose.anvil.yml) — mainnet + Linea forks
  • AnvilRpcHelper — wallet funding, ERC-20 storage manipulation, snapshot/revert isolation
  • MetaMask service worker fetch patching — redirects RPC calls to local Anvil (bypasses LavaMoat)
  • Smart Transactions (STX) disabler — file-level regex patching + SW fetch interceptor fallback

Deposit test specs (11 tests):

  • WETH vault: wrap ETH → deposit, direct deposit (sufficient WETH), partial wrap + deposit
  • SNT vault: deposit SNT tokens
  • LINEA vault: deposit with network switch to Linea
  • GUSD vault: deposit via USDT, USDC, USDS (parameterized)
  • Below-minimum validation: WETH, SNT, LINEA (parameterized)

CI:

  • Lint + typecheck step added before tests
  • MetaMask extension cached by version
  • Anvil forks start/stop automatically in workflow

Copilot AI review requested due to automatic review settings March 1, 2026 23:28
@at0m1x19 at0m1x19 had a problem deploying to preview-deploy-approval March 1, 2026 23:28 — with GitHub Actions Failure
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 1, 2026

🦋 Changeset detected

Latest commit: 2d7c37e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
hub Patch

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

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 1, 2026

Someone is attempting to deploy a commit to the Status Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/workflows/e2e.yml Outdated

- name: Read MetaMask version
id: metamask
run: echo "version=$(node -p "require('./e2e/package.json').config.metamaskVersion")" >> $GITHUB_OUTPUT
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
---
---
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
---
---
This changeset file previously contained empty frontmatter and has been cleared.
No release changes are defined here.

Copilot uses AI. Check for mistakes.
Comment thread apps/hub/src/app/_constants/chain.ts Outdated
Comment on lines 17 to 24
[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]
),
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@at0m1x19 at0m1x19 had a problem deploying to preview-deploy-approval March 2, 2026 00:26 — with GitHub Actions Failure
Egor Rachkovskii and others added 21 commits March 2, 2026 00:29
…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.
…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.
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 9, 2026 17:39 — with GitHub Actions Waiting
@at0m1x19
Copy link
Copy Markdown
Contributor Author

at0m1x19 commented Apr 9, 2026

@at0m1x19 here are the logs of the run after the latest changes: test-output-8.log

  1 failed
    [anvil-deposits] › tests/hub/pre-deposits/gusd-deposit.spec.ts:34:5 › GUSD Vault - Happy path deposits › G-1: deposit via USDT @anvil 
  10 passed (10.5m)

@JulesFiliot Pushed a Hub-side fix for the G-1 USDT failure.
For me tests pass locally. Please pull and try once more.

@JulesFiliot
Copy link
Copy Markdown
Contributor

@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?

@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 10, 2026 13:20 — with GitHub Actions Waiting
…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.
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 10, 2026 13:21 — with GitHub Actions Waiting
@at0m1x19
Copy link
Copy Markdown
Contributor Author

@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?

@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).

@JulesFiliot
Copy link
Copy Markdown
Contributor

@at0m1x19, looks like it did the trick. I ran the suite two times and all passed both times.

@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 13, 2026 13:37 — with GitHub Actions Waiting
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 13, 2026 13:56 — with GitHub Actions Waiting
Copy link
Copy Markdown
Contributor

@JulesFiliot JulesFiliot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@at0m1x19 thank you for the continuous and hard work 🙏 🙏 🙏

Comment thread .changeset/sixty-steaks-smile.md
Comment thread e2e/src/fixtures/anvil.fixture.ts Outdated
Comment thread e2e/src/fixtures/anvil.fixture.ts Outdated
Comment thread e2e/src/fixtures/anvil.fixture.ts
Comment thread e2e/src/fixtures/anvil.fixture.ts Outdated
Comment thread e2e/src/fixtures/anvil.fixture.ts Outdated
Comment thread e2e/src/fixtures/anvil.fixture.ts Outdated
Comment thread e2e/src/pages/metamask/notification.page.ts Outdated
Comment thread e2e/src/pages/metamask/notification.page.ts Outdated
Comment thread e2e/src/pages/metamask/notification.page.ts Outdated
@github-project-automation github-project-automation bot moved this from In Progress to Waiting in Web & User Interfaces Apr 14, 2026
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 14, 2026 12:49 — with GitHub Actions Waiting
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 14, 2026 12:52 — with GitHub Actions Waiting
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 14, 2026 13:00 — with GitHub Actions Waiting
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 14, 2026 13:01 — with GitHub Actions Waiting
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 14, 2026 18:48 — with GitHub Actions Waiting
Copy link
Copy Markdown
Collaborator

@jinhojang6 jinhojang6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.txt
@at0m1x19 Thanks for the great work. But the thing is I've encountered some new error in the latest branch. Can you please take a look?

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.
@at0m1x19 at0m1x19 requested a deployment to preview-deploy-approval April 16, 2026 17:56 — with GitHub Actions Waiting
@at0m1x19
Copy link
Copy Markdown
Contributor Author

log.txt @at0m1x19 Thanks for the great work. But the thing is I've encountered some new error in the latest branch. Can you please take a look?

@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.

@jinhojang6
Copy link
Copy Markdown
Collaborator

@at0m1x19 Thanks for the repl! But unfortunately, I've encountered errors again. Can you please take a look?
test.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting

Development

Successfully merging this pull request may close these issues.

6 participants