Skip to content

Commit

Permalink
fix: add test cases for #156
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Jun 1, 2023
1 parent 1fd26f6 commit d780138
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const _WebSockets = or(
)

export const WebSockets = or(
_WebSockets,
and(_WebSockets, base('p2p'))
and(_WebSockets, base('p2p')),
_WebSockets
)

const _WebSocketsSecure = or(
Expand All @@ -53,8 +53,8 @@ const _WebSocketsSecure = or(
)

export const WebSocketsSecure = or(
_WebSocketsSecure,
and(_WebSocketsSecure, base('p2p'))
and(_WebSocketsSecure, base('p2p')),
_WebSocketsSecure
)

export const HTTP = or(
Expand Down
25 changes: 23 additions & 2 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,38 @@ describe('multiaddr validation', function () {

const goodWS = [
'/dnsaddr/ipfs.io/ws',
'/dns4/ipfs.io/ws',
'/dns6/ipfs.io/ws',
'/ip4/1.2.3.4/tcp/3456/ws',
'/ip6/::/tcp/0/ws'
'/ip6/::/tcp/0/ws',
'/dnsaddr/ipfs.io/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/dns4/ipfs.io/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/dns6/ipfs.io/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/ip4/1.2.3.4/tcp/3456/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/ip6/::/tcp/3456/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79'
]

const goodWSS = [
'/dnsaddr/ipfs.io/wss',
'/dns4/ipfs.io/wss',
'/dns6/ipfs.io/wss',
'/ip4/1.2.3.4/tcp/3456/wss',
'/ip6/::/tcp/0/wss',
'/dnsaddr/ipfs.io/tls/ws',
'/dns4/ipfs.io/tls/ws',
'/dns6/ipfs.io/tls/ws',
'/ip4/1.2.3.4/tcp/3456/tls/ws',
'/ip6/::/tcp/0/tls/ws'
'/ip6/::/tcp/0/tls/ws',
'/dnsaddr/ipfs.io/wss/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/dns4/ipfs.io/wss/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/dns6/ipfs.io/wss/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/ip4/1.2.3.4/tcp/3456/wss/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/ip6/::/tcp/3456/wss/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/dnsaddr/ipfs.io/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/dns4/ipfs.io/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/dns6/ipfs.io/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/ip4/1.2.3.4/tcp/3456/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79',
'/ip6/::/tcp/3456/tls/ws/p2p/QmTysQQiTGMdfRsDQp516oZ9bR3FiSCDnicUnqny2q1d79'
]

const goodP2PWebRTCStar = [
Expand Down

0 comments on commit d780138

Please sign in to comment.