argotorg / argotorg/sourcify

Mock RPC calls in Etherscan tests

Open
#2,134 3 comments 0 reactions 0 assignees View on GitHub
server
Dominant language
TypeScript
Stars
949
Forks
542
Avg merge
2d 19h
Merged PRs (30d)
18

Description

Our Etherscan API tests (v2 - `verify.etherscan.spec.ts`; v1 - `etherscan.spec.ts`) depend on RPC calls to Eth mainnet. We already mock the API calls to Etherscan, but we use response mocks of real contracts from mainnet. Therefore, the verification also tries to get the bytecode via mainnet RPCs (not the Hardhat test chain as the other tests).

This was especially a problem for external PRs (see #2131), because they don't have the RPC API keys exposed. To also run these tests on external PRs we should mock the RPC responses. The problem with doing this for API v2 tests is that the RPC is called inside the worker thread where we cannot easily mock it.

With this, we should also remove the skipping in external PRs from the Etherscan tests.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with verify.etherscan.spec.ts and etherscan.spec.ts, then trace the RPC calls made by the API v2 worker thread and the existing external-PR skips. Run the Etherscan test suites to reproduce the mainnet dependency. Done means the RPC responses are mocked for both API versions and the tests no longer skip on external pull requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.