LCOV - code coverage report
Current view: top level - shared_model/validators/protobuf - proto_proposal_validator.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 9 13 69.2 %
Date: 2019-03-07 14:46:43 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : #include "validators/protobuf/proto_proposal_validator.hpp"
       6             : 
       7             : namespace shared_model {
       8             :   namespace validation {
       9             : 
      10             :     ProtoProposalValidator::ProtoProposalValidator(
      11             :         ProtoValidatorType transaction_validator)
      12         247 :         : transaction_validator_(std::move(transaction_validator)) {}
      13             : 
      14             :     Answer ProtoProposalValidator::validate(
      15             :         const iroha::protocol::Proposal &proposal) const {
      16        1317 :       Answer answer;
      17        1317 :       std::string tx_reason_name = "Protobuf Proposal";
      18        1317 :       ReasonsGroupType reason{tx_reason_name, GroupedReasons()};
      19             : 
      20        2639 :       for (const auto &tx : proposal.transactions()) {
      21        1322 :         if (auto tx_answer = transaction_validator_->validate(tx)) {
      22           0 :           reason.second.emplace_back(tx_answer.reason());
      23           0 :         }
      24             :       }
      25             : 
      26        1317 :       if (not reason.second.empty()) {
      27           0 :         answer.addReason(std::move(reason));
      28           0 :       }
      29             : 
      30        1317 :       return answer;
      31        1317 :     }
      32             : 
      33             :   }  // namespace validation
      34             : }  // namespace shared_model

Generated by: LCOV version 1.13