Skip to content

chore(test): Refactor FakeBlockTracker provider injection - #4345

Merged
legobeat merged 5 commits into
MetaMask:mainfrom
legobeat:transaction-controller-test-refactor
Jun 5, 2024
Merged

chore(test): Refactor FakeBlockTracker provider injection#4345
legobeat merged 5 commits into
MetaMask:mainfrom
legobeat:transaction-controller-test-refactor

Conversation

@legobeat

@legobeatlegobeat commented May 30, 2024

Copy link
Copy Markdown
Contributor

Explanation

transaction-controller constructor takes a provider and a blockTracker. In tests, there is mocking of these. A BlockTracker has its own provider and while in reality the blockTracker.provider == provider, it appears inconsistent in tests where a test may use both a mocked and a "real" provider instance at the same time.

This aims at making this more transparent by making the provider parameter of FakeBlockTracker mandatory.

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

@legobeatlegobeat changed the title chore: Refactor transaction-controller testchore(test): Refactor provider injection in testsMay 30, 2024
Comment threadtests/fake-block-tracker.ts Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Here the SafeEventEmitterProvider gets replaced and tests making use of the FakeBlockTracker now have to supply a provider explicitly.

@legobeat
legobeat marked this pull request as ready for review May 30, 2024 23:31
@legobeat
legobeat requested a review from a teamMay 30, 2024 23:31
@legobeatlegobeat changed the title chore(test): Refactor provider injection in testschore(test): Refactor FakeBlockTracker provider injectionMay 30, 2024
@legobeat
legobeatforce-pushed the transaction-controller-test-refactor branch 2 times, most recently from 41718b0 to eeb3f4eCompareMay 31, 2024 06:55
dbrans
dbrans previously approved these changes Jun 4, 2024

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

@legobeat Thank you, this is fantastic work.

@legobeat

Copy link
Copy Markdown
ContributorAuthor

@legobeat Thank you, this is fantastic work.

Thanks!

Just had to resolve a conflict in yarn.lock when syncing with main which invalidated your approve, no further changes.

@legobeat
legobeat requested review from a team and dbransJune 4, 2024 20:23
@legobeat
legobeatforce-pushed the transaction-controller-test-refactor branch from 360299a to 0a8fbbfCompareJune 5, 2024 01:57
@legobeat
legobeat merged commit ba07fd8 into MetaMask:mainJun 5, 2024
@legobeat
legobeat deleted the transaction-controller-test-refactor branch June 5, 2024 16:08
legobeat added a commit to legobeat/metamask-controllers that referenced this pull request Jun 6, 2024
Sign up for freeto 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.

3 participants

@legobeat@dbrans@pedronfigueiredo