support empty arrays in REQ filters

- These never match, so clients shouldn't really ever send them, but there is no reason to fail if they do
This commit is contained in:
Doug Hoyte
2023-01-16 14:04:44 -05:00
parent a9c69bd7c1
commit 18a7cc556a
5 changed files with 70 additions and 65 deletions

View File

@ -96,31 +96,36 @@ sub genRandomFilterGroup {
while (!keys %$f) {
if (rand() < .15) {
for (1..(rand()*10) + 1) {
$f->{ids} = [];
for (1..(rand()*10)) {
push @{$f->{ids}}, randPrefix($ids->[int(rand() * @$ids)]);
}
}
if (rand() < .3) {
for (1..(rand()*5) + 1) {
$f->{authors} = [];
for (1..(rand()*5)) {
push @{$f->{authors}}, randPrefix($pubkeys->[int(rand() * @$pubkeys)]);
}
}
if (rand() < .2) {
for (1..(rand()*5) + 1) {
$f->{kinds} = [];
for (1..(rand()*5)) {
push @{$f->{kinds}}, 0+$kinds->[int(rand() * @$kinds)];
}
}
if (rand() < .2) {
for (1..(rand()*10) + 1) {
$f->{'#e'} = [];
for (1..(rand()*10)) {
push @{$f->{'#e'}}, $ids->[int(rand() * @$ids)];
}
}
if (rand() < .2) {
for (1..(rand()*5) + 1) {
$f->{'#p'} = [];
for (1..(rand()*5)) {
push @{$f->{'#p'}}, $pubkeys->[int(rand() * @$pubkeys)];
}
}