about summary refs log tree commit homepage
path: root/xt/perf-nntpd.t
diff options
context:
space:
mode:
Diffstat (limited to 'xt/perf-nntpd.t')
-rw-r--r--xt/perf-nntpd.t18
1 files changed, 7 insertions, 11 deletions
diff --git a/xt/perf-nntpd.t b/xt/perf-nntpd.t
index f73afacc..85db036c 100644
--- a/xt/perf-nntpd.t
+++ b/xt/perf-nntpd.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
@@ -8,12 +8,15 @@ use PublicInbox::Inbox;
 use Net::NNTP;
 my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless defined($inboxdir);
-my ($host_port, $group, %opts, $s, $td, $tmp_obj);
+my ($host_port, $group, $s, $td, $tmp_obj);
 use PublicInbox::TestCommon;
 
 if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
         ($host_port, $group) = ($1, $2);
         $host_port .= ":119" unless index($host_port, ':') > 0;
+        my $six = substr($host_port, 0, 1) eq '[' ? '6' : '';
+        my $cls = "IO::Socket::INET$six";
+        $cls->new(Proto => 'tcp', Timeout => 1, PeerAddr => $host_port);
 } else {
         $group = 'inbox.test.perf.nntpd';
         my $ibx = { inboxdir => $inboxdir, newsgroup => $group };
@@ -34,18 +37,11 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
         }
 
         my $sock = tcp_server();
-        ok($sock, 'sock created');
         my $cmd = [ '-nntpd', '-W0' ];
         $td = start_script($cmd, { PI_CONFIG => $pi_config }, { 3 => $sock });
-        $host_port = $sock->sockhost . ':' . $sock->sockport;
+        $host_port = tcp_host_port($sock);
+        $s = tcp_connect($sock);
 }
-%opts = (
-        PeerAddr => $host_port,
-        Proto => 'tcp',
-        Timeout => 1,
-);
-$s = IO::Socket::INET->new(%opts);
-$s->autoflush(1);
 my $buf = $s->getline;
 like($buf, qr/\A201 .* ready - post via email\r\n/s, 'got greeting');