From 7f3f4923ec711ec97a1204ec2c080e219f50ff3b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 2 Sep 2019 04:51:31 +0000 Subject: tests: add tcp_connect() helper IO::Socket::INET->new is rather verbose with the options hash, extract it into a standalone sub --- t/nntpd.t | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 't/nntpd.t') diff --git a/t/nntpd.t b/t/nntpd.t index b47cf7db..aa686e9c 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -119,12 +119,6 @@ EOF is($n->code, 580, 'got 580 code on server w/o TLS'); }; - %opts = ( - PeerAddr => $host_port, - Proto => 'tcp', - Type => SOCK_STREAM, - Timeout => 1, - ); my $mid = ''; my %xhdr = ( 'message-id' => $mid, @@ -137,22 +131,20 @@ EOF 'references' => '', ); - my $s = IO::Socket::INET->new(%opts); + my $s = tcp_connect($sock); sysread($s, my $buf, 4096); is($buf, "201 " . hostname . " ready - post via email\r\n", 'got greeting'); - $s->autoflush(1); ok(syswrite($s, " \r\n"), 'wrote spaces'); ok(syswrite($s, "\r\n"), 'wrote nothing'); syswrite($s, "NEWGROUPS\t19990424 000000 \033GMT\007\r\n"); is(0, sysread($s, $buf, 4096), 'GOT EOF on cntrl'); - $s = IO::Socket::INET->new(%opts); + $s = tcp_connect($sock); sysread($s, $buf, 4096); is($buf, "201 " . hostname . " ready - post via email\r\n", 'got greeting'); - $s->autoflush(1); syswrite($s, "CAPABILITIES\r\n"); $buf = read_til_dot($s); -- cgit v1.2.3-24-ge0c7