Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
motxx committed Jun 22, 2017
1 parent 6522a08 commit 3e038bd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
3 changes: 1 addition & 2 deletions irohad/consensus/connection/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ limitations under the License.
*/

#include <grpc++/grpc++.h>
#include <endpoint.pb.h>
#include <endpoint.grpc.pb.h>
#include <block.pb.h>
#include "client.hpp"

namespace consensus {
Expand Down
2 changes: 2 additions & 0 deletions irohad/consensus/connection/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ limitations under the License.
#ifndef CONSENSUS_CONNECTION_CLIENT_HPP
#define CONSENSUS_CONNECTION_CLIENT_HPP

#include <grpc++/grpc++.h>
#include <memory>
#include <block.pb.h>
#include <endpoint.pb.h>
#include <endpoint.grpc.pb.h>

namespace consensus {
namespace connection {
Expand Down
2 changes: 2 additions & 0 deletions irohad/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

add_library(server_runner server_runner.cpp)
target_link_libraries(server_runner
logger
Expand Down
21 changes: 9 additions & 12 deletions test/module/irohad/consensus/connection/connection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,35 @@ limitations under the License.
#include <thread>
#include <endpoint.grpc.pb.h>

using namespace consensus::connection;
namespace conn = consensus::connection;
using iroha::protocol::Block;

class ConsensusConnectionTest : public ::testing::Test {
protected:
virtual void SetUp() {
std::vector<grpc::Service*> services {
serverRunner_.reset(new ServerRunner("0.0.0.0", 50051, {
&service_
};
serverRunner_ = std::make_unique<ServerRunner>("0.0.0.0", 50051, services);
}));
running_ = false;
}

virtual void TearDown() {
if (running_) {
serverRunner_->shutDown();
serverRunner_->shutdown();
serverThread_.join();
}
}

void RunServer() {
serverThread_ = std::thread(&ServerRunner::run, serverRunner_.get());
serverThread_ = std::thread(&IServerRunner::run, std::ref(*serverRunner_));
serverRunner_->waitForServersReady();
running_ = true;
}

private:
bool running_;
iroha::protocol::SumeragiService::Service service_;
std::unique_ptr<ServerRunner> serverRunner_;
conn::SumeragiService service_;
std::unique_ptr<IServerRunner> serverRunner_;
std::thread serverThread_;
};

Expand All @@ -60,15 +59,13 @@ class ConsensusConnectionTest : public ::testing::Test {
*/
TEST_F(ConsensusConnectionTest, FailConnectionWhenNotStandingServer) {
Block block;
block.mutable_header()->set_merkle_root("merkle");
auto response = unicast(block, "0.0.0.0");
auto response = conn::unicast(block, "0.0.0.0");
ASSERT_EQ(response.code(), iroha::protocol::ResponseCode::FAIL);
}

TEST_F(ConsensusConnectionTest, SuccessConnectionWhenStandingServer) {
RunServer();
Block block;
block.mutable_header()->set_merkle_root("merkle");
auto response = unicast(block, "0.0.0.0");
auto response = conn::unicast(block, "0.0.0.0");
ASSERT_EQ(response.code(), iroha::protocol::ResponseCode::OK);
}

0 comments on commit 3e038bd

Please sign in to comment.