Skip to content

Fix RustCrypto.resetEncryption failure #4772

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

Merged
merged 2 commits into from
Apr 1, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rust-crypto/rust-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
await this.backupManager.deleteAllKeyBackupVersions();

this.deleteSecretStorage();
await this.deleteSecretStorage();
Copy link
Member

Choose a reason for hiding this comment

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

Can you update the test so this would be caught by it please?

Copy link
Contributor Author

@florianduros florianduros Apr 1, 2025

Choose a reason for hiding this comment

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

This is difficult because we are using a mocked SecretStorage which is way faster than the real execution. Meaning that even by adding jest.fn().mockResolvedValue(undefined) to store or setDefaultKeyId, the test passes. Also I don't think that adding manual latency is a good thing neither.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I'd prefer the change to mockResolvedValue for async methods, even if it doesn't make the test fail. Personally I would add a small delay that makes the test fail but I definitely won't insist on that.

I'll tick the PR and you can use your judgement. Thank you!

Comment on lines 1468 to +1469
Copy link
Member

Choose a reason for hiding this comment

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

@florianduros: Why do we need to do this.deleteSecretStorage() and await this.deleteSecretStorage(); ?

Copy link
Contributor Author

@florianduros florianduros Apr 7, 2025

Choose a reason for hiding this comment

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

Oh, an error during the rebase. Good spot, I'll fix it tomorrow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in #4789


// Reset the cross-signing keys
await this.crossSigningIdentity.bootstrapCrossSigning({
Expand Down