From: alex Date: Thu, 28 Jul 2022 18:47:28 +0000 (-0700) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=48eded37712ecce0411800aeb358ffaf806a82a0;p=seeder ... --- diff --git a/inc/net.h b/inc/net.h index 1bee9dd..95ac067 100644 --- a/inc/net.h +++ b/inc/net.h @@ -43,6 +43,12 @@ struct net_info { (x[2]<<8) + \ x[3] +#define UINT32_T_TO_BYTES(x,buf) \ + buf[0] = (uint8_t) (x >> 24); \ + buf[1] = (uint8_t) (x >> 16 & 0xff); \ + buf[2] = (uint8_t) (x >> 8 & 0xff); \ + buf[3] = (uint8_t) (x & 0xff); + int net_cache(void**,size_t*,void*,size_t); ssize_t net_expected(struct peer*,enum peer_message*); void net_handler(int,struct peer*); diff --git a/src/peer/hash.c b/src/peer/hash.c index 88574d3..efe1b43 100644 --- a/src/peer/hash.c +++ b/src/peer/hash.c @@ -1,6 +1,11 @@ #include -int peer_hash_request(struct peer *info) { +#define HASH_REQUEST_LENGTH crypto_hash_sha256_BYTES+4+4+4+4 +int peer_hash_request(struct peer *info,const struct hash_request *request) { + unsigned char buf[HASH_REQUEST_LENGTH]; + + + return -1; } diff --git a/test/integration/Makefile.am b/test/integration/Makefile.am index 22d58d7..94b93aa 100644 --- a/test/integration/Makefile.am +++ b/test/integration/Makefile.am @@ -40,10 +40,12 @@ qbittorrent_tests_SOURCES = \ $(top_srcdir)/src/net/send.c \ $(top_srcdir)/src/net/wait.c \ $(top_srcdir)/src/peer/bitfield.c \ + $(top_srcdir)/src/peer/choke.c \ $(top_srcdir)/src/peer/free.c \ $(top_srcdir)/src/peer/handshake.c \ $(top_srcdir)/src/peer/id.c \ - $(top_srcdir)/src/peer/init.c + $(top_srcdir)/src/peer/init.c \ + $(top_srcdir)/src/peer/interest.c clean-local: -rm -rf $(TEST_DIRECTORY) diff --git a/test/integration/qbittorrent.tests.c b/test/integration/qbittorrent.tests.c index f1fef6f..28543b7 100644 --- a/test/integration/qbittorrent.tests.c +++ b/test/integration/qbittorrent.tests.c @@ -60,6 +60,16 @@ void qbittorrent_integration_test() { 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)); + + assert(1==peer_keepalive(info)); + + assert(1==peer_hash_request(info)); + close(info->sock); peer_free(info); }