diff --git a/extra/bittorrent/bittorrent-tests.factor b/extra/bittorrent/bittorrent-tests.factor index 1c2e9585c6..64079f7fbf 100644 --- a/extra/bittorrent/bittorrent-tests.factor +++ b/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 [ B{ 0b10110101 } check-bitfield ] map +] unit-test { { diff --git a/extra/bittorrent/bittorrent.factor b/extra/bittorrent/bittorrent.factor index c831372b39..d479e7338d 100644 --- a/extra/bittorrent/bittorrent.factor +++ b/extra/bittorrent/bittorrent.factor @@ -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