mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-03-31 04:31:17 +00:00
simple, gets it done
This commit is contained in:
parent
f1f7d9b5ce
commit
e79d664d24
@ -62,7 +62,7 @@ This method dials a connection to the Peer referenced by the peerInfo object.
|
||||
|
||||
multiaddr must be of the type [`multiaddr`](http://npmjs.org/multiaddr).
|
||||
|
||||
`stream` must implements the [abstract-stream](https://github.com/diasdavid/abstract-stream) interface.
|
||||
`stream` must implements the [abstract-transport](https://github.com/diasdavid/abstract-transport) interface.
|
||||
|
||||
`[options]` are not mandatory fields for all the implementations that might be passed for certain implementations for them to work (e.g. a Signalling Server for a WebRTC transport/connection implementation)
|
||||
|
||||
@ -72,7 +72,7 @@ multiaddr must be of the type [`multiaddr`](http://npmjs.org/multiaddr).
|
||||
|
||||
This method waits and listens for incoming connections by other peers.
|
||||
|
||||
`stream` must be a stream that implements the [abstract-stream](https://github.com/diasdavid/abstract-stream) interface.
|
||||
`stream` must be a stream that implements the [abstract-transport](https://github.com/diasdavid/abstract-transport) interface.
|
||||
|
||||
Options are the properties this listener must have access in order to properly listen on a given transport/socket
|
||||
|
||||
|
@ -21,5 +21,11 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/diasdavid/abstract-connection/issues"
|
||||
},
|
||||
"homepage": "https://github.com/diasdavid/abstract-connection"
|
||||
"homepage": "https://github.com/diasdavid/abstract-connection",
|
||||
"devDependencies": {
|
||||
},
|
||||
"dependencies": {
|
||||
"multiaddr": "^1.0.0",
|
||||
"timed-tape": "^0.1.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,31 @@
|
||||
var multiaddr = require('multiaddr')
|
||||
|
||||
module.exports.all = function (test, common) {
|
||||
test('a test', function (t) {
|
||||
common.setup(test, function (err, Connection) {
|
||||
common.setup(test, function (err, conn) {
|
||||
t.plan(5)
|
||||
t.ifError(err)
|
||||
t.pass('woot!')
|
||||
t.end()
|
||||
|
||||
var maddr = multiaddr('/ip4/127.0.0.1/tcp/9050')
|
||||
|
||||
var listener = conn.createListener(function (stream) {
|
||||
t.pass('received incoming connection')
|
||||
stream.end()
|
||||
listener.close(function () {
|
||||
t.pass('listener closed successfully')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
listener.listen(maddr.nodeAddress().port, function () {
|
||||
t.pass('started listening')
|
||||
var stream = conn.dial(maddr, {
|
||||
ready: function () {
|
||||
t.pass('dialed successfuly')
|
||||
stream.end()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// test for:
|
||||
// 1. dial and listen
|
||||
// 2. close
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user