Skip to content

Commit

Permalink
test: test for bad cases as well
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jan 22, 2017
1 parent 1d4aa10 commit af4db1d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ const mafmt = require('./../src')
describe('multiaddr validation', function () {
const goodDNS = [
'/dns/ipfs.io',
'/dns/protocol.ai'
'/dns4/ipfs.io',
'/dns4/libp2p.io',
'/dns6/protocol.ai'
]

const badDNS = [
'/ip4/127.0.0.1'
]

const goodIP = [
Expand Down Expand Up @@ -81,6 +87,11 @@ describe('multiaddr validation', function () {
'/ip6/::/ip4/0.0.0.0/udp/1234/ws'
]

const badWSS = [
'/ip4/0.0.0.0/tcp/12345/udp/2222/wss',
'/ip6/::/ip4/0.0.0.0/udp/1234/wss'
]

const goodIPFS = [
'/ip4/127.0.0.1/tcp/20008/ws/ipfs/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj',
'/libp2p-webrtc-star/ip4/1.2.3.4/tcp/3456/ws/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4',
Expand All @@ -107,7 +118,7 @@ describe('multiaddr validation', function () {

it('DNS validation', function () {
assertMatches(mafmt.DNS, goodDNS)
assertMismatches(mafmt.DNS, badIP, goodTCP)
assertMismatches(mafmt.DNS, badDNS, badIP, goodTCP)
})

it('IP validation', function () {
Expand Down Expand Up @@ -142,7 +153,7 @@ describe('multiaddr validation', function () {

it('WebSocketsSecure validation', function () {
assertMatches(mafmt.WebSocketsSecure, goodWSS)
assertMismatches(mafmt.WebSocketsSecure, goodIP, goodUDP, badWS)
assertMismatches(mafmt.WebSocketsSecure, goodIP, badWSS, goodUDP, badWS)
})

it('WebRTC-star validation', function () {
Expand Down

0 comments on commit af4db1d

Please sign in to comment.