@@ -13,6 +13,7 @@ import {
1313 isGiftWrapEvent ,
1414 isMarmotGroupEvent ,
1515 isParameterizedReplaceableEvent ,
16+ isProtectedEvent ,
1617 isReplaceableEvent ,
1718 isRequestToVanishEvent ,
1819 isSealEvent ,
@@ -655,3 +656,56 @@ describe('NIP-40', () => {
655656 } )
656657 } )
657658} )
659+
660+ describe ( 'NIP-70' , ( ) => {
661+ describe ( 'isProtectedEvent' , ( ) => {
662+ it ( 'returns true if event has a ["-"] tag' , ( ) => {
663+ const event : Event = {
664+ tags : [ [ '-' ] ] ,
665+ } as any
666+ expect ( isProtectedEvent ( event ) ) . to . be . true
667+ } )
668+
669+ it ( 'returns true if protected tag has extra values' , ( ) => {
670+ const event : Event = {
671+ tags : [ [ '-' , 'some-reason' ] ] ,
672+ } as any
673+ expect ( isProtectedEvent ( event ) ) . to . be . true
674+ } )
675+
676+ it ( 'returns false if event has no tags' , ( ) => {
677+ const event : Event = {
678+ tags : [ ] ,
679+ } as any
680+ expect ( isProtectedEvent ( event ) ) . to . be . false
681+ } )
682+
683+ it ( 'returns false if event has unrelated tags' , ( ) => {
684+ const event : Event = {
685+ tags : [
686+ [ 'e' , '7377fa81fc6c7ae7f7f4ef8938d4a603f7bf98183b35ab128235cc92d4bebf96' ] ,
687+ [ 'p' , '22e804d26ed16b68db5259e78449e96dab5d464c8f470bda3eb1a70467f2c793' ] ,
688+ ] ,
689+ } as any
690+ expect ( isProtectedEvent ( event ) ) . to . be . false
691+ } )
692+
693+ it ( 'returns false if "-" appears as a tag value, not a tag name' , ( ) => {
694+ const event : Event = {
695+ tags : [ [ 'e' , '-' ] ] ,
696+ } as any
697+ expect ( isProtectedEvent ( event ) ) . to . be . false
698+ } )
699+
700+ it ( 'returns true when protected tag is among other tags' , ( ) => {
701+ const event : Event = {
702+ tags : [
703+ [ 'e' , '7377fa81fc6c7ae7f7f4ef8938d4a603f7bf98183b35ab128235cc92d4bebf96' ] ,
704+ [ '-' ] ,
705+ [ 'p' , '22e804d26ed16b68db5259e78449e96dab5d464c8f470bda3eb1a70467f2c793' ] ,
706+ ] ,
707+ } as any
708+ expect ( isProtectedEvent ( event ) ) . to . be . true
709+ } )
710+ } )
711+ } )
0 commit comments