]> gitweb.factorcode.org Git - factor.git/commitdiff
bittorrent: fix check-bitfield, add a test.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Jan 2020 00:25:19 +0000 (16:25 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Jan 2020 00:25:19 +0000 (16:25 -0800)
extra/bittorrent/bittorrent-tests.factor
extra/bittorrent/bittorrent.factor

index 1c2e9585c6cbe0c058f69de20b6fef475db29e50..64079f7fbf01d5e985a5952b4b43adaca88058b5 100644 (file)
@@ -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
 
 {
     {
index c831372b39f8803316528c01394043f150e5412f..d479e7338da8ddf41c002d8b8f1c0d9e61e2d045 100644 (file)
@@ -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