Skip to content

test: fix flaky test PPOM Blockaid Alert for ERC20 Approve by adding missing mocks#22617

Merged
seaona merged 4 commits intodevelopfrom
test-flaky-ppom-erc20
Jan 23, 2024
Merged

test: fix flaky test PPOM Blockaid Alert for ERC20 Approve by adding missing mocks#22617
seaona merged 4 commits intodevelopfrom
test-flaky-ppom-erc20

Conversation

@seaona
Copy link
Copy Markdown
Member

@seaona seaona commented Jan 22, 2024

Description

There were 2 issues with the test: PPOM Blockaid Alert for ERC20 Approve transactions.

  • The test was flaky
  • After checking the artifacts, I've realized that the test was not triggering the Approve ERC20 screen, but a generic Contract Interaction, which was also not expected

For fixing the test, I've added some missing mocks, this results in:

  • making the test more reliable
  • displaying the correct ERC20 approve screen (see pics below)

ci runs

Note: other flaky tests might appear ocasionally, but here we should look for the ppom test and make sure it's green all the time:

Related issues

Fixes: #22577

Manual testing steps

  1. Trigger ci run
  2. Check test is passing

Screenshots/Recordings

Before

Screenshot from 2024-01-22 15-26-47

After

Screenshot from 2024-01-22 15-08-26

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

@github-actions
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.

@seaona seaona added the team-confirmations-secure-ux-PR PRs from the confirmations team label Jan 22, 2024
@seaona seaona self-assigned this Jan 22, 2024
['eth_gasPrice'],
['eth_getBalance'],
['eth_getBlockByNumber'],
['eth_createAccessList'],
Copy link
Copy Markdown
Member Author

@seaona seaona Jan 22, 2024

Choose a reason for hiding this comment

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

adding a couple of more mocks to requests that are also triggered by ppom when performing the approve ERC20 action, to stabilize the test

@seaona seaona marked this pull request as ready for review January 22, 2024 16:01
@seaona seaona requested a review from a team as a code owner January 22, 2024 16:01
[
'eth_call',
{
methodResultVariant: 'balanceApprove',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this mock fixes the "not displaying the ERC20 approve screeen"

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [8772b80]
Page Load Metrics (1259 ± 146 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint863071646833
domContentLoaded10219657636
load80918461259303146
domInteractive10218657636
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [49043c2]
Page Load Metrics (1609 ± 117 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint993181625326
domContentLoaded107127178
load108021541609244117
domInteractive107127178
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (35273da) 68.11% compared to head (49043c2) 68.11%.
Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #22617   +/-   ##
========================================
  Coverage    68.11%   68.11%           
========================================
  Files         1086     1086           
  Lines        42628    42628           
  Branches     11340    11340           
========================================
+ Hits         29033    29035    +2     
+ Misses       13595    13593    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seaona seaona merged commit f69e67d into develop Jan 23, 2024
@seaona seaona deleted the test-flaky-ppom-erc20 branch January 23, 2024 10:11
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2024
@metamaskbot metamaskbot added the release-11.10.0 Issue or pull request that will be included in release 11.10.0 label Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-11.10.0 Issue or pull request that will be included in release 11.10.0 team-confirmations-secure-ux-PR PRs from the confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix "PPOM Blockaid Alert - Malicious ERC20 Approval @no-mmi should show banner alert" flaky test

5 participants