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

fix: bootstrap rm return value when all option is set #2626

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/components/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ module.exports = function bootstrap (self) {
throw invalidMultiaddrError(multiaddr)
}

let res = []
const config = await self._repo.config.get()
if (args.all) {
res = config.Bootstrap
config.Bootstrap = []
} else {
config.Bootstrap = config.Bootstrap.filter((mh) => mh !== multiaddr)
}

await self._repo.config.set(config)

const res = []
if (!args.all && multiaddr) {
res.push(multiaddr)
}
Expand Down
10 changes: 6 additions & 4 deletions test/cli/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ describe('bootstrap', () => runOnAndOff((thing) => {
it('rm all bootstrap nodes', async function () {
this.timeout(40 * 1000)

const out = await ipfs('bootstrap rm --all')
expect(out).to.equal('')
const outListBefore = await ipfs('bootstrap list')

const out2 = await ipfs('bootstrap list')
expect(out2).to.equal('')
const outRm = await ipfs('bootstrap rm --all')
expect(outRm).to.equal(outListBefore)

const outListAfter = await ipfs('bootstrap list')
expect(outListAfter).to.equal('')
})
}))
2 changes: 1 addition & 1 deletion test/http-api/inject/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = (http) => {
})

expect(res.statusCode).to.be.eql(200)
expect(res.result.Peers).to.be.eql([])
expect(res.result.Peers).to.be.eql(defaultList)
})
})
}