Skip to content

Commit

Permalink
Adding tests for BEP 23
Browse files Browse the repository at this point in the history
  • Loading branch information
sanko committed Dec 29, 2011
1 parent f45e33d commit 85c0a36
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,7 +1,7 @@
Version 1.0.0 | Soon | xxxxxxxxxx

API Changes/Compatibility Information:
* New utility function ::BEP06::generate_fast_set( ... )
* New utility function ::BEP06::generate_fast_set(...)

Documentation/Sample Code/Test Suite:
* Example script is now a standalone module: AnyEvent::BitTorrent
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -18,4 +18,5 @@ t/0003_net_bittorrent_protocol_bep03_bencode.t
t/0006_net_bittorrent_protocol_bep06.t
t/0007_net_bittorrent_protocol_bep07.t
t/0010_net_bittorrent_protocol_bep10.t
t/0023_net_bittorrent_protocol_bep23.t
TODO
1 change: 0 additions & 1 deletion TODO
Expand Up @@ -2,7 +2,6 @@ Unwritten...
- ::BEP32 DHT ext for IPv6

Already in dist but require tests and/or docs...
- ::BEP23 Compact ipv4
- ::BEP05 DHT

Ideas...
Expand Down
6 changes: 2 additions & 4 deletions lib/Net/BitTorrent/Protocol.pm
Expand Up @@ -36,10 +36,8 @@ use Exporter qw[];
@{$Net::BitTorrent::Protocol::BEP06::EXPORT_TAGS{types}},
@{$Net::BitTorrent::Protocol::BEP10::EXPORT_TAGS{types}}
],

utils => [@{ $Net::BitTorrent::Protocol::BEP06::EXPORT_TAGS{utils}
},
] );
utils => [@{$Net::BitTorrent::Protocol::BEP06::EXPORT_TAGS{utils}}]
);
@EXPORT_OK = sort map { @$_ = sort @$_; @$_ } values %EXPORT_TAGS;
$EXPORT_TAGS{'all'} = \@EXPORT_OK;
my $parse_packet_dispatch;
Expand Down
11 changes: 5 additions & 6 deletions lib/Net/BitTorrent/Protocol/BEP07.pm
Expand Up @@ -84,24 +84,23 @@ L<uncompact|/"uncompact_ipv6 ( STRING )">.
=item C<compact_ipv6 ( @list )>
Compacts a list of IPv6:port strings into a single string.
Compacts a list of [IPv6, port] values into a single string.
A compact peer is 18 bytes; the first 15 bytes are the host and the last two
A compact peer is 18 bytes; the first 16 bytes are the host and the last two
bytes are the port.
=item C<uncompact_ipv6 ( $string )>
Inflates a compacted string of peers and returns a list of IPv6:port strings.
Inflates a compacted string of peers and returns a list of [IPv6, port]
values.
=back
=head1 See Also
=over
=item BEP 07: IPv6 Tracker Extension
http://bittorrent.org/beps/bep_0007.html
=item BEP 07: IPv6 Tracker Extension - http://bittorrent.org/beps/bep_0007.html
=back
Expand Down
32 changes: 32 additions & 0 deletions t/0023_net_bittorrent_protocol_bep23.t
@@ -0,0 +1,32 @@
use Test::More;
use lib './lib', '../lib';
$|++;

# Does it return 1?
use_ok 'Net::BitTorrent::Protocol::BEP23', ':all';

#
is compact_ipv4(['127.0.0.1', 2223]),
"\x7F\0\0\1\b\xAF",
'compact_ipv4( ... )';

#
is_deeply uncompact_ipv4("\x7F\0\0\1\b\xAF"),
['127.0.0.1', 2223],
'uncompact_ipv4( ... )';

# We're finished!
done_testing;
__END__
Copyright (C) 2008-2012 by Sanko Robinson <sanko@cpan.org>
This program is free software; you can redistribute it and/or modify it
under the terms of The Artistic License 2.0. See the LICENSE file
included with this distribution or
http://www.perlfoundation.org/artistic_license_2_0. For
clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
When separated from the distribution, all POD documentation is covered by
the Creative Commons Attribution-Share Alike 3.0 License. See
http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For
clarification, see http://creativecommons.org/licenses/by-sa/3.0/us/.

0 comments on commit 85c0a36

Please sign in to comment.