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

Provide more options for starting dehydration #4664

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

uhoreg
Copy link
Member

@uhoreg uhoreg commented Jan 29, 2025

Needed for starting dehydration after restart -- since we only want to do that if we already have a key cached, and we don't need to try to rehydrate a device.

Fixes #4484

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • Sign-off given on the changes (see CONTRIBUTING.md).

},
});

fetchMock.mockClear();
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer the above setup code to be in a function that takes arguments for the exact setup we need e.g. function setup(key_cached: boolean, device_exists: boolean, ...) ... and then separate tests for the things we want to be true:

it("should do nothing if no key is cached and onlyIfKeyCached is true")
it("should create a new key and device if no key or device exist")
it("should rehydrate an existing device using the existing key if it exists")
it("should create a new device if we don't have the key for the existing device")
it("should create a new device even if one exists if rehdrate is false")
it("should create a new device every time if createNewKey is true")

This would really help me understand what the code is supposed to do, and will help us understand what happened if future code changes affect this logic.

This is a preference, so if you have good reasons for this narrative style, you can ignore this request :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

The narrative style made sense when I was writing it, but this is probably clearer.

src/crypto-api/index.ts Show resolved Hide resolved
@uhoreg uhoreg requested a review from BillCarsonFr January 29, 2025 23:27
@uhoreg uhoreg dismissed BillCarsonFr’s stale review January 30, 2025 15:58

requested change addressed

@uhoreg uhoreg added this pull request to the merge queue Jan 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2025
@uhoreg uhoreg added this pull request to the merge queue Jan 30, 2025
Merged via the queue into matrix-org:develop with commit cc238c2 Jan 30, 2025
27 checks passed
@uhoreg uhoreg deleted the schedule_dehydration_on_reload branch January 30, 2025 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Device Dehydration | js-sdk: provide functions to allow application to create dehydrated devices on restart
3 participants