Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion sources/test/SessionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void SessionTest::takeSingleSellerToExchange(SellerPeer & peer) {
PeerToStartDownloadInformationMap<ID> 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();
Expand All @@ -549,3 +549,12 @@ void SessionTest::assertSellerInvited(const SellerPeer & peer) {
EXPECT_EQ(m2.index(), peer.sellerTermsIndex);

}


int SessionTest::nextPiecePicker(const std::vector<detail::Piece<ID>>* pieces) {
for(uint32_t i = 0;i < pieces->size();i++)
if(pieces->at(i).state() == PieceState::unassigned)
return i;

throw exception::NoPieceAvailableException();
}
4 changes: 3 additions & 1 deletion sources/test/SessionTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -233,6 +233,8 @@ class SessionTest : public ::testing::Test {
bool hasPendingFullPieceRequest(const std::vector<SellerPeer> &);
void takeSingleSellerToExchange(SellerPeer &);
void assertSellerInvited(const SellerPeer &);

static int nextPiecePicker(const std::vector<detail::Piece<ID>>* pieces);
};

#endif // TEST_HPP
2 changes: 1 addition & 1 deletion sources/test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ TEST_F(SessionTest, buying)
PeerToStartDownloadInformationMap<ID> 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();
Expand Down