Skip to content

Commit

Permalink
bittorrent: fix check-bitfield, add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jan 29, 2020
1 parent 6aa8f64 commit 2300311
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion extra/bittorrent/bittorrent-tests.factor
@@ -1,4 +1,9 @@
USING: bittorrent io.sockets tools.test ;
USING: bittorrent sequences io.sockets tools.test ;


{ { t f t t f t f t } } [
8 <iota> [ B{ 0b10110101 } check-bitfield ] map
] unit-test

{
{
Expand Down
2 changes: 1 addition & 1 deletion extra/bittorrent/bittorrent.factor
Expand Up @@ -40,7 +40,7 @@ torrent-port [ 6881 ] initialize
'[ _ _ [ set-bit ] [ clear-bit ] if ] change-nth ;

: check-bitfield ( n bitfield -- ? )
[ bitfield-index swap ] dip nth bit? ;
[ bitfield-index swap ] dip nth swap bit? ;


! http
Expand Down

0 comments on commit 2300311

Please sign in to comment.