Skip to content

Commit 28d8ce5

Browse files
authoredSep 3, 2017
feat: fix p2p addrs
* chore: update gitignore * chore: update CI * chore: update deps * feat: update protocols table * test: update tests to new names of p2p- multiaddrs
1 parent b86970f commit 28d8ce5

File tree

5 files changed

+70
-64
lines changed

5 files changed

+70
-64
lines changed
 

‎.gitignore

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
**/node_modules/
2+
**/*.log
3+
test/repo-tests*
4+
**/bundle.js
5+
16
# Logs
27
logs
38
*.log
49

10+
coverage
11+
512
# Runtime data
613
pids
714
*.pid
@@ -19,14 +26,17 @@ coverage
1926
# node-waf configuration
2027
.lock-wscript
2128

22-
# Compiled binary addons (http://nodejs.org/api/addons.html)
23-
build/Release
29+
build
2430

2531
# Dependency directory
2632
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2733
node_modules
2834

35+
lib
2936
dist
30-
docs
37+
test/test-data/go-ipfs-repo/LOCK
38+
test/test-data/go-ipfs-repo/LOG
39+
test/test-data/go-ipfs-repo/LOG.old
3140

32-
.vscode/
41+
# while testing npm5
42+
package-lock.json

‎.travis.yml

+5-10
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,16 @@ language: node_js
33

44
matrix:
55
include:
6-
- node_js: 4
7-
env: CXX=g++-4.8
86
- node_js: 6
9-
env:
10-
- CXX=g++-4.8
11-
- node_js: stable
127
env: CXX=g++-4.8
13-
14-
# Make sure we have new NPM.
15-
before_install:
16-
- npm install -g npm@4
8+
- node_js: 8
9+
env: CXX=g++-4.8
10+
# - node_js: stable
11+
# env: CXX=g++-4.8
1712

1813
script:
1914
- npm run lint
20-
- npm test
15+
- npm run test
2116
- npm run coverage
2217
- make test
2318

‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@
3636
},
3737
"homepage": "https://github.com/multiformats/js-multiaddr",
3838
"dependencies": {
39-
"bs58": "^4.0.0",
39+
"bs58": "^4.0.1",
4040
"ip": "^1.1.5",
4141
"lodash.filter": "^4.6.0",
4242
"lodash.map": "^4.6.0",
4343
"varint": "^5.0.0",
4444
"xtend": "^4.0.1"
4545
},
4646
"devDependencies": {
47-
"aegir": "^11.0.1",
47+
"aegir": "^11.0.2",
4848
"buffer-loader": "0.0.1",
49-
"chai": "^3.5.0",
50-
"dirty-chai": "^1.2.2",
49+
"chai": "^4.1.2",
50+
"dirty-chai": "^2.0.1",
5151
"pre-commit": "^1.2.2"
5252
},
5353
"contributors": [
@@ -62,4 +62,4 @@
6262
"greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>",
6363
"npm-to-cdn-bot (by Forbes Lindesay) <npmcdn-to-unpkg-bot@users.noreply.github.com>"
6464
]
65-
}
65+
}

‎src/protocols-table.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ Protocols.table = [
4141
[443, 0, 'https'],
4242
[477, 0, 'ws'],
4343
[478, 0, 'wss'],
44-
[275, 0, 'libp2p-webrtc-star'],
45-
[276, 0, 'libp2p-webrtc-direct'],
44+
[479, 0, 'p2p-websockets-star'],
45+
[275, 0, 'p2p-webrtc-star'],
46+
[276, 0, 'p2p-webrtc-direct'],
4647
[290, 0, 'p2p-circuit']
4748
]
4849

‎test/index.spec.js

+43-43
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('requiring varint', () => {
8181
describe('manipulation', () => {
8282
it('basic', () => {
8383
const udpAddrStr = '/ip4/127.0.0.1/udp/1234'
84-
const udpAddrBuf = new Buffer('047f0000011104d2', 'hex')
84+
const udpAddrBuf = Buffer.from('047f0000011104d2', 'hex')
8585
const udpAddr = multiaddr(udpAddrStr)
8686

8787
expect(udpAddr.toString()).to.equal(udpAddrStr)
@@ -299,15 +299,22 @@ describe('variants', () => {
299299
expect(addr.toString()).to.equal(str)
300300
})
301301

302-
it('webrtc-star', () => {
303-
const str = '/libp2p-webrtc-star/ip4/127.0.0.1/tcp/9090/ws/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC'
302+
it('p2p-webrtc-star', () => {
303+
const str = '/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC'
304304
const addr = multiaddr(str)
305305
expect(addr).to.have.property('buffer')
306306
expect(addr.toString()).to.equal(str)
307307
})
308308

309-
it('webrtc-direct', () => {
310-
const str = '/libp2p-webrtc-direct/ip4/127.0.0.1/tcp/9090/http'
309+
it('p2p-webrtc-direct', () => {
310+
const str = '/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct'
311+
const addr = multiaddr(str)
312+
expect(addr).to.have.property('buffer')
313+
expect(addr.toString()).to.equal(str)
314+
})
315+
316+
it('p2p-websockets-star', () => {
317+
const str = '/ip4/127.0.0.1/tcp/9090/ws/p2p-websockets-star'
311318
const addr = multiaddr(str)
312319
expect(addr).to.have.property('buffer')
313320
expect(addr.toString()).to.equal(str)
@@ -317,42 +324,37 @@ describe('variants', () => {
317324
describe('helpers', () => {
318325
describe('.toOptions', () => {
319326
it('returns a well formed options object', () => {
320-
expect(
321-
multiaddr('/ip4/0.0.0.0/tcp/1234').toOptions()
322-
).to.be.eql({
323-
family: 'ipv4',
324-
host: '0.0.0.0',
325-
transport: 'tcp',
326-
port: '1234'
327-
})
327+
expect(multiaddr('/ip4/0.0.0.0/tcp/1234').toOptions())
328+
.to.eql({
329+
family: 'ipv4',
330+
host: '0.0.0.0',
331+
transport: 'tcp',
332+
port: '1234'
333+
})
328334
})
329335
})
330336

331337
describe('.inspect', () => {
332338
it('renders the buffer as hex', () => {
333-
expect(
334-
multiaddr('/ip4/0.0.0.0/tcp/1234').inspect()
335-
).to.be.eql(
336-
'<Multiaddr 04000000000604d2 - /ip4/0.0.0.0/tcp/1234>'
337-
)
339+
expect(multiaddr('/ip4/0.0.0.0/tcp/1234').inspect())
340+
.to.eql('<Multiaddr 04000000000604d2 - /ip4/0.0.0.0/tcp/1234>')
338341
})
339342
})
340343

341344
describe('.protos', () => {
342345
it('returns a list of all protocols in the address', () => {
343-
expect(
344-
multiaddr('/ip4/0.0.0.0/utp').protos()
345-
).to.eql([{
346-
code: 4,
347-
name: 'ip4',
348-
size: 32,
349-
resolvable: false
350-
}, {
351-
code: 302,
352-
name: 'utp',
353-
size: 0,
354-
resolvable: false
355-
}])
346+
expect(multiaddr('/ip4/0.0.0.0/utp').protos())
347+
.to.eql([{
348+
code: 4,
349+
name: 'ip4',
350+
size: 32,
351+
resolvable: false
352+
}, {
353+
code: 302,
354+
name: 'utp',
355+
size: 0,
356+
resolvable: false
357+
}])
356358
})
357359

358360
it('works with ipfs', () => {
@@ -379,23 +381,21 @@ describe('helpers', () => {
379381

380382
describe('.tuples', () => {
381383
it('returns the tuples', () => {
382-
expect(
383-
multiaddr('/ip4/0.0.0.0/utp').tuples()
384-
).to.be.eql([
385-
[4, new Buffer([0, 0, 0, 0])],
386-
[302]
387-
])
384+
expect(multiaddr('/ip4/0.0.0.0/utp').tuples())
385+
.to.eql([
386+
[4, Buffer.from([0, 0, 0, 0])],
387+
[302]
388+
])
388389
})
389390
})
390391

391392
describe('.stringTuples', () => {
392393
it('returns the string partss', () => {
393-
expect(
394-
multiaddr('/ip4/0.0.0.0/utp').stringTuples()
395-
).to.be.eql([
396-
[4, '0.0.0.0'],
397-
[302]
398-
])
394+
expect(multiaddr('/ip4/0.0.0.0/utp').stringTuples())
395+
.to.eql([
396+
[4, '0.0.0.0'],
397+
[302]
398+
])
399399
})
400400
})
401401

0 commit comments

Comments
 (0)
Please sign in to comment.