This repository was archived by the owner on Jul 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -135,11 +135,8 @@ export class PersistentPeerStore extends EventEmitter<PeerStoreEvents> implement
135135 tags = Tags . decode ( buf ) . tags
136136 }
137137
138- for ( const t of tags ) {
139- if ( t . name === tag ) {
140- throw new CodeError ( 'Peer already tagged' , 'ERR_DUPLICATE_TAG' )
141- }
142- }
138+ // do not allow duplicate tags
139+ tags = tags . filter ( t => t . name !== tag )
143140
144141 tags . push ( {
145142 name : tag ,
Original file line number Diff line number Diff line change @@ -288,10 +288,18 @@ describe('peer-store', () => {
288288
289289 it ( 'does not tag a peer twice' , async ( ) => {
290290 const name = 'a-tag'
291- await peerStore . tagPeer ( peerIds [ 0 ] , name )
291+ await peerStore . tagPeer ( peerIds [ 0 ] , name , {
292+ value : 1
293+ } )
294+ await peerStore . tagPeer ( peerIds [ 0 ] , name , {
295+ value : 10
296+ } )
297+
298+ const allTags = await peerStore . getTags ( peerIds [ 0 ] )
299+ const tags = allTags . filter ( t => t . name === name )
292300
293- await expect ( peerStore . tagPeer ( peerIds [ 0 ] , name ) , 'PeerStore allowed duplicate tags' )
294- . to . eventually . be . rejected ( ) . with . property ( 'code ' , 'ERR_DUPLICATE_TAG' )
301+ expect ( tags ) . to . have . lengthOf ( 1 )
302+ expect ( tags ) . to . have . nested . property ( '[0].value ' , 10 )
295303 } )
296304
297305 it ( 'untags a peer' , async ( ) => {
You can’t perform that action at this time.
0 commit comments