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

fix: docs shouldn't require ready cores #29

Merged
merged 2 commits into from
Feb 22, 2024
Merged

fix: docs shouldn't require ready cores #29

merged 2 commits into from
Feb 22, 2024

Conversation

EvanHahn
Copy link
Contributor

We no longer require cores to be ready as of #24. This updates the docs to reflect that.

(Please let me know if I've misunderstood how things should work in this module!)

We no longer require cores to be ready as of
89ac7ae ([pull request #24][0]). This
updates the docs to reflect that.

[0]: #24
@EvanHahn EvanHahn requested a review from gmaclennan January 17, 2024 14:26
Copy link
Member

@achou11 achou11 left a comment

Choose a reason for hiding this comment

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

Yeah I think your assessment is correct! Maybe just to check, try running the tests without this line?

await core.ready()

@EvanHahn
Copy link
Contributor Author

It worked after a small (test-only) patch:

diff --git a/test/helpers/index.js b/test/helpers/index.js
index 65f229f..fb3db58 100644
--- a/test/helpers/index.js
+++ b/test/helpers/index.js
@@ -45,7 +45,7 @@ function replicate(a, b, t) {
 async function create(...args) {
   /* @ts-ignore: TODO: better types for random access modules */
   const core = new Hypercore(ram, ...args)
-  await core.ready()
+  // await core.ready()
   return core
 }
 
diff --git a/test/unit-tests/core-index-stream.test.js b/test/unit-tests/core-index-stream.test.js
index 67ef9c4..121a0c4 100644
--- a/test/unit-tests/core-index-stream.test.js
+++ b/test/unit-tests/core-index-stream.test.js
@@ -32,6 +32,7 @@ test('destroy before open', async (t) => {
 
 test('Indexes all items already in a core', async (t) => {
   const a = await create()
+  await a.ready()
   const blocks = generateFixture(0, 10)
   const expected = blocksToExpected(blocks, a.key)
   await a.append(blocks)
@@ -55,6 +56,7 @@ test("Empty core emits 'drained' event", async (t) => {
 test('.remaining property is accurate', async (t) => {
   const totalBlocks = 100
   const a = await create()
+  await a.ready()
   const blocks = generateFixture(0, totalBlocks)
   const expected = blocksToExpected(blocks, a.key)
   await a.append(blocks)

(I believe this is fine...it happens because the tests assume the key has already been set when concocting expected.)

@EvanHahn EvanHahn merged commit 7cd3aaf into main Feb 22, 2024
0 of 3 checks passed
@EvanHahn EvanHahn deleted the nonready-docs branch February 22, 2024 20:46
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