void qbittorrent_integration_test() {
struct addrinfo hints, *res;
struct peer *info;
- struct hash_request req;
enum peer_message type;
+ struct hash_request req;
ssize_t i;
- // test torrent: debian-live-11.4.0-amd64-xfce.iso
- const char infohash[] = {0x25, 0x11, 0xdf, 0x9f, 0x74, 0xdc, 0x6f, 0xc1, 0x8e, 0xc9, 0x46, 0x6c, 0xdd, 0x52, 0xf5, 0xa1, 0x83, 0x27, 0xe2, 0x6e};
- const size_t pieces = 2526;
+ /*
+ * Test uses the following torrent:
+ * name: bittorrent-v2-test
+ * infov2: caf1e1c30e81cb361b9ee167c4aa64228a7fa4fa9f6105232b28ad099f3a302e
+ *
+ * Files:
+ * '13.Popsy Team - ViP 2.vob.mp4'
+ * 'cncd_fairlight-ceasefire_(all_falls_down)-1080p.mp4'
+ * elevated_4000.avi
+ * 'Struct by Outracks (FullHD 1080p HQ demoscene).mov'
+ * asd-rupture.mp4
+ * 'crionics & silents - hardwired (1991, hpad, divx5).avi'
+ * 'luma - mercury _ 64k _ Final.mp4'
+ * tbl-starstruck-2006.avi
+ * 'Chameleon by ASD (female voice).mov'
+ * 'Darkroom (Stellar, 1994, Amiga ECS) HQ.mp4'
+ * readme.txt
+ */
+ const unsigned char infohash[] = {0xca, 0xf1, 0xe1, 0xc3, 0x0e, 0x81, 0xcb, 0x36, 0x1b, 0x9e, 0xe1, 0x67, 0xc4, 0xaa, 0x64, 0x22, 0x8a, 0x7f, 0xa4, 0xfa, 0x9f, 0x61, 0x05, 0x23, 0x2b, 0x28, 0xad, 0x09, 0x9f, 0x3a, 0x30, 0x2e};
+// const unsigned char readme_txt_pieces_root[] = { 0x3b, 0x3c, 0x50, 0xa1, 0x2e, 0x27, 0xa6, 0xb3, 0x42, 0x1b, 0x81, 0x7a, 0xfd, 0x49, 0xdf, 0xa0, 0xd5, 0x4f, 0x69, 0xa0, 0x86, 0xcf, 0x99, 0x14, 0x16, 0x4a, 0x9f, 0x51, 0x6e, 0x74, 0x16, 0xe4};
+ const unsigned char tbl_starstruck_2006_avi_pieces_root[] = {0xeb, 0x3f, 0xde, 0x5f, 0xce, 0xb8, 0xed, 0xa2, 0x55, 0xdb, 0x2f, 0x21, 0x8a, 0x0c, 0xec, 0xac, 0x95, 0x71, 0x75, 0xcd, 0x54, 0x4a, 0x83, 0xb0, 0x28, 0x65, 0x0f, 0xd4, 0x44, 0x7a, 0x17, 0x91};
+ const size_t pieces = 371;
assert(1==peer_init(&info));
assert(1==peer_handshake(info));
assert(1==peer_handshake_received(info));
+ assert(1==peer_interested(info));
+ assert(1==peer_unchoke(info));
+
+ /*
+ * skipping (un)choke, (not)interested, keepalive, etc.
+ */
assert(1==peer_bitfield(info));
i = net_expected(info,&type);
- assert(i>=0);
+ assert(i==52);
assert(PEER_MESSAGE_BITFIELD==type);
-
assert(1==peer_bitfield_received(info,i));
- assert(1==peer_choke(info));
- assert(1==peer_unchoke(info));
-
- assert(1==peer_not_interested(info));
- assert(1==peer_interested(info));
+ i = net_expected(info,&type);
+ assert(i==5);
+ assert(PEER_MESSAGE_UNCHOKE==type);
+ assert(1==peer_unchoke_received(info,i));
+
+ memset(&req,0,sizeof(req));
+ memcpy(req.pieces_root,tbl_starstruck_2006_avi_pieces_root,32);
+ req.base_layer = 0;
+ req.index = 1;
+ req.length = 1;
+ req.proof_layers = 1;
+ assert(1==peer_hash_request(info,&req));
- assert(1==peer_keepalive(info));
+ i = net_expected(info,&type);
+ assert(i==5);
+ assert(PEER_MESSAGE_UNCHOKE==type);
+ assert(1==peer_unchoke_received(info,i));
- assert(1==peer_hash_request(info,&req));
+ i = net_expected(info,&type);
+ assert(i>0);
+ assert(PEER_MESSAGE_HASHES==type);
+ assert(1==peer_hashes_received(info,i));
close(info->sock);
peer_free(info);