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 nodesGetAll handler #611

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Fix nodesGetAll handler #611

merged 1 commit into from
Oct 27, 2023

Conversation

addievo
Copy link
Contributor

@addievo addievo commented Oct 26, 2023

Description

nodesGetAll handler was obsolete and was breaking operation of nodes getAll on Polykey-CLI.

This simple PR just fixes the handler.

Handler previously was:

for await (const bucket of nodeGraph.getBuckets()) {
      let index;
      for (const id of Object.keys(bucket)) {
        const encodedId = nodesUtils.encodeNodeId(
          IdInternal.fromString<NodeId>(id),
        );
        // For every node in every bucket, add it to our message
        if (!index) {
          index = nodesUtils.bucketIndex(
            keyRing.getNodeId(),
            IdInternal.fromString<NodeId>(id),
          );
        }
        if (ctx.signal.aborted) throw ctx.signal.reason;
        yield {
          bucketIndex: index,
          nodeIdEncoded: encodedId,
          host: bucket[id].address.host,
          port: bucket[id].address.port,
        };
      }
    }

And now is changed to:

  for await (const [index, bucket] of nodeGraph.getBuckets()) {
      for (const [id, info] of bucket) {
        const encodedId = nodesUtils.encodeNodeId(keyRing.getNodeId());
        // For every node in every bucket, add it to our message
        if (ctx.signal.aborted) {
          throw ctx.signal.reason;
        }
        yield {
          bucketIndex: index,
          nodeIdEncoded: encodedId,
          host: info.address.host,
          port: info.address.port,
        };
      }
    }

Issues Fixed

Tasks

  • 1. Update handler.
  • 2. Verify it works on Polykey-CLI.

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@addievo addievo linked an issue Oct 26, 2023 that may be closed by this pull request
4 tasks
@ghost
Copy link

ghost commented Oct 26, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@addievo addievo self-assigned this Oct 26, 2023
@tegefaulkes
Copy link
Contributor

FYI, you don't need to code dump in the issue spec. Implementation detail is less relevant than requirements.

You want clear specification of what needs to be done, How the code looks like isn't that use. Focus on what needs to be done and what is required of the code. Not how it will look.

Copy link
Contributor

@tegefaulkes tegefaulkes left a comment

Choose a reason for hiding this comment

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

You also need to review the tests for this. no tests caught the problem so either they are insufficient or non-existent. Look into it.

src/client/handlers/NodesGetAll.ts Outdated Show resolved Hide resolved
@addievo
Copy link
Contributor Author

addievo commented Oct 27, 2023

You also need to review the tests for this. no tests caught the problem so either they are insufficient or non-existent. Look into it.

You are right, currently no tests exist for getAll. I will make one to test the same.

@tegefaulkes
Copy link
Contributor

Likely there is no test for the Nodes Connections as well.

@addievo
Copy link
Contributor Author

addievo commented Oct 27, 2023

Likely there is no test for the Nodes Connections as well.

Yep, there are currently only tests for add, claim, find, and ping.

Copy link
Contributor

@tegefaulkes tegefaulkes left a comment

Choose a reason for hiding this comment

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

Just a little more polish, Once that is done, so long as all the test pass, you can proceed to merge.

tests/client/handlers/nodes.test.ts Outdated Show resolved Hide resolved
tests/client/handlers/nodes.test.ts Outdated Show resolved Hide resolved
@CMCDragonkai
Copy link
Member

Good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

getAll handler is currently broken and needs fixing. CLI polish and fixes for deployment
3 participants