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

Mock tests should be independent #5835

Open
sosnovsky opened this issue Sep 16, 2024 · 4 comments
Open

Mock tests should be independent #5835

sosnovsky opened this issue Sep 16, 2024 · 4 comments
Assignees

Comments

@sosnovsky
Copy link
Collaborator

          Thank you for your hint. I thought tests were isolated and tests each other don't affect others. But seems like add/generate key affects other tests

Originally posted by @ioanmo226 in #5823 (comment)

@sosnovsky sosnovsky added this to the 8.5.8 milestone Sep 16, 2024
@sosnovsky
Copy link
Collaborator Author

Yes, tests should be isolated and don't affect each other, as they're expected to have separate mock environments.
Let's check why adding key affected other tests and fix it.

@ioanmo226
Copy link
Collaborator

During my review of the settings - my key page - generate key test failure, I discovered that other tests were failing because I initially attempted to save the backup to the Inbox. After switching to no-backup or backup to file, the tests passed.

It seems like the Inbox is shared across all tests. I'll investigate why this is happening.

@ioanmo226
Copy link
Collaborator

ioanmo226 commented Sep 19, 2024

I found the reason for this issue. The problem is that DATA is shared globally. When a user attempts to back up their private key to the inbox, the email data is saved into DATA. As a result, when another instance tries to load the backup list, it also returns the previously backed-up key.

This behavior is mentioned in a comment within our source code.
@sosnovsky Do you wanna me to proceed with this now or later?

const DATA: { [acct: string]: AcctDataFile } = {};

/**

  • This class is badly designed - it acts like a class (whose object should contain its own data),
  • but the data is shared globally across objects. Would be more appropriate to make this a static class.
  • Either that, or have each instance hold data independently (unless it turns out there are memory issues)
    */

@sosnovsky
Copy link
Collaborator Author

Thanks for checking, let's leave it for now, I'll move it to Later milestone

@sosnovsky sosnovsky modified the milestones: 8.5.8, Second priority Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants