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

Commit

Permalink
fix: await on things that need awaiting on (#2773)
Browse files Browse the repository at this point in the history
These are async methods and can result in unhandledPromiseRejection
events :(
  • Loading branch information
achingbrain authored Feb 13, 2020
1 parent b6ea4a7 commit ffb1ebe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions test/core/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('bitswap', function () {
it('2 peers', async function () {
const remote = (await df.spawn({ type: 'js' })).api
const proc = (await df.spawn({ type: 'proc' })).api
proc.swarm.connect(remote.peerId.addresses[0])
await proc.swarm.connect(remote.peerId.addresses[0])
const block = await makeBlock()

await proc.block.put(block)
Expand All @@ -41,9 +41,9 @@ describe('bitswap', function () {
const remote1 = (await df.spawn({ type: 'js' })).api
const remote2 = (await df.spawn({ type: 'js' })).api
const proc = (await df.spawn({ type: 'proc' })).api
proc.swarm.connect(remote1.peerId.addresses[0])
proc.swarm.connect(remote2.peerId.addresses[0])
remote1.swarm.connect(remote2.peerId.addresses[0])
await proc.swarm.connect(remote1.peerId.addresses[0])
await proc.swarm.connect(remote2.peerId.addresses[0])
await remote1.swarm.connect(remote2.peerId.addresses[0])

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

const files = await all(remote.add([{ path: 'awesome.txt', content: file }]))
const data = await concat(proc.cat(files[0].cid))
Expand Down
6 changes: 3 additions & 3 deletions test/core/name.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ describe('name', function () {
nodeB = (await createNode()).api
nodeC = (await createNode()).api

nodeC.swarm.connect(nodeA.peerId.addresses[0]) // C => A
nodeC.swarm.connect(nodeB.peerId.addresses[0]) // C => B
nodeA.swarm.connect(nodeB.peerId.addresses[0]) // A => B
await nodeC.swarm.connect(nodeA.peerId.addresses[0]) // C => A
await nodeC.swarm.connect(nodeB.peerId.addresses[0]) // C => B
await nodeA.swarm.connect(nodeB.peerId.addresses[0]) // A => B
})

after(() => df.clean())
Expand Down

0 comments on commit ffb1ebe

Please sign in to comment.