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

Commit

Permalink
fix: bootstrap rm return value when all option is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Santos committed Nov 25, 2019
1 parent 0671a5e commit ab5634d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
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)
})
})
}

0 comments on commit ab5634d

Please sign in to comment.