DefaultBtContextTest.cc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. #include "DefaultBtContext.h"
  2. #include <cstring>
  3. #include <iostream>
  4. #include <cppunit/extensions/HelperMacros.h>
  5. #include "Util.h"
  6. #include "RecoverableException.h"
  7. #include "AnnounceTier.h"
  8. #include "FixedNumberRandomizer.h"
  9. #include "FileEntry.h"
  10. #include "array_fun.h"
  11. namespace aria2 {
  12. class DefaultBtContextTest:public CppUnit::TestFixture {
  13. CPPUNIT_TEST_SUITE(DefaultBtContextTest);
  14. CPPUNIT_TEST(testGetInfoHash);
  15. CPPUNIT_TEST(testGetPieceHash);
  16. CPPUNIT_TEST(testGetFileEntries);
  17. CPPUNIT_TEST(testGetTotalLength);
  18. CPPUNIT_TEST(testGetFileEntriesSingle);
  19. CPPUNIT_TEST(testGetTotalLengthSingle);
  20. CPPUNIT_TEST(testGetFileModeMulti);
  21. CPPUNIT_TEST(testGetFileModeSingle);
  22. CPPUNIT_TEST(testGetNameMulti);
  23. CPPUNIT_TEST(testGetNameSingle);
  24. CPPUNIT_TEST(testOverrideName);
  25. CPPUNIT_TEST(testGetAnnounceTier);
  26. CPPUNIT_TEST(testGetAnnounceTierAnnounceList);
  27. CPPUNIT_TEST(testGetPieceLength);
  28. CPPUNIT_TEST(testGetInfoHashAsString);
  29. CPPUNIT_TEST(testGetPeerId);
  30. CPPUNIT_TEST(testComputeFastSet);
  31. CPPUNIT_TEST(testGetFileEntries_multiFileUrlList);
  32. CPPUNIT_TEST(testGetFileEntries_singleFileUrlList);
  33. CPPUNIT_TEST(testLoadFromMemory);
  34. CPPUNIT_TEST(testLoadFromMemory_somethingMissing);
  35. CPPUNIT_TEST(testLoadFromMemory_overrideName);
  36. CPPUNIT_TEST(testGetNodes);
  37. CPPUNIT_TEST_SUITE_END();
  38. public:
  39. void setUp() {
  40. }
  41. void testGetInfoHash();
  42. void testGetPieceHash();
  43. void testGetFileEntries();
  44. void testGetTotalLength();
  45. void testGetFileEntriesSingle();
  46. void testGetTotalLengthSingle();
  47. void testGetFileModeMulti();
  48. void testGetFileModeSingle();
  49. void testGetNameMulti();
  50. void testGetNameSingle();
  51. void testOverrideName();
  52. void testGetAnnounceTier();
  53. void testGetAnnounceTierAnnounceList();
  54. void testGetPieceLength();
  55. void testGetInfoHashAsString();
  56. void testGetPeerId();
  57. void testComputeFastSet();
  58. void testGetFileEntries_multiFileUrlList();
  59. void testGetFileEntries_singleFileUrlList();
  60. void testLoadFromMemory();
  61. void testLoadFromMemory_somethingMissing();
  62. void testLoadFromMemory_overrideName();
  63. void testGetNodes();
  64. };
  65. CPPUNIT_TEST_SUITE_REGISTRATION(DefaultBtContextTest);
  66. void DefaultBtContextTest::testGetInfoHash() {
  67. DefaultBtContext btContext;
  68. btContext.load("test.torrent");
  69. std::string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
  70. CPPUNIT_ASSERT_EQUAL((size_t)20, btContext.getInfoHashLength());
  71. CPPUNIT_ASSERT_EQUAL(correctHash, Util::toHex(btContext.getInfoHash(),
  72. btContext.getInfoHashLength()));
  73. }
  74. void DefaultBtContextTest::testGetPieceHash() {
  75. DefaultBtContext btContext;
  76. btContext.load("test.torrent");
  77. CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)"AAAAAAAAAAAAAAAAAAAA", 20),
  78. btContext.getPieceHash(0));
  79. CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)"BBBBBBBBBBBBBBBBBBBB", 20),
  80. btContext.getPieceHash(1));
  81. CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)"CCCCCCCCCCCCCCCCCCCC", 20),
  82. btContext.getPieceHash(2));
  83. CPPUNIT_ASSERT_EQUAL(std::string(""),
  84. btContext.getPieceHash(3));
  85. }
  86. void DefaultBtContextTest::testGetFileEntries() {
  87. DefaultBtContext btContext;
  88. btContext.load("test.torrent");
  89. // This is multi-file torrent.
  90. std::deque<SharedHandle<FileEntry> > fileEntries = btContext.getFileEntries();
  91. // There are 2 file entries.
  92. CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntries.size());
  93. std::deque<SharedHandle<FileEntry> >::iterator itr = fileEntries.begin();
  94. SharedHandle<FileEntry> fileEntry1 = *itr;
  95. CPPUNIT_ASSERT_EQUAL(std::string("aria2/src/aria2c"),
  96. fileEntry1->getPath());
  97. itr++;
  98. SharedHandle<FileEntry> fileEntry2 = *itr;
  99. CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.2.2.tar.bz2"),
  100. fileEntry2->getPath());
  101. }
  102. void DefaultBtContextTest::testGetFileEntriesSingle() {
  103. DefaultBtContext btContext;
  104. btContext.load("single.torrent");
  105. // This is multi-file torrent.
  106. std::deque<SharedHandle<FileEntry> > fileEntries = btContext.getFileEntries();
  107. // There is 1 file entry.
  108. CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntries.size());
  109. std::deque<SharedHandle<FileEntry> >::iterator itr = fileEntries.begin();
  110. SharedHandle<FileEntry> fileEntry1 = *itr;
  111. CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.8.2.tar.bz2"),
  112. fileEntry1->getPath());
  113. }
  114. void DefaultBtContextTest::testGetTotalLength() {
  115. DefaultBtContext btContext;
  116. btContext.load("test.torrent");
  117. CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, btContext.getTotalLength());
  118. }
  119. void DefaultBtContextTest::testGetTotalLengthSingle() {
  120. DefaultBtContext btContext;
  121. btContext.load("single.torrent");
  122. CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, btContext.getTotalLength());
  123. }
  124. void DefaultBtContextTest::testGetFileModeMulti() {
  125. DefaultBtContext btContext;
  126. btContext.load("test.torrent");
  127. CPPUNIT_ASSERT_EQUAL(BtContext::MULTI, btContext.getFileMode());
  128. }
  129. void DefaultBtContextTest::testGetFileModeSingle() {
  130. DefaultBtContext btContext;
  131. btContext.load("single.torrent");
  132. CPPUNIT_ASSERT_EQUAL(BtContext::SINGLE, btContext.getFileMode());
  133. }
  134. void DefaultBtContextTest::testGetNameMulti() {
  135. DefaultBtContext btContext;
  136. btContext.load("test.torrent");
  137. CPPUNIT_ASSERT_EQUAL(std::string("aria2-test"), btContext.getName());
  138. }
  139. void DefaultBtContextTest::testGetNameSingle() {
  140. DefaultBtContext btContext;
  141. btContext.load("single.torrent");
  142. CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.8.2.tar.bz2"), btContext.getName());
  143. }
  144. void DefaultBtContextTest::testOverrideName()
  145. {
  146. DefaultBtContext btContext;
  147. btContext.load("test.torrent", "aria2-override.name");
  148. CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"), btContext.getName());
  149. }
  150. void DefaultBtContextTest::testGetAnnounceTier() {
  151. DefaultBtContext btContext;
  152. btContext.load("single.torrent");
  153. std::deque<SharedHandle<AnnounceTier> > tiers = btContext.getAnnounceTiers();
  154. // There is 1 tier.
  155. CPPUNIT_ASSERT_EQUAL((size_t)1, tiers.size());
  156. std::deque<SharedHandle<AnnounceTier> >::iterator itr = tiers.begin();
  157. SharedHandle<AnnounceTier> tier1 = *itr;
  158. CPPUNIT_ASSERT_EQUAL((size_t)1, tier1->urls.size());
  159. CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/announce.php"),
  160. tier1->urls.at(0));
  161. }
  162. void DefaultBtContextTest::testGetAnnounceTierAnnounceList() {
  163. DefaultBtContext btContext;
  164. btContext.load("test.torrent");
  165. std::deque<SharedHandle<AnnounceTier> > tiers = btContext.getAnnounceTiers();
  166. // There are 3 tiers.
  167. CPPUNIT_ASSERT_EQUAL((size_t)3, tiers.size());
  168. SharedHandle<AnnounceTier> tier1 = tiers.at(0);
  169. CPPUNIT_ASSERT_EQUAL((size_t)1, tier1->urls.size());
  170. CPPUNIT_ASSERT_EQUAL(std::string("http://tracker1"),
  171. tier1->urls.at(0));
  172. SharedHandle<AnnounceTier> tier2 = tiers.at(1);
  173. CPPUNIT_ASSERT_EQUAL((size_t)1, tier2->urls.size());
  174. CPPUNIT_ASSERT_EQUAL(std::string("http://tracker2"), tier2->urls.at(0));
  175. SharedHandle<AnnounceTier> tier3 = tiers.at(2);
  176. CPPUNIT_ASSERT_EQUAL((size_t)1, tier3->urls.size());
  177. CPPUNIT_ASSERT_EQUAL(std::string("http://tracker3"), tier3->urls.at(0));
  178. }
  179. void DefaultBtContextTest::testGetPieceLength() {
  180. DefaultBtContext btContext;
  181. btContext.load("test.torrent");
  182. CPPUNIT_ASSERT_EQUAL((size_t)128, btContext.getPieceLength());
  183. }
  184. void DefaultBtContextTest::testGetInfoHashAsString() {
  185. DefaultBtContext btContext;
  186. btContext.load("test.torrent");
  187. CPPUNIT_ASSERT_EQUAL(std::string("248d0a1cd08284299de78d5c1ed359bb46717d8c"),
  188. btContext.getInfoHashAsString());
  189. }
  190. void DefaultBtContextTest::testGetPeerId() {
  191. DefaultBtContext btContext;
  192. btContext.setRandomizer(SharedHandle<Randomizer>(new FixedNumberRandomizer()));
  193. CPPUNIT_ASSERT_EQUAL(std::string("%2Daria2%2DAAAAAAAAAAAAA"), Util::torrentUrlencode(btContext.getPeerId(), 20));
  194. }
  195. void DefaultBtContextTest::testComputeFastSet()
  196. {
  197. std::string ipaddr = "192.168.0.1";
  198. unsigned char infoHash[20];
  199. memset(infoHash, 0, sizeof(infoHash));
  200. infoHash[0] = 0xff;
  201. int fastSetSize = 10;
  202. DefaultBtContext btContext;
  203. btContext.setInfoHash(infoHash);
  204. btContext.setNumPieces(1000);
  205. {
  206. std::deque<size_t> fastSet;
  207. btContext.computeFastSet(fastSet, ipaddr, fastSetSize);
  208. size_t ans[] = { 686, 459, 278, 200, 404, 834, 64, 203, 760, 950 };
  209. std::deque<size_t> ansSet(&ans[0], &ans[arrayLength(ans)]);
  210. CPPUNIT_ASSERT(std::equal(fastSet.begin(), fastSet.end(), ansSet.begin()));
  211. }
  212. ipaddr = "10.0.0.1";
  213. {
  214. std::deque<size_t> fastSet;
  215. btContext.computeFastSet(fastSet, ipaddr, fastSetSize);
  216. size_t ans[] = { 568, 188, 466, 452, 550, 662, 109, 226, 398, 11 };
  217. std::deque<size_t> ansSet(&ans[0], &ans[arrayLength(ans)]);
  218. CPPUNIT_ASSERT(std::equal(fastSet.begin(), fastSet.end(), ansSet.begin()));
  219. }
  220. // See when pieces < fastSetSize
  221. btContext.setNumPieces(9);
  222. {
  223. std::deque<size_t> fastSet;
  224. btContext.computeFastSet(fastSet, ipaddr, fastSetSize);
  225. size_t ans[] = { 8, 6, 7, 5, 1, 4, 0, 2, 3 };
  226. std::deque<size_t> ansSet(&ans[0], &ans[arrayLength(ans)]);
  227. CPPUNIT_ASSERT(std::equal(fastSet.begin(), fastSet.end(), ansSet.begin()));
  228. }
  229. }
  230. void DefaultBtContextTest::testGetFileEntries_multiFileUrlList() {
  231. DefaultBtContext btContext;
  232. btContext.load("url-list-multiFile.torrent");
  233. // This is multi-file torrent.
  234. std::deque<SharedHandle<FileEntry> > fileEntries = btContext.getFileEntries();
  235. // There are 2 file entries.
  236. CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntries.size());
  237. std::deque<SharedHandle<FileEntry> >::iterator itr = fileEntries.begin();
  238. SharedHandle<FileEntry> fileEntry1 = *itr;
  239. CPPUNIT_ASSERT_EQUAL(std::string("aria2/src/aria2c"),
  240. fileEntry1->getPath());
  241. std::deque<std::string> uris1 = fileEntry1->getAssociatedUris();
  242. CPPUNIT_ASSERT_EQUAL((size_t)2, uris1.size());
  243. CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test/aria2/src/aria2c"),
  244. uris1[0]);
  245. CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test/aria2/src/aria2c"),
  246. uris1[1]);
  247. itr++;
  248. SharedHandle<FileEntry> fileEntry2 = *itr;
  249. CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.2.2.tar.bz2"),
  250. fileEntry2->getPath());
  251. std::deque<std::string> uris2 = fileEntry2->getAssociatedUris();
  252. CPPUNIT_ASSERT_EQUAL((size_t)2, uris2.size());
  253. CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test/aria2-0.2.2.tar.bz2"),
  254. uris2[0]);
  255. CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test/aria2-0.2.2.tar.bz2"),
  256. uris2[1]);
  257. }
  258. void DefaultBtContextTest::testGetFileEntries_singleFileUrlList() {
  259. DefaultBtContext btContext;
  260. btContext.load("url-list-singleFile.torrent");
  261. // This is multi-file torrent.
  262. std::deque<SharedHandle<FileEntry> > fileEntries = btContext.getFileEntries();
  263. // There are 1 file entries.
  264. CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntries.size());
  265. SharedHandle<FileEntry> fileEntry1 = fileEntries.front();
  266. CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"),
  267. fileEntry1->getPath());
  268. std::deque<std::string> uris1 = fileEntry1->getAssociatedUris();
  269. CPPUNIT_ASSERT_EQUAL((size_t)1, uris1.size());
  270. CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2.tar.bz2"),
  271. uris1[0]);
  272. }
  273. void DefaultBtContextTest::testLoadFromMemory()
  274. {
  275. std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php13:announce-listll16:http://tracker1 el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee";
  276. DefaultBtContext btContext;
  277. btContext.loadFromMemory(memory, "default");
  278. std::string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
  279. CPPUNIT_ASSERT_EQUAL((size_t)20, btContext.getInfoHashLength());
  280. CPPUNIT_ASSERT_EQUAL(correctHash, Util::toHex(btContext.getInfoHash(),
  281. btContext.getInfoHashLength()));
  282. }
  283. void DefaultBtContextTest::testLoadFromMemory_somethingMissing()
  284. {
  285. // pieces missing
  286. try {
  287. std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php4:infod4:name13:aria2.tar.bz26:lengthi262144eee";
  288. DefaultBtContext btContext;
  289. btContext.loadFromMemory(memory, "default");
  290. CPPUNIT_FAIL("exception must be thrown.");
  291. } catch(Exception& e) {
  292. std::cerr << e.stackTrace() << std::endl;
  293. }
  294. }
  295. void DefaultBtContextTest::testLoadFromMemory_overrideName()
  296. {
  297. std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php13:announce-listll16:http://tracker1 el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee";
  298. DefaultBtContext btContext;
  299. btContext.loadFromMemory(memory, "default", "aria2-override.name");
  300. CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"), btContext.getName());
  301. }
  302. void DefaultBtContextTest::testGetNodes()
  303. {
  304. {
  305. std::string memory =
  306. "d5:nodesl"
  307. "l11:192.168.0.1i6881ee"
  308. "l11:192.168.0.2i6882ee"
  309. "e4:infod4:name13:aria2.tar.bz26:lengthi262144e"
  310. "12:piece lengthi262144e"
  311. "6:pieces20:AAAAAAAAAAAAAAAAAAAA"
  312. "ee";
  313. DefaultBtContext btContext;
  314. btContext.loadFromMemory(memory, "default");
  315. const std::deque<std::pair<std::string, uint16_t> >& nodes =
  316. btContext.getNodes();
  317. CPPUNIT_ASSERT_EQUAL((size_t)2, nodes.size());
  318. CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), nodes[0].first);
  319. CPPUNIT_ASSERT_EQUAL((uint16_t)6881, nodes[0].second);
  320. CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), nodes[1].first);
  321. CPPUNIT_ASSERT_EQUAL((uint16_t)6882, nodes[1].second);
  322. }
  323. {
  324. // empty hostname
  325. std::string memory =
  326. "d5:nodesl"
  327. "l1: i6881ee"
  328. "l11:192.168.0.2i6882ee"
  329. "e4:infod4:name13:aria2.tar.bz26:lengthi262144e"
  330. "12:piece lengthi262144e"
  331. "6:pieces20:AAAAAAAAAAAAAAAAAAAA"
  332. "ee";
  333. DefaultBtContext btContext;
  334. btContext.loadFromMemory(memory, "default");
  335. const std::deque<std::pair<std::string, uint16_t> >& nodes =
  336. btContext.getNodes();
  337. CPPUNIT_ASSERT_EQUAL((size_t)1, nodes.size());
  338. CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), nodes[0].first);
  339. CPPUNIT_ASSERT_EQUAL((uint16_t)6882, nodes[0].second);
  340. }
  341. {
  342. // bad port
  343. std::string memory =
  344. "d5:nodesl"
  345. "l11:192.168.0.11:xe"
  346. "l11:192.168.0.2i6882ee"
  347. "e4:infod4:name13:aria2.tar.bz26:lengthi262144e"
  348. "12:piece lengthi262144e"
  349. "6:pieces20:AAAAAAAAAAAAAAAAAAAA"
  350. "ee";
  351. DefaultBtContext btContext;
  352. btContext.loadFromMemory(memory, "default");
  353. const std::deque<std::pair<std::string, uint16_t> >& nodes =
  354. btContext.getNodes();
  355. CPPUNIT_ASSERT_EQUAL((size_t)1, nodes.size());
  356. CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), nodes[0].first);
  357. CPPUNIT_ASSERT_EQUAL((uint16_t)6882, nodes[0].second);
  358. }
  359. {
  360. // port missing
  361. std::string memory =
  362. "d5:nodesl"
  363. "l11:192.168.0.1e"
  364. "l11:192.168.0.2i6882ee"
  365. "e4:infod4:name13:aria2.tar.bz26:lengthi262144e"
  366. "12:piece lengthi262144e"
  367. "6:pieces20:AAAAAAAAAAAAAAAAAAAA"
  368. "ee";
  369. DefaultBtContext btContext;
  370. btContext.loadFromMemory(memory, "default");
  371. const std::deque<std::pair<std::string, uint16_t> >& nodes =
  372. btContext.getNodes();
  373. CPPUNIT_ASSERT_EQUAL((size_t)1, nodes.size());
  374. CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), nodes[0].first);
  375. CPPUNIT_ASSERT_EQUAL((uint16_t)6882, nodes[0].second);
  376. }
  377. {
  378. // nodes is not a list
  379. std::string memory =
  380. "d5:nodes"
  381. "l11:192.168.0.1e"
  382. "4:infod4:name13:aria2.tar.bz26:lengthi262144e"
  383. "12:piece lengthi262144e"
  384. "6:pieces20:AAAAAAAAAAAAAAAAAAAA"
  385. "ee";
  386. DefaultBtContext btContext;
  387. btContext.loadFromMemory(memory, "default");
  388. const std::deque<std::pair<std::string, uint16_t> >& nodes =
  389. btContext.getNodes();
  390. CPPUNIT_ASSERT_EQUAL((size_t)0, nodes.size());
  391. }
  392. {
  393. // the element of node is not Data
  394. std::string memory =
  395. "d5:nodesl"
  396. "ll11:192.168.0.1i6881eee"
  397. "l11:192.168.0.2i6882ee"
  398. "e4:infod4:name13:aria2.tar.bz26:lengthi262144e"
  399. "12:piece lengthi262144e"
  400. "6:pieces20:AAAAAAAAAAAAAAAAAAAA"
  401. "ee";
  402. DefaultBtContext btContext;
  403. btContext.loadFromMemory(memory, "default");
  404. const std::deque<std::pair<std::string, uint16_t> >& nodes =
  405. btContext.getNodes();
  406. CPPUNIT_ASSERT_EQUAL((size_t)1, nodes.size());
  407. CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), nodes[0].first);
  408. CPPUNIT_ASSERT_EQUAL((uint16_t)6882, nodes[0].second);
  409. }
  410. }
  411. } // namespace aria2