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

Commit

Permalink
chore: remove gh deps and add await where it is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Feb 10, 2020
1 parent dce5d9a commit 8665317
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"ipfs-http-response": "^0.5.0",
"ipfs-mfs": "^1.0.0",
"ipfs-multipart": "^0.3.0",
"ipfs-repo": "github:ipfs/js-ipfs-repo#feat-add-is-initialized-meethod",
"ipfs-repo": "^1.0.0",
"ipfs-unixfs": "^0.3.0",
"ipfs-unixfs-exporter": "^0.41.0",
"ipfs-unixfs-importer": "^0.44.0",
Expand Down Expand Up @@ -185,7 +185,7 @@
"hat": "0.0.3",
"interface-ipfs-core": "^0.132.0",
"ipfs-interop": "github:ipfs/interop#refactor/async-await",
"ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#refactor/remove-path-ref-findbin",
"ipfsd-ctl": "^3.0.0",
"ncp": "^2.0.0",
"p-event": "^4.1.0",
"p-map": "^3.0.0",
Expand Down
18 changes: 8 additions & 10 deletions test/core/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,29 @@ describe('bitswap', function () {
this.timeout(60 * 1000)
const df = factory()

afterEach(() => df.clean())

describe('transfer a block between', () => {
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)
const b = await remote.block.get(block.cid)

expect(b.data).to.eql(block.data)
await df.clean()
})

it('3 peers', async () => {
const blocks = await Promise.all([...Array(6).keys()].map(() => makeBlock()))
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 @@ -57,7 +58,6 @@ describe('bitswap', function () {
expect(await remote2.block.get(block.cid)).to.eql(block)
expect(await proc.block.get(block.cid)).to.eql(block)
}, { concurrency: 3 })
await df.clean()
})
})

Expand All @@ -66,14 +66,14 @@ describe('bitswap', function () {
// TODO make this test more interesting (10Mb file)
// TODO remove randomness from the test
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))
expect(data.slice()).to.eql(file)
await df.clean()
})
})

Expand All @@ -85,8 +85,6 @@ describe('bitswap', function () {
} catch (err) {
expect(err).to.exist()
expect(err.code).to.equal('ERR_INVALID_CID')
} finally {
await df.clean()
}
})
})
Expand Down
4 changes: 4 additions & 0 deletions test/core/create-node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ describe('create node', function () {
repo: tempRepo,
init: { bits: 512 },
config: {
Addresses: {
Swarm: []
},
Bootstrap: [],
Pubsub: {
Enabled: false
}
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 8665317

Please sign in to comment.