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

Commit 6da7777

Browse files
author
Alan Shaw
committed
fix: bitswap HTTP tests
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent 33d508a commit 6da7777

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/http-api/inject/bitswap.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const waitFor = require('../../utils/wait-for')
77

88
module.exports = (http) => {
99
describe('/bitswap', () => {
10-
const wantedCid = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
10+
const wantedCid0 = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
11+
const wantedCid1 = 'zb2rhafnd6kEUujnoMkozHnWXY7XpWttyVDWKXfChqA42VTDU'
1112
let api
1213

1314
before(() => {
@@ -18,10 +19,8 @@ module.exports = (http) => {
1819
this.timeout(120 * 1000)
1920

2021
// Add a CID to the wantlist
21-
api.inject({
22-
method: 'GET',
23-
url: `/api/v0/block/get?arg=${wantedCid}`
24-
})
22+
api.inject({ method: 'GET', url: `/api/v0/block/get?arg=${wantedCid0}` })
23+
api.inject({ method: 'GET', url: `/api/v0/block/get?arg=${wantedCid1}` })
2524

2625
const test = (cb) => {
2726
api.inject({
@@ -31,13 +30,14 @@ module.exports = (http) => {
3130
if (res.statusCode !== 200) {
3231
return cb(new Error(`unexpected status ${res.statusCode}`))
3332
}
34-
const wanted = Boolean(res.result.Keys.find(k => k['/'] === wantedCid))
35-
cb(null, wanted)
33+
const isWanted0 = res.result.Keys.some(k => k['/'] === wantedCid0)
34+
const isWanted1 = res.result.Keys.some(k => k['/'] === wantedCid1)
35+
cb(null, isWanted0 && isWanted1)
3636
})
3737
}
3838

3939
waitFor(test, {
40-
name: wantedCid + ' to be wanted',
40+
name: `${wantedCid0} and ${wantedCid1} to be wanted`,
4141
timeout: 60 * 1000
4242
}, done)
4343
})
@@ -49,13 +49,13 @@ module.exports = (http) => {
4949
}, (res) => {
5050
expect(res.statusCode).to.equal(200)
5151
expect(res.result).to.have.property('Keys')
52-
expect(res.result.Keys).to.deep.include({ '/': wantedCid })
52+
expect(res.result.Keys).to.deep.include({ '/': wantedCid0 })
5353
done()
5454
})
5555
})
5656

5757
it('/wantlist?cid-base=base64', (done) => {
58-
const base64Cid = new CID(wantedCid).toV1().toString('base64')
58+
const base64Cid = new CID(wantedCid1).toString('base64')
5959
api.inject({
6060
method: 'GET',
6161
url: '/api/v0/bitswap/wantlist?cid-base=base64'
@@ -97,7 +97,7 @@ module.exports = (http) => {
9797
})
9898

9999
it('/stat?cid-base=base64', (done) => {
100-
const base64Cid = new CID(wantedCid).toV1().toString('base64')
100+
const base64Cid = new CID(wantedCid1).toString('base64')
101101
api.inject({
102102
method: 'GET',
103103
url: '/api/v0/bitswap/stat?cid-base=base64'

0 commit comments

Comments
 (0)