2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 use PublicInbox::TestCommon;
7 require_mods 'IO::Socket::Socks';
8 use_ok 'PublicInbox::NetNNTPSocks';
9 my $url = $ENV{TEST_NNTP_ONION_URL} //
10 'nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta';
11 my $uri = URI->new($url);
12 my $on = PublicInbox::NetNNTPSocks->new_socks(
15 ProxyAddr => '127.0.0.1', # default Tor address + port
17 ) or xbail('err = '.eval('$IO::Socket::Socks::SOCKS_ERROR'));
18 my ($nr, $min, $max, $grp) = $on->group($uri->group);
19 ok($nr > 0 && $min > 0 && $min < $max, 'nr, min, max make sense') or
20 diag explain([$nr, $min, $max, $grp]);
21 is($grp, $uri->group, 'group matches');