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
135
135
tags = Tags . decode ( buf ) . tags
136
136
}
137
137
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 )
143
140
144
141
tags . push ( {
145
142
name : tag ,
Original file line number Diff line number Diff line change @@ -288,10 +288,18 @@ describe('peer-store', () => {
288
288
289
289
it ( 'does not tag a peer twice' , async ( ) => {
290
290
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 )
292
300
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 )
295
303
} )
296
304
297
305
it ( 'untags a peer' , async ( ) => {
You can’t perform that action at this time.
0 commit comments