Skip to content

Conversation

@matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Aug 2, 2024

Explanation

Fix the TransactionController integration tests with version 6.0.0 of @metamask/nonce-tracker.

This version of the nonce tracker constructs a new Web3Provider instance every time a eth_getTransactionCount call is required, this is needed in order to support the proxy provider which can dynamically point to different networks.

This Web3Provider extends the JsonRpcProvider whose constructor has the side effect of creating a timeout to determine the chain ID, if not provided in the constructor. When calling getTransactionCount on this provider, it first awaits the network being identified as a result of the timeout.

https://github.com/ethers-io/ethers.js/blob/v5.7.2/packages/providers/src.ts/json-rpc-provider.ts#L416

https://github.com/ethers-io/ethers.js/blob/v5.7.2/packages/providers/src.ts/base-provider.ts#L1461

Since the integration tests use fake timers, some of them were hanging when generating a nonce since an additional tick was required to process this constructor network timeout.

References

Related to #2668

Changelog

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 highlighted breaking changes using the "BREAKING" category above as appropriate

@socket-security
Copy link

socket-security bot commented Aug 2, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/nonce-tracker@6.0.0 None 0 29.1 kB lgbot

View full report↗︎

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review August 2, 2024 17:44
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner August 2, 2024 17:44
@matthewwalsh0 matthewwalsh0 requested a review from a team August 2, 2024 17:44
@legobeat legobeat requested a review from dbrans August 8, 2024 21:52
@matthewwalsh0 matthewwalsh0 merged commit 5318618 into main Aug 12, 2024
@matthewwalsh0 matthewwalsh0 deleted the test/fix-transaction-controller-integration-tests branch August 12, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants