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

crypto tests: import everything from index #111

Merged
merged 1 commit into from
May 31, 2024
Merged

Conversation

HerbCaudill
Copy link
Member

@HerbCaudill HerbCaudill commented May 24, 2024

libsodium has an async initialization step, which we deal with using a top-level await in the crypto package's main export:

await sodium.ready

But some tests were importing directly from the individual modules, e.g.

import { randomKey, randomKeyBytes } from '../randomKey.js'

and this was causing a race condition that resulted in intermittent test failures in the crypto package.

This PR ensures that all tests import from ../index.js so that libsodium is always initialized before we try to use it.

Testing plan

Confirm that the crypto tests consistently pass

otherwise we're not awaiting sodium.ready
Copy link
Collaborator

@brentkeller brentkeller left a comment

Choose a reason for hiding this comment

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

Lgtm and the tests were always passing when I ran them 👍

@HerbCaudill HerbCaudill merged commit 23e925e into main May 31, 2024
2 checks passed
@HerbCaudill HerbCaudill deleted the fix-crypto-tests branch May 31, 2024 14:11
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