test for querying non-fixed-size tags (#t)

This commit is contained in:
Doug Hoyte
2023-05-18 23:16:37 -04:00
parent 76ba9081b1
commit b61167fdf8
2 changed files with 31 additions and 0 deletions

View File

@ -102,6 +102,19 @@ sub doesMatchSingle {
return 0 if !$found; return 0 if !$found;
} }
if ($filter->{'#t'}) {
my $found;
foreach my $search (@{ $filter->{'#t'} }) {
foreach my $tag (@{ $ev->{tags} }) {
if ($tag->[0] eq 't' && $tag->[1] eq $search) {
$found = 1;
last;
}
}
}
return 0 if !$found;
}
return 1; return 1;
} }

View File

@ -87,6 +87,17 @@ c1e5e04d92d9bd20701bff4cbdac1cdc317d405035883b7adcf9a6a5308d0f54
3a15cb7cf951de54a23585ca003c96ca9a7c49fbf8e436575ff9bb710af301f0 3a15cb7cf951de54a23585ca003c96ca9a7c49fbf8e436575ff9bb710af301f0
}]; }];
my $topics = [qw{
bitcoin
nostr
gitlog
introductions
jb55
damus
chat
nosuchtopic
}];
sub genRandomFilterGroup { sub genRandomFilterGroup {
my $useLimit = shift; my $useLimit = shift;
@ -131,6 +142,13 @@ sub genRandomFilterGroup {
push @{$f->{'#p'}}, $pubkeys->[int(rand() * @$pubkeys)]; push @{$f->{'#p'}}, $pubkeys->[int(rand() * @$pubkeys)];
} }
} }
if (rand() < .2) {
$f->{'#t'} = [];
for (1..(rand()*5)) {
push @{$f->{'#t'}}, $topics->[int(rand() * @$topics)];
}
}
} }
if (rand() < .2) { if (rand() < .2) {