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

Commit b94fe54

Browse files
achingbrainAlan Shaw
authored and
Alan Shaw
committed
fix: await on things that need awaiting on (#2773)
These are async methods and can result in unhandledPromiseRejection events :(
1 parent 48aa3fa commit b94fe54

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

test/core/bitswap.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('bitswap', function () {
2626
it('2 peers', async function () {
2727
const remote = (await df.spawn({ type: 'js' })).api
2828
const proc = (await df.spawn({ type: 'proc' })).api
29-
proc.swarm.connect(remote.peerId.addresses[0])
29+
await proc.swarm.connect(remote.peerId.addresses[0])
3030
const block = await makeBlock()
3131

3232
await proc.block.put(block)
@@ -41,9 +41,9 @@ describe('bitswap', function () {
4141
const remote1 = (await df.spawn({ type: 'js' })).api
4242
const remote2 = (await df.spawn({ type: 'js' })).api
4343
const proc = (await df.spawn({ type: 'proc' })).api
44-
proc.swarm.connect(remote1.peerId.addresses[0])
45-
proc.swarm.connect(remote2.peerId.addresses[0])
46-
remote1.swarm.connect(remote2.peerId.addresses[0])
44+
await proc.swarm.connect(remote1.peerId.addresses[0])
45+
await proc.swarm.connect(remote2.peerId.addresses[0])
46+
await remote1.swarm.connect(remote2.peerId.addresses[0])
4747

4848
await remote1.block.put(blocks[0])
4949
await remote1.block.put(blocks[1])
@@ -68,7 +68,7 @@ describe('bitswap', function () {
6868
const file = Buffer.from(`I love IPFS <3 ${hat()}`)
6969
const remote = (await df.spawn({ type: 'js' })).api
7070
const proc = (await df.spawn({ type: 'proc' })).api
71-
proc.swarm.connect(remote.peerId.addresses[0])
71+
await proc.swarm.connect(remote.peerId.addresses[0])
7272

7373
const files = await all(remote.add([{ path: 'awesome.txt', content: file }]))
7474
const data = await concat(proc.cat(files[0].cid))

test/core/name.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ describe('name', function () {
9090
nodeB = (await createNode()).api
9191
nodeC = (await createNode()).api
9292

93-
nodeC.swarm.connect(nodeA.peerId.addresses[0]) // C => A
94-
nodeC.swarm.connect(nodeB.peerId.addresses[0]) // C => B
95-
nodeA.swarm.connect(nodeB.peerId.addresses[0]) // A => B
93+
await nodeC.swarm.connect(nodeA.peerId.addresses[0]) // C => A
94+
await nodeC.swarm.connect(nodeB.peerId.addresses[0]) // C => B
95+
await nodeA.swarm.connect(nodeB.peerId.addresses[0]) // A => B
9696
})
9797

9898
after(() => df.clean())

0 commit comments

Comments
 (0)