This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
test/http-api/over-ipfs-api Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ module.exports = function bootstrap (self) {
2727 }
2828 if ( args . default ) {
2929 config . Bootstrap = defaultNodes
30- } else if ( multiaddr ) {
30+ } else if ( multiaddr && config . Bootstrap . indexOf ( multiaddr ) === - 1 ) {
3131 config . Bootstrap . push ( multiaddr )
3232 }
3333 self . _repo . config . set ( config , ( err ) => {
Original file line number Diff line number Diff line change @@ -28,6 +28,30 @@ module.exports = (ctl) => {
2828 } )
2929 } )
3030
31+ it ( 'prevents duplicate inserts of bootstrap peers' , ( ) => {
32+ return ctl
33+ . bootstrap
34+ . rm ( null , { all : true } )
35+ . then ( ( res ) => {
36+ expect ( res . Peers . length ) . to . equal ( 0 )
37+ return ctl . bootstrap . add ( validIp4 )
38+ } )
39+ . then ( res => {
40+ expect ( res ) . to . be . eql ( { Peers : [ validIp4 ] } )
41+ return ctl . bootstrap . add ( validIp4 )
42+ } )
43+ . then ( ( res ) => {
44+ expect ( res ) . to . be . eql ( { Peers : [ validIp4 ] } )
45+ return ctl . bootstrap . list ( )
46+ } )
47+ . then ( ( res ) => {
48+ expect ( res ) . to . exist ( )
49+ const insertPosition = res . Peers . indexOf ( validIp4 )
50+ expect ( insertPosition ) . to . not . equal ( - 1 )
51+ expect ( res . Peers . length ) . to . equal ( 1 )
52+ } )
53+ } )
54+
3155 it ( 'returns a list of bootstrap peers when called with the default option' , ( done ) => {
3256 ctl . bootstrap . add ( { default : true } , ( err , res ) => {
3357 expect ( err ) . to . not . exist ( )
You can’t perform that action at this time.
0 commit comments