@@ -5,20 +5,21 @@ describe('parse NIP10-referenced events', () => {
5
5
test ( 'legacy + a lot of events' , ( ) => {
6
6
let event = {
7
7
tags : [
8
- [ 'e' , 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ] ,
9
- [ 'e' , 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' ] ,
10
- [ 'e' , '5e081ebb19153357d7c31e8a10b9ceeef29313f58dc8d701f66727fab02aef64' ] ,
11
- [ 'e' , '49aff7ae6daeaaa2777931b90f9bb29f6cb01c5a3d7d88c8ba82d890f264afb4' ] ,
12
- [ 'e' , '567b7c11f0fe582361e3cea6fcc7609a8942dfe196ee1b98d5604c93fbeea976' ] ,
13
- [ 'e' , '090c037b2e399ee74d9f134758928948dd9154413ca1a1acb37155046e03a051' ] ,
14
- [ 'e' , '89f220b63465c93542b1a78caa3a952cf4f196e91a50596493c8093c533ebc4d' ] ,
15
- [ 'p' , '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ] ,
16
- [ 'p' , '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ] ,
17
8
[ 'p' , '4ca4f5533e40da5e0508796d409e6bb35a50b26fc304345617ab017183d83ac0' ] ,
9
+ [ 'p' , '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ] ,
10
+ [ 'p' , '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ] ,
11
+ [ 'e' , '89f220b63465c93542b1a78caa3a952cf4f196e91a50596493c8093c533ebc4d' ] ,
12
+ [ 'e' , '090c037b2e399ee74d9f134758928948dd9154413ca1a1acb37155046e03a051' ] ,
13
+ [ 'e' , '567b7c11f0fe582361e3cea6fcc7609a8942dfe196ee1b98d5604c93fbeea976' ] ,
14
+ [ 'e' , '49aff7ae6daeaaa2777931b90f9bb29f6cb01c5a3d7d88c8ba82d890f264afb4' ] ,
15
+ [ 'e' , '5e081ebb19153357d7c31e8a10b9ceeef29313f58dc8d701f66727fab02aef64' ] ,
16
+ [ 'e' , 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' ] ,
17
+ [ 'e' , 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ] ,
18
18
] ,
19
19
}
20
20
21
21
expect ( parse ( event ) ) . toEqual ( {
22
+ quotes : [ ] ,
22
23
mentions : [
23
24
{
24
25
id : 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' ,
@@ -55,41 +56,37 @@ describe('parse NIP10-referenced events', () => {
55
56
relays : [ ] ,
56
57
} ,
57
58
] ,
58
- reply : {
59
+ root : {
59
60
id : '89f220b63465c93542b1a78caa3a952cf4f196e91a50596493c8093c533ebc4d' ,
60
61
relays : [ ] ,
61
62
} ,
62
- root : {
63
+ reply : {
63
64
id : 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ,
64
65
relays : [ ] ,
65
66
} ,
66
67
} )
67
68
} )
68
69
69
- test ( 'legacy + 3 events ' , ( ) => {
70
+ test ( 'modern ' , ( ) => {
70
71
let event = {
71
72
tags : [
72
- [ 'e' , 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ] ,
73
- [ 'e' , 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' ] ,
74
- [ 'e' , '5e081ebb19153357d7c31e8a10b9ceeef29313f58dc8d701f66727fab02aef64' ] ,
75
- [ 'p' , '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ] ,
76
- [ 'p' , '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ] ,
77
73
[ 'p' , '4ca4f5533e40da5e0508796d409e6bb35a50b26fc304345617ab017183d83ac0' ] ,
74
+ [ 'p' , '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ] ,
75
+ [ 'e' , '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ] ,
76
+ [ 'e' , 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' , '' , 'root' ] ,
77
+ [ 'e' , 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' , '' , 'reply' ] ,
78
78
] ,
79
79
}
80
80
81
81
expect ( parse ( event ) ) . toEqual ( {
82
+ quotes : [ ] ,
82
83
mentions : [
83
84
{
84
- id : 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631 ' ,
85
+ id : '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7 ' ,
85
86
relays : [ ] ,
86
87
} ,
87
88
] ,
88
89
profiles : [
89
- {
90
- pubkey : '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ,
91
- relays : [ ] ,
92
- } ,
93
90
{
94
91
pubkey : '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ,
95
92
relays : [ ] ,
@@ -99,30 +96,43 @@ describe('parse NIP10-referenced events', () => {
99
96
relays : [ ] ,
100
97
} ,
101
98
] ,
102
- reply : {
103
- id : '5e081ebb19153357d7c31e8a10b9ceeef29313f58dc8d701f66727fab02aef64 ' ,
99
+ root : {
100
+ id : 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631 ' ,
104
101
relays : [ ] ,
105
102
} ,
106
- root : {
103
+ reply : {
107
104
id : 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ,
108
105
relays : [ ] ,
109
106
} ,
110
107
} )
111
108
} )
112
109
113
- test ( 'legacy + 2 events ' , ( ) => {
110
+ test ( 'modern, inverted, author hint ' , ( ) => {
114
111
let event = {
115
112
tags : [
116
- [ 'e' , 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ] ,
117
- [ 'e' , 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' ] ,
118
- [ 'p' , '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ] ,
113
+ [ 'p' , '4ca4f5533e40da5e0508796d409e6bb35a50b26fc304345617ab017183d83ac0' , 'wss://goiaba.com' ] ,
119
114
[ 'p' , '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ] ,
120
- [ 'p' , '4ca4f5533e40da5e0508796d409e6bb35a50b26fc304345617ab017183d83ac0' ] ,
115
+ [ 'p' , '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ] ,
116
+ [ 'e' , '5e081ebb19153357d7c31e8a10b9ceeef29313f58dc8d701f66727fab02aef64' , '' , 'reply' ] ,
117
+ [
118
+ 'e' ,
119
+ 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' ,
120
+ 'wss://banana.com' ,
121
+ 'root' ,
122
+ '4ca4f5533e40da5e0508796d409e6bb35a50b26fc304345617ab017183d83ac0' ,
123
+ ] ,
124
+ [ 'e' , 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ] ,
121
125
] ,
122
126
}
123
127
124
128
expect ( parse ( event ) ) . toEqual ( {
125
- mentions : [ ] ,
129
+ quotes : [ ] ,
130
+ mentions : [
131
+ {
132
+ id : 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c' ,
133
+ relays : [ ] ,
134
+ } ,
135
+ ] ,
126
136
profiles : [
127
137
{
128
138
pubkey : '77ce56f89d1228f7ff3743ce1ad1b254857b9008564727ebd5a1f317362f6ca7' ,
@@ -134,60 +144,80 @@ describe('parse NIP10-referenced events', () => {
134
144
} ,
135
145
{
136
146
pubkey : '4ca4f5533e40da5e0508796d409e6bb35a50b26fc304345617ab017183d83ac0' ,
137
- relays : [ ] ,
147
+ relays : [ 'wss://banana.com' , 'wss://goiaba.com' ] ,
138
148
} ,
139
149
] ,
140
- reply : {
150
+ root : {
141
151
id : 'bbd72f0ae14374aa8fb166b483cfcf99b57d7f4cf1600ccbf17c350040834631' ,
142
- relays : [ ] ,
152
+ relays : [ 'wss://banana.com' , 'wss://goiaba.com' ] ,
153
+ author : '4ca4f5533e40da5e0508796d409e6bb35a50b26fc304345617ab017183d83ac0' ,
143
154
} ,
144
- root : {
145
- id : 'b857504288c18a15950dd05b9e8772c62ca6289d5aac373c0a8ee5b132e94e7c ' ,
155
+ reply : {
156
+ id : '5e081ebb19153357d7c31e8a10b9ceeef29313f58dc8d701f66727fab02aef64 ' ,
146
157
relays : [ ] ,
147
158
} ,
148
159
} )
149
160
} )
150
161
151
- test ( 'legacy + 1 event' , ( ) => {
162
+ test ( '1 event, relay hint from author ' , ( ) => {
152
163
let event = {
153
164
tags : [
154
- [ 'e' , '9abbfd9b9ac5ecdab45d14b8bf8d746139ea039e931a1b376d19a239f1946590' ] ,
155
- [ 'p' , '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ] ,
165
+ [ 'p' , '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' , 'wss://banana.com' ] ,
166
+ [
167
+ 'e' ,
168
+ '9abbfd9b9ac5ecdab45d14b8bf8d746139ea039e931a1b376d19a239f1946590' ,
169
+ '' ,
170
+ 'root' ,
171
+ '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ,
172
+ ] ,
156
173
] ,
157
174
}
158
175
159
176
expect ( parse ( event ) ) . toEqual ( {
177
+ quotes : [ ] ,
160
178
mentions : [ ] ,
161
179
profiles : [
162
180
{
163
181
pubkey : '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ,
164
- relays : [ ] ,
182
+ relays : [ 'wss://banana.com' ] ,
165
183
} ,
166
184
] ,
167
- reply : undefined ,
185
+ reply : {
186
+ author : '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ,
187
+ id : '9abbfd9b9ac5ecdab45d14b8bf8d746139ea039e931a1b376d19a239f1946590' ,
188
+ relays : [ 'wss://banana.com' ] ,
189
+ } ,
168
190
root : {
191
+ author : '534780e44da7b494485e85cd4cca6af4f6caa1627472432b6f2a4ece0e9e54ec' ,
169
192
id : '9abbfd9b9ac5ecdab45d14b8bf8d746139ea039e931a1b376d19a239f1946590' ,
170
- relays : [ ] ,
193
+ relays : [ 'wss://banana.com' ] ,
171
194
} ,
172
195
} )
173
196
} )
174
197
175
- test ( 'recommended + 1 event ' , ( ) => {
198
+ test ( 'many p 1 reply ' , ( ) => {
176
199
let event = {
177
200
tags : [
178
- [ 'p' , 'a8c21fcd8aa1f4befba14d72fc7a012397732d30d8b3131af912642f3c726f52' , 'wss://relay.mostr.pub' ] ,
179
- [ 'p' , '003d7fd21fd09ff7f6f63a75daf194dd99feefbe6919cc376b7359d5090aa9a6' , 'wss://relay.mostr.pub' ] ,
180
- [ 'p' , '2f6fbe452edd3987d3c67f3b034c03ec5bcf4d054c521c3a954686f89f03212e' , 'wss://relay.mostr.pub' ] ,
181
- [ 'p' , '44c7c74668ff222b0e0b30579c49fc6e22dafcdeaad091036c947f9856590f1e' , 'wss://relay.mostr.pub' ] ,
182
- [ 'p' , 'c5cf39149caebda4cdd61771c51f6ba91ef5645919004e5c4998a4ea69f00512' , 'wss://relay.mostr.pub' ] ,
183
- [ 'p' , '094d44bb1e812696c57f57ad1c0c707812dedbe72c07e538b80639032c236a9e' , 'wss://relay.mostr.pub' ] ,
184
201
[ 'p' , 'a1ba0ac9b6ec098f726a3c11ec654df4a32cbb84b5377e8788395e9c27d9ecda' , 'wss://relay.mostr.pub' ] ,
185
- [ 'e' , 'f9472913904ab7e9da008dcb2d85fd4af2d2993ada483d00c646d0c4481d031d' , 'wss://relay.mostr.pub' , 'reply' ] ,
202
+ [ 'p' , '094d44bb1e812696c57f57ad1c0c707812dedbe72c07e538b80639032c236a9e' , 'wss://relay.mostr.pub' ] ,
203
+ [ 'p' , 'c5cf39149caebda4cdd61771c51f6ba91ef5645919004e5c4998a4ea69f00512' , 'wss://relay.mostr.pub' ] ,
204
+ [ 'p' , '44c7c74668ff222b0e0b30579c49fc6e22dafcdeaad091036c947f9856590f1e' , 'wss://relay.mostr.pub' ] ,
205
+ [ 'p' , '2f6fbe452edd3987d3c67f3b034c03ec5bcf4d054c521c3a954686f89f03212e' , 'wss://relay.mostr.pub' ] ,
206
+ [ 'p' , '003d7fd21fd09ff7f6f63a75daf194dd99feefbe6919cc376b7359d5090aa9a6' , 'wss://relay.mostr.pub' ] ,
207
+ [ 'p' , 'a8c21fcd8aa1f4befba14d72fc7a012397732d30d8b3131af912642f3c726f52' , 'wss://relay.mostr.pub' ] ,
208
+ [
209
+ 'e' ,
210
+ 'f9472913904ab7e9da008dcb2d85fd4af2d2993ada483d00c646d0c4481d031d' ,
211
+ 'wss://relay.mostr.pub' ,
212
+ 'reply' ,
213
+ 'c5cf39149caebda4cdd61771c51f6ba91ef5645919004e5c4998a4ea69f00512' ,
214
+ ] ,
186
215
[ 'mostr' , 'https://poa.st/objects/dc50684b-6364-4264-ab16-49f4622f05ea' ] ,
187
216
] ,
188
217
}
189
218
190
219
expect ( parse ( event ) ) . toEqual ( {
220
+ quotes : [ ] ,
191
221
mentions : [ ] ,
192
222
profiles : [
193
223
{
@@ -222,8 +252,13 @@ describe('parse NIP10-referenced events', () => {
222
252
reply : {
223
253
id : 'f9472913904ab7e9da008dcb2d85fd4af2d2993ada483d00c646d0c4481d031d' ,
224
254
relays : [ 'wss://relay.mostr.pub' ] ,
255
+ author : 'c5cf39149caebda4cdd61771c51f6ba91ef5645919004e5c4998a4ea69f00512' ,
256
+ } ,
257
+ root : {
258
+ id : 'f9472913904ab7e9da008dcb2d85fd4af2d2993ada483d00c646d0c4481d031d' ,
259
+ relays : [ 'wss://relay.mostr.pub' ] ,
260
+ author : 'c5cf39149caebda4cdd61771c51f6ba91ef5645919004e5c4998a4ea69f00512' ,
225
261
} ,
226
- root : undefined ,
227
262
} )
228
263
} )
229
264
} )
0 commit comments