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

Commit 345ce91

Browse files
jacobheunAlan Shaw
authored and
Alan Shaw
committed
fix: make circuit relay test (#1710)
* avoid running long circuit tests that will fail * add check for addresses to circuit tests
1 parent aefb261 commit 345ce91

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

test/core/circuit-relay.js

+22-18
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ function setupInProcNode (addrs, hop, callback) {
3838
}
3939

4040
procDf.spawn({
41-
relay: {
42-
enabled: true,
43-
hop: {
44-
enabled: hop
41+
libp2p: {
42+
config: {
43+
relay: {
44+
enabled: true,
45+
hop: {
46+
enabled: hop
47+
}
48+
}
4549
}
4650
},
4751
config: Object.assign({}, baseConf, {
@@ -73,7 +77,7 @@ describe('circuit relay', () => {
7377
let relayNode
7478

7579
let nodes
76-
before(function (done) {
80+
before('create and connect', function (done) {
7781
parallel([
7882
(cb) => setupInProcNode([
7983
'/ip4/0.0.0.0/tcp/0',
@@ -88,29 +92,29 @@ describe('circuit relay', () => {
8892
relayNode = res[0].ipfsd
8993

9094
nodeAAddr = tcpAddr(res[1].addrs)
91-
nodeA = res[0].ipfsd.api
95+
nodeA = res[1].ipfsd.api
9296

9397
nodeBAddr = wsAddr(res[2].addrs)
9498

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

98-
done()
102+
// ensure we have an address string
103+
expect(nodeAAddr).to.be.a('string')
104+
expect(nodeBAddr).to.be.a('string')
105+
expect(nodeBCircuitAddr).to.be.a('string')
106+
107+
series([
108+
(cb) => relayNode.api.swarm.connect(nodeAAddr, cb),
109+
(cb) => relayNode.api.swarm.connect(nodeBAddr, cb),
110+
(cb) => setTimeout(cb, 1000),
111+
(cb) => nodeA.swarm.connect(nodeBCircuitAddr, cb)
112+
], done)
99113
})
100114
})
101115

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

104-
it('should connect', function (done) {
105-
series([
106-
(cb) => relayNode.api.swarm.connect(nodeAAddr, cb),
107-
(cb) => setTimeout(cb, 1000),
108-
(cb) => relayNode.api.swarm.connect(nodeBAddr, cb),
109-
(cb) => setTimeout(cb, 1000),
110-
(cb) => nodeA.swarm.connect(nodeBCircuitAddr, cb)
111-
], done)
112-
})
113-
114118
it('should transfer', function (done) {
115119
const data = crypto.randomBytes(128)
116120
waterfall([

0 commit comments

Comments
 (0)