Skip to content

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Aug 25, 2025

Explanation

There are a large amount of tests that exist for the network client in network-controller. This is because the network client assembles a JsonRpcEngine middleware stack, one for Infura RPC endpoints and one for custom RPC endpoints, and we must verify the resulting behavior across not only official Ethereum RPC methods but also MetaMask-specific RPC methods.

Unfortunately, running all of these tests takes a long time in comparison to others, around 3.25 minutes. This is rather painful when working with network-controller, as the feedback loop is quite long. We can reduce this number by splitting up the suite of network client tests into multiple files. This means that Jest is able to now run them in parallel. As a result, they now run in about 1.5 minutes, a 2x speedup.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@mcmire
Copy link
Contributor Author

mcmire commented Aug 25, 2025

Adding no-changelog because these are changes to tests.

There are a large amount of tests that exist for the network client that
NetworkController creates and exposes. This is because the network
client assembles a JsonRpcEngine middleware stack, one for Infura RPC
endpoints and one for custom RPC endpoints, and the resulting behavior
must be exercised somehow. Furthermore, we support not only RPC methods
that are in the official Ethereum spec but also ones that fall outside
of the spec, and we must exercise all of those methods too.

Unfortunately, running all of these tests takes a long time in
comparison to others, around 4+ minutes. This is rather painful when
working with `network-controller` as the feedback loop is quite long. We
can reduce this number by splitting up the suite of network client tests
into multiple files. This means that Jest is able to now run them in
parallel.
@mcmire mcmire force-pushed the speed-up-network-client-tests branch from 4c4ccc3 to 6014c69 Compare August 25, 2025 19:01
@mcmire mcmire marked this pull request as ready for review August 25, 2025 19:05
@mcmire mcmire requested review from a team as code owners August 25, 2025 19:05
cursor[bot]

This comment was marked as outdated.

@mcmire mcmire changed the title Speed up network client tests chore(network-controller): Speed up network client tests Aug 26, 2025
Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

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

Nice work!

@mcmire mcmire enabled auto-merge (squash) August 29, 2025 21:55
@mcmire mcmire merged commit c4de052 into main Aug 29, 2025
235 checks passed
@mcmire mcmire deleted the speed-up-network-client-tests branch August 29, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants