mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 21:47:37 +03:00
2008-10-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed signature of DHTMessageFactory::createResponseMessage(). Removed unused validateIDMatch. * src/DHTMessageFactory.h * src/DHTMessageFactoryImpl.cc * src/DHTMessageFactoryImpl.h * src/DHTMessageTracker.cc * test/DHTMessageFactoryImplTest.cc * test/MockDHTMessageFactory.h Dropped DHT message coming from same ID of localhost. * src/DHTMessageReceiver.cc Rejected adding node whose ID is the same as localhost's. * src/DHTRoutingTable.cc * test/BtPortMessageTest.cc * test/DHTRoutingTableTest.cc
This commit is contained in:
parent
90c6d5072b
commit
8a920ba5e3
11 changed files with 113 additions and 35 deletions
|
@ -1,4 +1,10 @@
|
|||
#include "DHTMessageFactoryImpl.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "RecoverableException.h"
|
||||
#include "Util.h"
|
||||
#include "DHTNode.h"
|
||||
|
@ -17,9 +23,6 @@
|
|||
#include "DHTGetPeersReplyMessage.h"
|
||||
#include "DHTAnnouncePeerMessage.h"
|
||||
#include "DHTAnnouncePeerReplyMessage.h"
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -112,7 +115,10 @@ void DHTMessageFactoryImplTest::testCreatePingReplyMessage()
|
|||
remoteNode->setPort(6881);
|
||||
|
||||
SharedHandle<DHTPingReplyMessage> m
|
||||
(dynamic_pointer_cast<DHTPingReplyMessage>(factory->createResponseMessage("ping", d.get(), remoteNode)));
|
||||
(dynamic_pointer_cast<DHTPingReplyMessage>
|
||||
(factory->createResponseMessage("ping", d.get(),
|
||||
remoteNode->getIPAddress(),
|
||||
remoteNode->getPort())));
|
||||
|
||||
CPPUNIT_ASSERT(localNode == m->getLocalNode());
|
||||
CPPUNIT_ASSERT(remoteNode == m->getRemoteNode());
|
||||
|
@ -176,7 +182,10 @@ void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage()
|
|||
remoteNode->setPort(6881);
|
||||
|
||||
SharedHandle<DHTFindNodeReplyMessage> m
|
||||
(dynamic_pointer_cast<DHTFindNodeReplyMessage>(factory->createResponseMessage("find_node", d.get(), remoteNode)));
|
||||
(dynamic_pointer_cast<DHTFindNodeReplyMessage>
|
||||
(factory->createResponseMessage("find_node", d.get(),
|
||||
remoteNode->getIPAddress(),
|
||||
remoteNode->getPort())));
|
||||
|
||||
CPPUNIT_ASSERT(localNode == m->getLocalNode());
|
||||
CPPUNIT_ASSERT(remoteNode == m->getRemoteNode());
|
||||
|
@ -247,7 +256,10 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes()
|
|||
remoteNode->setPort(6881);
|
||||
|
||||
SharedHandle<DHTGetPeersReplyMessage> m
|
||||
(dynamic_pointer_cast<DHTGetPeersReplyMessage>(factory->createResponseMessage("get_peers", d.get(), remoteNode)));
|
||||
(dynamic_pointer_cast<DHTGetPeersReplyMessage>
|
||||
(factory->createResponseMessage("get_peers", d.get(),
|
||||
remoteNode->getIPAddress(),
|
||||
remoteNode->getPort())));
|
||||
|
||||
CPPUNIT_ASSERT(localNode == m->getLocalNode());
|
||||
CPPUNIT_ASSERT(remoteNode == m->getRemoteNode());
|
||||
|
@ -290,7 +302,10 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values()
|
|||
remoteNode->setPort(6881);
|
||||
|
||||
SharedHandle<DHTGetPeersReplyMessage> m
|
||||
(dynamic_pointer_cast<DHTGetPeersReplyMessage>(factory->createResponseMessage("get_peers", d.get(), remoteNode)));
|
||||
(dynamic_pointer_cast<DHTGetPeersReplyMessage>
|
||||
(factory->createResponseMessage("get_peers", d.get(),
|
||||
remoteNode->getIPAddress(),
|
||||
remoteNode->getPort())));
|
||||
|
||||
CPPUNIT_ASSERT(localNode == m->getLocalNode());
|
||||
CPPUNIT_ASSERT(remoteNode == m->getRemoteNode());
|
||||
|
@ -356,7 +371,10 @@ void DHTMessageFactoryImplTest::testCreateAnnouncePeerReplyMessage()
|
|||
remoteNode->setPort(6881);
|
||||
|
||||
SharedHandle<DHTAnnouncePeerReplyMessage> m
|
||||
(dynamic_pointer_cast<DHTAnnouncePeerReplyMessage>(factory->createResponseMessage("announce_peer", d.get(), remoteNode)));
|
||||
(dynamic_pointer_cast<DHTAnnouncePeerReplyMessage>
|
||||
(factory->createResponseMessage("announce_peer", d.get(),
|
||||
remoteNode->getIPAddress(),
|
||||
remoteNode->getPort())));
|
||||
|
||||
CPPUNIT_ASSERT(localNode == m->getLocalNode());
|
||||
CPPUNIT_ASSERT(remoteNode == m->getRemoteNode());
|
||||
|
@ -379,7 +397,9 @@ void DHTMessageFactoryImplTest::testReceivedErrorMessage()
|
|||
remoteNode->setPort(6881);
|
||||
|
||||
try {
|
||||
factory->createResponseMessage("announce_peer", d.get(), remoteNode);
|
||||
factory->createResponseMessage("announce_peer", d.get(),
|
||||
remoteNode->getIPAddress(),
|
||||
remoteNode->getPort());
|
||||
CPPUNIT_FAIL("exception must be thrown.");
|
||||
} catch(RecoverableException& e) {
|
||||
std::cerr << e.stackTrace() << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue