mirror of
https://github.com/aria2/aria2.git
synced 2025-04-06 05:57:36 +03:00
MessageDigestHelper is introduced in order to simplify the use of message digest. Removed repeated code. The message digest algorithm is now specified by string, like "sha1", "md5". * src/messageDigest.{h, cc} * src/MessageDigestHelper.{h, cc}: New class. * src/DefaultPieceStorage.cc * src/DefaultBtContext.{h, cc} (computeFastSet): New function. (setInfoHash): Added for unit testing. (setNumPieces): Added for unit testing. * src/DefaultBtInteractive.cc * src/BtPieceMessage.cc * src/Peer.cc * src/Checksum.h * src/message.h * src/IteratableChecksumValidator.h * src/ChunkChecksumValidator.{h, cc}: Use IteratableChecksumValidator inside it. * src/SegmentMan.{h, cc} (checkIntegrity): Removed. * src/IteratableChunkChecksumValidator.{h, cc} * src/Util.h (sha1Sum): Removed. (simpleMessageDigest): Removed. (fileChecksum): Removed. (computeFastSet): Removed. * src/ShaVisitor.cc * src/ChunkChecksum.h * src/DownloadCommand.cc Removed messageDigest virtual functions. * src/MultiDiskAdaptor.{h, cc} * src/DiskAdaptor.h * src/ByteArrayDiskWriter.h * src/DiskWriter.h * src/DiskAdaptorWriter.h * src/AbstractSingleDiskAdaptor.{h, cc} * src/AbstractDiskWriter.{h, cc} Fixed comilation error when message digest is disabled. * src/MetalinkEntry.{h, cc} * src/MetalinkRequestInfo.cc Removed srandom and random. * src/SimpleRandomizer.h Added size() virtual function to DiskAdaptor * src/MultiDiskAdaptor.h Fixed the bug that causes that files are not opened correctly in multi-file torrent. * src/TorrentRequestInfo.cc * src/MultiDiskAdaptor.cc Added SHA256 support * src/messageDigest.cc * src/Xml2MetalinkProcessor.cc Show supported message digest algorithms * src/main.cc Updated contact info. * src/main.cc
97 lines
2.9 KiB
C++
97 lines
2.9 KiB
C++
#include "TrackerWatcherCommand.h"
|
|
#include "TorrentConsoleDownloadEngine.h"
|
|
#include "MetaFileUtil.h"
|
|
#include "Exception.h"
|
|
#include "prefs.h"
|
|
#include "HttpInitiateConnectionCommand.h"
|
|
#include "ByteArrayDiskWriter.h"
|
|
#include "DefaultBtContext.h"
|
|
#include "DefaultBtAnnounce.h"
|
|
#include "DefaultPieceStorage.h"
|
|
#include "DefaultPeerStorage.h"
|
|
#include "BtRegistry.h"
|
|
#include "RequestFactory.h"
|
|
#include "CUIDCounter.h"
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
using namespace std;
|
|
|
|
class TrackerWatcherCommandTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(TrackerWatcherCommandTest);
|
|
CPPUNIT_TEST(testCreateCommand);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
Option op;
|
|
public:
|
|
TrackerWatcherCommandTest()
|
|
{
|
|
}
|
|
|
|
void setUp()
|
|
{
|
|
CUIDCounterHandle counter = new CUIDCounter();
|
|
CUIDCounterSingletonHolder::instance(counter);
|
|
|
|
op.put(PREF_TRACKER_MAX_TRIES, "10");
|
|
RequestFactoryHandle requestFactory = new RequestFactory();
|
|
requestFactory->setOption(&op);
|
|
RequestFactorySingletonHolder::instance(requestFactory);
|
|
}
|
|
|
|
void testCreateCommand();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( TrackerWatcherCommandTest );
|
|
|
|
void TrackerWatcherCommandTest::testCreateCommand() {
|
|
try {
|
|
|
|
BtContextHandle btContext(new DefaultBtContext());
|
|
btContext->load("test.torrent");
|
|
|
|
BtRuntimeHandle btRuntime;
|
|
BtRegistry::registerBtRuntime(btContext->getInfoHashAsString(), btRuntime);
|
|
|
|
PieceStorageHandle pieceStorage(new DefaultPieceStorage(btContext, &op));
|
|
BtRegistry::registerPieceStorage(btContext->getInfoHashAsString(),
|
|
pieceStorage);
|
|
|
|
PeerStorageHandle peerStorage(new DefaultPeerStorage(btContext, &op));
|
|
BtRegistry::registerPeerStorage(btContext->getInfoHashAsString(),
|
|
peerStorage);
|
|
|
|
BtAnnounceHandle btAnnounce(new DefaultBtAnnounce(btContext, &op));
|
|
BtRegistry::registerBtAnnounce(btContext->getInfoHashAsString(), btAnnounce);
|
|
TorrentConsoleDownloadEngine* te = new TorrentConsoleDownloadEngine();
|
|
te->option = &op;
|
|
te->_requestGroupMan = new RequestGroupMan();
|
|
|
|
TrackerWatcherCommand command(1, te, btContext);
|
|
|
|
RequestFactorySingletonHolder::instance()->createHttpAuthResolver();
|
|
|
|
CPPUNIT_ASSERT(dynamic_cast<HttpInitiateConnectionCommand*>(command.createCommand()));
|
|
//cerr << btAnnounce->getAnnounceUrl() << endl;
|
|
|
|
btAnnounce->announceSuccess();
|
|
btAnnounce->resetAnnounce();
|
|
te->_requestGroupMan = new RequestGroupMan();
|
|
|
|
btRuntime->setHalt(true);
|
|
|
|
CPPUNIT_ASSERT(dynamic_cast<HttpInitiateConnectionCommand*>(command.createCommand()));
|
|
//cerr << btAnnounce->getAnnounceUrl() << endl;
|
|
|
|
btAnnounce->announceSuccess();
|
|
btAnnounce->resetAnnounce();
|
|
te->_requestGroupMan = new RequestGroupMan();
|
|
|
|
CPPUNIT_ASSERT(btAnnounce->noMoreAnnounce());
|
|
|
|
} catch(Exception* e) {
|
|
cerr << e->getMsg() << endl;
|
|
delete e;
|
|
}
|
|
}
|