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

Use JSON onboarding in e2e tests of transactions #3559

Merged
merged 12 commits into from
Jul 25, 2023
Merged

Conversation

michalinacienciala
Copy link
Contributor

@michalinacienciala michalinacienciala commented Jul 20, 2023

Prior to this change we were onboarding using a seed phrase, which was not ideal, as it could lead to a seed phrase leakage in the Playwright report added to the artifacts of CI jobs (that's why we've temporarily switched off storing of the test artifacts).
Now that we support in Taho the onboarding with a JSON keystore file (which stores an encrypted private key), we are good to use this method of account import in our E2E tests. This method is safer, as the sensitive data entered in the form during onboarding is obfuscated, so there's no risk it will leak in the Playwright report (and even if so, what will leak will be just a password, not a corresponding to it JSON file).
As we're switching to this onboarding method, we can bring back storing of the Playwright reports in the CI jobs artifacts.

Apart from the above, as part of this commit/PR we're also introducing a script which can be used to generate a JSON keystore file based on the provided private key and password.

TODO:

  • Add TEST_WALLET_JSON_BODY and TEST_WALLET_JSON_PASSWORD secrets in the GitHub Settings
  • Rerun the failing CI jobs and make sure they're passing
  • Delete the TEST_WALLET_RECOVERY_PHRASE secret

Latest build: extension-builds-3559 (as of Tue, 25 Jul 2023 19:09:50 GMT).

Prior to this change we were onbording using a seed phrase, which was not ideal,
as it could lead to a seed phrase leakage in the Playwright report added to the
artifacts of CI jobs (that's why we've temporarily switched off storing of the
test artifacts).
Now that we support in Taho the onboarding with a JSON keystore file (which
stores an encrypted private key), we are good to use this method of account
import in our E2E tests. This method is safer, as the sensitive data entered in
the form during onboarding is obfuscated, so there's no risk it will leak in the
Playwright report (and even if so, what will leak will be just a password, not a
corresponding to it JSON file).
As we're switching to this onboarding method, we can bring back storing of the
Playwrigt reports in the CI jobs artifacts.

Apart from the above, as part of this commit/PR we're also introducing a script
which can be used to generate a JSON keystore file based on the provided private
key and password.
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-var-requires */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to add a linter exception here, as I couldn't make the linter happy without braking the script (can't say confidently that this can't be done though...).

Copy link
Contributor

Choose a reason for hiding this comment

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

Choice looks correct, just drop a note above it that since this is a script we can’t use import yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michalinacienciala
Copy link
Contributor Author

Hmm, I don't why the lint check is failing... When I run yarn eslint scripts/key-generation/ locally I don't get an error.

@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require("fs")
const wallet = require("ethereumjs-wallet").default
Copy link
Contributor

Choose a reason for hiding this comment

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

For the lint error below—we need to yarn install in the parent dir in the actions workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 24b20bc, it helped, thanks!

We need to run the install there to avoid complaints from the linter about a
missing module (`Unable to resolve path to module 'ethereumjs-wallet'`).
The transactions e2e tests use the first address of the testing wallet
(`testertesting.eth`). But we already know that in some tests that we plan to
add in the future, we'll want to use a different account - the third address of
the testing wallet (`e2e.testertesting.eth`). So we will need to use names of
the variables and secrets that differenciate those different addresses.
I've pushed by mistake a change commenting out some fragment of the e2e tests
that shouldn't be commented out. I'm fixing it in this commit.
@michalinacienciala
Copy link
Contributor Author

@Shadowfiend, ready for an another round of review.

michalinacienciala and others added 3 commits July 21, 2023 19:49
We changed this for production fork builds to differentiate from the release builds, and we updated e2e tests to look for the suffix, but on non release branches the fork builds were not getting the suffix, leading to test failures.
@Shadowfiend
Copy link
Contributor

The fork build still seems to be failing here, so once we get that sorted we'll be good to go.

Which is good because the main e2e tests are failing atm 😅

@michalinacienciala
Copy link
Contributor Author

@Shadowfiend, since merging the main to the feature branch of this PR the tests are passing. I think we can merge 🚀

Let's remove TEST_WALLET_RECOVERY_PHRASE secret after the merge.

@Shadowfiend
Copy link
Contributor

Ok, I think we're good here. Going to see if the e2e tests run as expected and then will land this fellow.

Copy link
Contributor

@Shadowfiend Shadowfiend left a comment

Choose a reason for hiding this comment

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

All righty let's rock and roll!

@Shadowfiend Shadowfiend merged commit 4d97a2e into main Jul 25, 2023
6 checks passed
@Shadowfiend Shadowfiend deleted the json-import-in-e2e branch July 25, 2023 19:10
@kkosiorowska kkosiorowska mentioned this pull request Jul 28, 2023
jagodarybacka added a commit that referenced this pull request Aug 2, 2023
## What's Changed
* v0.43.3 by @hyphenized in
#3570
* Use JSON onboarding in e2e tests of transactions by
@michalinacienciala in #3559
* Refactor prices caching by @hyphenized in
#3526
* Fix assertions made on the latest transaction by @michalinacienciala
in #3573


**Full Changelog**:
v0.43.3...v0.44.0

Latest build:
[extension-builds-3577](https://github.com/tahowallet/extension/suites/14645396551/artifacts/830824018)
(as of Fri, 28 Jul 2023 14:43:48 GMT).
hyphenized added a commit that referenced this pull request Aug 16, 2023
This commit introduces E2E test that checks the functiolality of
verified/unverified tokens. Following general steps are executed:
1. Import account
2. Enable `Show unverified assets`
3. Hide asset
4. Trust asset
5. Hide trusted asset
A number of checks is performed during each step.

The commit also introduces helper functions and adds `data-testid`
attribute to a couple of DOM elements.

TODO:

- [x] As some of the code is similar or identical as in the
#3418 PR which is yet not
merged to `main`, some conflicts may arise and will need to be resolved
before this change lands on `main`.
- [x] Also some changes will need to be made once
#3195 gets merged to `main`,
as this PR solves a bug causing failures in the tests (the failing part
of the test was temporarily commented out).
- [x] Add `E2E_TEST_ONLY_WALLET_JSON_BODY` and
`E2E_TEST_ONLY_WALLET_JSON_PASSWORD` secrets in GitHub's settings.
- [x] Wait for #3559 to be
merged and merge main to feature branch (should fix the failing
`e2e-tests` job)
- [x] Handle TODOs in the code

Latest build:
[extension-builds-3472](https://github.com/tahowallet/extension/suites/15116290312/artifacts/863816729)
(as of Tue, 15 Aug 2023 18:12:30 GMT).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants