Skip to content

Commit

Permalink
Update torii service test
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsa authored and lebdron committed Aug 2, 2017
1 parent f821ba2 commit 865773a
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions test/module/irohad/torii/torii_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,8 @@ class ToriiServiceTest : public testing::Test {
public:
virtual void SetUp() {
runner = new ServerRunner(Ip, Port);
th = std::thread([runner = runner] {
th = std::thread([this, runner = runner] {
// ----------- Command Service --------------
PCSMock pcsMock;
StatelessValidatorMock svMock;

EXPECT_CALL(svMock, validate(A<const iroha::model::Transaction &>()))
.WillRepeatedly(Return(true));

EXPECT_CALL(pcsMock, propagate_transaction(_)).Times(AtLeast(1));

auto tx_processor =
iroha::torii::TransactionProcessorImpl(pcsMock, svMock);
Expand All @@ -67,13 +60,8 @@ class ToriiServiceTest : public testing::Test {
std::make_unique<torii::CommandService>(pb_tx_factory, tx_processor);

//----------- Query Service ----------
WsvQueryMock wsv_query;
BlockQueryMock block_query;
iroha::model::QueryProcessingFactory qpf(wsv_query, block_query);

EXPECT_CALL(svMock, validate(A<const iroha::model::Query &>()))
.WillRepeatedly(Return(false));

iroha::torii::QueryProcessorImpl qpi(qpf, svMock);

iroha::model::converters::PbQueryFactory pb_query_factory;
Expand All @@ -97,9 +85,20 @@ class ToriiServiceTest : public testing::Test {

ServerRunner *runner;
std::thread th;

WsvQueryMock wsv_query;
BlockQueryMock block_query;

PCSMock pcsMock;
StatelessValidatorMock svMock;
};

TEST_F(ToriiServiceTest, ToriiWhenBlocking) {
EXPECT_CALL(svMock, validate(A<const iroha::model::Transaction &>()))
.WillRepeatedly(Return(true));

EXPECT_CALL(pcsMock, propagate_transaction(_)).Times(AtLeast(1));

for (size_t i = 0; i < TimesToriiBlocking; ++i) {
iroha::protocol::ToriiResponse response;
// One client is generating transaction
Expand All @@ -118,6 +117,11 @@ TEST_F(ToriiServiceTest, ToriiWhenNonBlocking) {
torii::CommandAsyncClient client(Ip, Port);
std::atomic_int count{0};

EXPECT_CALL(svMock, validate(A<const iroha::model::Transaction &>()))
.WillRepeatedly(Return(true));

EXPECT_CALL(pcsMock, propagate_transaction(_)).Times(AtLeast(1));

for (size_t i = 0; i < TimesToriiNonBlocking; ++i) {
auto new_tx = iroha::protocol::Transaction();
auto meta = new_tx.mutable_meta();
Expand Down

0 comments on commit 865773a

Please sign in to comment.