Skip to content

test(e2e): mock popular network RPCs to remove from allowlist (MMQA-1785)#29682

Merged
chrisleewilcox merged 5 commits into
mainfrom
MMQA-1785-tier-4-rpc-mocks
May 5, 2026
Merged

test(e2e): mock popular network RPCs to remove from allowlist (MMQA-1785)#29682
chrisleewilcox merged 5 commits into
mainfrom
MMQA-1785-tier-4-rpc-mocks

Conversation

@chrisleewilcox

@chrisleewilcox chrisleewilcox commented May 4, 2026

Copy link
Copy Markdown
Contributor

Description

Tier 4 of the E2E allowlist reduction (epic MMQA-1364). Removes four entries from tests/api-mocking/mock-e2e-allowlist.ts by adding default RPC mocks where the URL is actually pinged at runtime, and deleting one stale entry whose host is never wired into a NetworkController.

Entries removed:

Entry Disposition
api.avax.network/ext/bc/C/rpc Default mock added (pinged on controller load via withPopularNetworks()).
mainnet.era.zksync.io Default mock added (same source).
rpc.atlantischain.network CUSTOM_RPC_PROVIDER_MOCKS extended to also cover this host. Used by permission-system-dapp-chain-switch-grant.spec.ts (ElysiumTestnet).
testnet-rpc.monad.xyz Deleted from allowlist — stale: only used in tests/resources/mock-configs.ts to read ticker/nickname; the actual rpcUrl is overridden to http://localhost:8545, so the live URL is never set on a controller.

Detox's blacklistURLs.json entries for avax + zksync are also removed — those URLs are now intercepted by the mock server and no longer leak to Detox's network-sync.

Out of scope: the npm: URI regex hack in MockServerE2E.ts (Tier 4 — Part 2, blocked by MMQA-1366). The Polymarket allowlist follow-up will be a separate ticket.

After this lands, ALLOWLISTED_HOSTS is down to 9 entries (4 local + 4 Tenderly + Polymarket carve-out + metamask.github.io) and ALLOWLISTED_URLS is down to 1 entry (metamask.github.io/test-dapp/metamask-fox.svg).

Changelog

CHANGELOG entry: null

Related issues

MMQA-1785 (Tier 4 — Part 1)
Parent epic: MMQA-1364

Fixes:

Manual testing steps

Feature: E2E mock coverage for popular network RPCs and ElysiumTestnet

  Scenario: smoke specs that load popular networks no longer leak live requests
    Given an E2E run that builds a fixture with withPopularNetworks()

    When the wallet boots and the NetworkController initializes
    Then requests to api.avax.network and mainnet.era.zksync.io are answered by the mock server
    And no entry for those hosts/URLs is required in mock-e2e-allowlist.ts

  Scenario: dapp chain-switch flow on ElysiumTestnet
    Given the spec permission-system-dapp-chain-switch-grant.spec.ts is run

    When the test taps Elysium Testnet to grant chain permission
    Then RPC calls routed via /proxy?url=https://rpc.atlantischain.network/... are intercepted by CUSTOM_RPC_PROVIDER_MOCKS
    And the spec passes without a live request leak

Screenshots/Recordings

Before

tests/api-mocking/mock-e2e-allowlist.ts — Tier 4 entries still permitted to leak as live requests:

export const ALLOWLISTED_HOSTS = [
  // ... local + Tenderly ...
  'testnet-rpc.monad.xyz',
  // ... Polymarket + metamask.github.io ...
];

export const ALLOWLISTED_URLS = [
  'https://api.avax.network/ext/bc/C/rpc',
  'https://mainnet.era.zksync.io/',
  'https://rpc.atlantischain.network/',
  'https://metamask.github.io/test-dapp/metamask-fox.svg',
];

tests/resources/blacklistURLs.json — Detox dropping the same hosts at the network layer:

".*mainnet.era.zksync.io/.*",
".*api.avax.network/ext/bc/C/rpc.*"

After

tests/api-mocking/mock-e2e-allowlist.ts — four entries removed (1 host + 3 URLs):

export const ALLOWLISTED_HOSTS = [
  '0.0.0.0',
  '127.0.0.1',
  'localhost',
  '10.0.2.2',
  'api.tenderly.co',
  'rpc.tenderly.co',
  'virtual.mainnet.rpc.tenderly.co',
  'virtual.linea.rpc.tenderly.co',
  'gamma-api.polymarket.com',
  '*.polymarket.com',
  'metamask.github.io',
];

export const ALLOWLISTED_URLS = [
  'https://metamask.github.io/test-dapp/metamask-fox.svg',
];

tests/resources/blacklistURLs.json — corresponding zkSync / avax patterns removed.

CI verification (commit cf2ba92fcc):

iOS E2E Smoke Tests
  ✓ network-abstraction-ios-smoke (1)  16m3s   PASS
  ✓ network-abstraction-ios-smoke (2)  16m32s  PASS

network-abstraction-ios-smoke is the suite that runs permission-system-dapp-chain-switch-grant.spec.ts (Elysium / atlantischain) and the multichain wallet-* specs that build fixtures with withPopularNetworks() (Avalanche / zkSync). Both shards passed on the latest commit, validating the new mocks across both code paths.

Note: Android smoke jobs flaked with an unrelated infrastructure error (Error: kill EPERM from nick-fields/retry during apt-get install on the runner — tests never executed). Same root cause across multiple suites and reruns; not a code issue.

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

…785)

Tier 4 of the E2E allowlist reduction (epic MMQA-1364).

- Adds default RPC mocks for api.avax.network and mainnet.era.zksync.io
  (pinged on controller load via withPopularNetworks())
- Extends CUSTOM_RPC_PROVIDER_MOCKS to also handle rpc.atlantischain.network
  (used by permission-system-dapp-chain-switch-grant.spec.ts)
- Removes testnet-rpc.monad.xyz from allowlist — stale entry, only used
  for ticker/nickname extraction; actual rpcUrl overridden to localhost
- Drops corresponding entries from Detox blacklistURLs.json

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@metamaskbotv2 metamaskbotv2 Bot added the team-qa QA team label May 4, 2026
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions Bot added the size-S label May 4, 2026
@chrisleewilcox chrisleewilcox added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label May 4, 2026
@chrisleewilcox chrisleewilcox added no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed no changelog required No changelog entry is required for this change and removed skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run labels May 5, 2026
@chrisleewilcox chrisleewilcox marked this pull request as ready for review May 5, 2026 16:36
@chrisleewilcox chrisleewilcox requested a review from a team as a code owner May 5, 2026 16:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cb3af18. Configure here.

Comment thread tests/api-mocking/mock-responses/custom-rpc-provider-mocks.ts
…DER_MOCKS

The proxy matcher was returning Ethereum mainnet values (chainId 0x1,
net_version 1) for every mocked custom-RPC host. With atlantischain
(Elysium Testnet, chainId 0x53a) now sharing this matcher, that masked
chain identity. Split the table into per-host overrides for chainId and
net_version, with a shared table for the remaining method stubs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeMultiChainAPI
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are entirely within the E2E test infrastructure (api-mocking and test resources), not app code. Here's the impact breakdown:

  1. custom-rpc-provider-mocks.ts: Extended CUSTOM_RPC_PROVIDER_MOCKS to cover both eth.llamarpc.com (Ethereum mainnet custom) and rpc.atlantischain.network (Elysium Testnet), with per-host chain identity. This mock is used exclusively by permission-system-dapp-chain-switch-grant.spec.ts which is tagged SmokeNetworkAbstractions. The fix ensures chain-switch tests get correct chainId/netVersion per network, which is critical for the dApp chain permission test.

  2. rpc-endpoints.ts (defaults): Added proper mock responses for api.avax.network (Avalanche) and mainnet.era.zksync.io (zkSync Era). These were previously live requests (allowlisted). Now they're fully mocked, which affects any test that uses these networks. Avalanche and zkSync are popular networks tested in SmokeNetworkAbstractions (add-popular-networks, network-manager tests).

  3. mock-e2e-allowlist.ts: Removed testnet-rpc.monad.xyz, api.avax.network, mainnet.era.zksync.io, and rpc.atlantischain.network from the allowlist. These are now properly mocked. This is a global change affecting the mock server's behavior for all tests — any test that previously relied on these being allowlisted will now get mocked responses instead.

  4. blacklistURLs.json: Removed mainnet.era.zksync.io and api.avax.network from Detox URL blacklist. This is used in FixtureHelper.ts for all tests. Removing these from the blacklist means Detox won't block these URLs at the network level anymore (they're now handled by the mock server instead).

Tag selection rationale:

  • SmokeNetworkAbstractions: Directly affected — the CUSTOM_RPC_PROVIDER_MOCKS change is used in a SmokeNetworkAbstractions test, and the Avalanche/zkSync mock additions affect popular network tests in this suite.
  • SmokeNetworkExpansion: Per tag description, integrates with SmokeNetworkAbstractions for chain permissions. The multi-chain provider tests may also use these network configurations.
  • SmokeMultiChainAPI: Per tag description, integrates with SmokeNetworkAbstractions for permission system. Chain permission changes affect CAIP-25 session tests.

The blacklistURLs.json change is global but low-risk since it's removing entries that are now properly mocked. No performance impact expected from these test infrastructure changes.

Performance Test Selection:
All changes are in E2E test infrastructure files (api-mocking, test resources). No app code was modified, so there is no performance impact on the app itself. Performance tests measure app responsiveness and render times, which are unaffected by changes to mock server configurations, URL allowlists, or test-specific mock responses.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

@chrisleewilcox chrisleewilcox enabled auto-merge May 5, 2026 17:56
@chrisleewilcox chrisleewilcox added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit f5da506 May 5, 2026
102 checks passed
@chrisleewilcox chrisleewilcox deleted the MMQA-1785-tier-4-rpc-mocks branch May 5, 2026 18:19
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no changelog required No changelog entry is required for this change no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-S team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants