Compare commits

...

8 Commits

Author SHA1 Message Date
e01046eb03 chore: release version v0.7.4 2016-08-03 14:57:30 +01:00
918b9df322 chore: update contributors 2016-08-03 14:57:30 +01:00
31b47fbfd2 Merge pull request #17 from libp2p/update-deps
update dependencies
2016-08-03 14:47:05 +01:00
26e9268bb5 update dependencies 2016-08-03 14:42:35 +01:00
676b5f3dbf chore: release version v0.7.3 2016-06-26 21:18:26 +01:00
ad7a331d9a chore: update contributors 2016-06-26 21:18:25 +01:00
a00c38437e Merge pull request #16 from libp2p/destroy-properly
use duplexify fork while PR is not up yet
2016-06-26 21:18:02 +01:00
cf0e9a1a8f use duplexify fork while PR is not up yet 2016-06-26 21:13:39 +01:00
2 changed files with 58 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "libp2p-tcp", "name": "libp2p-tcp",
"version": "0.7.2", "version": "0.7.4",
"description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces", "description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces",
"main": "lib/index.js", "main": "lib/index.js",
"jsnext:main": "src/index.js", "jsnext:main": "src/index.js",
@ -32,15 +32,14 @@
}, },
"homepage": "https://github.com/diasdavid/js-libp2p-tcp", "homepage": "https://github.com/diasdavid/js-libp2p-tcp",
"devDependencies": { "devDependencies": {
"aegir": "^3.0.4", "aegir": "^4.0.0",
"chai": "^3.5.0", "chai": "^3.5.0",
"interface-transport": "^0.2.0", "interface-transport": "^0.2.0",
"pre-commit": "^1.1.2", "pre-commit": "^1.1.2",
"tape": "^4.5.1" "tape": "^4.5.1"
}, },
"dependencies": { "dependencies": {
"duplexify": "^3.4.3", "interface-connection": "0.1.8",
"interface-connection": "0.1.2",
"ip-address": "^5.8.0", "ip-address": "^5.8.0",
"lodash.contains": "^2.4.3", "lodash.contains": "^2.4.3",
"mafmt": "^2.1.0", "mafmt": "^2.1.0",

View File

@ -243,6 +243,61 @@ describe('dial', () => {
} }
}) })
it('dial and destroy on listener', (done) => {
let count = 0
const closed = () => ++count === 2 ? finish() : null
const ma = multiaddr('/ip6/::/tcp/9067')
const listener = tcp.createListener((conn) => {
conn.on('close', closed)
conn.destroy()
})
listener.listen(ma, dialStep)
function dialStep () {
const conn = tcp.dial(ma)
conn.on('close', closed)
}
function finish () {
listener.close(done)
}
})
it('dial and destroy on dialer', (done) => {
let count = 0
const destroyed = () => ++count === 2 ? finish() : null
const ma = multiaddr('/ip6/::/tcp/9068')
const listener = tcp.createListener((conn) => {
conn.on('close', () => {
console.log('closed on the listener socket')
destroyed()
})
})
listener.listen(ma, dialStep)
function dialStep () {
const conn = tcp.dial(ma)
conn.on('close', () => {
console.log('closed on the dialer socket')
destroyed()
})
conn.resume()
setTimeout(() => {
conn.destroy()
}, 10)
}
function finish () {
listener.close(done)
}
})
it('dial on IPv4 with IPFS Id', (done) => { it('dial on IPv4 with IPFS Id', (done) => {
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw') const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const conn = tcp.dial(ma) const conn = tcp.dial(ma)