diff --git a/sources/test/SessionTest.cpp b/sources/test/SessionTest.cpp index 49fbf67..cd9df38 100644 --- a/sources/test/SessionTest.cpp +++ b/sources/test/SessionTest.cpp @@ -527,7 +527,7 @@ void SessionTest::takeSingleSellerToExchange(SellerPeer & peer) { PeerToStartDownloadInformationMap map = downloadInformationMap(v); // Start download - session->startDownloading(contractTx, map); + session->startDownloading(contractTx, map, nextPiecePicker); // make sure contract was announced to only relevant peers peer.contractAnnounced(); @@ -549,3 +549,12 @@ void SessionTest::assertSellerInvited(const SellerPeer & peer) { EXPECT_EQ(m2.index(), peer.sellerTermsIndex); } + + +int SessionTest::nextPiecePicker(const std::vector>* pieces) { + for(uint32_t i = 0;i < pieces->size();i++) + if(pieces->at(i).state() == PieceState::unassigned) + return i; + + throw exception::NoPieceAvailableException(); +} diff --git a/sources/test/SessionTest.hpp b/sources/test/SessionTest.hpp index b585f1f..d675a4d 100644 --- a/sources/test/SessionTest.hpp +++ b/sources/test/SessionTest.hpp @@ -159,7 +159,7 @@ class SessionTest : public ::testing::Test { return joiningContract; } - void contractAnnounced() { + void contractAnnounced() { auto slot = spy->sendReadyCallbackSlot; EXPECT_TRUE((int)slot.size() > 0); ready = std::get<0>(slot.front()); @@ -233,6 +233,8 @@ class SessionTest : public ::testing::Test { bool hasPendingFullPieceRequest(const std::vector &); void takeSingleSellerToExchange(SellerPeer &); void assertSellerInvited(const SellerPeer &); + + static int nextPiecePicker(const std::vector>* pieces); }; #endif // TEST_HPP diff --git a/sources/test/test_main.cpp b/sources/test/test_main.cpp index 0edf246..eb59cbb 100644 --- a/sources/test/test_main.cpp +++ b/sources/test/test_main.cpp @@ -485,7 +485,7 @@ TEST_F(SessionTest, buying) PeerToStartDownloadInformationMap map = downloadInformationMap(v); // Start download - session->startDownloading(contractTx, map); + session->startDownloading(contractTx, map, SessionTest::nextPiecePicker); // make sure contract was announced to only relevant peers first.contractAnnounced();