+ my $long_hdr = 'for-leafnode-'.('y'x200).'@example.com';
+ $for_leafnode->header_set('Message-ID', "<$long_hdr>");
+ $im->add($for_leafnode);
+ $im->done;
+ if ($version == 1) {
+ my $s = PublicInbox::SearchIdx->new($ibx, 1);
+ $s->index_sync;
+ }
+ my $hdr = $n->head("<$long_hdr>");
+ my $expect = qr/\AMessage-ID: /i . qr/\Q<$long_hdr>\E/;
+ ok(scalar(grep(/$expect/, @$hdr)), 'Message-ID not folded');
+ ok(scalar(grep(/^Path:/, @$hdr)), 'Path: header found');
+
+ # it's possible for v2 messages to have 2+ Message-IDs,
+ # but leafnode can't handle it
+ if ($version != 1) {
+ my @mids = ("<$long_hdr>", '<2mid@wtf>');
+ $for_leafnode->header_set('Message-ID', @mids);
+ $for_leafnode->body_set('not-a-dupe');
+ my $warn = '';
+ $SIG{__WARN__} = sub { $warn .= join('', @_) };
+ $im->add($for_leafnode);
+ $im->done;
+ like($warn, qr/reused/, 'warned for reused MID');
+ $hdr = $n->head('<2mid@wtf>');
+ my @hmids = grep(/\AMessage-ID: /i, @$hdr);
+ is(scalar(@hmids), 1, 'Single Message-ID in header');
+ like($hmids[0], qr/: <2mid\@wtf>/, 'got expected mid');
+ }
+ }
+
+ # pipelined requests:
+ {
+ my $nreq = 90;
+ syswrite($s, "GROUP $group\r\n");
+ my $res = <$s>;
+ my $rdr = fork;
+ if ($rdr == 0) {
+ use POSIX qw(_exit);
+ for (1..$nreq) {
+ <$s> =~ /\A224 / or _exit(1);
+ <$s> =~ /\A1/ or _exit(2);
+ <$s> eq ".\r\n" or _exit(3);
+ }
+ _exit(0);
+ }
+ for (1..$nreq) {
+ syswrite($s, "XOVER 1\r\n");
+ }
+ is($rdr, waitpid($rdr, 0), 'reader done');
+ is($? >> 8, 0, 'no errors');
+ }
+ SKIP: {
+ my @of = `lsof -p $td->{pid} 2>/dev/null`;
+ skip('lsof broken', 1) if (!scalar(@of) || $?);
+ my @xap = grep m!Search/Xapian!, @of;
+ is_deeply(\@xap, [], 'Xapian not loaded in nntpd');
+ }