Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: make circuit relay test (#1710)
Browse files Browse the repository at this point in the history
* avoid running long circuit tests that will fail
* add check for addresses to circuit tests
  • Loading branch information
jacobheun authored and Alan Shaw committed Nov 13, 2018
1 parent aefb261 commit 345ce91
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions test/core/circuit-relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ function setupInProcNode (addrs, hop, callback) {
}

procDf.spawn({
relay: {
enabled: true,
hop: {
enabled: hop
libp2p: {
config: {
relay: {
enabled: true,
hop: {
enabled: hop
}
}
}
},
config: Object.assign({}, baseConf, {
Expand Down Expand Up @@ -73,7 +77,7 @@ describe('circuit relay', () => {
let relayNode

let nodes
before(function (done) {
before('create and connect', function (done) {
parallel([
(cb) => setupInProcNode([
'/ip4/0.0.0.0/tcp/0',
Expand All @@ -88,29 +92,29 @@ describe('circuit relay', () => {
relayNode = res[0].ipfsd

nodeAAddr = tcpAddr(res[1].addrs)
nodeA = res[0].ipfsd.api
nodeA = res[1].ipfsd.api

nodeBAddr = wsAddr(res[2].addrs)

nodeB = res[1].ipfsd.api
nodeB = res[2].ipfsd.api
nodeBCircuitAddr = `/p2p-circuit/ipfs/${multiaddr(nodeBAddr).getPeerId()}`

done()
// ensure we have an address string
expect(nodeAAddr).to.be.a('string')
expect(nodeBAddr).to.be.a('string')
expect(nodeBCircuitAddr).to.be.a('string')

series([
(cb) => relayNode.api.swarm.connect(nodeAAddr, cb),
(cb) => relayNode.api.swarm.connect(nodeBAddr, cb),
(cb) => setTimeout(cb, 1000),
(cb) => nodeA.swarm.connect(nodeBCircuitAddr, cb)
], done)
})
})

after((done) => parallel(nodes.map((node) => (cb) => node.stop(cb)), done))

it('should connect', function (done) {
series([
(cb) => relayNode.api.swarm.connect(nodeAAddr, cb),
(cb) => setTimeout(cb, 1000),
(cb) => relayNode.api.swarm.connect(nodeBAddr, cb),
(cb) => setTimeout(cb, 1000),
(cb) => nodeA.swarm.connect(nodeBCircuitAddr, cb)
], done)
})

it('should transfer', function (done) {
const data = crypto.randomBytes(128)
waterfall([
Expand Down

0 comments on commit 345ce91

Please sign in to comment.