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

Commit 467ef34

Browse files
committedJan 11, 2016
bootstrap add rm list complete + cli + cli tests
1 parent ef701dc commit 467ef34

File tree

4 files changed

+86
-42
lines changed

4 files changed

+86
-42
lines changed
 

‎src/cli/commands/bootstrap/add.js

+5-21
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
'use strict'
22

33
const Command = require('ronin').Command
4-
const IPFS = require('../../ipfs-core')
4+
const IPFS = require('../../../ipfs-core')
55
const debug = require('debug')
66
const log = debug('cli:version')
77
log.error = debug('cli:version:error')
88

99
module.exports = Command.extend({
10-
desc: 'Shows IPFS version information',
10+
desc: 'Show peers in the bootstrap list',
1111

12-
options: {
13-
number: {
14-
alias: 'n',
15-
type: 'boolean',
16-
default: false
17-
},
18-
commit: {
19-
type: 'boolean',
20-
default: false
21-
},
22-
repo: {
23-
type: 'boolean',
24-
default: false
25-
}
26-
},
12+
options: {},
2713

28-
run: (name) => {
14+
run: (multiaddr) => {
2915
var node = new IPFS()
30-
node.version((err, version) => {
16+
node.bootstrap.add(multiaddr, (err, list) => {
3117
if (err) { return log.error(err) }
32-
33-
console.log(version)
3418
})
3519
}
3620
})

‎src/cli/commands/bootstrap/rm.js

+5-21
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
'use strict'
22

33
const Command = require('ronin').Command
4-
const IPFS = require('../../ipfs-core')
4+
const IPFS = require('../../../ipfs-core')
55
const debug = require('debug')
66
const log = debug('cli:version')
77
log.error = debug('cli:version:error')
88

99
module.exports = Command.extend({
10-
desc: 'Shows IPFS version information',
10+
desc: 'Show peers in the bootstrap list',
1111

12-
options: {
13-
number: {
14-
alias: 'n',
15-
type: 'boolean',
16-
default: false
17-
},
18-
commit: {
19-
type: 'boolean',
20-
default: false
21-
},
22-
repo: {
23-
type: 'boolean',
24-
default: false
25-
}
26-
},
12+
options: {},
2713

28-
run: (name) => {
14+
run: (multiaddr) => {
2915
var node = new IPFS()
30-
node.version((err, version) => {
16+
node.bootstrap.rm(multiaddr, (err, list) => {
3117
if (err) { return log.error(err) }
32-
33-
console.log(version)
3418
})
3519
}
3620
})

‎src/ipfs-core/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function IPFS () {
9090
config.Bootstrap.push(multiaddr)
9191
repo.config.set(config, err => {
9292
if (err) { return callback(err) }
93+
9394
callback()
9495
})
9596
})
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* globals describe, it */
2+
3+
'use strict'
4+
5+
const expect = require('chai').expect
6+
const nexpect = require('nexpect')
7+
8+
describe('bootstrap', () => {
9+
const defaultList = [
10+
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
11+
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
12+
'/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
13+
'/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
14+
'/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
15+
'/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
16+
'/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
17+
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
18+
'/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx'
19+
]
20+
21+
const updatedList = [
22+
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
23+
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
24+
'/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
25+
'/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
26+
'/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
27+
'/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
28+
'/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
29+
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
30+
'/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx',
31+
'/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'
32+
]
33+
34+
it('list the bootstrap nodes', done => {
35+
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'list'])
36+
.run((err, stdout, exitcode) => {
37+
expect(stdout).to.deep.equal(defaultList)
38+
expect(err).to.not.exist
39+
expect(exitcode).to.equal(0)
40+
done()
41+
})
42+
})
43+
44+
it('add another bootstrap node', done => {
45+
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'add', '/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'])
46+
.run((err, stdout, exitcode) => {
47+
expect(err).to.not.exist
48+
expect(exitcode).to.equal(0)
49+
50+
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'list'])
51+
.run((err, stdout, exitcode) => {
52+
expect(stdout).to.deep.equal(updatedList)
53+
expect(err).to.not.exist
54+
expect(exitcode).to.equal(0)
55+
done()
56+
})
57+
})
58+
})
59+
60+
it('rm a bootstrap node', done => {
61+
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'rm', '/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'])
62+
.run((err, stdout, exitcode) => {
63+
expect(err).to.not.exist
64+
expect(exitcode).to.equal(0)
65+
66+
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'list'])
67+
.run((err, stdout, exitcode) => {
68+
expect(stdout).to.deep.equal(defaultList)
69+
expect(err).to.not.exist
70+
expect(exitcode).to.equal(0)
71+
done()
72+
})
73+
})
74+
})
75+
})

0 commit comments

Comments
 (0)
This repository has been archived.