Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: moving long multiaddr to a fixture
Browse files Browse the repository at this point in the history
dryajov committed Apr 18, 2017

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 8d80c5e commit 1548348
Showing 3 changed files with 24 additions and 38 deletions.
20 changes: 20 additions & 0 deletions test/fixtures/long-address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

module.exports = Buffer.from(
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit`)
21 changes: 2 additions & 19 deletions test/listener.spec.js
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ const PeerId = require('peer-id')
const lp = require('pull-length-prefixed')
const pull = require('pull-stream')
const multiaddr = require('multiaddr')
const longaddr = require('./fixtures/long-address')

const sinon = require('sinon')
const expect = require('chai').expect
@@ -97,25 +98,7 @@ describe('listener', function () {

it(`handle request with a long multiaddress`, function (done) {
pull(
pull.values([Buffer.from(
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit`)]
),
pull.values([longaddr]),
lp.encode(),
pull.collect((err, encoded) => {
expect(err).to.be.null
21 changes: 2 additions & 19 deletions test/relay.spec.js
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ const handshake = require('pull-handshake')
const waterfall = require('async/waterfall')
const PeerInfo = require('peer-info')
const PeerId = require('peer-id')
const longaddr = require('./fixtures/long-address')

const sinon = require('sinon')
const expect = require('chai').expect
@@ -110,25 +111,7 @@ describe('relay', function () {
})

it(`fail on address exceeding 1024 bytes`, function (done) {
let dstMa = multiaddr(
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit` +
`/ip4/0.0.0.0/tcp/9033/ws/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE/p2p-circuit`)

let dstMa = multiaddr(longaddr.toString())
dialer.negotiateRelay(fromConn, dstMa, (err, newConn) => {
expect(err).to.not.be.null
expect(err).to.be.an.instanceOf(Error)

0 comments on commit 1548348

Please sign in to comment.