Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: blockaid update version and reenable specs #28121

Merged
merged 2 commits into from
Oct 28, 2024
Merged

test: blockaid update version and reenable specs #28121

merged 2 commits into from
Oct 28, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Oct 28, 2024

Description

This PR does the following:

  • Changes the specs that were going to the test dapp using the ip address as hostname, to use localhost instead (see issue here)
  • Re-enables skipped specs
  • Updates the update-mock-cdn script, so it adds "Content-Type": "text/plain" into the response headers
  • Updates the ppom module to the last version (config, stale and stale diff) using the updated script

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Check ci

Screenshots/Recordings

Example of malicious signature working on e2e environment

malicious-e2e-working.mp4

Encoded mock data before/after content type

encoded-data-mcked.mp4

Pre-merge author checklist

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.

Copy link
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.

@github-actions github-actions bot added the team-extension-platform Extension Platform team label Oct 28, 2024
@seaona seaona changed the title test: blockaid update and reenable test: blockaid update version and reenable specs Oct 28, 2024
@seaona seaona self-assigned this Oct 28, 2024
})
.forGet(
'https://static.cx.metamask.io/api/v1/confirmations/ppom/ppom_version.json',
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to cause a warning, it doesn't work anymore the debug_traceCall 500, but we can use this failed request instead

@seaona seaona marked this pull request as ready for review October 28, 2024 12:00
@seaona seaona requested a review from a team as a code owner October 28, 2024 12:00
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the updated txt files are obtained by running the update-mock-cdn script. The data is encoded in brotli, taken from making a real request to the prod endpoints, to get the latest data

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @seaona for documenting this information.

@@ -1,3 +1,4 @@
{
"Etag": "W/\"ece7f5f533b8978063633ea5b1f8a0fc\""
"Content-Type": "text/plain",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

with this addition, we are now able to see the mocked response in the network tab (see attached video in the description)

@@ -161,14 +157,17 @@ async function mockInfura(mockServer) {
}

describe('PPOM Blockaid Alert - Malicious ERC20 Transfer @no-mmi', function () {
// eslint-disable-next-line mocha/no-skipped-tests
it.skip('should show banner alert', async function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not skipping the test anymore as it's now fixed

@metamaskbot
Copy link
Collaborator

Builds ready [94bad92]
Page Load Metrics (2113 ± 46 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1961240721178943
domContentLoaded1888229420628038
load1961244921139546
domInteractive197947189
backgroundConnect13156553416
firstReactRender552151003316
getState86319189
initialActions01000
loadScripts1371170615256933
setupStore1496402713
uiStartup21782677235312459
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 121 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@@ -181,10 +180,10 @@ describe('PPOM Blockaid Alert - Malicious ERC20 Transfer @no-mmi', function () {
async ({ driver }) => {
const expectedTitle = 'This is a deceptive request';
const expectedDescription =
'If you approve this request, you might lose your assets.';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the malicious descriptions have slightly changed so we need to modify them in the specs

assert(
bannerAlertText.includes(expectedDescription),
`Unexpected banner alert description. Expected: ${expectedDescription} \nExpected reason: transfer_farming\n`,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we already find the element by its text, so no need to assert after

@@ -90,14 +86,17 @@ async function mockInfura(mockServer) {
}

describe('PPOM Blockaid Alert - Set Trade farming order @no-mmi', function () {
// eslint-disable-next-line mocha/no-skipped-tests
it.skip('should show banner alert', async function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not skipping the test anymore as it's now fixed


await unlockWallet(driver);
await openDapp(driver);
await driver.openNewPage('http://localhost:8080');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need to go to localhost and not 127.0.0.1 otherwise the interactions won't be flagged by ppom (see issue)

Copy link
Contributor

@hjetpoluru hjetpoluru left a comment

Choose a reason for hiding this comment

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

LGTM

},
);
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip('should show "Request may not be safe" if the PPOM request fails to check transaction', async function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not skipping the test anymore as it's now fixed

@chloeYue
Copy link
Contributor

LGTM !

@seaona seaona added this pull request to the merge queue Oct 28, 2024
Merged via the queue into develop with commit 3624df4 Oct 28, 2024
100 checks passed
@seaona seaona deleted the ppom-update branch October 28, 2024 16:21
@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2024
@metamaskbot metamaskbot added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Oct 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.7.0 Issue or pull request that will be included in release 12.7.0 team-extension-platform Extension Platform team
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants