From 765d2a36461ac279684ae80031c3da9f25c55ec8 Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Fri, 22 Nov 2019 16:51:25 +0000 Subject: [PATCH] fix: bootstrap rm return value when all option is set --- src/core/components/bootstrap.js | 3 ++- test/cli/bootstrap.js | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/components/bootstrap.js b/src/core/components/bootstrap.js index 156ecc1134..dad39cdd26 100644 --- a/src/core/components/bootstrap.js +++ b/src/core/components/bootstrap.js @@ -45,8 +45,10 @@ 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) @@ -54,7 +56,6 @@ module.exports = function bootstrap (self) { await self._repo.config.set(config) - const res = [] if (!args.all && multiaddr) { res.push(multiaddr) } diff --git a/test/cli/bootstrap.js b/test/cli/bootstrap.js index 3d5f0f6562..b9e4f1659b 100644 --- a/test/cli/bootstrap.js +++ b/test/cli/bootstrap.js @@ -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('') }) }))