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: coverage_cleared.info Lines: 35 56 62.5 %
Date: 2018-12-05 17:11:35 Functions: 10 15 66.7 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved.
       3             :  * http://soramitsu.co.jp
       4             :  *
       5             :  * Licensed under the Apache License, Version 2.0 (the "License");
       6             :  * you may not use this file except in compliance with the License.
       7             :  * You may obtain a copy of the License at
       8             :  *
       9             :  *        http://www.apache.org/licenses/LICENSE-2.0
      10             :  *
      11             :  * Unless required by applicable law or agreed to in writing, software
      12             :  * distributed under the License is distributed on an "AS IS" BASIS,
      13             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14             :  * See the License for the specific language governing permissions and
      15             :  * limitations under the License.
      16             :  */
      17             : 
      18             : #include "builders/protobuf/transaction_responses/proto_transaction_status_builder.hpp"
      19             : #include "cryptography/hash.hpp"
      20             : 
      21             : namespace shared_model {
      22             :   namespace proto {
      23             : 
      24             :     shared_model::proto::TransactionResponse TransactionStatusBuilder::build()
      25             :         && {
      26           6 :       return shared_model::proto::TransactionResponse(std::move(tx_response_));
      27             :     }
      28             : 
      29             :     shared_model::proto::TransactionResponse TransactionStatusBuilder::build()
      30             :         & {
      31          16 :       return shared_model::proto::TransactionResponse(
      32          16 :           iroha::protocol::ToriiResponse(tx_response_));
      33           0 :     }
      34             : 
      35             :     TransactionStatusBuilder
      36             :     TransactionStatusBuilder::statelessValidationSuccess() {
      37           2 :       TransactionStatusBuilder copy(*this);
      38           2 :       copy.tx_response_.set_tx_status(
      39             :           iroha::protocol::TxStatus::STATELESS_VALIDATION_SUCCESS);
      40           2 :       return copy;
      41           2 :     }
      42             : 
      43             :     TransactionStatusBuilder
      44             :     TransactionStatusBuilder::statelessValidationFailed() {
      45           2 :       TransactionStatusBuilder copy(*this);
      46           2 :       copy.tx_response_.set_tx_status(
      47             :           iroha::protocol::TxStatus::STATELESS_VALIDATION_FAILED);
      48           2 :       return copy;
      49           2 :     }
      50             : 
      51             :     TransactionStatusBuilder TransactionStatusBuilder::mstPending() {
      52           0 :       TransactionStatusBuilder copy(*this);
      53           0 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::MST_PENDING);
      54           0 :       return copy;
      55           0 :     }
      56             : 
      57             :     TransactionStatusBuilder
      58             :     TransactionStatusBuilder::enoughSignaturesCollected() {
      59           0 :       TransactionStatusBuilder copy(*this);
      60           0 :       copy.tx_response_.set_tx_status(
      61             :           iroha::protocol::TxStatus::ENOUGH_SIGNATURES_COLLECTED);
      62           0 :       return copy;
      63           0 :     }
      64             : 
      65             :     TransactionStatusBuilder
      66             :     TransactionStatusBuilder::statefulValidationSuccess() {
      67           2 :       TransactionStatusBuilder copy(*this);
      68           2 :       copy.tx_response_.set_tx_status(
      69             :           iroha::protocol::TxStatus::STATEFUL_VALIDATION_SUCCESS);
      70           2 :       return copy;
      71           2 :     }
      72             : 
      73             :     TransactionStatusBuilder
      74             :     TransactionStatusBuilder::statefulValidationFailed() {
      75           2 :       TransactionStatusBuilder copy(*this);
      76           2 :       copy.tx_response_.set_tx_status(
      77             :           iroha::protocol::TxStatus::STATEFUL_VALIDATION_FAILED);
      78           2 :       return copy;
      79           2 :     }
      80             : 
      81             :     TransactionStatusBuilder TransactionStatusBuilder::committed() {
      82           2 :       TransactionStatusBuilder copy(*this);
      83           2 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::COMMITTED);
      84           2 :       return copy;
      85           2 :     }
      86             : 
      87             :     TransactionStatusBuilder TransactionStatusBuilder::notReceived() {
      88           9 :       TransactionStatusBuilder copy(*this);
      89           9 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::NOT_RECEIVED);
      90           9 :       return copy;
      91           9 :     }
      92             : 
      93             :     TransactionStatusBuilder TransactionStatusBuilder::mstExpired() {
      94           1 :       TransactionStatusBuilder copy(*this);
      95           1 :       copy.tx_response_.set_tx_status(iroha::protocol::TxStatus::MST_EXPIRED);
      96           1 :       return copy;
      97           1 :     }
      98             : 
      99             :     TransactionStatusBuilder TransactionStatusBuilder::txHash(
     100             :         const crypto::Hash &hash) {
     101          20 :       TransactionStatusBuilder copy(*this);
     102          20 :       copy.tx_response_.set_tx_hash(crypto::toBinaryString(hash));
     103          20 :       return copy;
     104          20 :     }
     105             : 
     106             :     TransactionStatusBuilder TransactionStatusBuilder::statelessErrorOrCmdName(
     107             :         const std::string &err_or_cmd) {
     108           0 :       TransactionStatusBuilder copy(*this);
     109           0 :       copy.tx_response_.set_err_or_cmd_name(err_or_cmd);
     110           0 :       return copy;
     111           0 :     }
     112             : 
     113             :     TransactionStatusBuilder TransactionStatusBuilder::failedCmdIndex(
     114             :         uint32_t index) {
     115           0 :       TransactionStatusBuilder copy(*this);
     116           0 :       copy.tx_response_.set_failed_cmd_index(index);
     117           0 :       return copy;
     118           0 :     }
     119             : 
     120             :     TransactionStatusBuilder TransactionStatusBuilder::errorCode(
     121             :         uint32_t code) {
     122           0 :       TransactionStatusBuilder copy(*this);
     123           0 :       copy.tx_response_.set_error_code(code);
     124           0 :       return copy;
     125           0 :     }
     126             : 
     127             :   }  // namespace proto
     128             : }  // namespace shared_model

Generated by: LCOV version 1.13