This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 2 files changed +25
-1
lines changed
test/http-api/over-ipfs-api
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) {
27
27
}
28
28
if ( args . default ) {
29
29
config . Bootstrap = defaultNodes
30
- } else if ( multiaddr ) {
30
+ } else if ( multiaddr && config . Bootstrap . indexOf ( multiaddr ) === - 1 ) {
31
31
config . Bootstrap . push ( multiaddr )
32
32
}
33
33
self . _repo . config . set ( config , ( err ) => {
Original file line number Diff line number Diff line change @@ -28,6 +28,30 @@ module.exports = (ctl) => {
28
28
} )
29
29
} )
30
30
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
+
31
55
it ( 'returns a list of bootstrap peers when called with the default option' , ( done ) => {
32
56
ctl . bootstrap . add ( { default : true } , ( err , res ) => {
33
57
expect ( err ) . to . not . exist ( )
You can’t perform that action at this time.
0 commit comments