-
Notifications
You must be signed in to change notification settings - Fork 64
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: make getPeerId return the target peer id from relay addrs #325
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -997,6 +997,11 @@ describe('helpers', () => { | |
multiaddr('/p2p-circuit/p2p/12D3KooWNvSZnPi3RrhrTwEY4LuuBeB6K6facKUCJcyWG1aoDd2p').getPeerId() | ||
).to.equal('12D3KooWNvSZnPi3RrhrTwEY4LuuBeB6K6facKUCJcyWG1aoDd2p') | ||
}) | ||
it('does not extract a peer Id from a circuit relay multiaddr where only the relay peer id is present', () => { | ||
expect( | ||
multiaddr('/ip4/127.0.0.1/tcp/123/p2p/bafzbeigweq4zr4x4ky2dvv7nanbkw6egutvrrvzw6g3h2rftp7gidyhtt4/p2p-circuit').getPeerId() | ||
).to.be.null() | ||
}) | ||
Comment on lines
+1000
to
+1004
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the positive test case (peerId of relayed peer exists) already exists in the tests from what I can see. However, do we need to check a case where we have something like
to make sure the correct peer ID is returned when there are two? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we have this in the |
||
}) | ||
|
||
describe('.getPeerId should return null on missing peer id in multiaddr', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i find it confusing that we push to tuples and then empty tuples if p2p-circuit is found.
Could this result in (eventually longer and currently unknown) multiaddr tuples being removed that shouldn't? Instead, should we just not call
tuples.push
if it's the p2p-circuit case for the current code?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, because circuit relay addresses are not supposed to be relayed themselves so whatever is after
p2p-circuit
should be what we are interested in.We reset the tuples because whatever was before the
p2p-circuit
tuple is the relay address and we're trying to extract the PeerId of the target, not the relay.It's trying to handle the case of:
/ip4/foo/p2p/QmRelay/p2p-circuit
-> should returnnull
notQmRelay