mirror of https://github.com/aria2/aria2
				
				
				
			2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added testcase for BtNotInterestedMessage from unchoked peer. * test/BtNotInterestedMessageTest.ccpull/1/head
							parent
							
								
									6d01f8f94f
								
							
						
					
					
						commit
						0b7033abb7
					
				| 
						 | 
					@ -1,3 +1,8 @@
 | 
				
			||||||
 | 
					2008-11-03  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Added testcase for BtNotInterestedMessage from unchoked peer.
 | 
				
			||||||
 | 
						* test/BtNotInterestedMessageTest.cc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2008-11-03  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
					2008-11-03  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Execute choking algorithm when BtInterestedMessage arrives from
 | 
						Execute choking algorithm when BtInterestedMessage arrives from
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "PeerMessageUtil.h"
 | 
					#include "PeerMessageUtil.h"
 | 
				
			||||||
#include "Peer.h"
 | 
					#include "Peer.h"
 | 
				
			||||||
#include "PeerStorage.h"
 | 
					#include "MockPeerStorage.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace aria2 {
 | 
					namespace aria2 {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,13 +19,7 @@ class BtNotInterestedMessageTest:public CppUnit::TestFixture {
 | 
				
			||||||
  CPPUNIT_TEST(testOnSendComplete);
 | 
					  CPPUNIT_TEST(testOnSendComplete);
 | 
				
			||||||
  CPPUNIT_TEST(testToString);
 | 
					  CPPUNIT_TEST(testToString);
 | 
				
			||||||
  CPPUNIT_TEST_SUITE_END();
 | 
					  CPPUNIT_TEST_SUITE_END();
 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  void setUp() {
 | 
					 | 
				
			||||||
    // TODO add peer storage here
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  void testCreate();
 | 
					  void testCreate();
 | 
				
			||||||
  void testGetMessage();
 | 
					  void testGetMessage();
 | 
				
			||||||
  void testDoReceivedAction();
 | 
					  void testDoReceivedAction();
 | 
				
			||||||
| 
						 | 
					@ -71,11 +65,21 @@ void BtNotInterestedMessageTest::testDoReceivedAction() {
 | 
				
			||||||
  SharedHandle<Peer> peer(new Peer("host", 6969));
 | 
					  SharedHandle<Peer> peer(new Peer("host", 6969));
 | 
				
			||||||
  peer->allocateSessionResource(1024, 1024*1024);
 | 
					  peer->allocateSessionResource(1024, 1024*1024);
 | 
				
			||||||
  peer->peerInterested(true);
 | 
					  peer->peerInterested(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  SharedHandle<MockPeerStorage> peerStorage(new MockPeerStorage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  BtNotInterestedMessage msg;
 | 
					  BtNotInterestedMessage msg;
 | 
				
			||||||
  msg.setPeer(peer);
 | 
					  msg.setPeer(peer);
 | 
				
			||||||
 | 
					  msg.setPeerStorage(peerStorage);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  CPPUNIT_ASSERT(peer->peerInterested());
 | 
					  CPPUNIT_ASSERT(peer->peerInterested());
 | 
				
			||||||
  msg.doReceivedAction();
 | 
					  msg.doReceivedAction();
 | 
				
			||||||
  CPPUNIT_ASSERT(!peer->peerInterested());
 | 
					  CPPUNIT_ASSERT(!peer->peerInterested());
 | 
				
			||||||
 | 
					  CPPUNIT_ASSERT_EQUAL(0, peerStorage->getNumChokeExecuted());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  peer->amChoking(false);
 | 
				
			||||||
 | 
					  msg.doReceivedAction();
 | 
				
			||||||
 | 
					  CPPUNIT_ASSERT_EQUAL(1, peerStorage->getNumChokeExecuted());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BtNotInterestedMessageTest::testOnSendComplete() {
 | 
					void BtNotInterestedMessageTest::testOnSendComplete() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue