1
0
mirror of https://github.com/fluencelabs/js-libp2p synced 2025-03-16 23:50:51 +00:00
js-libp2p/pdd/pdd-transport--story-3--peer-b.js
Thomas Eizinger 4ed5c039fc chore: change from ipfs to p2p protocol ()
https://github.com/multiformats/js-multiaddr/pull/76 changed the
default protocol from ipfs to p2p.

js-multiaddr is a transitive dependency of peer-info, so in order
to get this change, we had to bump the version of peer-info.

* fix: revert ipfs -> p2p change for some tests

As per PR feedback. Needed for backwards-compatibility.
2019-02-05 19:59:42 +01:00

43 lines
1.1 KiB
JavaScript

'use strict'
const test = require('tape')
const libp2p = require('libp2p')
const WebSockets = require('libp2p-websockets')
const PeerInfo = require('peer-info')
const waterfall = require('async/waterfall')
const PeerA = require('libp2p-interop/peer-a.json')
const PeerB = require('libp2p-interop/peer-b.json')
class MyBundle extends libp2p {
constructor (peerInfo) {
const modules = {
transport: [new WebSockets()]
}
super(modules, peerInfo)
}
}
test('story 3 - peerB', (t) => {
t.plan(4)
let node
waterfall([
(cb) => PeerInfo.create(PeerB, cb),
(peerInfo, cb) => {
peerInfo.multiaddrs.add('/ip4/127.0.0.1/tcp/10000/ws')
node = new MyBundle(peerInfo)
node.start(cb)
}
], (err) => {
t.ifErr(err, 'created Node')
t.ok(node.isStarted(), 'PeerA is running')
const PeerAAddr = `/ip4/127.0.0.1/tcp/10000/ws/p2p/${PeerA.id}`
setTimeout(() => node.dial(PeerAAddr, '/echo/1.0.0', (err, conn) => {
t.ok(err, 'dial failed')
node.stop((err) => t.ifErr(err, 'PeerA has stopped'))
}), 1000)
})
})