diff --git a/irohad/network/impl/peer_communication_service_impl.cpp b/irohad/network/impl/peer_communication_service_impl.cpp index 8dfd6b9df5..4bd7e15b33 100644 --- a/irohad/network/impl/peer_communication_service_impl.cpp +++ b/irohad/network/impl/peer_communication_service_impl.cpp @@ -1,5 +1,5 @@ /* -Copyright Soramitsu Co., Ltd. 2016 All Rights Reserved. +Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -31,17 +31,12 @@ namespace iroha { std::shared_ptr transaction) { log_->info("propagate tx"); - ordering_gate_->propagateTransaction( - std::shared_ptr(transaction->makeOldModel())); + ordering_gate_->propagateTransaction(transaction); } rxcpp::observable> PeerCommunicationServiceImpl::on_proposal() const { - return ordering_gate_->on_proposal().map( - [](auto prop) -> std::shared_ptr { - return std::make_shared( - shared_model::proto::from_old(prop)); - }); + return ordering_gate_->on_proposal(); } rxcpp::observable PeerCommunicationServiceImpl::on_commit() const { diff --git a/irohad/network/ordering_gate.hpp b/irohad/network/ordering_gate.hpp index 326cb66fe3..35b6ca8806 100644 --- a/irohad/network/ordering_gate.hpp +++ b/irohad/network/ordering_gate.hpp @@ -19,10 +19,15 @@ #define IROHA_ORDERING_SERVICE_HPP #include -#include "model/proposal.hpp" -#include "model/transaction.hpp" #include "network/peer_communication_service.hpp" +namespace shared_model { + namespace interface { + class Transaction; + class Proposal; + } // namespace interface +} // namespace shared_model + namespace iroha { namespace network { @@ -36,13 +41,16 @@ namespace iroha { * @param transaction */ virtual void propagateTransaction( - std::shared_ptr transaction) = 0; + std::shared_ptr + transaction) = 0; /** * Return observable of all proposals in the consensus * @return observable with notifications */ - virtual rxcpp::observable on_proposal() = 0; + virtual rxcpp::observable< + std::shared_ptr> + on_proposal() = 0; /** * Set peer communication service for commit notification diff --git a/irohad/network/ordering_gate_transport.hpp b/irohad/network/ordering_gate_transport.hpp index a0201bc461..34a9bcfc5b 100644 --- a/irohad/network/ordering_gate_transport.hpp +++ b/irohad/network/ordering_gate_transport.hpp @@ -18,7 +18,13 @@ #define IROHA_ORDERING_GATE_TRANSPORT_H #include -#include "model/proposal.hpp" + +namespace shared_model { + namespace interface { + class Transaction; + class Proposal; + } // namespace interface +} // namespace shared_model namespace iroha { namespace network { @@ -33,7 +39,8 @@ namespace iroha { * Callback on receiving proposal * @param proposal - proposal object itself */ - virtual void onProposal(model::Proposal) = 0; + virtual void onProposal( + std::shared_ptr) = 0; virtual ~OrderingGateNotification() = default; }; @@ -58,7 +65,8 @@ namespace iroha { * @param transaction : transaction to be propagated */ virtual void propagateTransaction( - std::shared_ptr transaction) = 0; + std::shared_ptr + transaction) = 0; virtual ~OrderingGateTransport() = default; }; diff --git a/irohad/ordering/impl/ordering_gate_impl.cpp b/irohad/ordering/impl/ordering_gate_impl.cpp index d37e311a2b..0dfad79966 100644 --- a/irohad/ordering/impl/ordering_gate_impl.cpp +++ b/irohad/ordering/impl/ordering_gate_impl.cpp @@ -17,6 +17,7 @@ #include +#include "interfaces/transaction.hpp" #include "ordering/impl/ordering_gate_impl.hpp" namespace iroha { @@ -27,15 +28,17 @@ namespace iroha { : transport_(std::move(transport)), log_(logger::log("OrderingGate")) {} void OrderingGateImpl::propagateTransaction( - std::shared_ptr transaction) { - log_->info("propagate tx, tx_counter: " - + std::to_string(transaction->tx_counter) - + " account_id: " + transaction->creator_account_id); + std::shared_ptr + transaction) { + log_->info("propagate tx, tx_counter: {} account_id: {}", + std::to_string(transaction->transactionCounter()), + " account_id: " + transaction->creatorAccountId()); transport_->propagateTransaction(transaction); } - rxcpp::observable OrderingGateImpl::on_proposal() { + rxcpp::observable> + OrderingGateImpl::on_proposal() { return proposals_.get_observable(); } @@ -50,20 +53,19 @@ namespace iroha { }); } - void OrderingGateImpl::onProposal(model::Proposal proposal) { + void OrderingGateImpl::onProposal( + std::shared_ptr proposal) { log_->info("Received new proposal"); - proposal_queue_.push( - std::make_shared(std::move(proposal))); + proposal_queue_.push(std::move(proposal)); tryNextRound(); } void OrderingGateImpl::tryNextRound() { - if (not proposal_queue_.empty() - and unlock_next_.exchange(false)) { - std::shared_ptr next_proposal; + if (not proposal_queue_.empty() and unlock_next_.exchange(false)) { + std::shared_ptr next_proposal; proposal_queue_.try_pop(next_proposal); log_->info("Pass the proposal to pipeline"); - proposals_.get_subscriber().on_next(*next_proposal); + proposals_.get_subscriber().on_next(next_proposal); } } diff --git a/irohad/ordering/impl/ordering_gate_impl.hpp b/irohad/ordering/impl/ordering_gate_impl.hpp index 0f5fae4364..c614f95900 100644 --- a/irohad/ordering/impl/ordering_gate_impl.hpp +++ b/irohad/ordering/impl/ordering_gate_impl.hpp @@ -21,14 +21,18 @@ #include "network/ordering_gate.hpp" #include - #include -#include "model/converters/pb_transaction_factory.hpp" +#include "logger/logger.hpp" #include "network/impl/async_grpc_client.hpp" #include "network/ordering_gate_transport.hpp" -#include "logger/logger.hpp" +namespace shared_model { + namespace interaface { + class Transaction; + class Proposal; + } // namespace interaface +} // namespace shared_model namespace iroha { namespace ordering { @@ -46,13 +50,16 @@ namespace iroha { std::shared_ptr transport); void propagateTransaction( - std::shared_ptr transaction) override; + std::shared_ptr + transaction) override; - rxcpp::observable on_proposal() override; + rxcpp::observable> + on_proposal() override; void setPcs(const iroha::network::PeerCommunicationService &pcs) override; - void onProposal(model::Proposal proposal) override; + void onProposal( + std::shared_ptr proposal) override; ~OrderingGateImpl() override; @@ -62,14 +69,17 @@ namespace iroha { */ void tryNextRound(); - rxcpp::subjects::subject proposals_; + rxcpp::subjects::subject< + std::shared_ptr> + proposals_; std::shared_ptr transport_; /// invariant: true if proposal can be pushed to subscribers std::atomic_bool unlock_next_{true}; /// queue with all proposals received from ordering service - tbb::concurrent_queue> proposal_queue_; + tbb::concurrent_queue> + proposal_queue_; /// subscription of pcs::on_commit rxcpp::composite_subscription pcs_subscriber_; diff --git a/irohad/ordering/impl/ordering_gate_transport_grpc.cpp b/irohad/ordering/impl/ordering_gate_transport_grpc.cpp index 2922354f0f..316300e784 100644 --- a/irohad/ordering/impl/ordering_gate_transport_grpc.cpp +++ b/irohad/ordering/impl/ordering_gate_transport_grpc.cpp @@ -16,6 +16,10 @@ */ #include "ordering_gate_transport_grpc.hpp" +#include "backend/protobuf/transaction.hpp" +#include "builders/protobuf/proposal.hpp" +#include "interfaces/common_objects/types.hpp" + using namespace iroha::ordering; grpc::Status OrderingGateTransportGrpc::onProposal( @@ -24,15 +28,19 @@ grpc::Status OrderingGateTransportGrpc::onProposal( ::google::protobuf::Empty *response) { log_->info("receive proposal"); - auto transactions = decltype(std::declval().transactions)(); + std::vector transactions; for (const auto &tx : request->transactions()) { - transactions.push_back(*factory_.deserialize(tx)); + transactions.emplace_back(tx); } log_->info("transactions in proposal: {}", transactions.size()); - model::Proposal proposal(transactions); - proposal.height = request->height(); - proposal.created_time = request->created_time(); + auto proposal = std::make_shared( + shared_model::proto::ProposalBuilder() + .transactions(transactions) + .height(request->height()) + .createdTime(request->created_time()) + .build()); + if (not subscriber_.expired()) { subscriber_.lock()->onProposal(std::move(proposal)); } else { @@ -49,12 +57,15 @@ OrderingGateTransportGrpc::OrderingGateTransportGrpc( log_(logger::log("OrderingGate")) {} void OrderingGateTransportGrpc::propagateTransaction( - std::shared_ptr transaction) { + std::shared_ptr transaction) { log_->info("Propagate tx (on transport)"); auto call = new AsyncClientCall; - call->response_reader = client_->AsynconTransaction( - &call->context, factory_.serialize(*transaction), &cq_); + auto transaction_transport = + static_cast(*transaction) + .getTransport(); + call->response_reader = + client_->AsynconTransaction(&call->context, transaction_transport, &cq_); call->response_reader->Finish(&call->reply, &call->status, call); } diff --git a/irohad/ordering/impl/ordering_gate_transport_grpc.hpp b/irohad/ordering/impl/ordering_gate_transport_grpc.hpp index 96d1123f1e..005bd16de4 100644 --- a/irohad/ordering/impl/ordering_gate_transport_grpc.hpp +++ b/irohad/ordering/impl/ordering_gate_transport_grpc.hpp @@ -18,12 +18,17 @@ #define IROHA_ORDERING_GATE_TRANSPORT_GRPC_H #include + #include "logger/logger.hpp" -#include "model/converters/pb_transaction_factory.hpp" #include "network/impl/async_grpc_client.hpp" #include "network/ordering_gate_transport.hpp" #include "ordering.grpc.pb.h" -#include "proposal.pb.h" + +namespace shared_model { + namespace interface { + class Transaction; + } +} // namespace shared_model namespace iroha { namespace ordering { @@ -39,7 +44,8 @@ namespace iroha { ::google::protobuf::Empty *response) override; void propagateTransaction( - std::shared_ptr transaction) override; + std::shared_ptr + transaction) override; void subscribe(std::shared_ptr subscriber) override; @@ -47,7 +53,6 @@ namespace iroha { private: std::weak_ptr subscriber_; std::unique_ptr client_; - model::converters::PbTransactionFactory factory_; logger::Logger log_; }; diff --git a/irohad/ordering/impl/ordering_service_impl.cpp b/irohad/ordering/impl/ordering_service_impl.cpp index 168d87179a..503771782a 100644 --- a/irohad/ordering/impl/ordering_service_impl.cpp +++ b/irohad/ordering/impl/ordering_service_impl.cpp @@ -1,5 +1,5 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. * http://soramitsu.co.jp * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,11 +16,13 @@ */ #include "ordering/impl/ordering_service_impl.hpp" + #include "ametsuchi/ordering_service_persistent_state.hpp" +#include "ametsuchi/peer_query.hpp" +#include "backend/protobuf/proposal.hpp" #include "backend/protobuf/transaction.hpp" -#include "builders/protobuf/proposal.hpp" -#include "logger/logger.hpp" -#include "proposal.pb.h" +#include "datetime/time.hpp" +#include "network/ordering_service_transport.hpp" namespace iroha { namespace ordering { diff --git a/irohad/ordering/impl/ordering_service_impl.hpp b/irohad/ordering/impl/ordering_service_impl.hpp index 69fd5a3d27..b06cda5f02 100644 --- a/irohad/ordering/impl/ordering_service_impl.hpp +++ b/irohad/ordering/impl/ordering_service_impl.hpp @@ -1,5 +1,5 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. * http://soramitsu.co.jp * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,20 +21,19 @@ #include #include #include -#include -#include "ametsuchi/peer_query.hpp" #include "logger/logger.hpp" -#include "network/impl/async_grpc_client.hpp" #include "network/ordering_service.hpp" -#include "network/ordering_service_transport.hpp" #include "ordering.grpc.pb.h" namespace iroha { namespace ametsuchi { class OrderingServicePersistentState; - } + class OrderingServiceTransport; + class PeerQuery; + } // namespace ametsuchi + namespace ordering { /** diff --git a/irohad/ordering/impl/ordering_service_transport_grpc.cpp b/irohad/ordering/impl/ordering_service_transport_grpc.cpp index 0621197a43..98554df766 100644 --- a/irohad/ordering/impl/ordering_service_transport_grpc.cpp +++ b/irohad/ordering/impl/ordering_service_transport_grpc.cpp @@ -1,5 +1,5 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. * http://soramitsu.co.jp * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +15,7 @@ * limitations under the License. */ #include "ordering/impl/ordering_service_transport_grpc.hpp" + #include "backend/protobuf/transaction.hpp" #include "builders/protobuf/proposal.hpp" diff --git a/irohad/ordering/impl/ordering_service_transport_grpc.hpp b/irohad/ordering/impl/ordering_service_transport_grpc.hpp index b12b1b52a9..4e65196303 100644 --- a/irohad/ordering/impl/ordering_service_transport_grpc.hpp +++ b/irohad/ordering/impl/ordering_service_transport_grpc.hpp @@ -1,5 +1,5 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. * http://soramitsu.co.jp * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,12 +18,12 @@ #define IROHA_ORDERING_SERVICE_TRANSPORT_GRPC_HPP #include + #include "block.pb.h" #include "logger/logger.hpp" -#include "ordering.grpc.pb.h" - #include "network/impl/async_grpc_client.hpp" #include "network/ordering_service_transport.hpp" +#include "ordering.grpc.pb.h" namespace iroha { namespace ordering { diff --git a/irohad/simulator/impl/simulator.cpp b/irohad/simulator/impl/simulator.cpp index 00576c8907..39a51c49be 100644 --- a/irohad/simulator/impl/simulator.cpp +++ b/irohad/simulator/impl/simulator.cpp @@ -38,9 +38,9 @@ namespace iroha { crypto_provider_(std::move(crypto_provider)) { log_ = logger::log("Simulator"); ordering_gate->on_proposal().subscribe( - proposal_subscription_, [this](model::Proposal old_proposal) { - this->process_proposal(shared_model::proto::Proposal( - shared_model::proto::from_old(old_proposal))); + proposal_subscription_, + [this](std::shared_ptr proposal) { + this->process_proposal(*proposal); }); notifier_.get_observable().subscribe( diff --git a/test/module/irohad/network/network_mocks.hpp b/test/module/irohad/network/network_mocks.hpp index 7f75a99c1d..2b7caf4065 100644 --- a/test/module/irohad/network/network_mocks.hpp +++ b/test/module/irohad/network/network_mocks.hpp @@ -24,6 +24,12 @@ #include "network/ordering_gate.hpp" #include "network/peer_communication_service.hpp" +namespace shared_model { + namespace interface { + class Transaction; + } +} // namespace shared_model + namespace iroha { namespace network { class MockPeerCommunicationService : public PeerCommunicationService { @@ -42,30 +48,38 @@ namespace iroha { class MockBlockLoader : public BlockLoader { public: - MOCK_METHOD1(retrieveBlocks, - rxcpp::observable>( - const shared_model::crypto::PublicKey &)); - MOCK_METHOD2(retrieveBlock, - boost::optional>( - const shared_model::crypto::PublicKey &, - const shared_model::interface::types::HashType &)); + MOCK_METHOD1( + retrieveBlocks, + rxcpp::observable>( + const shared_model::crypto::PublicKey &)); + MOCK_METHOD2( + retrieveBlock, + boost::optional>( + const shared_model::crypto::PublicKey &, + const shared_model::interface::types::HashType &)); }; class MockOrderingGate : public OrderingGate { public: - MOCK_METHOD1(propagateTransaction, - void(std::shared_ptr transaction)); + MOCK_METHOD1( + propagateTransaction, + void(std::shared_ptr + transaction)); - MOCK_METHOD0(on_proposal, rxcpp::observable()); + MOCK_METHOD0(on_proposal, + rxcpp::observable< + std::shared_ptr>()); MOCK_METHOD1(setPcs, void(const PeerCommunicationService &)); }; class MockConsensusGate : public ConsensusGate { public: - MOCK_METHOD1(vote, void(const shared_model::interface::Block&)); + MOCK_METHOD1(vote, void(const shared_model::interface::Block &)); - MOCK_METHOD0(on_commit, rxcpp::observable>()); + MOCK_METHOD0( + on_commit, + rxcpp::observable>()); }; } // namespace network } // namespace iroha diff --git a/test/module/irohad/ordering/ordering_gate_service_test.cpp b/test/module/irohad/ordering/ordering_gate_service_test.cpp index f3a8c9f73f..94d7e48c2b 100644 --- a/test/module/irohad/ordering/ordering_gate_service_test.cpp +++ b/test/module/irohad/ordering/ordering_gate_service_test.cpp @@ -17,20 +17,17 @@ #include -#include "backend/protobuf/common_objects/peer.hpp" #include "builders/protobuf/common_objects/proto_peer_builder.hpp" -#include "builders/common_objects/peer_builder.hpp" #include "framework/test_subscriber.hpp" #include "mock_ordering_service_persistent_state.hpp" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/network/network_mocks.hpp" +#include "module/shared_model/builders/protobuf/test_block_builder.hpp" +#include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" #include "ordering/impl/ordering_gate_impl.hpp" #include "ordering/impl/ordering_gate_transport_grpc.hpp" #include "ordering/impl/ordering_service_impl.hpp" #include "ordering/impl/ordering_service_transport_grpc.hpp" -#include "validators/field_validator.hpp" - -#include "module/shared_model/builders/protobuf/test_block_builder.hpp" using namespace iroha; using namespace iroha::ordering; @@ -102,7 +99,8 @@ class OrderingGateServiceTest : public ::testing::Test { } } - TestSubscriber init(size_t times) { + TestSubscriber> init( + size_t times) { auto wrapper = make_test_subscriber(gate->on_proposal(), times); gate->on_proposal().subscribe([this](auto) { counter--; @@ -128,8 +126,8 @@ class OrderingGateServiceTest : public ::testing::Test { * @param i - number of transaction */ void send_transaction(size_t i) { - auto tx = std::make_shared(); - tx->tx_counter = i; + auto tx = std::make_shared( + TestTransactionBuilder().txCounter(i).build()); gate->propagateTransaction(tx); // otherwise tx may come unordered std::this_thread::sleep_for(20ms); @@ -144,7 +142,7 @@ class OrderingGateServiceTest : public ::testing::Test { std::shared_ptr pcs_; rxcpp::subjects::subject commit_subject_; - std::vector proposals; + std::vector> proposals; std::atomic counter; std::condition_variable cv; std::mutex m; @@ -206,15 +204,15 @@ TEST_F(OrderingGateServiceTest, SplittingBunchTransactions) { std::this_thread::sleep_for(1s); ASSERT_EQ(proposals.size(), 2); - ASSERT_EQ(proposals.at(0).transactions.size(), 8); - ASSERT_EQ(proposals.at(1).transactions.size(), 2); + ASSERT_EQ(proposals.at(0)->transactions().size(), 8); + ASSERT_EQ(proposals.at(1)->transactions().size(), 2); ASSERT_EQ(counter, 0); ASSERT_TRUE(wrapper.validate()); size_t i = 0; for (auto &&proposal : proposals) { - for (auto &&tx : proposal.transactions) { - ASSERT_EQ(tx.tx_counter, i++); + for (auto &&tx : proposal->transactions()) { + ASSERT_EQ(tx->transactionCounter(), i++); } } } @@ -268,9 +266,9 @@ TEST_F(OrderingGateServiceTest, ProposalsReceivedWhenProposalSize) { size_t i = 0; for (auto &&proposal : proposals) { - ASSERT_EQ(proposal.transactions.size(), 5); - for (auto &&tx : proposal.transactions) { - ASSERT_EQ(tx.tx_counter, i++); + ASSERT_EQ(proposal->transactions().size(), 5); + for (auto &&tx : proposal->transactions()) { + ASSERT_EQ(tx->transactionCounter(), i++); } } } diff --git a/test/module/irohad/ordering/ordering_gate_test.cpp b/test/module/irohad/ordering/ordering_gate_test.cpp index f087cbbd80..8156015ff7 100644 --- a/test/module/irohad/ordering/ordering_gate_test.cpp +++ b/test/module/irohad/ordering/ordering_gate_test.cpp @@ -20,14 +20,11 @@ #include "framework/test_subscriber.hpp" #include "module/irohad/network/network_mocks.hpp" -#include "network/ordering_service.hpp" - +#include "module/shared_model/builders/protobuf/test_block_builder.hpp" +#include "module/shared_model/builders/protobuf/test_proposal_builder.hpp" +#include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" #include "ordering/impl/ordering_gate_impl.hpp" #include "ordering/impl/ordering_gate_transport_grpc.hpp" -#include "ordering/impl/ordering_service_impl.hpp" -#include "ordering/impl/ordering_service_transport_grpc.hpp" - -#include "module/shared_model/builders/protobuf/test_block_builder.hpp" using namespace iroha; using namespace iroha::ordering; @@ -35,9 +32,9 @@ using namespace iroha::network; using namespace framework::test_subscriber; using namespace std::chrono_literals; -using ::testing::_; using ::testing::InvokeWithoutArgs; using ::testing::Return; +using ::testing::_; class MockOrderingGateTransportGrpcService : public proto::OrderingServiceTransportGrpc::Service { @@ -50,8 +47,9 @@ class MockOrderingGateTransportGrpcService class MockOrderingGateTransport : public OrderingGateTransport { MOCK_METHOD1(subscribe, void(std::shared_ptr)); - MOCK_METHOD1(propagateTransaction, - void(std::shared_ptr)); + MOCK_METHOD1( + propagateTransaction, + void(std::shared_ptr)); }; class OrderingGateTest : public ::testing::Test { @@ -119,7 +117,9 @@ TEST_F(OrderingGateTest, TransactionReceivedByServerWhenSent) { })); for (size_t i = 0; i < 5; ++i) { - gate_impl->propagateTransaction(std::make_shared()); + auto tx = std::make_shared( + TestTransactionBuilder().build()); + gate_impl->propagateTransaction(tx); } std::unique_lock lock(m); @@ -172,8 +172,13 @@ TEST(OrderingGateQueueBehaviour, SendManyProposals) { make_test_subscriber(ordering_gate.on_proposal(), 2); wrapper_after.subscribe(); - ordering_gate.onProposal(iroha::model::Proposal{{}}); - ordering_gate.onProposal(iroha::model::Proposal{{}}); + auto proposal1 = std::make_shared( + TestProposalBuilder().build()); + auto proposal2 = std::make_shared( + TestProposalBuilder().build()); + + ordering_gate.onProposal(proposal1); + ordering_gate.onProposal(proposal2); ASSERT_TRUE(wrapper_before.validate()); diff --git a/test/module/irohad/ordering/ordering_service_test.cpp b/test/module/irohad/ordering/ordering_service_test.cpp index f2537a5c4a..9f28a56ddb 100644 --- a/test/module/irohad/ordering/ordering_service_test.cpp +++ b/test/module/irohad/ordering/ordering_service_test.cpp @@ -17,26 +17,16 @@ #include +#include "backend/protobuf/common_objects/peer.hpp" +#include "builders/protobuf/common_objects/proto_peer_builder.hpp" #include "logger/logger.hpp" -#include "network/ordering_service.hpp" - #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/network/network_mocks.hpp" - -#include "ametsuchi/ordering_service_persistent_state.hpp" -#include "backend/protobuf/common_objects/peer.hpp" -#include "mock_ordering_service_persistent_state.hpp" -#include "builders/common_objects/peer_builder.hpp" -#include "builders/protobuf/common_objects/proto_peer_builder.hpp" -#include "ordering/impl/ordering_gate_impl.hpp" -#include "ordering/impl/ordering_gate_transport_grpc.hpp" -#include "ordering/impl/ordering_service_impl.hpp" -#include "ordering/impl/ordering_service_transport_grpc.hpp" -#include "validators/field_validator.hpp" - -#include "builders/protobuf/common_objects/proto_peer_builder.hpp" +#include "module/irohad/ordering/mock_ordering_service_persistent_state.hpp" #include "module/shared_model/builders/protobuf/test_proposal_builder.hpp" #include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" +#include "ordering/impl/ordering_service_impl.hpp" +#include "ordering/impl/ordering_service_transport_grpc.hpp" using namespace iroha; using namespace iroha::ordering; @@ -44,12 +34,12 @@ using namespace iroha::network; using namespace iroha::ametsuchi; using namespace std::chrono_literals; -using ::testing::_; using ::testing::AtLeast; using ::testing::DoAll; using ::testing::Invoke; using ::testing::InvokeWithoutArgs; using ::testing::Return; +using ::testing::_; static logger::Logger log_ = logger::testLog("OrderingService"); diff --git a/test/module/irohad/simulator/simulator_test.cpp b/test/module/irohad/simulator/simulator_test.cpp index b2e3acd31d..b53f9a76c3 100644 --- a/test/module/irohad/simulator/simulator_test.cpp +++ b/test/module/irohad/simulator/simulator_test.cpp @@ -15,7 +15,9 @@ * limitations under the License. */ +#include "simulator/impl/simulator.hpp" #include "backend/protobuf/transaction.hpp" +#include "framework/test_subscriber.hpp" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/model/model_mocks.hpp" #include "module/irohad/network/network_mocks.hpp" @@ -23,9 +25,6 @@ #include "module/shared_model/builders/protobuf/test_block_builder.hpp" #include "module/shared_model/builders/protobuf/test_proposal_builder.hpp" -#include "framework/test_subscriber.hpp" -#include "simulator/impl/simulator.hpp" - using namespace iroha; using namespace iroha::validation; using namespace iroha::ametsuchi; @@ -82,7 +81,8 @@ shared_model::proto::Proposal makeProposal(int height) { TEST_F(SimulatorTest, ValidWhenInitialized) { // simulator constructor => on_proposal subscription called EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty())); + .WillOnce(Return(rxcpp::observable<>::empty< + std::shared_ptr>())); init(); } @@ -102,7 +102,8 @@ TEST_F(SimulatorTest, ValidWhenPreviousBlock) { EXPECT_CALL(*validator, validate(_, _)).WillOnce(Return(proposal)); EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty())); + .WillOnce(Return(rxcpp::observable<>::empty< + std::shared_ptr>())); EXPECT_CALL(*crypto_provider, sign(A())).Times(1); @@ -140,7 +141,8 @@ TEST_F(SimulatorTest, FailWhenNoBlock) { EXPECT_CALL(*validator, validate(_, _)).Times(0); EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty())); + .WillOnce(Return(rxcpp::observable<>::empty< + std::shared_ptr>())); EXPECT_CALL(*crypto_provider, sign(A())).Times(0); @@ -175,7 +177,8 @@ TEST_F(SimulatorTest, FailWhenSameAsProposalHeight) { EXPECT_CALL(*validator, validate(_, _)).Times(0); EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty())); + .WillOnce(Return(rxcpp::observable<>::empty< + std::shared_ptr>())); EXPECT_CALL(*crypto_provider, sign(A())).Times(0);