Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 7fef266

Browse files
committed
fix: code review
1 parent c59ce77 commit 7fef266

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

test/ipns-pubsub.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const spawnGoDaemon = (callback) => {
5050

5151
const ipfsRef = '/ipfs/QmPFVLPmp9zv5Z5KUqLhe2EivAGccQW2r7M7jhVJGLZoZU'
5252

53-
describe('ipns-pubsub', () => {
53+
describe.only('ipns-pubsub', () => {
5454
let nodeAId
5555
let nodeBId
5656
let nodes = []
@@ -87,7 +87,10 @@ describe('ipns-pubsub', () => {
8787
nodeAId = ids[0]
8888
nodeBId = ids[1]
8989

90-
nodes[0].api.swarm.connect(ids[1].addresses[0], () => {
90+
nodes[0].api.swarm.connect(ids[1].addresses[0], (err) => {
91+
expect(err).to.not.exist()
92+
93+
console.log('wait for republish as we can receive the republish message first')
9194
setTimeout(done, 60000) // wait for republish as we can receive the republish message first
9295
})
9396
})
@@ -130,21 +133,22 @@ const subscribeToReceiveByPubsub = (nodeA, nodeB, id, callback) => {
130133
const keys = ipns.getIdKeys(fromB58String(id))
131134
const topic = `${namespace}${base64url.encode(keys.routingKey.toBuffer())}`
132135

133-
nodeB.api.name.resolve(id, () => {
136+
// try to resolve a unpublished record (will subscribe it)
137+
nodeB.api.name.resolve(id, (err) => {
138+
expect(err).to.exist() // not found
139+
134140
series([
135141
(cb) => waitForPeerToSubscribe(nodeB.api, topic, cb),
136142
(cb) => nodeB.api.pubsub.subscribe(topic, checkMessage, cb),
137143
(cb) => nodeA.api.name.publish(ipfsRef, { resolve: false }, cb),
138-
(cb) => nodeA.api.name.resolve(id, cb),
139144
(cb) => waitFor(() => subscribed === true, (50 * 1000), cb),
140145
(cb) => nodeB.api.name.resolve(id, cb)
141146
], (err, res) => {
142147
expect(err).to.not.exist()
143148
expect(res).to.exist()
144149

145150
expect(res[2].name).to.equal(id) // Published to Node A ID
146-
expect(res[3]).to.equal(ipfsRef) // TODO: remove path once not using proc daemon
147-
expect(res[5]).to.equal(ipfsRef)
151+
expect(res[4]).to.equal(ipfsRef)
148152

149153
callback()
150154
})

test/utils/wait-for.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ module.exports = (predicate, ttl, callback) => {
2020
clearInterval(self)
2121
return callback(new Error('waitFor time expired'))
2222
}
23-
}, 500)
23+
}, 50)
2424
}

0 commit comments

Comments
 (0)