-
Notifications
You must be signed in to change notification settings - Fork 453
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: upgrader should not need muxers #517
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 |
---|---|---|
|
@@ -116,6 +116,35 @@ describe('Upgrader', () => { | |
expect(result).to.eql([hello]) | ||
}) | ||
|
||
it('should upgrade with only crypto', async () => { | ||
const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer }) | ||
|
||
// No available muxers | ||
const muxers = new Map() | ||
sinon.stub(localUpgrader, 'muxers').value(muxers) | ||
sinon.stub(remoteUpgrader, 'muxers').value(muxers) | ||
|
||
const cryptos = new Map([[Crypto.protocol, Crypto]]) | ||
sinon.stub(localUpgrader, 'cryptos').value(cryptos) | ||
sinon.stub(remoteUpgrader, 'cryptos').value(cryptos) | ||
|
||
const connections = await Promise.all([ | ||
localUpgrader.upgradeOutbound(outbound), | ||
remoteUpgrader.upgradeInbound(inbound) | ||
]) | ||
|
||
expect(connections).to.have.length(2) | ||
|
||
await expect(connections[0].newStream('/echo/1.0.0')).to.be.rejected() | ||
|
||
// Verify the MultiaddrConnection close method is called | ||
sinon.spy(inbound, 'close') | ||
sinon.spy(outbound, 'close') | ||
await Promise.all(connections.map(conn => conn.close())) | ||
expect(inbound.close.callCount).to.equal(1) | ||
expect(outbound.close.callCount).to.equal(1) | ||
}) | ||
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. Should I test the errors with multiplexer operations in the 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. It might be good to add a quick test. They should also throw errors with codes. 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 it would be good to also add a test for closing. It's going to the MultiaddrConn so it should be fine, but I think having it for avoid regressions in the future would be good. 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 added to this test. I think it is better than create a new test |
||
|
||
it('should use a private connection protector when provided', async () => { | ||
const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer }) | ||
|
||
|
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.
We should just set this right after we created the timeline Proxy, that way we don't need to set it here and in the
!Muxer
if statement above.