diff --git a/test/dumbFilter.pl b/test/dumbFilter.pl index 138be4d..eabaab6 100644 --- a/test/dumbFilter.pl +++ b/test/dumbFilter.pl @@ -102,6 +102,19 @@ sub doesMatchSingle { 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; } diff --git a/test/filterFuzzTest.pl b/test/filterFuzzTest.pl index 2fb87c7..cfed927 100644 --- a/test/filterFuzzTest.pl +++ b/test/filterFuzzTest.pl @@ -87,6 +87,17 @@ c1e5e04d92d9bd20701bff4cbdac1cdc317d405035883b7adcf9a6a5308d0f54 3a15cb7cf951de54a23585ca003c96ca9a7c49fbf8e436575ff9bb710af301f0 }]; +my $topics = [qw{ +bitcoin +nostr +gitlog +introductions +jb55 +damus +chat +nosuchtopic +}]; + sub genRandomFilterGroup { my $useLimit = shift; @@ -131,6 +142,13 @@ sub genRandomFilterGroup { 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) {