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>
 | 
			
		||||
 | 
			
		||||
	Execute choking algorithm when BtInterestedMessage arrives from
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
 | 
			
		||||
#include "PeerMessageUtil.h"
 | 
			
		||||
#include "Peer.h"
 | 
			
		||||
#include "PeerStorage.h"
 | 
			
		||||
#include "MockPeerStorage.h"
 | 
			
		||||
 | 
			
		||||
namespace aria2 {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -19,13 +19,7 @@ class BtNotInterestedMessageTest:public CppUnit::TestFixture {
 | 
			
		|||
  CPPUNIT_TEST(testOnSendComplete);
 | 
			
		||||
  CPPUNIT_TEST(testToString);
 | 
			
		||||
  CPPUNIT_TEST_SUITE_END();
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  void setUp() {
 | 
			
		||||
    // TODO add peer storage here
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void testCreate();
 | 
			
		||||
  void testGetMessage();
 | 
			
		||||
  void testDoReceivedAction();
 | 
			
		||||
| 
						 | 
				
			
			@ -71,11 +65,21 @@ void BtNotInterestedMessageTest::testDoReceivedAction() {
 | 
			
		|||
  SharedHandle<Peer> peer(new Peer("host", 6969));
 | 
			
		||||
  peer->allocateSessionResource(1024, 1024*1024);
 | 
			
		||||
  peer->peerInterested(true);
 | 
			
		||||
 | 
			
		||||
  SharedHandle<MockPeerStorage> peerStorage(new MockPeerStorage());
 | 
			
		||||
 | 
			
		||||
  BtNotInterestedMessage msg;
 | 
			
		||||
  msg.setPeer(peer);
 | 
			
		||||
  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 BtNotInterestedMessageTest::testOnSendComplete() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue