LCOV - code coverage report
Current view: top level - shared_model/builders/protobuf/transaction_responses - proto_transaction_status_builder.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 35 56 62.5 %
Date: 2019-03-07 14:46:43 Functions: 10 15 66.7 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include "builders/protobuf/transaction_responses/proto_transaction_status_builder.hpp"
       7             : #include "cryptography/hash.hpp"
       8             : 
       9             : namespace shared_model {
      10             :   namespace proto {
      11             : 
      12             :     shared_model::proto::TransactionResponse TransactionStatusBuilder::build()
      13             :         && {
      14           6 :       return shared_model::proto::TransactionResponse(std::move(tx_response_));
      15             :     }
      16             : 
      17             :     shared_model::proto::TransactionResponse TransactionStatusBuilder::build()
      18             :         & {
      19          16 :       return shared_model::proto::TransactionResponse(
      20          16 :           iroha::protocol::ToriiResponse(tx_response_));
      21           0 :     }
      22             : 
      23             :     TransactionStatusBuilder
      24             :     TransactionStatusBuilder::statelessValidationSuccess() {
      25           2 :       TransactionStatusBuilder copy(*this);
      26           2 :       copy.tx_response_.set_tx_status(
      27             :           iroha::protocol::TxStatus::STATELESS_VALIDATION_SUCCESS);
      28           2 :       return copy;
      29           2 :     }
      30             : 
      31             :     TransactionStatusBuilder
      32             :     TransactionStatusBuilder::statelessValidationFailed() {
      33           2 :       TransactionStatusBuilder copy(*this);
      34           2 :       copy.tx_response_.set_tx_status(
      35             :           iroha::protocol::TxStatus::STATELESS_VALIDATION_FAILED);
      36           2 :       return copy;
      37           2 :     }
      38             : 
      39             :     TransactionStatusBuilder TransactionStatusBuilder::mstPending() {
      40           0 :       TransactionStatusBuilder copy(*this);
      41           0 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::MST_PENDING);
      42           0 :       return copy;
      43           0 :     }
      44             : 
      45             :     TransactionStatusBuilder
      46             :     TransactionStatusBuilder::enoughSignaturesCollected() {
      47           0 :       TransactionStatusBuilder copy(*this);
      48           0 :       copy.tx_response_.set_tx_status(
      49             :           iroha::protocol::TxStatus::ENOUGH_SIGNATURES_COLLECTED);
      50           0 :       return copy;
      51           0 :     }
      52             : 
      53             :     TransactionStatusBuilder
      54             :     TransactionStatusBuilder::statefulValidationSuccess() {
      55           2 :       TransactionStatusBuilder copy(*this);
      56           2 :       copy.tx_response_.set_tx_status(
      57             :           iroha::protocol::TxStatus::STATEFUL_VALIDATION_SUCCESS);
      58           2 :       return copy;
      59           2 :     }
      60             : 
      61             :     TransactionStatusBuilder
      62             :     TransactionStatusBuilder::statefulValidationFailed() {
      63           2 :       TransactionStatusBuilder copy(*this);
      64           2 :       copy.tx_response_.set_tx_status(
      65             :           iroha::protocol::TxStatus::STATEFUL_VALIDATION_FAILED);
      66           2 :       return copy;
      67           2 :     }
      68             : 
      69             :     TransactionStatusBuilder TransactionStatusBuilder::committed() {
      70           2 :       TransactionStatusBuilder copy(*this);
      71           2 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::COMMITTED);
      72           2 :       return copy;
      73           2 :     }
      74             : 
      75             :     TransactionStatusBuilder TransactionStatusBuilder::notReceived() {
      76           9 :       TransactionStatusBuilder copy(*this);
      77           9 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::NOT_RECEIVED);
      78           9 :       return copy;
      79           9 :     }
      80             : 
      81             :     TransactionStatusBuilder TransactionStatusBuilder::mstExpired() {
      82           1 :       TransactionStatusBuilder copy(*this);
      83           1 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::MST_EXPIRED);
      84           1 :       return copy;
      85           1 :     }
      86             : 
      87             :     TransactionStatusBuilder TransactionStatusBuilder::txHash(
      88             :         const crypto::Hash &hash) {
      89          20 :       TransactionStatusBuilder copy(*this);
      90          20 :       copy.tx_response_.set_tx_hash(hash.hex());
      91          20 :       return copy;
      92          20 :     }
      93             : 
      94             :     TransactionStatusBuilder TransactionStatusBuilder::statelessErrorOrCmdName(
      95             :         const std::string &err_or_cmd) {
      96           0 :       TransactionStatusBuilder copy(*this);
      97           0 :       copy.tx_response_.set_err_or_cmd_name(err_or_cmd);
      98           0 :       return copy;
      99           0 :     }
     100             : 
     101             :     TransactionStatusBuilder TransactionStatusBuilder::failedCmdIndex(
     102             :         uint32_t index) {
     103           0 :       TransactionStatusBuilder copy(*this);
     104           0 :       copy.tx_response_.set_failed_cmd_index(index);
     105           0 :       return copy;
     106           0 :     }
     107             : 
     108             :     TransactionStatusBuilder TransactionStatusBuilder::errorCode(
     109             :         uint32_t code) {
     110           0 :       TransactionStatusBuilder copy(*this);
     111           0 :       copy.tx_response_.set_error_code(code);
     112           0 :       return copy;
     113           0 :     }
     114             : 
     115             :   }  // namespace proto
     116             : }  // namespace shared_model

Generated by: LCOV version 1.13