|
| 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