summaryrefslogtreecommitdiff
path: root/test/BtInterestedMessageTest.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-11-03 12:04:57 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-11-03 12:04:57 +0000
commit6d01f8f94ff83241fbae5130d1904e03a08945aa (patch)
treebc844a75513ea5b8c89a6aba455d4e75818e25ec /test/BtInterestedMessageTest.cc
parent8fab0ff2160399487fb0010d3b0c8b431dfe545f (diff)
2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Execute choking algorithm when BtInterestedMessage arrives from unchoked peer. * src/BtInterestedMessage.cc * src/BtInterestedMessage.h * src/DefaultBtMessageFactory.cc * test/BtInterestedMessageTest.cc * test/MockPeerStorage.h
Diffstat (limited to 'test/BtInterestedMessageTest.cc')
-rw-r--r--test/BtInterestedMessageTest.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/BtInterestedMessageTest.cc b/test/BtInterestedMessageTest.cc
index 28226106..37c73040 100644
--- a/test/BtInterestedMessageTest.cc
+++ b/test/BtInterestedMessageTest.cc
@@ -6,6 +6,7 @@
#include "PeerMessageUtil.h"
#include "Peer.h"
+#include "MockPeerStorage.h"
namespace aria2 {
@@ -18,12 +19,7 @@ class BtInterestedMessageTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testOnSendComplete);
CPPUNIT_TEST(testToString);
CPPUNIT_TEST_SUITE_END();
-private:
-
public:
- void setUp() {
- }
-
void testCreate();
void testGetMessage();
void testDoReceivedAction();
@@ -71,9 +67,18 @@ void BtInterestedMessageTest::testDoReceivedAction() {
peer->allocateSessionResource(1024, 1024*1024);
msg.setPeer(peer);
+ SharedHandle<MockPeerStorage> peerStorage(new MockPeerStorage());
+
+ msg.setPeerStorage(peerStorage);
+
CPPUNIT_ASSERT(!peer->peerInterested());
msg.doReceivedAction();
CPPUNIT_ASSERT(peer->peerInterested());
+ CPPUNIT_ASSERT_EQUAL(0, peerStorage->getNumChokeExecuted());
+
+ peer->amChoking(false);
+ msg.doReceivedAction();
+ CPPUNIT_ASSERT_EQUAL(1, peerStorage->getNumChokeExecuted());
}
void BtInterestedMessageTest::testOnSendComplete() {