mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 13:37:40 +03:00
2009-04-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Put BDE in aria2 namespace. BDE will also be used to store xml-rpc request. * src/AnnounceList.cc * src/AnnounceList.h * src/BDE.cc: Added * src/BDE.h: Added * src/DHTAbstractMessage.cc * src/DHTAbstractMessage.h * src/DHTAnnouncePeerMessage.cc * src/DHTAnnouncePeerMessage.h * src/DHTAnnouncePeerReplyMessage.cc * src/DHTAnnouncePeerReplyMessage.h * src/DHTFindNodeMessage.cc * src/DHTFindNodeMessage.h * src/DHTFindNodeReplyMessage.cc * src/DHTFindNodeReplyMessage.h * src/DHTGetPeersMessage.cc * src/DHTGetPeersMessage.h * src/DHTGetPeersReplyMessage.cc * src/DHTGetPeersReplyMessage.h * src/DHTMessageFactory.h * src/DHTMessageFactoryImpl.cc * src/DHTMessageFactoryImpl.h * src/DHTMessageReceiver.cc * src/DHTMessageTracker.cc * src/DHTMessageTracker.h * src/DHTPingMessage.cc * src/DHTPingMessage.h * src/DHTPingReplyMessage.cc * src/DHTPingReplyMessage.h * src/DHTQueryMessage.cc * src/DHTQueryMessage.h * src/DHTResponseMessage.cc * src/DHTResponseMessage.h * src/DefaultBtAnnounce.cc * src/DefaultBtContext.cc * src/DefaultBtContext.h * src/HandshakeExtensionMessage.cc * src/Makefile.am * src/PeerListProcessor.h * src/UTPexExtensionMessage.cc * src/bencode.cc * src/bencode.h * test/AnnounceListTest.cc * test/BDETest.cc: Added * test/BencodeTest.cc * test/DHTAnnouncePeerMessageTest.cc * test/DHTAnnouncePeerReplyMessageTest.cc * test/DHTFindNodeMessageTest.cc * test/DHTFindNodeReplyMessageTest.cc * test/DHTGetPeersMessageTest.cc * test/DHTGetPeersReplyMessageTest.cc * test/DHTMessageFactoryImplTest.cc * test/DHTMessageTrackerTest.cc * test/DHTPingMessageTest.cc * test/DHTPingReplyMessageTest.cc * test/Makefile.am * test/MockDHTMessageFactory.h * test/PeerListProcessorTest.cc
This commit is contained in:
parent
d58742ad21
commit
49b4cfbfcd
60 changed files with 1207 additions and 1044 deletions
|
@ -79,12 +79,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DHTMessageFactoryImplTest);
|
|||
|
||||
void DHTMessageFactoryImplTest::testCreatePingMessage()
|
||||
{
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("q");
|
||||
dict["q"] = bencode::BDE("ping");
|
||||
bencode::BDE aDict = bencode::BDE::dict();
|
||||
aDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("q");
|
||||
dict["q"] = BDE("ping");
|
||||
BDE aDict = BDE::dict();
|
||||
aDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
dict["a"] = aDict;
|
||||
|
||||
SharedHandle<DHTPingMessage> m
|
||||
|
@ -102,11 +102,11 @@ void DHTMessageFactoryImplTest::testCreatePingMessage()
|
|||
|
||||
void DHTMessageFactoryImplTest::testCreatePingReplyMessage()
|
||||
{
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("r");
|
||||
bencode::BDE rDict = bencode::BDE::dict();
|
||||
rDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("r");
|
||||
BDE rDict = BDE::dict();
|
||||
rDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
dict["r"] = rDict;
|
||||
|
||||
SharedHandle<DHTNode> remoteNode(new DHTNode(remoteNodeID));
|
||||
|
@ -127,15 +127,15 @@ void DHTMessageFactoryImplTest::testCreatePingReplyMessage()
|
|||
|
||||
void DHTMessageFactoryImplTest::testCreateFindNodeMessage()
|
||||
{
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("q");
|
||||
dict["q"] = bencode::BDE("find_node");
|
||||
bencode::BDE aDict = bencode::BDE::dict();
|
||||
aDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("q");
|
||||
dict["q"] = BDE("find_node");
|
||||
BDE aDict = BDE::dict();
|
||||
aDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
unsigned char targetNodeID[DHT_ID_LENGTH];
|
||||
memset(targetNodeID, 0x11, DHT_ID_LENGTH);
|
||||
aDict["target"] = bencode::BDE(targetNodeID, DHT_ID_LENGTH);
|
||||
aDict["target"] = BDE(targetNodeID, DHT_ID_LENGTH);
|
||||
dict["a"] = aDict;
|
||||
|
||||
SharedHandle<DHTFindNodeMessage> m
|
||||
|
@ -156,11 +156,11 @@ void DHTMessageFactoryImplTest::testCreateFindNodeMessage()
|
|||
void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage()
|
||||
{
|
||||
try {
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("r");
|
||||
bencode::BDE rDict = bencode::BDE::dict();
|
||||
rDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("r");
|
||||
BDE rDict = BDE::dict();
|
||||
rDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
std::string compactNodeInfo;
|
||||
SharedHandle<DHTNode> nodes[8];
|
||||
for(size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
|
@ -202,15 +202,15 @@ void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage()
|
|||
|
||||
void DHTMessageFactoryImplTest::testCreateGetPeersMessage()
|
||||
{
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("q");
|
||||
dict["q"] = bencode::BDE("get_peers");
|
||||
bencode::BDE aDict = bencode::BDE::dict();
|
||||
aDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("q");
|
||||
dict["q"] = BDE("get_peers");
|
||||
BDE aDict = BDE::dict();
|
||||
aDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
unsigned char infoHash[DHT_ID_LENGTH];
|
||||
memset(infoHash, 0x11, DHT_ID_LENGTH);
|
||||
aDict["info_hash"] = bencode::BDE(infoHash, DHT_ID_LENGTH);
|
||||
aDict["info_hash"] = BDE(infoHash, DHT_ID_LENGTH);
|
||||
dict["a"] = aDict;
|
||||
|
||||
SharedHandle<DHTGetPeersMessage> m
|
||||
|
@ -231,11 +231,11 @@ void DHTMessageFactoryImplTest::testCreateGetPeersMessage()
|
|||
void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes()
|
||||
{
|
||||
try {
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("r");
|
||||
bencode::BDE rDict = bencode::BDE::dict();
|
||||
rDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("r");
|
||||
BDE rDict = BDE::dict();
|
||||
rDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
std::string compactNodeInfo;
|
||||
SharedHandle<DHTNode> nodes[8];
|
||||
for(size_t i = 0; i < DHTBucket::K; ++i) {
|
||||
|
@ -251,7 +251,7 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes()
|
|||
std::string(&buf[0], &buf[sizeof(buf)]);
|
||||
}
|
||||
rDict["nodes"] = compactNodeInfo;
|
||||
rDict["token"] = bencode::BDE("token");
|
||||
rDict["token"] = BDE("token");
|
||||
dict["r"] = rDict;
|
||||
|
||||
SharedHandle<DHTNode> remoteNode(new DHTNode(remoteNodeID));
|
||||
|
@ -280,24 +280,24 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes()
|
|||
void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values()
|
||||
{
|
||||
try {
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("r");
|
||||
bencode::BDE rDict = bencode::BDE::dict();
|
||||
rDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("r");
|
||||
BDE rDict = BDE::dict();
|
||||
rDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
|
||||
std::deque<SharedHandle<Peer> > peers;
|
||||
bencode::BDE valuesList = bencode::BDE::list();
|
||||
BDE valuesList = BDE::list();
|
||||
for(size_t i = 0; i < 4; ++i) {
|
||||
SharedHandle<Peer> peer(new Peer("192.168.0."+Util::uitos(i+1), 6881+i));
|
||||
unsigned char buffer[6];
|
||||
CPPUNIT_ASSERT(PeerMessageUtil::createcompact(buffer, peer->ipaddr,
|
||||
peer->port));
|
||||
valuesList << bencode::BDE(buffer, sizeof(buffer));
|
||||
valuesList << BDE(buffer, sizeof(buffer));
|
||||
peers.push_back(peer);
|
||||
}
|
||||
rDict["values"] = valuesList;
|
||||
rDict["token"] = bencode::BDE("token");
|
||||
rDict["token"] = BDE("token");
|
||||
dict["r"] = rDict;
|
||||
|
||||
SharedHandle<DHTNode> remoteNode(new DHTNode(remoteNodeID));
|
||||
|
@ -326,15 +326,15 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values()
|
|||
void DHTMessageFactoryImplTest::testCreateAnnouncePeerMessage()
|
||||
{
|
||||
try {
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("q");
|
||||
dict["q"] = bencode::BDE("announce_peer");
|
||||
bencode::BDE aDict = bencode::BDE::dict();
|
||||
aDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("q");
|
||||
dict["q"] = BDE("announce_peer");
|
||||
BDE aDict = BDE::dict();
|
||||
aDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
unsigned char infoHash[DHT_ID_LENGTH];
|
||||
memset(infoHash, 0x11, DHT_ID_LENGTH);
|
||||
aDict["info_hash"] = bencode::BDE(infoHash, DHT_ID_LENGTH);
|
||||
aDict["info_hash"] = BDE(infoHash, DHT_ID_LENGTH);
|
||||
std::string token = "ffff";
|
||||
uint16_t port = 6881;
|
||||
aDict["port"] = port;
|
||||
|
@ -363,11 +363,11 @@ void DHTMessageFactoryImplTest::testCreateAnnouncePeerMessage()
|
|||
|
||||
void DHTMessageFactoryImplTest::testCreateAnnouncePeerReplyMessage()
|
||||
{
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("r");
|
||||
bencode::BDE rDict = bencode::BDE::dict();
|
||||
rDict["id"] = bencode::BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("r");
|
||||
BDE rDict = BDE::dict();
|
||||
rDict["id"] = BDE(remoteNodeID, DHT_ID_LENGTH);
|
||||
dict["r"] = rDict;
|
||||
|
||||
SharedHandle<DHTNode> remoteNode(new DHTNode(remoteNodeID));
|
||||
|
@ -388,12 +388,12 @@ void DHTMessageFactoryImplTest::testCreateAnnouncePeerReplyMessage()
|
|||
|
||||
void DHTMessageFactoryImplTest::testReceivedErrorMessage()
|
||||
{
|
||||
bencode::BDE dict = bencode::BDE::dict();
|
||||
dict["t"] = bencode::BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = bencode::BDE("e");
|
||||
bencode::BDE list = bencode::BDE::list();
|
||||
BDE dict = BDE::dict();
|
||||
dict["t"] = BDE(transactionID, DHT_TRANSACTION_ID_LENGTH);
|
||||
dict["y"] = BDE("e");
|
||||
BDE list = BDE::list();
|
||||
list << 404;
|
||||
list << bencode::BDE("Not found");
|
||||
list << BDE("Not found");
|
||||
dict["e"] = list;
|
||||
|
||||
SharedHandle<DHTNode> remoteNode(new DHTNode(remoteNodeID));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue