Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 9d66bfd

Browse files
committed
add connect Nodes a to b and c
1 parent e65b042 commit 9d66bfd

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

test/test.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,50 @@ describe('ipfs node api', function () {
8282
}
8383
})
8484

85-
it('connect Node a to b and c', function () {
85+
it('connect Node a to b and c', function (done) {
86+
var addrs = {}
87+
var counter = 0
88+
collectAddr('b', finish)
89+
collectAddr('c', finish)
90+
91+
function finish () {
92+
counter++
93+
if (counter === 2) {
94+
dial()
95+
}
96+
}
97+
98+
function collectAddr (key, cb) {
99+
apiClients[key].id(function (err, id) {
100+
if (err) {
101+
throw err
102+
}
103+
addrs[key] = ipfsNodes[key].apiAddr + '/ipfs/' + id.ID
104+
cb()
105+
})
106+
}
86107

108+
function dial () {
109+
apiClients['a'].swarm.connect(addrs['b'], function (err) {
110+
if (err) {
111+
throw err
112+
}
113+
apiClients['a'].swarm.connect(addrs['c'], function (err) {
114+
if (err) {
115+
throw err
116+
}
117+
done()
118+
})
119+
})
120+
}
121+
// apiClients['a'].id(function (err, id) {
122+
// if (err) {
123+
// throw err
124+
// }
125+
// console.log(id)
126+
// })
127+
// console.log(ipfsNodes['a'].apiAddr)
128+
// localDaemon.swarm.connect(CUBE_NODE, function (err) {})
87129
})
88130

89131
it('has the api object', function () {

0 commit comments

Comments
 (0)