From 6def6954194399b8f69142679aa720396159fda0 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Tue, 11 Dec 2018 17:38:37 +0300 Subject: [PATCH 01/61] Map is substituted by a vector Signed-off-by: Akvinikym --- irohad/simulator/impl/simulator.cpp | 4 +-- .../impl/transaction_processor_impl.cpp | 8 +++--- .../impl/stateful_validator_impl.cpp | 3 ++- .../validation/stateful_validator_common.hpp | 25 ++++++++++--------- test/module/iroha-cli/client_test.cpp | 9 ++++--- .../irohad/simulator/simulator_test.cpp | 14 +++++++---- .../processor/transaction_processor_test.cpp | 4 +-- .../irohad/torii/torii_service_test.cpp | 10 +++++--- .../validation/stateful_validator_test.cpp | 8 +++--- 9 files changed, 47 insertions(+), 38 deletions(-) diff --git a/irohad/simulator/impl/simulator.cpp b/irohad/simulator/impl/simulator.cpp index ef1b11fb8f..ee75d17d9b 100644 --- a/irohad/simulator/impl/simulator.cpp +++ b/irohad/simulator/impl/simulator.cpp @@ -5,7 +5,6 @@ #include "simulator/impl/simulator.hpp" -#include #include #include "common/bind.hpp" @@ -122,7 +121,8 @@ namespace iroha { const auto &proposal = verified_proposal_and_errors->verified_proposal; const auto &rejected_tx_hashes = verified_proposal_and_errors->rejected_transactions - | boost::adaptors::map_keys; + | boost::adaptors::transformed( + [](const auto &tx_error) { return tx_error.tx_hash; }); std::shared_ptr block = block_factory_->unsafeCreateBlock(height, last_block->hash(), diff --git a/irohad/torii/processor/impl/transaction_processor_impl.cpp b/irohad/torii/processor/impl/transaction_processor_impl.cpp index 2dac3757af..bed25e0aa9 100644 --- a/irohad/torii/processor/impl/transaction_processor_impl.cpp +++ b/irohad/torii/processor/impl/transaction_processor_impl.cpp @@ -21,8 +21,8 @@ namespace iroha { namespace { std::string composeErrorMessage( const validation::TransactionError &tx_hash_and_error) { - const auto tx_hash = tx_hash_and_error.first.hex(); - const auto &cmd_error = tx_hash_and_error.second; + const auto tx_hash = tx_hash_and_error.tx_hash.hex(); + const auto &cmd_error = tx_hash_and_error.error; if (not cmd_error.tx_passed_initial_validation) { return (boost::format( "Stateful validation error: transaction %s " @@ -63,8 +63,8 @@ namespace iroha { for (const auto &tx_error : errors) { log_->info(composeErrorMessage(tx_error)); this->publishStatus(TxStatusType::kStatefulFailed, - tx_error.first, - tx_error.second); + tx_error.tx_hash, + tx_error.error); } // notify about success txs for (const auto &successful_tx : diff --git a/irohad/validation/impl/stateful_validator_impl.cpp b/irohad/validation/impl/stateful_validator_impl.cpp index 9e84f55361..0d36d37ed4 100644 --- a/irohad/validation/impl/stateful_validator_impl.cpp +++ b/irohad/validation/impl/stateful_validator_impl.cpp @@ -34,7 +34,8 @@ namespace iroha { [](expected::Value &) { return true; }, [&tx, &transactions_errors_log]( expected::Error &error) { - transactions_errors_log.emplace(tx.hash(), std::move(error.error)); + transactions_errors_log.emplace_back(validation::TransactionError{ + tx.hash(), std::move(error.error)}); return false; }); }; diff --git a/irohad/validation/stateful_validator_common.hpp b/irohad/validation/stateful_validator_common.hpp index 6735ca5c24..1337690573 100644 --- a/irohad/validation/stateful_validator_common.hpp +++ b/irohad/validation/stateful_validator_common.hpp @@ -44,18 +44,19 @@ namespace iroha { size_t index = 0; }; - /// Collection of transactions errors - a map from the failed transaction - /// hash to the description of failed command. - using TransactionHash = shared_model::crypto::Hash; - using TransactionsErrors = std:: - unordered_map; - using TransactionError = TransactionsErrors::value_type; - - /// Type of verified proposal and errors appeared in the process; first - /// dimension of errors vector is transaction, second is error itself with - /// number of transaction, where it happened - // TODO mboldyrev 27.10.2018: create a special class for VerifiedProposal - // IR-1849 which will include the rejected tx hashes + /// Hash of transaction with error, which appeared during validation of this + /// transaction + struct TransactionError { + shared_model::crypto::Hash tx_hash; + CommandError error; + }; + + /// Collection of transactions errors + using TransactionsErrors = std::vector; + + /// Type of verified proposal and errors appeared in the process + // TODO [IR-1849] mboldyrev 27.10.2018: create a special class + // for VerifiedProposal which will include the rejected tx hashes struct VerifiedProposalAndErrors { std::unique_ptr verified_proposal; TransactionsErrors rejected_transactions; diff --git a/test/module/iroha-cli/client_test.cpp b/test/module/iroha-cli/client_test.cpp index b1642c3ad4..e44c3b0a76 100644 --- a/test/module/iroha-cli/client_test.cpp +++ b/test/module/iroha-cli/client_test.cpp @@ -328,10 +328,11 @@ TEST_F(ClientServerTest, SendTxWhenStatefulInvalid) { verified_proposal_and_errors ->verified_proposal = std::make_unique( TestProposalBuilder().height(0).createdTime(iroha::time::now()).build()); - verified_proposal_and_errors->rejected_transactions.emplace( - std::make_pair(tx.hash(), - iroha::validation::CommandError{ - cmd_name, error_code, "", true, cmd_index})); + verified_proposal_and_errors->rejected_transactions.emplace_back( + iroha::validation::TransactionError{ + tx.hash(), + iroha::validation::CommandError{ + cmd_name, error_code, "", true, cmd_index}}); verified_prop_notifier.get_subscriber().on_next(verified_proposal_and_errors); auto getAnswer = [&]() { diff --git a/test/module/irohad/simulator/simulator_test.cpp b/test/module/irohad/simulator/simulator_test.cpp index 85fd918221..b45cac3141 100644 --- a/test/module/irohad/simulator/simulator_test.cpp +++ b/test/module/irohad/simulator/simulator_test.cpp @@ -5,7 +5,7 @@ #include -#include +#include #include #include "backend/protobuf/proto_block_factory.hpp" #include "backend/protobuf/transaction.hpp" @@ -31,9 +31,9 @@ using namespace framework::test_subscriber; using ::testing::_; using ::testing::A; using ::testing::Invoke; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnArg; -using ::testing::NiceMock; using wBlock = std::shared_ptr; @@ -305,8 +305,10 @@ TEST_F(SimulatorTest, SomeFailingTxs) { .build()); for (auto rejected_tx = txs.begin() + 1; rejected_tx != txs.end(); ++rejected_tx) { - verified_proposal_and_errors->rejected_transactions.emplace( - rejected_tx->hash(), validation::CommandError{"SomeCommand", 1, "", true}); + verified_proposal_and_errors->rejected_transactions.emplace_back( + validation::TransactionError{ + rejected_tx->hash(), + validation::CommandError{"SomeCommand", 1, "", true}}); } shared_model::proto::Block block = makeBlock(proposal->height() - 1); @@ -342,7 +344,9 @@ TEST_F(SimulatorTest, SomeFailingTxs) { ASSERT_TRUE(verified_proposal_->rejected_transactions.size() == kNumTransactions - 1); const auto verified_proposal_rejected_tx_hashes = - verified_proposal_->rejected_transactions | boost::adaptors::map_keys; + verified_proposal_->rejected_transactions + | boost::adaptors::transformed( + [](const auto &tx_error) { return tx_error.tx_hash; }); for (auto rejected_tx = txs.begin() + 1; rejected_tx != txs.end(); ++rejected_tx) { ASSERT_NE(boost::range::find(verified_proposal_rejected_tx_hashes, diff --git a/test/module/irohad/torii/processor/transaction_processor_test.cpp b/test/module/irohad/torii/processor/transaction_processor_test.cpp index bc99e7b9b6..c62f3b4995 100644 --- a/test/module/irohad/torii/processor/transaction_processor_test.cpp +++ b/test/module/irohad/torii/processor/transaction_processor_test.cpp @@ -389,9 +389,9 @@ TEST_F(TransactionProcessorTest, TransactionProcessorInvalidTxsTest) { std::make_unique( TestProposalBuilder().transactions(block_txs).build()); for (size_t i = 0; i < invalid_txs.size(); ++i) { - validation_result->rejected_transactions.emplace( + validation_result->rejected_transactions.emplace_back(validation::TransactionError{ invalid_txs[i].hash(), - iroha::validation::CommandError{"SomeCommandName", 1, "", true, i}); + iroha::validation::CommandError{"SomeCommandName", 1, "", true, i}}); } verified_prop_notifier.get_subscriber().on_next(validation_result); diff --git a/test/module/irohad/torii/torii_service_test.cpp b/test/module/irohad/torii/torii_service_test.cpp index 1aa6d4aede..b57c00f493 100644 --- a/test/module/irohad/torii/torii_service_test.cpp +++ b/test/module/irohad/torii/torii_service_test.cpp @@ -23,6 +23,7 @@ #include "torii/impl/command_service_transport_grpc.hpp" #include "torii/impl/status_bus_impl.hpp" #include "torii/processor/transaction_processor_impl.hpp" +#include "validation/stateful_validator_common.hpp" #include "validators/protobuf/proto_transaction_validator.hpp" constexpr size_t TimesToriiBlocking = 5; @@ -343,10 +344,11 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { auto cmd_name = "FailedCommand"; size_t cmd_index = 2; uint32_t error_code = 3; - validation_result->rejected_transactions.emplace( - failed_tx_hash, - iroha::validation::CommandError{ - cmd_name, error_code, "", true, cmd_index}); + validation_result->rejected_transactions.emplace_back( + iroha::validation::TransactionError{ + failed_tx_hash, + iroha::validation::CommandError{ + cmd_name, error_code, "", true, cmd_index}}); verified_prop_notifier_.get_subscriber().on_next(validation_result); // create commit from block notifier's observable diff --git a/test/module/irohad/validation/stateful_validator_test.cpp b/test/module/irohad/validation/stateful_validator_test.cpp index 9fb5c5cbac..1812e6f438 100644 --- a/test/module/irohad/validation/stateful_validator_test.cpp +++ b/test/module/irohad/validation/stateful_validator_test.cpp @@ -236,10 +236,10 @@ TEST_F(Validator, SomeTxsFail) { 2); ASSERT_EQ(verified_proposal_and_errors->rejected_transactions.size(), 1); EXPECT_EQ(verified_proposal_and_errors->rejected_transactions.begin() - ->second.error_code, + ->error.error_code, sample_error_code); EXPECT_EQ(verified_proposal_and_errors->rejected_transactions.begin() - ->second.error_extra, + ->error.error_extra, sample_error_extra); } @@ -318,9 +318,9 @@ TEST_F(Validator, Batches) { 5); ASSERT_EQ(verified_proposal_and_errors->rejected_transactions.size(), 1); EXPECT_EQ(verified_proposal_and_errors->rejected_transactions.begin() - ->second.error_code, + ->error.error_code, sample_error_code); EXPECT_EQ(verified_proposal_and_errors->rejected_transactions.begin() - ->second.error_extra, + ->error.error_extra, sample_error_extra); } From a192a8a7be75beb1f0a24e8cc6026012c8eb0f46 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Wed, 12 Dec 2018 11:04:52 +0300 Subject: [PATCH 02/61] Merged with dev 2 Signed-off-by: Akvinikym --- test/module/iroha-cli/client_test.cpp | 7 ++++--- test/module/irohad/simulator/simulator_test.cpp | 5 +++-- test/module/irohad/torii/torii_service_test.cpp | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/module/iroha-cli/client_test.cpp b/test/module/iroha-cli/client_test.cpp index 8e355e22a2..83622de5aa 100644 --- a/test/module/iroha-cli/client_test.cpp +++ b/test/module/iroha-cli/client_test.cpp @@ -328,9 +328,10 @@ TEST_F(ClientServerTest, SendTxWhenStatefulInvalid) { ->verified_proposal = std::make_unique( TestProposalBuilder().height(0).createdTime(iroha::time::now()).build()); verified_proposal_and_errors->rejected_transactions.emplace_back( - iroha::validation::TransactionError{tx.hash(), - iroha::validation::CommandError{ - cmd_name, error_code, "", true, cmd_index}}); + iroha::validation::TransactionError{ + tx.hash(), + iroha::validation::CommandError{ + cmd_name, error_code, "", true, cmd_index}}); verified_prop_notifier.get_subscriber().on_next( iroha::simulator::VerifiedProposalCreatorEvent{ verified_proposal_and_errors, round}); diff --git a/test/module/irohad/simulator/simulator_test.cpp b/test/module/irohad/simulator/simulator_test.cpp index a1686ea2a9..fa546eb555 100644 --- a/test/module/irohad/simulator/simulator_test.cpp +++ b/test/module/irohad/simulator/simulator_test.cpp @@ -306,8 +306,9 @@ TEST_F(SimulatorTest, SomeFailingTxs) { for (auto rejected_tx = txs.begin() + 1; rejected_tx != txs.end(); ++rejected_tx) { verified_proposal_and_errors->rejected_transactions.emplace_back( - validation::TransactionError{rejected_tx->hash(), - validation::CommandError{"SomeCommand", 1, "", true}}); + validation::TransactionError{ + rejected_tx->hash(), + validation::CommandError{"SomeCommand", 1, "", true}}); } shared_model::proto::Block block = makeBlock(proposal->height() - 1); diff --git a/test/module/irohad/torii/torii_service_test.cpp b/test/module/irohad/torii/torii_service_test.cpp index 352125aa1d..67dfdfc53a 100644 --- a/test/module/irohad/torii/torii_service_test.cpp +++ b/test/module/irohad/torii/torii_service_test.cpp @@ -341,9 +341,10 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { size_t cmd_index = 2; uint32_t error_code = 3; validation_result->rejected_transactions.emplace_back( - iroha::validation::TransactionError{failed_tx_hash, - iroha::validation::CommandError{ - cmd_name, error_code, "", true, cmd_index}}); + iroha::validation::TransactionError{ + failed_tx_hash, + iroha::validation::CommandError{ + cmd_name, error_code, "", true, cmd_index}}); verified_prop_notifier_.get_subscriber().on_next( iroha::simulator::VerifiedProposalCreatorEvent{validation_result, round}); From 2d22d1369677592a1bebaff432872d01b65c299c Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Wed, 12 Dec 2018 11:32:59 +0300 Subject: [PATCH 03/61] Commands Mocks Factory (#1933) * Factory is ready Signed-off-by: Akvinikym * Minor fixes Signed-off-by: Akvinikym * CMake fixed Signed-off-by: Akvinikym * Review issues Signed-off-by: Akvinikym * Fix build Signed-off-by: Akvinikym --- test/module/shared_model/CMakeLists.txt | 11 + test/module/shared_model/command_mocks.hpp | 166 ++++++++++ .../mock_command_factory.cpp | 306 ++++++++++++++++++ .../mock_command_factory.hpp | 201 ++++++++++++ 4 files changed, 684 insertions(+) create mode 100644 test/module/shared_model/command_mocks.hpp create mode 100644 test/module/shared_model/mock_objects_factories/mock_command_factory.cpp create mode 100644 test/module/shared_model/mock_objects_factories/mock_command_factory.hpp diff --git a/test/module/shared_model/CMakeLists.txt b/test/module/shared_model/CMakeLists.txt index 4eccaefc67..403d157a46 100644 --- a/test/module/shared_model/CMakeLists.txt +++ b/test/module/shared_model/CMakeLists.txt @@ -29,3 +29,14 @@ target_link_libraries(interface_test shared_model_default_builders logger ) + +add_library(commands_mocks_factory + mock_objects_factories/mock_command_factory.cpp + ) +target_link_libraries(commands_mocks_factory + shared_model_interfaces + shared_model_proto_backend + logger + gtest::main + gmock::main + ) diff --git a/test/module/shared_model/command_mocks.hpp b/test/module/shared_model/command_mocks.hpp new file mode 100644 index 0000000000..273668dd3d --- /dev/null +++ b/test/module/shared_model/command_mocks.hpp @@ -0,0 +1,166 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_COMMAND_MOCKS_HPP +#define IROHA_COMMAND_MOCKS_HPP + +#include +#include +#include "cryptography/public_key.hpp" +#include "interfaces/commands/add_asset_quantity.hpp" +#include "interfaces/commands/add_peer.hpp" +#include "interfaces/commands/add_signatory.hpp" +#include "interfaces/commands/append_role.hpp" +#include "interfaces/commands/command.hpp" +#include "interfaces/commands/create_account.hpp" +#include "interfaces/commands/create_asset.hpp" +#include "interfaces/commands/create_domain.hpp" +#include "interfaces/commands/create_role.hpp" +#include "interfaces/commands/detach_role.hpp" +#include "interfaces/commands/grant_permission.hpp" +#include "interfaces/commands/remove_signatory.hpp" +#include "interfaces/commands/revoke_permission.hpp" +#include "interfaces/commands/set_account_detail.hpp" +#include "interfaces/commands/set_quorum.hpp" +#include "interfaces/commands/subtract_asset_quantity.hpp" +#include "interfaces/commands/transfer_asset.hpp" +#include "logger/logger.hpp" + +using testing::Return; + +namespace shared_model { + namespace interface { + struct MockCommand : public shared_model::interface::Command { + MOCK_CONST_METHOD0(get, const Command::CommandVariantType &()); + MOCK_CONST_METHOD0(clone, Command *()); + }; + + struct MockAddAssetQuantity + : public shared_model::interface::AddAssetQuantity { + MOCK_CONST_METHOD0(assetId, const types::AssetIdType &()); + MOCK_CONST_METHOD0(amount, const Amount &()); + MOCK_CONST_METHOD0(clone, AddAssetQuantity *()); + }; + + struct MockAddPeer : public shared_model::interface::AddPeer { + MOCK_CONST_METHOD0(peer, const Peer &()); + MOCK_CONST_METHOD0(clone, MockAddPeer *()); + }; + + struct MockAddSignatory : public shared_model::interface::AddSignatory { + MOCK_CONST_METHOD0(pubkey, const types::PubkeyType &()); + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(clone, MockAddSignatory *()); + }; + + struct MockAppendRole : public shared_model::interface::AppendRole { + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(roleName, const types::RoleIdType &()); + MOCK_CONST_METHOD0(clone, MockAppendRole *()); + }; + + struct MockCreateAccount : public shared_model::interface::CreateAccount { + MOCK_CONST_METHOD0(accountName, const types::AccountNameType &()); + MOCK_CONST_METHOD0(domainId, const types::DomainIdType &()); + MOCK_CONST_METHOD0(pubkey, const types::PubkeyType &()); + MOCK_CONST_METHOD0(clone, MockCreateAccount *()); + }; + + struct MockCreateAsset : public shared_model::interface::CreateAsset { + MOCK_CONST_METHOD0(assetName, const types::AssetNameType &()); + MOCK_CONST_METHOD0(domainId, const types::DomainIdType &()); + MOCK_CONST_METHOD0(precision, const PrecisionType &()); + MOCK_CONST_METHOD0(clone, MockCreateAsset *()); + }; + + struct MockCreateDomain : public shared_model::interface::CreateDomain { + MOCK_CONST_METHOD0(domainId, const types::DomainIdType &()); + MOCK_CONST_METHOD0(userDefaultRole, const types::RoleIdType &()); + MOCK_CONST_METHOD0(clone, MockCreateDomain *()); + }; + + struct MockCreateRole : public shared_model::interface::CreateRole { + MockCreateRole() { + ON_CALL(*this, toString()).WillByDefault(Return("MockCreateRole")); + } + + MOCK_CONST_METHOD0(roleName, const types::RoleIdType &()); + MOCK_CONST_METHOD0(rolePermissions, const RolePermissionSet &()); + MOCK_CONST_METHOD0(toString, std::string()); + MOCK_CONST_METHOD0(clone, MockCreateRole *()); + }; + + struct MockDetachRole : public shared_model::interface::DetachRole { + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(roleName, const types::RoleIdType &()); + MOCK_CONST_METHOD0(clone, MockDetachRole *()); + }; + + struct MockGrantPermission + : public shared_model::interface::GrantPermission { + MockGrantPermission() { + ON_CALL(*this, toString()) + .WillByDefault(Return("MockGrantPermissions")); + } + + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(permissionName, permissions::Grantable()); + MOCK_CONST_METHOD0(toString, std::string()); + MOCK_CONST_METHOD0(clone, MockGrantPermission *()); + }; + + struct MockRemoveSignatory + : public shared_model::interface::RemoveSignatory { + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(pubkey, const types::PubkeyType &()); + MOCK_CONST_METHOD0(clone, MockRemoveSignatory *()); + }; + + struct MockRevokePermission + : public shared_model::interface::RevokePermission { + MockRevokePermission() { + ON_CALL(*this, toString()) + .WillByDefault(Return("MockRevokePermission")); + } + + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(permissionName, permissions::Grantable()); + MOCK_CONST_METHOD0(toString, std::string()); + MOCK_CONST_METHOD0(clone, MockRevokePermission *()); + }; + + struct MockSetAccountDetail + : public shared_model::interface::SetAccountDetail { + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(key, const types::AccountDetailKeyType &()); + MOCK_CONST_METHOD0(value, const types::AccountDetailValueType &()); + MOCK_CONST_METHOD0(clone, MockSetAccountDetail *()); + }; + + struct MockSetQuorum : public shared_model::interface::SetQuorum { + MOCK_CONST_METHOD0(accountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(newQuorum, types::QuorumType()); + MOCK_CONST_METHOD0(clone, MockSetQuorum *()); + }; + + struct MockSubtractAssetQuantity + : public shared_model::interface::SubtractAssetQuantity { + MOCK_CONST_METHOD0(assetId, const types::AssetIdType &()); + MOCK_CONST_METHOD0(amount, const Amount &()); + MOCK_CONST_METHOD0(clone, MockSubtractAssetQuantity *()); + }; + + struct MockTransferAsset : public shared_model::interface::TransferAsset { + MOCK_CONST_METHOD0(srcAccountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(destAccountId, const types::AccountIdType &()); + MOCK_CONST_METHOD0(assetId, const types::AssetIdType &()); + MOCK_CONST_METHOD0(amount, const Amount &()); + MOCK_CONST_METHOD0(description, const types::DescriptionType &()); + MOCK_CONST_METHOD0(clone, MockTransferAsset *()); + }; + } // namespace interface +} // namespace shared_model + +#endif // IROHA_COMMAND_MOCKS_HPP diff --git a/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp b/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp new file mode 100644 index 0000000000..807c697075 --- /dev/null +++ b/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp @@ -0,0 +1,306 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "module/shared_model/mock_objects_factories/mock_command_factory.hpp" +#include "backend/protobuf/permissions.hpp" +#include "utils/string_builder.hpp" + +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::ReturnRefOfCopy; + +namespace shared_model { + namespace interface { + template + MockCommandFactory::FactoryResult + MockCommandFactory::createFactoryResult( + ExpectsCallable expects_callable) const { + auto specific_cmd_mock = std::make_unique(); + return expects_callable(std::move(specific_cmd_mock)); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructAddAssetQuantity( + const types::AssetIdType &asset_id, const Amount &asset_amount) const { + return createFactoryResult( + [&asset_id, &asset_amount]( + FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, assetId()) + .WillRepeatedly(ReturnRefOfCopy(asset_id)); + EXPECT_CALL(*specific_cmd_mock, amount()) + .WillRepeatedly(ReturnRefOfCopy(asset_amount)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructAddPeer(const Peer &peer) const { + return createFactoryResult( + [&peer](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, peer()) + .WillRepeatedly(ReturnRef(peer)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructAddSignatory( + const types::PubkeyType &pubkey, + const types::AccountIdType &account_id) const { + return createFactoryResult( + [&pubkey, + &account_id](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, pubkey()) + .WillRepeatedly(ReturnRefOfCopy(pubkey)); + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructAppendRole( + const types::AccountIdType &account_id, + const types::RoleIdType &role_name) const { + return createFactoryResult( + [&account_id, + &role_name](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + EXPECT_CALL(*specific_cmd_mock, roleName()) + .WillRepeatedly(ReturnRefOfCopy(role_name)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructCreateAccount( + const types::AccountNameType &account_name, + const types::DomainIdType &domain_id, + const types::PubkeyType &pubkey) const { + return createFactoryResult( + [&account_name, &domain_id, &pubkey]( + FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountName()) + .WillRepeatedly(ReturnRefOfCopy(account_name)); + EXPECT_CALL(*specific_cmd_mock, domainId()) + .WillRepeatedly(ReturnRefOfCopy(domain_id)); + EXPECT_CALL(*specific_cmd_mock, pubkey()) + .WillRepeatedly(ReturnRefOfCopy(pubkey)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructCreateAsset( + const types::AssetNameType &asset_name, + const types::DomainIdType &domain_id, + const types::PrecisionType &precision) const { + return createFactoryResult( + [&asset_name, &domain_id, &precision]( + FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, assetName()) + .WillRepeatedly(ReturnRefOfCopy(asset_name)); + EXPECT_CALL(*specific_cmd_mock, domainId()) + .WillRepeatedly(ReturnRefOfCopy(domain_id)); + EXPECT_CALL(*specific_cmd_mock, precision()) + .WillRepeatedly(ReturnRefOfCopy(precision)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructCreateDomain( + const types::DomainIdType &domain_id, + const types::RoleIdType &role_id) const { + return createFactoryResult( + [&domain_id, + &role_id](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, domainId()) + .WillRepeatedly(ReturnRefOfCopy(domain_id)); + EXPECT_CALL(*specific_cmd_mock, userDefaultRole()) + .WillRepeatedly(ReturnRefOfCopy(role_id)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructCreateRole( + const types::RoleIdType &role_id, + const RolePermissionSet &role_permissions) const { + return createFactoryResult( + [&role_id, + &role_permissions](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, roleName()) + .WillRepeatedly(ReturnRefOfCopy(role_id)); + EXPECT_CALL(*specific_cmd_mock, rolePermissions()) + .WillRepeatedly(ReturnRefOfCopy(role_permissions)); + EXPECT_CALL(*specific_cmd_mock, toString()) + .WillRepeatedly(Return( + detail::PrettyStringBuilder() + .init("CreateRole") + .append("role_name", role_id) + .appendAll(shared_model::proto::permissions::toString( + role_permissions), + [](auto p) { return p; }) + .finalize())); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructDetachRole( + const types::AccountIdType &account_id, + const types::RoleIdType &role_id) const { + return createFactoryResult( + [&account_id, + &role_id](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + EXPECT_CALL(*specific_cmd_mock, roleName()) + .WillRepeatedly(ReturnRefOfCopy(role_id)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructGrantPermission( + const types::AccountIdType &account_id, + permissions::Grantable permission) const { + return createFactoryResult( + [&account_id, + permission](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + EXPECT_CALL(*specific_cmd_mock, permissionName()) + .WillRepeatedly(Return(permission)); + EXPECT_CALL(*specific_cmd_mock, toString()) + .WillRepeatedly(Return( + detail::PrettyStringBuilder() + .init("GrantPermission") + .append("account_id", account_id) + .append("permission", + shared_model::proto::permissions::toString( + permission)) + .finalize())); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructRemoveSignatory( + const types::AccountIdType &account_id, + const types::PubkeyType &pubkey) const { + return createFactoryResult( + [&account_id, + &pubkey](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + EXPECT_CALL(*specific_cmd_mock, pubkey()) + .WillRepeatedly(ReturnRefOfCopy(pubkey)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructRevokePermission( + const types::AccountIdType &account_id, + permissions::Grantable permission) const { + return createFactoryResult( + [&account_id, + permission](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + EXPECT_CALL(*specific_cmd_mock, permissionName()) + .WillRepeatedly(Return(permission)); + EXPECT_CALL(*specific_cmd_mock, toString()) + .WillRepeatedly(Return( + detail::PrettyStringBuilder() + .init("RevokePermission") + .append("account_id", account_id) + .append("permission", + shared_model::proto::permissions::toString( + permission)) + .finalize())); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructSetAccountDetail( + const types::AccountIdType &account_id, + const types::AccountDetailKeyType &cmd_key, + const types::AccountDetailValueType &cmd_value) const { + return createFactoryResult( + [&account_id, &cmd_key, &cmd_value]( + FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + EXPECT_CALL(*specific_cmd_mock, key()) + .WillRepeatedly(ReturnRefOfCopy(cmd_key)); + EXPECT_CALL(*specific_cmd_mock, value()) + .WillRepeatedly(ReturnRefOfCopy(cmd_value)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructSetQuorum( + const types::AccountIdType &account_id, + types::QuorumType quorum) const { + return createFactoryResult( + [&account_id, + quorum](FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, accountId()) + .WillRepeatedly(ReturnRefOfCopy(account_id)); + EXPECT_CALL(*specific_cmd_mock, newQuorum()) + .WillRepeatedly(Return(quorum)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructSubtractAssetQuantity( + const types::AssetIdType &asset_id, const Amount &cmd_amount) const { + return createFactoryResult( + [&asset_id, &cmd_amount]( + FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, assetId()) + .WillRepeatedly(ReturnRefOfCopy(asset_id)); + EXPECT_CALL(*specific_cmd_mock, amount()) + .WillRepeatedly(ReturnRefOfCopy(cmd_amount)); + return specific_cmd_mock; + }); + } + + MockCommandFactory::FactoryResult + MockCommandFactory::constructTransferAsset( + const types::AccountIdType &src_account_id, + const types::AccountIdType &dest_account_id, + const types::AssetIdType &asset_id, + const Amount &cmd_amount, + const types::DescriptionType &cmd_description) const { + return createFactoryResult( + [&src_account_id, + &dest_account_id, + &asset_id, + &cmd_amount, + &cmd_description]( + FactoryResult specific_cmd_mock) { + EXPECT_CALL(*specific_cmd_mock, srcAccountId()) + .WillRepeatedly(ReturnRefOfCopy(src_account_id)); + EXPECT_CALL(*specific_cmd_mock, destAccountId()) + .WillRepeatedly(ReturnRefOfCopy(dest_account_id)); + EXPECT_CALL(*specific_cmd_mock, assetId()) + .WillRepeatedly(ReturnRefOfCopy(asset_id)); + EXPECT_CALL(*specific_cmd_mock, amount()) + .WillRepeatedly(ReturnRefOfCopy(cmd_amount)); + EXPECT_CALL(*specific_cmd_mock, description()) + .WillRepeatedly(ReturnRefOfCopy(cmd_description)); + return specific_cmd_mock; + }); + } + } // namespace interface +} // namespace shared_model diff --git a/test/module/shared_model/mock_objects_factories/mock_command_factory.hpp b/test/module/shared_model/mock_objects_factories/mock_command_factory.hpp new file mode 100644 index 0000000000..1c4ba05826 --- /dev/null +++ b/test/module/shared_model/mock_objects_factories/mock_command_factory.hpp @@ -0,0 +1,201 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_MOCK_COMMAND_FACTORY_HPP +#define IROHA_MOCK_COMMAND_FACTORY_HPP + +#include "module/shared_model/command_mocks.hpp" + +namespace shared_model { + namespace interface { + class MockCommandFactory { + template + using FactoryResult = std::unique_ptr; + + public: + /** + * Construct a mocked AddAssetQuantity + * @param asset_id to be in that command + * @param asset_amount to be in that command + * @return pointer to the created command + */ + FactoryResult constructAddAssetQuantity( + const types::AssetIdType &asset_id, const Amount &asset_amount) const; + + /** + * Construct a mocked AddPeer + * @param peer to be in that command + * @return pointer to the created command + */ + FactoryResult constructAddPeer(const Peer &peer) const; + + /** + * Construct a mocked AddSignatory + * @param pubkey to be in that command + * @param account_id to be in that command + * @return pointer to the created command + */ + FactoryResult constructAddSignatory( + const types::PubkeyType &pubkey, + const types::AccountIdType &account_id) const; + + /** + * Construct a mocked AppendRole + * @param account_id to be in that command + * @param role_name to be in that command + * @return pointer to the created command + */ + FactoryResult constructAppendRole( + const types::AccountIdType &account_id, + const types::RoleIdType &role_name) const; + + /** + * Construct a mocked CreateAccount + * @param account_name to be in that command + * @param domain_id to be in that command + * @param pubkey to be in that command + * @return pointer to the created command + */ + FactoryResult constructCreateAccount( + const types::AccountNameType &account_name, + const types::DomainIdType &domain_id, + const types::PubkeyType &pubkey) const; + + /** + * Construct a mocked CreateAsset + * @param asset_name to be in that command + * @param domain_id to be in that command + * @param precision to be in that command + * @return pointer to the created command + */ + FactoryResult constructCreateAsset( + const types::AssetNameType &asset_name, + const types::DomainIdType &domain_id, + const types::PrecisionType &precision) const; + + /** + * Construct a mocked CreateDomain + * @param domain_id to be in that command + * @param role_id to be in that command + * @return pointer to the created command + */ + FactoryResult constructCreateDomain( + const types::DomainIdType &domain_id, + const types::RoleIdType &role_id) const; + + /** + * Construct a mocked CreateRole + * @param role_id to be in that command + * @param role_permissions to be in that command + * @return pointer to the created command + */ + FactoryResult constructCreateRole( + const types::RoleIdType &role_id, + const RolePermissionSet &role_permissions) const; + + /** + * Construct a mocked DetachRole + * @param account_id to be in that command + * @param role_id to be in that command + * @return pointer to the created command + */ + FactoryResult constructDetachRole( + const types::AccountIdType &account_id, + const types::RoleIdType &role_id) const; + + /** + * Construct a mocked GrantPermission + * @param account_id to be in that command + * @param permission to be in that command + * @return pointer to the created command + */ + FactoryResult constructGrantPermission( + const types::AccountIdType &account_id, + permissions::Grantable permission) const; + + /** + * Construct a mocked RemoveSignatory + * @param account_id to be in that command + * @param pubkey to be in that command + * @return pointer to the created command + */ + FactoryResult constructRemoveSignatory( + const types::AccountIdType &account_id, + const types::PubkeyType &pubkey) const; + + /** + * Construct a mocked RevokePermission + * @param account_id to be in that command + * @param permission to be in that command + * @return pointer to the created command + */ + FactoryResult constructRevokePermission( + const types::AccountIdType &account_id, + permissions::Grantable permission) const; + + /** + * Construct a mocked SetAccountDetail + * @param account_id to be in that command + * @param key to be in that command + * @param value to be in that command + * @return pointer to the created command + */ + FactoryResult constructSetAccountDetail( + const types::AccountIdType &account_id, + const types::AccountDetailKeyType &key, + const types::AccountDetailValueType &value) const; + + /** + * Construct a mocked SetQuorum + * @param account_id to be in that command + * @param quorum to be in that command + * @return pointer to the created command + */ + FactoryResult constructSetQuorum( + const types::AccountIdType &account_id, + types::QuorumType quorum) const; + + /** + * Construct a mocked SubtractAssetQuantity + * @param asset_id to be in that command + * @param amount to be in that command + * @return pointer to the created command + */ + FactoryResult constructSubtractAssetQuantity( + const types::AssetIdType &asset_id, const Amount &amount) const; + + /** + * Construct a mocked TransferAsset + * @param src_account_id to be in that command + * @param dest_account_id to be in that command + * @param asset_id to be in that command + * @param amount to be in that command + * @param description to be in that command + * @return pointer to the created command + */ + FactoryResult constructTransferAsset( + const types::AccountIdType &src_account_id, + const types::AccountIdType &dest_account_id, + const types::AssetIdType &asset_id, + const Amount &amount, + const types::DescriptionType &description) const; + + private: + /** + * Actually create a pointer to the mocked command + * @tparam CommandType - type of the command to be mocked + * @tparam ExpectsCallable - type of callable, which contains necessary + * EXPECT-s statements + * @param callable - that callable + * @return pointer to the mocked command + */ + template + FactoryResult createFactoryResult( + ExpectsCallable callable) const; + }; + } // namespace interface +} // namespace shared_model + +#endif // IROHA_MOCK_COMMAND_FACTORY_HPP From 74fd61a4c32859397d37cc0b9c2cd07cecb46a30 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Wed, 12 Dec 2018 12:15:19 +0300 Subject: [PATCH 04/61] Maybe fixed tests Signed-off-by: Akvinikym --- irohad/simulator/impl/simulator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/irohad/simulator/impl/simulator.cpp b/irohad/simulator/impl/simulator.cpp index 06555e3352..480746049e 100644 --- a/irohad/simulator/impl/simulator.cpp +++ b/irohad/simulator/impl/simulator.cpp @@ -125,7 +125,7 @@ namespace iroha { return; } const auto &proposal = verified_proposal_and_errors->verified_proposal; - const auto &rejected_tx_hashes = + auto rejected_tx_hashes = verified_proposal_and_errors->rejected_transactions | boost::adaptors::transformed( [](const auto &tx_error) { return tx_error.tx_hash; }); @@ -134,7 +134,7 @@ namespace iroha { last_block->hash(), proposal->createdTime(), proposal->transactions(), - rejected_tx_hashes); + std::move(rejected_tx_hashes)); crypto_signer_->sign(*block); block_notifier_.get_subscriber().on_next( BlockCreatorEvent{RoundData{proposal, block}, round}); From 56096638aceb95464d74a3bb4b054575b579d7fb Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Wed, 12 Dec 2018 16:25:42 +0300 Subject: [PATCH 05/61] Fixed build Signed-off-by: Akvinikym --- irohad/simulator/impl/simulator.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/irohad/simulator/impl/simulator.cpp b/irohad/simulator/impl/simulator.cpp index 480746049e..08995c2981 100644 --- a/irohad/simulator/impl/simulator.cpp +++ b/irohad/simulator/impl/simulator.cpp @@ -125,16 +125,17 @@ namespace iroha { return; } const auto &proposal = verified_proposal_and_errors->verified_proposal; - auto rejected_tx_hashes = - verified_proposal_and_errors->rejected_transactions - | boost::adaptors::transformed( - [](const auto &tx_error) { return tx_error.tx_hash; }); + std::vector rejected_hashes; + for (const auto &rejected_tx : + verified_proposal_and_errors->rejected_transactions) { + rejected_hashes.push_back(rejected_tx.tx_hash); + } std::shared_ptr block = block_factory_->unsafeCreateBlock(height, last_block->hash(), proposal->createdTime(), proposal->transactions(), - std::move(rejected_tx_hashes)); + rejected_hashes); crypto_signer_->sign(*block); block_notifier_.get_subscriber().on_next( BlockCreatorEvent{RoundData{proposal, block}, round}); From df7de63a7232f94829aebeb3eb5662ea6db1f593 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Thu, 13 Dec 2018 10:32:52 +0300 Subject: [PATCH 06/61] Rework QueryExecutorTest with Command mocks (#1937) * Factory is ready Signed-off-by: Akvinikym * Minor fixes Signed-off-by: Akvinikym * CMake fixed Signed-off-by: Akvinikym * QueryExecutorTest is reworked with CommandFactory Signed-off-by: Akvinikym * Maybe fixed the build Signed-off-by: Akvinikym * Refactored a bit Signed-off-by: Akvinikym --- test/module/irohad/ametsuchi/CMakeLists.txt | 1 + .../postgres_query_executor_test.cpp | 228 +++++++----------- 2 files changed, 88 insertions(+), 141 deletions(-) diff --git a/test/module/irohad/ametsuchi/CMakeLists.txt b/test/module/irohad/ametsuchi/CMakeLists.txt index b9be86ce3d..0838c5dabe 100644 --- a/test/module/irohad/ametsuchi/CMakeLists.txt +++ b/test/module/irohad/ametsuchi/CMakeLists.txt @@ -58,6 +58,7 @@ addtest(postgres_query_executor_test postgres_query_executor_test.cpp) target_link_libraries(postgres_query_executor_test ametsuchi_fixture ametsuchi + commands_mocks_factory ) addtest(tx_presence_cache_test tx_presence_cache_test.cpp) diff --git a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp index b171acbfab..c77a193f39 100644 --- a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp @@ -28,6 +28,7 @@ #include "module/shared_model/builders/protobuf/test_peer_builder.hpp" #include "module/shared_model/builders/protobuf/test_query_builder.hpp" #include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" +#include "module/shared_model/mock_objects_factories/mock_command_factory.hpp" namespace iroha { namespace ametsuchi { @@ -52,6 +53,8 @@ namespace iroha { shared_model::interface::permissions::Grantable::kAddMySignatory; pubkey = std::make_unique( std::string('1', 32)); + pubkey2 = std::make_unique( + std::string('2', 32)); another_domain = clone( TestDomainBuilder().domainId("andomain").defaultRole(role).build()); @@ -79,27 +82,22 @@ namespace iroha { std::make_unique(*sql, perm_converter); pending_txs_storage = std::make_shared(); - auto result = execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true); - ASSERT_TRUE(val(result)) << err(result)->error.toString(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - another_domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", another_domain->domainId(), *pubkey)), - true))); + execute( + *mock_command_factory->constructCreateRole(role, role_permissions), + true); + execute(*mock_command_factory->constructCreateDomain(domain->domainId(), + role), + true); + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true); + + execute(*mock_command_factory->constructCreateDomain( + another_domain->domainId(), role), + true); + execute(*mock_command_factory->constructCreateAccount( + "id", another_domain->domainId(), *pubkey), + true); } void TearDown() override { @@ -115,27 +113,15 @@ namespace iroha { }; } - CommandResult execute( - const std::unique_ptr &command, - bool do_validation = false, - const shared_model::interface::types::AccountIdType &creator = - "id@domain") { + template + void execute(CommandType &&command, + bool do_validation = false, + const shared_model::interface::types::AccountIdType + &creator = "id@domain") { executor->doValidation(not do_validation); executor->setCreatorAccountId(creator); - return boost::apply_visitor(*executor, command->get()); - } - - // TODO 2018-04-20 Alexey Chernyshov - IR-1276 - rework function with - // CommandBuilder - /** - * Helper function to build command and wrap it into - * std::unique_ptr<> - * @param builder command builder - * @return command - */ - std::unique_ptr buildCommand( - const TestTransactionBuilder &builder) { - return clone(builder.build().commands().front()); + ASSERT_TRUE( + val(executor->operator()(std::forward(command)))); } void addPerms( @@ -143,13 +129,9 @@ namespace iroha { const shared_model::interface::types::AccountIdType account_id = "id@domain", const shared_model::interface::types::RoleIdType role_id = "perms") { - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder().createRole(role_id, set)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().appendRole( - account_id, role_id)), - true))); + execute(*mock_command_factory->constructCreateRole(role_id, set), true); + execute(*mock_command_factory->constructAppendRole(account_id, role_id), + true); } void addAllPerms( @@ -158,14 +140,11 @@ namespace iroha { const shared_model::interface::types::RoleIdType role_id = "all") { shared_model::interface::RolePermissionSet permissions; permissions.set(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role_id, permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().appendRole( - account_id, role_id)), - true))); + execute( + *mock_command_factory->constructCreateRole(role_id, permissions), + true); + execute(*mock_command_factory->constructAppendRole(account_id, role_id), + true); } // TODO [IR-1816] Akvinikym 06.12.18: remove these constants after @@ -216,6 +195,18 @@ namespace iroha { }) << exec_result->toString(); } + void createDefaultAccount() { + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey2), + true); + } + + void createDefaultAsset() { + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1), + true); + } + std::string role = "role"; shared_model::interface::RolePermissionSet role_permissions; shared_model::interface::permissions::Grantable grantable_permission; @@ -223,6 +214,7 @@ namespace iroha { another_account; std::unique_ptr domain, another_domain; std::unique_ptr pubkey; + std::unique_ptr pubkey2; std::unique_ptr sql; @@ -240,6 +232,10 @@ namespace iroha { std::shared_ptr perm_converter = std::make_shared(); + + std::unique_ptr + mock_command_factory = + std::make_unique(); }; class BlocksQueryExecutorTest : public QueryExecutorTest {}; @@ -287,13 +283,7 @@ namespace iroha { .quorum(1) .jsonData(R"({"id@domain": {"key": "value"}})") .build()); - auto pubkey2 = - std::make_unique( - std::string('2', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), - true))); + createDefaultAccount(); } std::unique_ptr account2; @@ -397,13 +387,7 @@ namespace iroha { .quorum(1) .jsonData(R"({"id@domain": {"key": "value"}})") .build()); - auto pubkey2 = - std::make_unique( - std::string('2', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), - true))); + createDefaultAccount(); } std::unique_ptr account2; @@ -512,30 +496,16 @@ namespace iroha { .quorum(1) .jsonData(R"({"id@domain": {"key": "value"}})") .build()); - auto pubkey2 = - std::make_unique( - std::string('2', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), - true))); - - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), - true))); - - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, "1.0") - .creatorAccountId(account->accountId())), - true))); - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, "1.0") - .creatorAccountId(account2->accountId())), - true, - account2->accountId()))); + createDefaultAccount(); + createDefaultAsset(); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, shared_model::interface::Amount{"1.0"}), + true); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, shared_model::interface::Amount{"1.0"}), + true, + account2->accountId()); } std::unique_ptr account2; @@ -649,39 +619,25 @@ namespace iroha { " \"id2@domain\": {\"key\": \"value\", " "\"key2\": \"value2\"}}") .build()); - auto pubkey2 = - std::make_unique( - std::string('2', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), - true))); - - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), - true))); - - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key", "value")), - true, - account->accountId()))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key2", "value2")), - true, - account->accountId()))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key", "value")), - true, - account2->accountId()))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key2", "value2")), - true, - account2->accountId()))); + createDefaultAccount(); + createDefaultAsset(); + + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + true, + account->accountId()); + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key2", "value2"), + true, + account->accountId()); + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + true, + account2->accountId()); + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key2", "value2"), + true, + account2->accountId()); } std::unique_ptr account2; @@ -947,10 +903,9 @@ namespace iroha { } void createAsset() { - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), - true))); + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1), + true); } const std::string asset_id = "coin#domain"; }; @@ -1027,17 +982,8 @@ namespace iroha { .quorum(1) .jsonData(R"({"id@domain": {"key": "value"}})") .build()); - auto pubkey2 = - std::make_unique( - std::string('2', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), - true))); + createDefaultAccount(); + createDefaultAsset(); } /** From bc791bc90cb8c97867d9f8863855a17aabb00850 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Thu, 13 Dec 2018 12:52:03 +0300 Subject: [PATCH 07/61] Remove Reference Holder from Command and Rework CommandExecutorTest (#1934) * Factory is ready Signed-off-by: Akvinikym * Reference is removed, and test is started to be reworked Signed-off-by: Akvinikym * Minor fixes Signed-off-by: Akvinikym * CommandExecutor tests are reworked with the factory Signed-off-by: Akvinikym * Some includes are fixed Signed-off-by: Akvinikym * CMake fixed Signed-off-by: Akvinikym * Little crypto issue Signed-off-by: Akvinikym * Amounts are refactored Signed-off-by: Akvinikym * Refactor the execute method Signed-off-by: Akvinikym --- shared_model/backend/protobuf/CMakeLists.txt | 1 + .../protobuf/commands/impl/proto_command.cpp | 24 +- .../protobuf/commands/proto_command.hpp | 11 +- .../backend/protobuf/impl/transaction.cpp | 2 +- test/module/irohad/ametsuchi/CMakeLists.txt | 1 + .../ametsuchi/postgres_executor_test.cpp | 1353 +++++++---------- .../mock_command_factory.cpp | 13 +- .../mock_command_factory.hpp | 6 +- 8 files changed, 608 insertions(+), 803 deletions(-) diff --git a/shared_model/backend/protobuf/CMakeLists.txt b/shared_model/backend/protobuf/CMakeLists.txt index e1d9b90663..63eb61b082 100644 --- a/shared_model/backend/protobuf/CMakeLists.txt +++ b/shared_model/backend/protobuf/CMakeLists.txt @@ -69,4 +69,5 @@ target_link_libraries(shared_model_proto_backend schema common shared_model_interfaces + logger ) diff --git a/shared_model/backend/protobuf/commands/impl/proto_command.cpp b/shared_model/backend/protobuf/commands/impl/proto_command.cpp index 32c89bca6d..f7eacf7bd3 100644 --- a/shared_model/backend/protobuf/commands/impl/proto_command.cpp +++ b/shared_model/backend/protobuf/commands/impl/proto_command.cpp @@ -21,7 +21,7 @@ #include "backend/protobuf/commands/proto_set_quorum.hpp" #include "backend/protobuf/commands/proto_subtract_asset_quantity.hpp" #include "backend/protobuf/commands/proto_transfer_asset.hpp" -#include "utils/reference_holder.hpp" +#include "logger/logger.hpp" #include "utils/variant_deserializer.hpp" namespace { @@ -52,13 +52,12 @@ namespace shared_model { namespace proto { struct Command::Impl { - explicit Impl(TransportType &&ref) : proto_(std::move(ref)) {} - explicit Impl(const TransportType &ref) : proto_(ref) {} + explicit Impl(TransportType &ref) : proto_(ref) {} - detail::ReferenceHolder proto_; + TransportType &proto_; ProtoCommandVariantType variant_{[this] { - auto &&ar = *proto_; + const auto &ar = proto_; int which = ar.GetDescriptor()->FindFieldByNumber(ar.command_case())->index(); return shared_model::detail::variant_impl:: @@ -67,17 +66,15 @@ namespace shared_model { }()}; CommandVariantType ivariant_{variant_}; + + logger::Logger log_{logger::log("ProtoCommand")}; }; - Command::Command(const Command &o) : Command(*o.impl_->proto_) {} Command::Command(Command &&o) noexcept = default; - Command::Command(const TransportType &ref) { + Command::Command(TransportType &ref) { impl_ = std::make_unique(ref); } - Command::Command(TransportType &&ref) { - impl_ = std::make_unique(std::move(ref)); - } Command::~Command() = default; @@ -86,7 +83,12 @@ namespace shared_model { } Command *Command::clone() const { - return new Command(*impl_->proto_); + logError("tried to clone a proto command, which is uncloneable"); + std::terminate(); + } + + void Command::logError(const std::string &message) const { + impl_->log_->error(message); } } // namespace proto diff --git a/shared_model/backend/protobuf/commands/proto_command.hpp b/shared_model/backend/protobuf/commands/proto_command.hpp index 1457c8bf08..1dbdaecec8 100644 --- a/shared_model/backend/protobuf/commands/proto_command.hpp +++ b/shared_model/backend/protobuf/commands/proto_command.hpp @@ -6,8 +6,8 @@ #ifndef IROHA_SHARED_MODEL_PROTO_COMMAND_HPP #define IROHA_SHARED_MODEL_PROTO_COMMAND_HPP -#include "interfaces/commands/command.hpp" #include "commands.pb.h" +#include "interfaces/commands/command.hpp" namespace shared_model { namespace proto { @@ -16,25 +16,26 @@ namespace shared_model { public: using TransportType = iroha::protocol::Command; - Command(const Command &o); Command(Command &&o) noexcept; - explicit Command(const TransportType &ref); - explicit Command(TransportType &&ref); + explicit Command(TransportType &ref); ~Command() override; const CommandVariantType &get() const override; protected: + // TODO [IR-126] Akvinikym 13.12.18: Rework inheritance hierarchy so that + // this clone will disappear Command *clone() const override; private: struct Impl; std::unique_ptr impl_; + + void logError(const std::string &message) const; }; } // namespace proto } // namespace shared_model - #endif // IROHA_SHARED_MODEL_PROTO_COMMAND_HPP diff --git a/shared_model/backend/protobuf/impl/transaction.cpp b/shared_model/backend/protobuf/impl/transaction.cpp index 9904d7cae8..329d0691a7 100644 --- a/shared_model/backend/protobuf/impl/transaction.cpp +++ b/shared_model/backend/protobuf/impl/transaction.cpp @@ -61,7 +61,7 @@ namespace shared_model { return SignatureSetType(signatures.begin(), signatures.end()); }()}; - }; + }; // namespace proto Transaction::Transaction(const TransportType &transaction) { impl_ = std::make_unique(transaction); diff --git a/test/module/irohad/ametsuchi/CMakeLists.txt b/test/module/irohad/ametsuchi/CMakeLists.txt index 0838c5dabe..2855430222 100644 --- a/test/module/irohad/ametsuchi/CMakeLists.txt +++ b/test/module/irohad/ametsuchi/CMakeLists.txt @@ -52,6 +52,7 @@ addtest(postgres_executor_test postgres_executor_test.cpp) target_link_libraries(postgres_executor_test integration_framework ametsuchi + commands_mocks_factory ) addtest(postgres_query_executor_test postgres_query_executor_test.cpp) diff --git a/test/module/irohad/ametsuchi/postgres_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_executor_test.cpp index 40e6d72397..2823c504d6 100644 --- a/test/module/irohad/ametsuchi/postgres_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_executor_test.cpp @@ -14,7 +14,7 @@ #include "module/shared_model/builders/protobuf/test_asset_builder.hpp" #include "module/shared_model/builders/protobuf/test_domain_builder.hpp" #include "module/shared_model/builders/protobuf/test_peer_builder.hpp" -#include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" +#include "module/shared_model/mock_objects_factories/mock_command_factory.hpp" namespace iroha { namespace ametsuchi { @@ -64,43 +64,51 @@ namespace iroha { AmetsuchiTest::TearDown(); } - CommandResult execute( - const std::unique_ptr &command, - bool do_validation = false, - const shared_model::interface::types::AccountIdType &creator = - "id@domain") { - executor->doValidation(not do_validation); - executor->setCreatorAccountId(creator); - return boost::apply_visitor(*executor, command->get()); + /** + * Check that passed result contains value and not an error (without this + * method the one below is not able to perform this check + * @param result to be checked + */ + void checkCommandResult(const CommandResult &result) { + ASSERT_TRUE(val(result)); } - // TODO 2018-04-20 Alexey Chernyshov - IR-1276 - rework function with - // CommandBuilder /** - * Hepler function to build command and wrap it into - * std::unique_ptr<> - * @param builder command builder - * @return command + * Execute a given command and optionally check its result + * @tparam check_result - if the result command execution should be + * checked + * @tparam CommandType - type of the command + * @param command - the command to execute + * @param do_validation - of the command should be validated + * @param creator - creator of the command + * @return result of command execution */ - std::unique_ptr buildCommand( - const TestTransactionBuilder &builder) { - return clone(builder.build().commands().front()); + template + CommandResult execute(CommandType &&command, + bool do_validation = false, + const shared_model::interface::types::AccountIdType + &creator = "id@domain") { + executor->doValidation(not do_validation); + executor->setCreatorAccountId(creator); + auto result = executor->operator()(std::forward(command)); + if (check_result) { + checkCommandResult(result); + } + return result; } void addAllPerms( - const shared_model::interface::types::AccountIdType account_id = + const shared_model::interface::types::AccountIdType &account_id = "id@domain", - const shared_model::interface::types::RoleIdType role_id = "all") { + const shared_model::interface::types::RoleIdType &role_id = "all") { shared_model::interface::RolePermissionSet permissions; permissions.set(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role_id, permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().appendRole( - account_id, role_id)), - true))); + + execute( + *mock_command_factory->constructCreateRole(role_id, permissions), + true); + execute(*mock_command_factory->constructAppendRole(account_id, role_id), + true); } /** @@ -121,6 +129,28 @@ namespace iroha { EXPECT_THAT(str_error, HasSubstr(substring)); \ } + /* + * The functions below create common objects with default parameters + * without any validation - specifically for SetUp methods + */ + void createDefaultRole() { + execute( + *mock_command_factory->constructCreateRole(role, role_permissions), + true); + } + + void createDefaultDomain() { + execute(*mock_command_factory->constructCreateDomain(domain->domainId(), + role), + true); + } + + void createDefaultAccount() { + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true); + } + const std::string role = "role"; const std::string another_role = "role2"; shared_model::interface::RolePermissionSet role_permissions; @@ -139,11 +169,15 @@ namespace iroha { perm_converter = std::make_shared(); - const std::string uint256_halfmax = - "57896044618658097711785492504343953926634992332820282019728792003956" - "5648" - "19966.0"; // 2**255 - const std::string asset_amount_one_zero = "1.0"; + const shared_model::interface::Amount uint256_halfmax{ + "5789604461865809771178549250434395392663499233282028201972879200" + "3956" + "564819966.0"}; // 2**255 + const shared_model::interface::Amount asset_amount_one_zero{"1.0"}; + + std::unique_ptr + mock_command_factory = + std::make_unique(); }; class AddAccountAssetTest : public CommandExecutorTest { @@ -151,33 +185,17 @@ namespace iroha { void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } /** * Add default asset and check that it is done */ void addAsset() { - auto asset = clone(TestAccountAssetBuilder() - .domainId(domain->domainId()) - .assetId(asset_id) - .precision(1) - .build()); - - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), - true))); + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1), + true); } shared_model::interface::types::AssetIdType asset_id = @@ -192,19 +210,18 @@ namespace iroha { TEST_F(AddAccountAssetTest, Valid) { addAsset(); addAllPerms(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))))); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero)); + auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))))); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero)); + account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); @@ -217,24 +234,22 @@ namespace iroha { */ TEST_F(AddAccountAssetTest, NoPerms) { addAsset(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); + + auto add_asset = mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero); + execute(*add_asset, true); + auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - auto cmd_result = execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))); + auto cmd_result = execute(*add_asset); - std::vector query_args{ - account->accountId(), asset_amount_one_zero, asset_id, "1"}; + std::vector query_args{account->accountId(), + asset_amount_one_zero.toStringRepr(), + asset_id, + "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -244,14 +259,15 @@ namespace iroha { * @then account asset fails to be added */ TEST_F(AddAccountAssetTest, InvalidAsset) { - auto cmd_result = execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true); + auto cmd_result = + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); - std::vector query_args{ - account->accountId(), asset_amount_one_zero, asset_id, "1"}; + std::vector query_args{account->accountId(), + asset_amount_one_zero.toStringRepr(), + asset_id, + "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } @@ -262,19 +278,15 @@ namespace iroha { */ TEST_F(AddAccountAssetTest, Uint256Overflow) { addAsset(); - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, uint256_halfmax) - .creatorAccountId(account->accountId())), - true))); - auto cmd_result = - execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, uint256_halfmax) - .creatorAccountId(account->accountId())), - true); + + auto add_asset = mock_command_factory->constructAddAssetQuantity( + asset_id, uint256_halfmax); + execute(*add_asset, true); + + auto cmd_result = execute(*add_asset, true); std::vector query_args{ - account->accountId(), uint256_halfmax, asset_id, "1"}; + account->accountId(), uint256_halfmax.toStringRepr(), asset_id, "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -283,18 +295,9 @@ namespace iroha { void SetUp() override { CommandExecutorTest::SetUp(); peer = clone(TestPeerBuilder().build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } std::unique_ptr peer; }; @@ -306,8 +309,7 @@ namespace iroha { */ TEST_F(AddPeer, Valid) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder().addPeer(peer->address(), peer->pubkey()))))); + execute(*mock_command_factory->constructAddPeer(*peer)); } /** @@ -316,8 +318,8 @@ namespace iroha { * @then peer is not added */ TEST_F(AddPeer, NoPerms) { - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().addPeer(peer->address(), peer->pubkey()))); + auto cmd_result = + execute(*mock_command_factory->constructAddPeer(*peer)); std::vector query_args{peer->toString()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -327,21 +329,14 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", - domain->domainId(), - shared_model::interface::types::PubkeyType( - std::string('5', 32)))), - true))); + createDefaultRole(); + createDefaultDomain(); + execute(*mock_command_factory->constructCreateAccount( + "id", + domain->domainId(), + shared_model::interface::types::PubkeyType( + std::string('5', 32))), + true); } }; @@ -352,9 +347,10 @@ namespace iroha { */ TEST_F(AddSignatory, Valid) { addAllPerms(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), *pubkey))))); + + execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId())); + auto signatories = query->getSignatories(account->accountId()); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) @@ -367,22 +363,20 @@ namespace iroha { * @then signatory is successfully added */ TEST_F(AddSignatory, ValidGrantablePerms) { - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", - domain->domainId(), - shared_model::interface::types::PubkeyType( - std::string('2', 32)))), - true))); + execute( + *mock_command_factory->constructCreateAccount( + "id2", + domain->domainId(), + shared_model::interface::types::PubkeyType(std::string('2', 32))), + true); auto perm = shared_model::interface::permissions::Grantable::kAddMySignatory; - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().grantPermission( - account->accountId(), perm)), - true, - "id2@domain"))); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder().addSignatory("id2@domain", *pubkey))))); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain"); + execute( + *mock_command_factory->constructAddSignatory(*pubkey, "id2@domain")); auto signatories = query->getSignatories("id2@domain"); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) @@ -396,8 +390,8 @@ namespace iroha { */ TEST_F(AddSignatory, NoPerms) { auto cmd_result = - execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), *pubkey))); + execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId())); std::vector query_args{account->accountId(), pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -416,13 +410,12 @@ namespace iroha { */ TEST_F(AddSignatory, ExistingPubKey) { addAllPerms(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), *pubkey))))); + execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId())); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), *pubkey))); + execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId())); std::vector query_args{account->accountId(), pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -432,18 +425,9 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } shared_model::interface::RolePermissionSet role_permissions2; }; @@ -455,11 +439,11 @@ namespace iroha { */ TEST_F(AppendRole, Valid) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions)), - true))); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().appendRole( - account->accountId(), another_role))))); + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions), + true); + execute(*mock_command_factory->constructAppendRole(account->accountId(), + another_role)); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -473,11 +457,10 @@ namespace iroha { */ TEST_F(AppendRole, ValidEmptyPerms) { addAllPerms(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder().createRole(another_role, {})), - true))); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().appendRole( - account->accountId(), another_role))))); + execute(*mock_command_factory->constructCreateRole(another_role, {}), + true); + execute(*mock_command_factory->constructAppendRole(account->accountId(), + another_role)); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -493,12 +476,12 @@ namespace iroha { TEST_F(AppendRole, AccountDoesNotHavePermsGenesis) { role_permissions2.set( shared_model::interface::permissions::Role::kRemoveMySignatory); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions2)), - true))); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().appendRole( - account->accountId(), another_role)), - true))); + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions2), + true); + execute(*mock_command_factory->constructAppendRole(account->accountId(), + another_role), + true); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -511,12 +494,12 @@ namespace iroha { * @then role is not appended */ TEST_F(AppendRole, NoPerms) { - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions)), - true))); + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions), + true); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().appendRole( - account->accountId(), another_role))); + execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -535,12 +518,12 @@ namespace iroha { TEST_F(AppendRole, NoRolePermsInAccount) { role_permissions2.set( shared_model::interface::permissions::Role::kRemoveMySignatory); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions2)), - true))); + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions2), + true); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().appendRole( - account->accountId(), another_role))); + execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -553,11 +536,11 @@ namespace iroha { */ TEST_F(AppendRole, NoAccount) { addAllPerms(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder().createRole(another_role, {})), - true))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().appendRole("doge@noaccount", another_role))); + execute(*mock_command_factory->constructCreateRole(another_role, {}), + true); + auto cmd_result = + execute(*mock_command_factory->constructAppendRole( + "doge@noaccount", another_role)); std::vector query_args{"doge@noaccount", another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -571,8 +554,8 @@ namespace iroha { TEST_F(AppendRole, NoRole) { addAllPerms(); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().appendRole( - account->accountId(), another_role))); + execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -594,18 +577,9 @@ namespace iroha { .quorum(1) .jsonData("{}") .build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } std::unique_ptr account2; @@ -618,9 +592,8 @@ namespace iroha { */ TEST_F(CreateAccount, Valid) { addAllPerms(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey))))); + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey)); auto acc = query->getAccount(account2->accountId()); ASSERT_TRUE(acc); ASSERT_EQ(*account2.get(), *acc.get()); @@ -633,8 +606,8 @@ namespace iroha { */ TEST_F(CreateAccount, NoPerms) { auto cmd_result = - execute(buildCommand(TestTransactionBuilder().createAccount( - account2->accountId(), domain->domainId(), *pubkey))); + execute(*mock_command_factory->constructCreateAccount( + account2->accountId(), domain->domainId(), *pubkey)); auto acc = query->getAccount(account2->accountId()); ASSERT_FALSE(acc); @@ -650,8 +623,9 @@ namespace iroha { */ TEST_F(CreateAccount, NoDomain) { addAllPerms(); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().createAccount("doge", "domain6", *pubkey))); + auto cmd_result = + execute(*mock_command_factory->constructCreateAccount( + "doge", "domain6", *pubkey)); std::vector query_args{"doge", "domain6", pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -665,8 +639,8 @@ namespace iroha { TEST_F(CreateAccount, NameExists) { addAllPerms(); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey))); + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey)); std::vector query_args{ "id", domain->domainId(), pubkey->hex()}; @@ -691,24 +665,22 @@ namespace iroha { TEST_F(CreateAsset, Valid) { role_permissions.set( shared_model::interface::permissions::Role::kCreateAsset); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); + execute( + *mock_command_factory->constructCreateRole(role, role_permissions), + true); + execute(*mock_command_factory->constructCreateDomain(domain->domainId(), + role), + true); auto asset = clone(TestAccountAssetBuilder() .domainId(domain->domainId()) .assetId(asset_id) .precision(1) .build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1))))); + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true); + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1)); auto ass = query->getAsset(asset->assetId()); ASSERT_TRUE(ass); ASSERT_EQ(*asset.get(), *ass.get()); @@ -720,24 +692,23 @@ namespace iroha { * @then asset is not created */ TEST_F(CreateAsset, NoPerms) { - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); + execute( + *mock_command_factory->constructCreateRole(role, role_permissions), + true); + execute(*mock_command_factory->constructCreateDomain(domain->domainId(), + role), + true); auto asset = clone(TestAccountAssetBuilder() .domainId(domain->domainId()) .assetId(asset_id) .precision(1) .build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().createAsset("coin", domain->domainId(), 1))); + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true); + auto cmd_result = + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1)); auto ass = query->getAsset(asset->assetId()); ASSERT_FALSE(ass); @@ -753,19 +724,18 @@ namespace iroha { TEST_F(CreateAsset, NoDomain) { role_permissions.set( shared_model::interface::permissions::Role::kCreateAsset); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().createAsset(asset_name, "no_domain", 1))); + execute( + *mock_command_factory->constructCreateRole(role, role_permissions), + true); + execute(*mock_command_factory->constructCreateDomain(domain->domainId(), + role), + true); + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true); + auto cmd_result = + execute(*mock_command_factory->constructCreateAsset( + asset_name, "no_domain", 1)); std::vector query_args{asset_name, "no_domain", "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -779,21 +749,20 @@ namespace iroha { TEST_F(CreateAsset, NameNotUnique) { role_permissions.set( shared_model::interface::permissions::Role::kCreateAsset); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1))))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().createAsset("coin", domain->domainId(), 1))); + execute( + *mock_command_factory->constructCreateRole(role, role_permissions), + true); + execute(*mock_command_factory->constructCreateDomain(domain->domainId(), + role), + true); + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true); + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1)); + auto cmd_result = + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1)); std::vector query_args{"coin", domain->domainId(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -805,18 +774,9 @@ namespace iroha { CommandExecutorTest::SetUp(); domain2 = clone( TestDomainBuilder().domainId("domain2").defaultRole(role).build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } std::unique_ptr domain2; @@ -829,8 +789,8 @@ namespace iroha { */ TEST_F(CreateDomain, Valid) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder().createDomain(domain2->domainId(), role))))); + execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), + role)); auto dom = query->getDomain(domain2->domainId()); ASSERT_TRUE(dom); ASSERT_EQ(*dom.get(), *domain2.get()); @@ -842,8 +802,9 @@ namespace iroha { * @then domain is not created */ TEST_F(CreateDomain, NoPerms) { - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().createDomain(domain2->domainId(), role))); + auto cmd_result = + execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role)); auto dom = query->getDomain(domain2->domainId()); ASSERT_FALSE(dom); @@ -858,10 +819,11 @@ namespace iroha { */ TEST_F(CreateDomain, NameNotUnique) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder().createDomain(domain2->domainId(), role))))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().createDomain(domain2->domainId(), role))); + execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), + role)); + auto cmd_result = + execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role)); std::vector query_args{domain2->domainId(), role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -875,8 +837,8 @@ namespace iroha { TEST_F(CreateDomain, NoDefaultRole) { addAllPerms(); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().createDomain( - domain2->domainId(), another_role))); + execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), another_role)); std::vector query_args{domain2->domainId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -886,18 +848,9 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } shared_model::interface::RolePermissionSet role_permissions2; }; @@ -909,8 +862,8 @@ namespace iroha { */ TEST_F(CreateRole, Valid) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions))))); + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions)); auto rl = query->getRolePermissions(role); ASSERT_TRUE(rl); ASSERT_EQ(rl.get(), role_permissions); @@ -925,8 +878,8 @@ namespace iroha { role_permissions2.set( shared_model::interface::permissions::Role::kRemoveMySignatory); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions2))); + execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions2)); auto rl = query->getRolePermissions(another_role); ASSERT_TRUE(rl); ASSERT_TRUE(rl->none()); @@ -943,10 +896,11 @@ namespace iroha { */ TEST_F(CreateRole, NameNotUnique) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions))))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().createRole(another_role, role_permissions))); + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions)); + auto cmd_result = + execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions)); std::vector query_args{another_role, role_permissions.toBitstring()}; @@ -957,26 +911,16 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().appendRole( - account->accountId(), another_role)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); + + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions), + true); + execute(*mock_command_factory->constructAppendRole(account->accountId(), + another_role), + true); } }; @@ -987,8 +931,8 @@ namespace iroha { */ TEST_F(DetachRole, Valid) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().detachRole( - account->accountId(), another_role))))); + execute(*mock_command_factory->constructDetachRole(account->accountId(), + another_role)); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -1002,8 +946,8 @@ namespace iroha { */ TEST_F(DetachRole, NoPerms) { auto cmd_result = - execute(buildCommand(TestTransactionBuilder().detachRole( - account->accountId(), another_role))); + execute(*mock_command_factory->constructDetachRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -1021,8 +965,9 @@ namespace iroha { */ TEST_F(DetachRole, NoAccount) { addAllPerms(); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().detachRole("doge@noaccount", another_role))); + auto cmd_result = + execute(*mock_command_factory->constructDetachRole( + "doge@noaccount", another_role)); std::vector query_args{"doge@noaccount", another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -1035,11 +980,11 @@ namespace iroha { */ TEST_F(DetachRole, NoSuchRoleInAccount) { addAllPerms(); - ASSERT_TRUE(val(execute(buildCommand(TestTransactionBuilder().detachRole( - account->accountId(), another_role))))); + execute(*mock_command_factory->constructDetachRole(account->accountId(), + another_role)); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().detachRole( - account->accountId(), another_role))); + execute(*mock_command_factory->constructDetachRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -1053,8 +998,8 @@ namespace iroha { TEST_F(DetachRole, NoRole) { addAllPerms(); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().detachRole( - account->accountId(), "not_existing_role"))); + execute(*mock_command_factory->constructDetachRole( + account->accountId(), "not_existing_role")); std::vector query_args{account->accountId(), "not_existing_role"}; @@ -1065,22 +1010,12 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - another_role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions), + true); } }; @@ -1092,10 +1027,8 @@ namespace iroha { TEST_F(GrantPermission, Valid) { addAllPerms(); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .grantPermission(account->accountId(), perm) - .creatorAccountId(account->accountId()))))); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm)); auto has_perm = query->hasAccountGrantablePermission( account->accountId(), account->accountId(), perm); ASSERT_TRUE(has_perm); @@ -1109,10 +1042,8 @@ namespace iroha { TEST_F(GrantPermission, NoPerms) { auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; auto cmd_result = - - execute(buildCommand(TestTransactionBuilder() - .grantPermission(account->accountId(), perm) - .creatorAccountId(account->accountId()))); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm)); auto has_perm = query->hasAccountGrantablePermission( account->accountId(), account->accountId(), perm); ASSERT_FALSE(has_perm); @@ -1131,9 +1062,8 @@ namespace iroha { addAllPerms(); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; auto cmd_result = - execute(buildCommand(TestTransactionBuilder() - .grantPermission("doge@noaccount", perm) - .creatorAccountId(account->accountId()))); + execute(*mock_command_factory->constructGrantPermission( + "doge@noaccount", perm)); std::vector query_args{"doge@noaccount", perm_converter->toString(perm)}; @@ -1149,18 +1079,9 @@ namespace iroha { another_pubkey = std::make_unique( std::string('7', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } std::unique_ptr pubkey; std::unique_ptr @@ -1175,13 +1096,11 @@ namespace iroha { TEST_F(RemoveSignatory, Valid) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), pk)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().removeSignatory( - account->accountId(), *pubkey))))); + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true); + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *pubkey)); auto signatories = query->getSignatories(account->accountId()); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) @@ -1196,27 +1115,24 @@ namespace iroha { * @then signatory is successfully removed */ TEST_F(RemoveSignatory, ValidGrantablePerm) { - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey)), - true))); + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey), + true); auto perm = shared_model::interface::permissions::Grantable::kRemoveMySignatory; - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().grantPermission( - account->accountId(), perm)), - true, - "id2@domain"))); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain"); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder().addSignatory("id2@domain", pk)), - true))); + execute(*mock_command_factory->constructAddSignatory(pk, "id2@domain"), + true); auto signatories = query->getSignatories("id2@domain"); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), pk) != signatories->end()); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder().removeSignatory("id2@domain", pk))))); + execute( + *mock_command_factory->constructRemoveSignatory("id2@domain", pk)); signatories = query->getSignatories("id2@domain"); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) @@ -1232,13 +1148,12 @@ namespace iroha { */ TEST_F(RemoveSignatory, NoPerms) { shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), pk)), - true))); + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().removeSignatory( - account->accountId(), *pubkey))); + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *pubkey)); std::vector query_args{account->accountId(), pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -1259,13 +1174,12 @@ namespace iroha { TEST_F(RemoveSignatory, NoAccount) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), pk)), - true))); + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().removeSignatory("hello", *pubkey))); + auto cmd_result = execute( + *mock_command_factory->constructRemoveSignatory("hello", *pubkey)); std::vector query_args{"hello", pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -1279,22 +1193,19 @@ namespace iroha { TEST_F(RemoveSignatory, NoSuchSignatory) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), pk)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), *another_pubkey)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().removeSignatory( - account->accountId(), *another_pubkey)), - true))); + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true); + execute(*mock_command_factory->constructAddSignatory( + *another_pubkey, account->accountId()), + true); + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *another_pubkey), + true); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().removeSignatory( - account->accountId(), *another_pubkey))); + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *another_pubkey)); std::vector query_args{account->accountId(), another_pubkey->hex()}; @@ -1310,15 +1221,14 @@ namespace iroha { TEST_F(RemoveSignatory, SignatoriesLessThanQuorum) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), pk)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().removeSignatory( - account->accountId(), *pubkey))))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().removeSignatory(account->accountId(), pk))); + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true); + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *pubkey)); + auto cmd_result = + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), pk)); std::vector query_args{account->accountId(), pk.hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 5, query_args); @@ -1328,24 +1238,12 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .grantPermission(account->accountId(), - grantable_permission) - .creatorAccountId(account->accountId())), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), grantable_permission), + true); } }; @@ -1360,24 +1258,16 @@ namespace iroha { ASSERT_TRUE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), grantable_permission)); - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .grantPermission(account->accountId(), perm) - .creatorAccountId(account->accountId())), - true))); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true); ASSERT_TRUE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), grantable_permission)); ASSERT_TRUE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), perm)); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder() - .revokePermission(account->accountId(), grantable_permission) - .creatorAccountId(account->accountId()))))); - ASSERT_TRUE(err(execute(buildCommand( - TestTransactionBuilder() - .revokePermission(account->accountId(), grantable_permission) - .creatorAccountId(account->accountId()))))); + execute(*mock_command_factory->constructRevokePermission( + account->accountId(), grantable_permission)); ASSERT_FALSE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), grantable_permission)); ASSERT_TRUE(query->hasAccountGrantablePermission( @@ -1393,9 +1283,8 @@ namespace iroha { auto perm = shared_model::interface::permissions::Grantable::kRemoveMySignatory; auto cmd_result = - execute(buildCommand(TestTransactionBuilder() - .revokePermission(account->accountId(), perm) - .creatorAccountId(account->accountId()))); + execute(*mock_command_factory->constructRevokePermission( + account->accountId(), perm)); std::vector query_args{account->accountId(), perm_converter->toString(perm)}; @@ -1406,31 +1295,21 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); account2 = clone(TestAccountBuilder() .domainId(domain->domainId()) .accountId("id2@" + domain->domainId()) .quorum(1) .jsonData("") .build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", - domain->domainId(), - shared_model::interface::types::PubkeyType( - std::string('2', 32)))), - true))); + execute(*mock_command_factory->constructCreateAccount( + "id2", + domain->domainId(), + shared_model::interface::types::PubkeyType( + std::string('2', 32))), + true); } std::unique_ptr account2; }; @@ -1441,9 +1320,8 @@ namespace iroha { * @then kv is set */ TEST_F(SetAccountDetail, Valid) { - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account->accountId(), "key", "value"))))); + execute(*mock_command_factory->constructSetAccountDetail( + account->accountId(), "key", "value")); auto kv = query->getAccountDetail(account->accountId()); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); @@ -1457,16 +1335,14 @@ namespace iroha { TEST_F(SetAccountDetail, ValidGrantablePerm) { auto perm = shared_model::interface::permissions::Grantable::kSetMyAccountDetail; - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().grantPermission( - account->accountId(), perm)), - true, - "id2@domain"))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key", "value")), - false, - account->accountId()))); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain"); + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + false, + account->accountId()); auto kv = query->getAccountDetail(account2->accountId()); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); @@ -1479,11 +1355,10 @@ namespace iroha { */ TEST_F(SetAccountDetail, ValidRolePerm) { addAllPerms(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key", "value")), - false, - account->accountId()))); + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + false, + account->accountId()); auto kv = query->getAccountDetail(account2->accountId()); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); @@ -1496,10 +1371,10 @@ namespace iroha { */ TEST_F(SetAccountDetail, NoPerms) { auto cmd_result = - execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key", "value")), - false, - account->accountId()); + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + false, + account->accountId()); std::vector query_args{ account2->accountId(), "key", "value"}; @@ -1518,10 +1393,10 @@ namespace iroha { TEST_F(SetAccountDetail, NoAccount) { addAllPerms(); auto cmd_result = - execute(buildCommand(TestTransactionBuilder().setAccountDetail( - "doge@noaccount", "key", "value")), - false, - account->accountId()); + execute(*mock_command_factory->constructSetAccountDetail( + "doge@noaccount", "key", "value"), + false, + account->accountId()); std::vector query_args{"doge@noaccount", "key", "value"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -1529,31 +1404,18 @@ namespace iroha { class SetQuorum : public CommandExecutorTest { public: - SetQuorum() - : additional_key_(shared_model::crypto::DefaultCryptoAlgorithmType:: - generateKeypair()) {} + SetQuorum() : additional_pubkey_{std::string('9', 32)} {} void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), additional_key_.publicKey())), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); + execute(*mock_command_factory->constructAddSignatory( + additional_pubkey_, account->accountId()), + true); } - - shared_model::crypto::Keypair additional_key_; + shared_model::interface::types::PubkeyType additional_pubkey_; }; /** @@ -1564,9 +1426,8 @@ namespace iroha { TEST_F(SetQuorum, Valid) { addAllPerms(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountQuorum( - account->accountId(), 2))))); + execute( + *mock_command_factory->constructSetQuorum(account->accountId(), 2)); } /** @@ -1575,25 +1436,21 @@ namespace iroha { * @then quorum is set */ TEST_F(SetQuorum, ValidGrantablePerms) { - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey)), - true))); + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey), + true); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().grantPermission( - account->accountId(), perm)), - true, - "id2@domain"))); + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain"); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - "id2@domain", additional_key_.publicKey())), - true, - "id2@domain"))); + execute(*mock_command_factory->constructAddSignatory(additional_pubkey_, + "id2@domain"), + true, + "id2@domain"); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder().setAccountQuorum("id2@domain", 2))))); + execute(*mock_command_factory->constructSetQuorum("id2@domain", 2)); } /** @@ -1602,8 +1459,8 @@ namespace iroha { * @then quorum is not set */ TEST_F(SetQuorum, NoPerms) { - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().setAccountQuorum(account->accountId(), 3))); + auto cmd_result = execute( + *mock_command_factory->constructSetQuorum(account->accountId(), 3)); std::vector query_args{account->accountId(), "3"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -1617,16 +1474,14 @@ namespace iroha { TEST_F(SetQuorum, LessSignatoriesThanNewQuorum) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addSignatory( - account->accountId(), pk)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().setAccountQuorum( - account->accountId(), 3))))); + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true); + execute( + *mock_command_factory->constructSetQuorum(account->accountId(), 3)); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().setAccountQuorum(account->accountId(), 5))); + auto cmd_result = execute( + *mock_command_factory->constructSetQuorum(account->accountId(), 5)); std::vector query_args{account->accountId(), "5"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 5, query_args); @@ -1635,18 +1490,9 @@ namespace iroha { class SubtractAccountAssetTest : public CommandExecutorTest { void SetUp() override { CommandExecutorTest::SetUp(); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); } public: @@ -1660,10 +1506,9 @@ namespace iroha { .precision(1) .build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), - true))); + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1), + true); } shared_model::interface::types::AssetIdType asset_id = @@ -1678,32 +1523,24 @@ namespace iroha { TEST_F(SubtractAccountAssetTest, Valid) { addAllPerms(); addAsset(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder() - .subtractAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))))); + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, asset_amount_one_zero)); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } /** @@ -1713,30 +1550,27 @@ namespace iroha { */ TEST_F(SubtractAccountAssetTest, NoPerms) { addAsset(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder() - .subtractAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))); + auto cmd_result = + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, asset_amount_one_zero)); - std::vector query_args{ - account->accountId(), asset_id, asset_amount_one_zero, "1"}; + std::vector query_args{account->accountId(), + asset_id, + asset_amount_one_zero.toStringRepr(), + "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } /** @@ -1746,13 +1580,14 @@ namespace iroha { */ TEST_F(SubtractAccountAssetTest, NoAsset) { addAllPerms(); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder() - .subtractAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))); + auto cmd_result = + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, asset_amount_one_zero)); - std::vector query_args{ - account->accountId(), asset_id, asset_amount_one_zero, "1"}; + std::vector query_args{account->accountId(), + asset_id, + asset_amount_one_zero.toStringRepr(), + "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } @@ -1765,9 +1600,8 @@ namespace iroha { addAllPerms(); addAsset(); auto cmd_result = - execute(buildCommand(TestTransactionBuilder() - .subtractAssetQuantity(asset_id, "1.0000") - .creatorAccountId(account->accountId()))); + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, shared_model::interface::Amount{"1.0000"})); std::vector query_args{ account->accountId(), asset_id, "1.0000", "1"}; @@ -1782,15 +1616,12 @@ namespace iroha { TEST_F(SubtractAccountAssetTest, NotEnoughAsset) { addAllPerms(); addAsset(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); auto cmd_result = - execute(buildCommand(TestTransactionBuilder() - .subtractAssetQuantity(asset_id, "2.0") - .creatorAccountId(account->accountId()))); + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, shared_model::interface::Amount{"2.0"})); std::vector query_args{ account->accountId(), asset_id, "2.0", "1"}; @@ -1808,22 +1639,12 @@ namespace iroha { .jsonData("{}") .build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role, role_permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey)), - true))); + createDefaultRole(); + createDefaultDomain(); + createDefaultAccount(); + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey), + true); } public: @@ -1837,10 +1658,9 @@ namespace iroha { .precision(1) .build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), - true))); + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1), + true); } shared_model::interface::types::AssetIdType asset_id = @@ -1857,38 +1677,31 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder().transferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero))))); + execute( + *mock_command_factory->constructTransferAsset(account->accountId(), + account2->accountId(), + asset_id, + "desc", + asset_amount_one_zero)); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); account_asset = query->getAccountAsset(account2->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } /** @@ -1901,38 +1714,32 @@ namespace iroha { addAsset(); auto perm = shared_model::interface::permissions::Grantable::kTransferMyAssets; - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().grantPermission( - account2->accountId(), perm)), - true, - account->accountId()))); - - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, "2.0") - .creatorAccountId(account->accountId())), - true))); + execute(*mock_command_factory->constructGrantPermission( + account2->accountId(), perm), + true, + account->accountId()); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, shared_model::interface::Amount{"2.0"}), + true); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().transferAsset( - account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero)), - false, - account2->accountId()))); + execute( + *mock_command_factory->constructTransferAsset(account->accountId(), + account2->accountId(), + asset_id, + "desc", + asset_amount_one_zero), + false, + account2->accountId()); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); account_asset = query->getAccountAsset(account2->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } /** @@ -1941,17 +1748,17 @@ namespace iroha { * @then account asset fails to be transferred */ TEST_F(TransferAccountAssetTest, NoPerms) { - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().transferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero))); + auto cmd_result = execute( + *mock_command_factory->constructTransferAsset(account->accountId(), + account2->accountId(), + asset_id, + "desc", + asset_amount_one_zero)); std::vector query_args{account->accountId(), account2->accountId(), asset_id, - asset_amount_one_zero, + asset_amount_one_zero.toStringRepr(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -1965,43 +1772,42 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); - auto cmd_result = - execute(buildCommand(TestTransactionBuilder().transferAsset( - "some@domain", - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero)), - true); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); + auto cmd_result = execute( + *mock_command_factory->constructTransferAsset("some@domain", + account2->accountId(), + asset_id, + "desc", + asset_amount_one_zero), + true); { - std::vector query_args{"some@domain", - account2->accountId(), - asset_id, - asset_amount_one_zero, - "1"}; + std::vector query_args{ + "some@domain", + account2->accountId(), + asset_id, + asset_amount_one_zero.toStringRepr(), + "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } - cmd_result = execute(buildCommand(TestTransactionBuilder().transferAsset( - account->accountId(), - "some@domain", - asset_id, - "desc", - asset_amount_one_zero)), - true); + cmd_result = execute( + *mock_command_factory->constructTransferAsset(account->accountId(), + "some@domain", + asset_id, + "desc", + asset_amount_one_zero), + true); { - std::vector query_args{account->accountId(), - "some@domain", - asset_id, - asset_amount_one_zero, - "1"}; + std::vector query_args{ + account->accountId(), + "some@domain", + asset_id, + asset_amount_one_zero.toStringRepr(), + "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } } @@ -2014,17 +1820,17 @@ namespace iroha { TEST_F(TransferAccountAssetTest, NoAsset) { addAllPerms(); addAllPerms(account2->accountId(), "all2"); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().transferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero))); + auto cmd_result = execute( + *mock_command_factory->constructTransferAsset(account->accountId(), + account2->accountId(), + asset_id, + "desc", + asset_amount_one_zero)); std::vector query_args{account->accountId(), account2->accountId(), asset_id, - asset_amount_one_zero, + asset_amount_one_zero.toStringRepr(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 5, query_args); } @@ -2038,17 +1844,16 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); - auto cmd_result = execute(buildCommand( - TestTransactionBuilder().transferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - "2.0"))); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); + auto cmd_result = + execute(*mock_command_factory->constructTransferAsset( + account->accountId(), + account2->accountId(), + asset_id, + "desc", + shared_model::interface::Amount{"2.0"})); std::vector query_args{ account->accountId(), account2->accountId(), asset_id, "2.0", "1"}; @@ -2065,29 +1870,25 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, uint256_halfmax) - .creatorAccountId(account->accountId())), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().addAssetQuantity( - asset_id, uint256_halfmax)), - false, - account2->accountId()))); - auto cmd_result = - execute(buildCommand(TestTransactionBuilder().transferAsset( - account->accountId(), - account2->accountId(), - asset_id, - "desc", - uint256_halfmax)), - true); + execute(*mock_command_factory->constructAddAssetQuantity(asset_id, + uint256_halfmax), + true); + execute(*mock_command_factory->constructAddAssetQuantity(asset_id, + uint256_halfmax), + false, + account2->accountId()); + auto cmd_result = execute( + *mock_command_factory->constructTransferAsset(account->accountId(), + account2->accountId(), + asset_id, + "desc", + uint256_halfmax), + true); std::vector query_args{account->accountId(), account2->accountId(), asset_id, - uint256_halfmax, + uint256_halfmax.toStringRepr(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 7, query_args); } diff --git a/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp b/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp index 807c697075..63ba3213fe 100644 --- a/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp +++ b/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp @@ -280,25 +280,24 @@ namespace shared_model { const types::AccountIdType &src_account_id, const types::AccountIdType &dest_account_id, const types::AssetIdType &asset_id, - const Amount &cmd_amount, - const types::DescriptionType &cmd_description) const { + const types::DescriptionType &cmd_description, + const Amount &cmd_amount) const { return createFactoryResult( [&src_account_id, &dest_account_id, &asset_id, - &cmd_amount, - &cmd_description]( - FactoryResult specific_cmd_mock) { + &cmd_description, + &cmd_amount](FactoryResult specific_cmd_mock) { EXPECT_CALL(*specific_cmd_mock, srcAccountId()) .WillRepeatedly(ReturnRefOfCopy(src_account_id)); EXPECT_CALL(*specific_cmd_mock, destAccountId()) .WillRepeatedly(ReturnRefOfCopy(dest_account_id)); EXPECT_CALL(*specific_cmd_mock, assetId()) .WillRepeatedly(ReturnRefOfCopy(asset_id)); - EXPECT_CALL(*specific_cmd_mock, amount()) - .WillRepeatedly(ReturnRefOfCopy(cmd_amount)); EXPECT_CALL(*specific_cmd_mock, description()) .WillRepeatedly(ReturnRefOfCopy(cmd_description)); + EXPECT_CALL(*specific_cmd_mock, amount()) + .WillRepeatedly(ReturnRefOfCopy(cmd_amount)); return specific_cmd_mock; }); } diff --git a/test/module/shared_model/mock_objects_factories/mock_command_factory.hpp b/test/module/shared_model/mock_objects_factories/mock_command_factory.hpp index 1c4ba05826..a02dbeb4dc 100644 --- a/test/module/shared_model/mock_objects_factories/mock_command_factory.hpp +++ b/test/module/shared_model/mock_objects_factories/mock_command_factory.hpp @@ -171,16 +171,16 @@ namespace shared_model { * @param src_account_id to be in that command * @param dest_account_id to be in that command * @param asset_id to be in that command - * @param amount to be in that command * @param description to be in that command + * @param amount to be in that command * @return pointer to the created command */ FactoryResult constructTransferAsset( const types::AccountIdType &src_account_id, const types::AccountIdType &dest_account_id, const types::AssetIdType &asset_id, - const Amount &amount, - const types::DescriptionType &description) const; + const types::DescriptionType &description, + const Amount &amount) const; private: /** From 762b1b164a16818a9fa32386b93173cadbe768ec Mon Sep 17 00:00:00 2001 From: BulatSaif Date: Thu, 13 Dec 2018 13:24:49 +0300 Subject: [PATCH 08/61] System tests with sanitizer (#1936) Signed-off-by: Bulat Saifullin --- .jenkinsci/debug-build.groovy | 9 ++++++++- Jenkinsfile | 1 + test/system/CMakeLists.txt | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.jenkinsci/debug-build.groovy b/.jenkinsci/debug-build.groovy index 2bf7684dcf..9fec296e9f 100644 --- a/.jenkinsci/debug-build.groovy +++ b/.jenkinsci/debug-build.groovy @@ -5,12 +5,16 @@ def doDebugBuild(coverageEnabled=false) { def manifest = load ".jenkinsci/docker-manifest.groovy" def pCommit = load ".jenkinsci/previous-commit.groovy" def parallelism = params.PARALLELISM + def sanitizeEnabled = params.sanitize def platform = sh(script: 'uname -m', returnStdout: true).trim() def previousCommit = pCommit.previousCommitOrCurrent() // params are always null unless job is started // this is the case for the FIRST build only. // So just set this to same value as default. // This is a known bug. See https://issues.jenkins-ci.org/browse/JENKINS-41929 + if (sanitizeEnabled == null){ + sanitizeEnabled = true + } if (!parallelism) { parallelism = 4 } @@ -62,7 +66,10 @@ def doDebugBuild(coverageEnabled=false) { def scmVars = checkout scm def cmakeOptions = "" if ( coverageEnabled ) { - cmakeOptions = " -DCOVERAGE=ON " + cmakeOptions += " -DCOVERAGE=ON " + } + if ( sanitizeEnabled ){ + cmakeOptions += " -DSANITIZE='address;leak' " } env.IROHA_VERSION = "0x${scmVars.GIT_COMMIT}" env.IROHA_HOME = "/opt/iroha" diff --git a/Jenkinsfile b/Jenkinsfile index c57d7a9d2d..1d4861e506 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,6 +18,7 @@ properties([parameters([ choice(choices: 'Release\nDebug', description: 'Android bindings build type', name: 'ABBuildType'), choice(choices: 'arm64-v8a\narmeabi-v7a\narmeabi\nx86_64\nx86', description: 'Android bindings platform', name: 'ABPlatform'), booleanParam(defaultValue: true, description: 'Build docs', name: 'Doxygen'), + booleanParam(defaultValue: true, description: 'Sanitize address;leak', name: 'sanitize'), string(defaultValue: '8', description: 'Expect ~3GB memory consumtion per CPU core', name: 'PARALLELISM')])]) diff --git a/test/system/CMakeLists.txt b/test/system/CMakeLists.txt index 9fdc52ee88..ca48833e29 100644 --- a/test/system/CMakeLists.txt +++ b/test/system/CMakeLists.txt @@ -15,3 +15,10 @@ target_link_libraries(irohad_test add_dependencies(irohad_test irohad) add_definitions(-DPATHIROHAD="${PROJECT_BINARY_DIR}/bin") add_definitions(-DPATHTESTDATA="${CMAKE_CURRENT_SOURCE_DIR}/irohad_test_data") + +if (SANITIZE) + target_link_libraries(irohad_test asan) + foreach(el ${SANITIZE}) + target_compile_options(irohad_test PRIVATE -fsanitize=${el}) + endforeach(el) +endif () From 0c77c564ac1857e68bb0bb99ed47bf2c6d6e5ae2 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Thu, 13 Dec 2018 13:49:06 +0300 Subject: [PATCH 09/61] Tests are adjusted to check the described use-case Signed-off-by: Akvinikym --- .../acceptance/revoke_permission_test.cpp | 62 ++++++++++++++----- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/test/integration/acceptance/revoke_permission_test.cpp b/test/integration/acceptance/revoke_permission_test.cpp index 415b21bef3..c9adf9ade4 100644 --- a/test/integration/acceptance/revoke_permission_test.cpp +++ b/test/integration/acceptance/revoke_permission_test.cpp @@ -83,26 +83,54 @@ TEST_F(GrantablePermissionsFixture, RevokeTwice) { /** * Revoke without permission + * @given ITF instance, three accounts: + * - first account does not have any permissions + * - second account has a grantable permission from the third account + * - third account gives a grantable permissions to the second account + * @when first account tries to revoke permissions from the second + * @then revoke fails + */ +TEST_F(GrantablePermissionsFixture, RevokeWithoutPermission) { + IntegrationTestFramework itf(1); + itf.setInitialState(kAdminKeypair); + createTwoAccounts(itf, {}, {Role::kReceive}) + .sendTxAwait(makeUserWithPerms( + {interface::permissions::Role::kSetMyQuorum}), + [](auto &block) { ASSERT_EQ(block->transactions().size(), 1); }) + .sendTxAwait( + grantPermission(kUser, + kUserKeypair, + kAccount2, + permissions::Grantable::kSetMyQuorum), + [](auto &block) { ASSERT_EQ(block->transactions().size(), 1); }) + .sendTxAwait( + revokePermission(kAccount1, + kAccount1Keypair, + kAccount2, + permissions::Grantable::kSetMyQuorum), + [](auto &block) { ASSERT_EQ(block->transactions().size(), 0); }) + .done(); +} + +/** + * Revoke permission, which was granted, though the granter does not have a + * corresponding permission already * @given ITF instance, two accounts, at the beginning first account have * can_grant permission and grants a permission to second account, then the * first account lost can_grant permission * @when the first account tries to revoke permission from the second - * @then stateful validation fails - */ -/** - * TODO igor-egorov, 2018-08-03, enable test case - * https://soramitsu.atlassian.net/browse/IR-1572 + * @then revoke is successful */ -TEST_F(GrantablePermissionsFixture, DISABLED_RevokeWithoutPermission) { - auto detach_role_tx = - GrantablePermissionsFixture::TxBuilder() - .createdTime(getUniqueTime()) - .creatorAccountId(kAdminId) - .quorum(1) - .detachRole(kAccount1 + "@" + kDomain, kRole1) - .build() - .signAndAddSignature(kAdminKeypair) - .finish(); +TEST_F(GrantablePermissionsFixture, + RevokeTheGrantedPermissionWithoutPermission) { + auto detach_role_tx = GrantablePermissionsFixture::TxBuilder() + .createdTime(getUniqueTime()) + .creatorAccountId(kAdminId) + .quorum(1) + .detachRole(kAccount1 + "@" + kDomain, kRole1) + .build() + .signAndAddSignature(kAdminKeypair) + .finish(); IntegrationTestFramework itf(1); itf.setInitialState(kAdminKeypair); @@ -123,9 +151,9 @@ TEST_F(GrantablePermissionsFixture, DISABLED_RevokeWithoutPermission) { .checkProposal( [](auto &proposal) { ASSERT_EQ(proposal->transactions().size(), 1); }) .checkVerifiedProposal( - [](auto &proposal) { ASSERT_EQ(proposal->transactions().size(), 0); }) + [](auto &proposal) { ASSERT_EQ(proposal->transactions().size(), 1); }) .checkBlock( - [](auto &block) { ASSERT_EQ(block->transactions().size(), 0); }) + [](auto &block) { ASSERT_EQ(block->transactions().size(), 1); }) .done(); } From b0c353c248648c7902b83b2e3f6e0e32280aa07e Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Thu, 13 Dec 2018 16:21:51 +0300 Subject: [PATCH 10/61] Merge with dev Signed-off-by: Akvinikym --- .jenkinsci/debug-build.groovy | 11 +- .jenkinsci/release-build.groovy | 20 +- docs/permissions_compiler/consts.py | 2 + docs/source/api/queries.rst | 38 +- docs/source/maintenance/permissions.rst | 40 ++ docs/source/permissions/matrix.csv | 2 + example/genesis.block | 242 ++++---- .../permissions/can_add_domain_asset_qty.py | 8 + .../can_subtract_domain_asset_qty.py | 10 + iroha-cli/main.cpp | 18 +- .../ametsuchi/impl/postgres_block_index.cpp | 13 +- .../ametsuchi/impl/postgres_block_query.cpp | 8 +- .../impl/postgres_command_executor.cpp | 55 +- .../impl/postgres_query_executor.cpp | 274 +++++---- .../impl/postgres_query_executor.hpp | 18 + irohad/ametsuchi/impl/storage_impl.cpp | 17 +- irohad/consensus/CMakeLists.txt | 26 +- irohad/consensus/gate_object.hpp | 67 +++ irohad/consensus/impl/gate_object.cpp | 17 + irohad/consensus/round.hpp | 4 +- irohad/consensus/yac/CMakeLists.txt | 1 + irohad/consensus/yac/impl/yac.cpp | 28 +- irohad/consensus/yac/impl/yac_gate_impl.cpp | 204 ++++--- irohad/consensus/yac/impl/yac_gate_impl.hpp | 34 +- .../yac/impl/yac_hash_provider_impl.cpp | 18 +- .../yac/impl/yac_hash_provider_impl.hpp | 19 +- .../yac/storage/impl/yac_block_storage.cpp | 29 +- .../yac/transport/yac_pb_converters.hpp | 38 +- irohad/consensus/yac/yac_hash_provider.hpp | 23 +- irohad/main/CMakeLists.txt | 11 +- irohad/main/application.cpp | 103 +++- irohad/main/application.hpp | 19 +- irohad/main/impl/block_loader_init.cpp | 5 +- irohad/main/impl/consensus_init.cpp | 1 - irohad/main/impl/on_demand_ordering_init.cpp | 306 ++++++++++ irohad/main/impl/on_demand_ordering_init.hpp | 150 +++++ irohad/main/impl/raw_block_loader.cpp | 2 +- irohad/main/irohad.cpp | 11 +- irohad/main/server_runner.cpp | 31 +- irohad/main/server_runner.hpp | 25 +- .../converters/impl/pb_block_factory.cpp | 17 +- irohad/model/sha3_hash.cpp | 2 +- irohad/network/CMakeLists.txt | 7 + irohad/network/consensus_gate.hpp | 57 +- irohad/network/impl/block_loader_service.cpp | 20 +- .../impl/peer_communication_service_impl.cpp | 35 +- .../impl/peer_communication_service_impl.hpp | 38 +- irohad/network/ordering_gate.hpp | 30 +- irohad/network/ordering_gate_common.cpp | 17 + irohad/network/ordering_gate_common.hpp | 38 ++ irohad/network/peer_communication_service.hpp | 32 +- irohad/ordering/CMakeLists.txt | 13 + irohad/ordering/impl/on_demand_common.cpp | 33 + irohad/ordering/impl/on_demand_common.hpp | 30 + .../impl/on_demand_connection_manager.cpp | 46 +- .../impl/on_demand_connection_manager.hpp | 8 +- .../ordering/impl/on_demand_ordering_gate.cpp | 56 +- .../ordering/impl/on_demand_ordering_gate.hpp | 32 +- .../impl/on_demand_ordering_service_impl.cpp | 75 ++- .../impl/on_demand_ordering_service_impl.hpp | 10 +- .../impl/on_demand_os_client_grpc.hpp | 6 +- .../ordering_gate_cache/on_demand_cache.cpp | 7 +- irohad/ordering/impl/ordering_gate_impl.cpp | 23 +- irohad/ordering/impl/ordering_gate_impl.hpp | 7 +- irohad/simulator/CMakeLists.txt | 21 + irohad/simulator/block_creator.hpp | 37 +- irohad/simulator/block_creator_common.cpp | 17 + irohad/simulator/block_creator_common.hpp | 44 ++ irohad/simulator/impl/simulator.cpp | 72 ++- irohad/simulator/impl/simulator.hpp | 24 +- .../simulator/verified_proposal_creator.hpp | 40 +- .../verified_proposal_creator_common.cpp | 19 + .../verified_proposal_creator_common.hpp | 32 + irohad/synchronizer/CMakeLists.txt | 1 + .../synchronizer/impl/synchronizer_impl.cpp | 135 +++-- .../synchronizer/impl/synchronizer_impl.hpp | 13 +- irohad/synchronizer/synchronizer.hpp | 26 +- irohad/synchronizer/synchronizer_common.hpp | 6 +- irohad/torii/processor/CMakeLists.txt | 4 + .../impl/transaction_processor_impl.cpp | 11 +- .../validation/stateful_validator_common.hpp | 2 +- libs/common/delay.hpp | 188 ++++++ libs/common/timeout.hpp | 2 +- libs/logger/logger.hpp | 6 +- shared_model/backend/protobuf/CMakeLists.txt | 2 + shared_model/backend/protobuf/block.hpp | 4 +- shared_model/backend/protobuf/impl/block.cpp | 4 +- .../protobuf/impl/proto_block_factory.cpp | 21 +- .../impl/proto_block_json_converter.cpp | 6 +- .../impl/proto_query_response_factory.cpp | 50 +- .../backend/protobuf/proto_block_factory.hpp | 13 +- .../protobuf/proto_query_response_factory.hpp | 13 + .../queries/impl/proto_blocks_query.cpp | 14 +- .../proto_get_account_asset_transactions.cpp | 10 +- .../impl/proto_get_account_transactions.cpp | 10 +- .../queries/impl/proto_get_transactions.cpp | 22 +- .../queries/impl/proto_tx_pagination_meta.cpp | 36 ++ .../protobuf/queries/proto_blocks_query.hpp | 12 +- .../proto_get_account_asset_transactions.hpp | 4 + .../proto_get_account_transactions.hpp | 4 + .../queries/proto_get_transactions.hpp | 5 +- .../queries/proto_tx_pagination_meta.hpp | 35 ++ .../impl/proto_block_response.cpp | 2 +- .../impl/proto_query_response.cpp | 4 +- .../impl/proto_transaction_page_response.cpp | 60 ++ .../query_responses/proto_query_response.hpp | 1 + .../proto_transactions_page_response.hpp | 46 ++ shared_model/bindings/model_query_builder.cpp | 15 +- shared_model/bindings/model_query_builder.hpp | 11 +- .../builder_templates/query_template.hpp | 28 +- shared_model/interfaces/CMakeLists.txt | 2 + .../interfaces/common_objects/amount.hpp | 1 - .../interfaces/common_objects/types.hpp | 2 +- .../iroha_internal/query_response_factory.hpp | 33 +- shared_model/interfaces/permissions.hpp | 3 +- .../get_account_asset_transactions.hpp | 6 + .../queries/get_account_transactions.hpp | 7 + .../impl/get_account_asset_transactions.cpp | 3 + .../queries/impl/get_account_transactions.cpp | 3 + .../queries/impl/tx_pagination_meta.cpp | 25 + .../interfaces/queries/tx_pagination_meta.hpp | 34 ++ .../query_responses/impl/query_response.cpp | 1 + .../impl/transactions_page_response.cpp | 33 + .../query_responses/query_response.hpp | 20 +- .../transactions_page_response.hpp | 46 ++ shared_model/schema/block.proto | 8 +- shared_model/schema/primitive.proto | 2 + shared_model/schema/qry_responses.proto | 9 + shared_model/schema/queries.proto | 9 + shared_model/utils/lazy_initializer.hpp | 104 ---- .../utils/query_error_response_visitor.hpp | 7 + shared_model/utils/reference_holder.hpp | 1 - shared_model/utils/string_builder.cpp | 7 + shared_model/utils/string_builder.hpp | 12 +- shared_model/validators/CMakeLists.txt | 1 + shared_model/validators/field_validator.cpp | 18 + shared_model/validators/field_validator.hpp | 5 + .../protobuf/proto_block_validator.cpp | 27 + .../protobuf/proto_block_validator.hpp | 22 + shared_model/validators/query_validator.hpp | 3 + test/CMakeLists.txt | 18 +- test/framework/CMakeLists.txt | 2 +- .../integration_test_framework.cpp | 37 +- .../integration_test_framework.hpp | 3 +- .../integration_framework/test_irohad.hpp | 10 + test/fuzzing/status_fuzz.cpp | 4 +- test/fuzzing/torii_fuzz.cpp | 4 +- .../acceptance/acceptance_fixture.hpp | 4 +- .../acceptance/get_account_asset_txs_test.cpp | 25 +- .../acceptance/get_account_test.cpp | 1 + .../query_permission_test_ast_txs.cpp | 11 +- .../acceptance/query_permission_test_txs.cpp | 10 +- .../pipeline/multisig_tx_pipeline_test.cpp | 24 +- test/integration/pipeline/pipeline_test.cpp | 22 +- test/module/iroha-cli/client_test.cpp | 15 +- test/module/irohad/CMakeLists.txt | 13 +- test/module/irohad/ametsuchi/CMakeLists.txt | 5 +- .../irohad/ametsuchi/ametsuchi_fixture.hpp | 5 +- .../irohad/ametsuchi/block_query_test.cpp | 12 +- .../ametsuchi/block_query_transfer_test.cpp | 13 +- .../ametsuchi/postgres_executor_test.cpp | 189 +++++- .../postgres_query_executor_test.cpp | 567 ++++++++++++++---- .../irohad/common/raw_block_loader_test.cpp | 16 +- .../irohad/consensus/yac/yac_gate_test.cpp | 359 +++++------ .../consensus/yac/yac_hash_provider_test.cpp | 24 +- .../module/irohad/consensus/yac/yac_mocks.hpp | 2 +- .../irohad/network/block_loader_test.cpp | 4 +- test/module/irohad/network/network_mocks.hpp | 19 +- test/module/irohad/ordering/CMakeLists.txt | 19 +- .../irohad/ordering/on_demand_cache_test.cpp | 28 +- .../on_demand_connection_manager_test.cpp | 27 +- .../ordering/on_demand_ordering_gate_test.cpp | 141 +++-- .../irohad/ordering/on_demand_os_test.cpp | 7 +- .../irohad/ordering/ordering_gate_test.cpp | 43 +- .../irohad/simulator/simulator_mocks.hpp | 25 +- .../irohad/simulator/simulator_test.cpp | 84 +-- .../module/irohad/synchronizer/CMakeLists.txt | 1 + .../irohad/synchronizer/synchronizer_test.cpp | 333 +++++----- test/module/irohad/torii/CMakeLists.txt | 2 + .../processor/transaction_processor_test.cpp | 27 +- .../irohad/torii/torii_queries_test.cpp | 6 +- .../irohad/torii/torii_service_query_test.cpp | 5 +- .../irohad/torii/torii_service_test.cpp | 69 +-- test/module/shared_model/CMakeLists.txt | 7 - .../proto_block_factory_test.cpp | 10 +- .../proto_query_response_factory_test.cpp | 85 ++- .../builder_templates/block_template.hpp | 4 +- test/module/shared_model/interface_mocks.hpp | 41 +- test/module/shared_model/lazy_test.cpp | 59 -- .../shared_model/validators/CMakeLists.txt | 8 + .../validators/field_validator_test.cpp | 13 +- .../protobuf/proto_block_validator_test.cpp | 44 ++ .../validators/validators_fixture.hpp | 5 + test/system/irohad_test.cpp | 4 +- test/system/irohad_test_data/genesis.block | 6 +- 195 files changed, 4530 insertions(+), 2164 deletions(-) create mode 100644 example/python/permissions/can_add_domain_asset_qty.py create mode 100644 example/python/permissions/can_subtract_domain_asset_qty.py create mode 100644 irohad/consensus/gate_object.hpp create mode 100644 irohad/consensus/impl/gate_object.cpp create mode 100644 irohad/main/impl/on_demand_ordering_init.cpp create mode 100644 irohad/main/impl/on_demand_ordering_init.hpp create mode 100644 irohad/network/ordering_gate_common.cpp create mode 100644 irohad/network/ordering_gate_common.hpp create mode 100644 irohad/ordering/impl/on_demand_common.cpp create mode 100644 irohad/ordering/impl/on_demand_common.hpp create mode 100644 irohad/simulator/block_creator_common.cpp create mode 100644 irohad/simulator/block_creator_common.hpp create mode 100644 irohad/simulator/verified_proposal_creator_common.cpp create mode 100644 irohad/simulator/verified_proposal_creator_common.hpp create mode 100644 libs/common/delay.hpp create mode 100644 shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp create mode 100644 shared_model/backend/protobuf/queries/proto_tx_pagination_meta.hpp create mode 100644 shared_model/backend/protobuf/query_responses/impl/proto_transaction_page_response.cpp create mode 100644 shared_model/backend/protobuf/query_responses/proto_transactions_page_response.hpp create mode 100644 shared_model/interfaces/queries/impl/tx_pagination_meta.cpp create mode 100644 shared_model/interfaces/queries/tx_pagination_meta.hpp create mode 100644 shared_model/interfaces/query_responses/impl/transactions_page_response.cpp create mode 100644 shared_model/interfaces/query_responses/transactions_page_response.hpp delete mode 100644 shared_model/utils/lazy_initializer.hpp create mode 100644 shared_model/validators/protobuf/proto_block_validator.cpp create mode 100644 shared_model/validators/protobuf/proto_block_validator.hpp delete mode 100644 test/module/shared_model/lazy_test.cpp create mode 100644 test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp diff --git a/.jenkinsci/debug-build.groovy b/.jenkinsci/debug-build.groovy index 2bf7684dcf..1205d91ba6 100644 --- a/.jenkinsci/debug-build.groovy +++ b/.jenkinsci/debug-build.groovy @@ -28,17 +28,12 @@ def doDebugBuild(coverageEnabled=false) { // or it is a commit into PR which base branch is develop (usually develop -> master) if ((GIT_LOCAL_BRANCH == 'develop' || CHANGE_BRANCH_LOCAL == 'develop' || GIT_LOCAL_BRANCH == 'dev' || CHANGE_BRANCH_LOCAL == 'dev') && manifest.manifestSupportEnabled()) { manifest.manifestCreate("${DOCKER_REGISTRY_BASENAME}:develop-build", - ["${DOCKER_REGISTRY_BASENAME}:x86_64-develop-build", - "${DOCKER_REGISTRY_BASENAME}:armv7l-develop-build", - "${DOCKER_REGISTRY_BASENAME}:aarch64-develop-build"]) + ["${DOCKER_REGISTRY_BASENAME}:x86_64-develop-build"] + ) manifest.manifestAnnotate("${DOCKER_REGISTRY_BASENAME}:develop-build", [ [manifest: "${DOCKER_REGISTRY_BASENAME}:x86_64-develop-build", - arch: 'amd64', os: 'linux', osfeatures: [], variant: ''], - [manifest: "${DOCKER_REGISTRY_BASENAME}:armv7l-develop-build", - arch: 'arm', os: 'linux', osfeatures: [], variant: 'v7'], - [manifest: "${DOCKER_REGISTRY_BASENAME}:aarch64-develop-build", - arch: 'arm64', os: 'linux', osfeatures: [], variant: ''] + arch: 'amd64', os: 'linux', osfeatures: [], variant: ''] ]) withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', usernameVariable: 'login', passwordVariable: 'password')]) { manifest.manifestPush("${DOCKER_REGISTRY_BASENAME}:develop-build", login, password) diff --git a/.jenkinsci/release-build.groovy b/.jenkinsci/release-build.groovy index 0e958196ba..c98b7ce2cf 100644 --- a/.jenkinsci/release-build.groovy +++ b/.jenkinsci/release-build.groovy @@ -66,17 +66,11 @@ def doReleaseBuild() { } if (manifest.manifestSupportEnabled()) { manifest.manifestCreate("${DOCKER_REGISTRY_BASENAME}:develop", - ["${DOCKER_REGISTRY_BASENAME}:x86_64-develop", - "${DOCKER_REGISTRY_BASENAME}:armv7l-develop", - "${DOCKER_REGISTRY_BASENAME}:aarch64-develop"]) + ["${DOCKER_REGISTRY_BASENAME}:x86_64-develop"]) manifest.manifestAnnotate("${DOCKER_REGISTRY_BASENAME}:develop", [ [manifest: "${DOCKER_REGISTRY_BASENAME}:x86_64-develop", - arch: 'amd64', os: 'linux', osfeatures: [], variant: ''], - [manifest: "${DOCKER_REGISTRY_BASENAME}:armv7l-develop", - arch: 'arm', os: 'linux', osfeatures: [], variant: 'v7'], - [manifest: "${DOCKER_REGISTRY_BASENAME}:aarch64-develop", - arch: 'arm64', os: 'linux', osfeatures: [], variant: ''] + arch: 'amd64', os: 'linux', osfeatures: [], variant: ''] ]) withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', usernameVariable: 'login', passwordVariable: 'password')]) { manifest.manifestPush("${DOCKER_REGISTRY_BASENAME}:develop", login, password) @@ -89,17 +83,11 @@ def doReleaseBuild() { } if (manifest.manifestSupportEnabled()) { manifest.manifestCreate("${DOCKER_REGISTRY_BASENAME}:latest", - ["${DOCKER_REGISTRY_BASENAME}:x86_64-latest", - "${DOCKER_REGISTRY_BASENAME}:armv7l-latest", - "${DOCKER_REGISTRY_BASENAME}:aarch64-latest"]) + ["${DOCKER_REGISTRY_BASENAME}:x86_64-latest"]) manifest.manifestAnnotate("${DOCKER_REGISTRY_BASENAME}:latest", [ [manifest: "${DOCKER_REGISTRY_BASENAME}:x86_64-latest", - arch: 'amd64', os: 'linux', osfeatures: [], variant: ''], - [manifest: "${DOCKER_REGISTRY_BASENAME}:armv7l-latest", - arch: 'arm', os: 'linux', osfeatures: [], variant: 'v7'], - [manifest: "${DOCKER_REGISTRY_BASENAME}:aarch64-latest", - arch: 'arm64', os: 'linux', osfeatures: [], variant: ''] + arch: 'amd64', os: 'linux', osfeatures: [], variant: ''] ]) withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', usernameVariable: 'login', passwordVariable: 'password')]) { manifest.manifestPush("${DOCKER_REGISTRY_BASENAME}:latest", login, password) diff --git a/docs/permissions_compiler/consts.py b/docs/permissions_compiler/consts.py index bbe998eb20..4af449f716 100644 --- a/docs/permissions_compiler/consts.py +++ b/docs/permissions_compiler/consts.py @@ -13,6 +13,7 @@ role = { 'can_add_asset_qty': 'kAddAssetQty', + 'can_add_domain_asset_qty': 'kAddDomainAssetQty', 'can_add_peer': 'kAddPeer', 'can_add_signatory': 'kAddSignatory', 'can_append_role': 'kAppendRole', @@ -54,5 +55,6 @@ 'can_set_detail': 'kSetDetail', 'can_set_quorum': 'kSetQuorum', 'can_subtract_asset_qty': 'kSubtractAssetQty', + 'can_subtract_domain_asset_qty': 'kSubtractDomainAssetQty', 'can_transfer': 'kTransfer' } diff --git a/docs/source/api/queries.rst b/docs/source/api/queries.rst index 92db08badd..470f6d9d8f 100644 --- a/docs/source/api/queries.rst +++ b/docs/source/api/queries.rst @@ -204,14 +204,23 @@ Purpose ------- In a case when a list of transactions per account is needed, `GetAccountTransactions` query can be formed. +.. note:: This query uses pagination for query responses. Request Schema -------------- .. code-block:: proto + message TxPaginationMeta { + uint32 page_size = 1; + oneof opt_first_tx_hash { + string first_tx_hash = 2; + } + } + message GetAccountTransactions { string account_id = 1; + TxPaginationMeta pagination_meta = 2; } Request Structure @@ -222,14 +231,20 @@ Request Structure :widths: 15, 30, 20, 15 "Account ID", "account id to request transactions from", "@", "makoto@soramitsu" + "Page size", "size of the page to be returned by the query, if the response contains fewer transactions than a page size, then next tx hash will be empty in response", "page_size > 0", "5" + "First tx hash", "hash of the first transaction in the page. If that field is not set — then the first transactions are returned", "hash in hex format", "bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929" Response Schema --------------- .. code-block:: proto - message TransactionsResponse { + message TransactionsPageResponse { repeated Transaction transactions = 1; + uint32 all_transactions_size = 2; + oneof next_page_tag { + string next_tx_hash = 3; + } } Response Structure @@ -240,6 +255,8 @@ Response Structure :widths: 15, 30, 20, 15 "Transactions", "an array of transactions for given account", "Committed transactions", "{tx1, tx2…}" + "All transactions size", "total number of transactions created by the given account", "", "100" + "Next transaction hash", "hash pointing to the next transaction after the last transaction in the page. Empty if a page contains the last transaction for the given account", "bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929" Get Account Asset Transactions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -248,15 +265,24 @@ Purpose ------- `GetAccountAssetTransactions` query returns all transactions associated with given account and asset. +.. note:: This query uses pagination for query responses. Request Schema -------------- .. code-block:: proto + message TxPaginationMeta { + uint32 page_size = 1; + oneof opt_first_tx_hash { + string first_tx_hash = 2; + } + } + message GetAccountAssetTransactions { string account_id = 1; string asset_id = 2; + TxPaginationMeta pagination_meta = 3; } Request Structure @@ -268,14 +294,20 @@ Request Structure "Account ID", "account id to request transactions from", "@", "makoto@soramitsu" "Asset ID", "asset id in order to filter transactions containing this asset", "#", "jpy#japan" + "Page size", "size of the page to be returned by the query, if the response contains fewer transactions than a page size, then next tx hash will be empty in response", "page_size > 0", "5" + "First tx hash", "hash of the first transaction in the page. If that field is not set — then the first transactions are returned", "hash in hex format", "bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929" Response Schema --------------- .. code-block:: proto - message TransactionsResponse { + message TransactionsPageResponse { repeated Transaction transactions = 1; + uint32 all_transactions_size = 2; + oneof next_page_tag { + string next_tx_hash = 3; + } } Response Structure @@ -286,6 +318,8 @@ Response Structure :widths: 15, 30, 20, 15 "Transactions", "an array of transactions for given account and asset", "Committed transactions", "{tx1, tx2…}" + "All transactions size", "total number of transactions for given account and asset", "", "100" + "Next transaction hash", "hash pointing to the next transaction after the last transaction in the page. Empty if a page contains the last transaction for given account and asset", "bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929" Get Account Assets ^^^^^^^^^^^^^^^^^^ diff --git a/docs/source/maintenance/permissions.rst b/docs/source/maintenance/permissions.rst index e179a8a186..c68f9c6589 100644 --- a/docs/source/maintenance/permissions.rst +++ b/docs/source/maintenance/permissions.rst @@ -58,6 +58,12 @@ List of Permissions * - `can_subtract_asset_qty`_ - Asset Quantity - Command + * - `can_add_domain_asset_qty`_ + - Asset Quantity + - Command + * - `can_subtract_domain_asset_qty`_ + - Asset Quantity + - Command * - `can_create_domain`_ - Domain - Command @@ -383,6 +389,40 @@ The corresponding `command <../core_concepts/glossary.html#command>`__ can be ex :linenos: :lines: 9-42 +can_add_domain_asset_qty +^^^^^^^^^^^^^^^^^^^^^^^^ + +Allows issuing `assets <../core_concepts/glossary.html#asset>`__ only in own `domain <../core_concepts/glossary.html#domain>`__. + +The corresponding `command <../core_concepts/glossary.html#command>`__ can be executed only for an `account <../core_concepts/glossary.html#account>`__ of `transaction <../core_concepts/glossary.html#transaction>`__ creator and only if that account has a `role <../core_concepts/glossary.html#role>`__ with the `permission <../core_concepts/glossary.html#permission>`__ and only for assets in creator’s domain. + +| Related API method: `Add Asset Quantity <../api/commands.html#add-asset-quantity>`__ +| Usage in Java bindings: ``Role.kAddDomainAssetQty`` +| Usage in Python bindings: ``Role_kAddDomainAssetQty`` +| + +.. literalinclude:: ../../../example/python/permissions/can_add_domain_asset_qty.py + :language: python + :linenos: + :lines: 1-8 + +can_subtract_domain_asset_qty +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Allows burning `assets <../core_concepts/glossary.html#asset>`__ only in own `domain <../core_concepts/glossary.html#domain>`__. + +The corresponding `command <../core_concepts/glossary.html#command>`__ can be executed only for an `account <../core_concepts/glossary.html#account>`__ of `transaction <../core_concepts/glossary.html#transaction>`__ creator and only if that account has a `role <../core_concepts/glossary.html#role>`__ with the `permission <../core_concepts/glossary.html#permission>`__ and only for assets in creator’s domain. + +| Related API method: `Subtract Asset Quantity <../api/commands.html#subtract-asset-quantity>`__ +| Usage in Java bindings: ``Role.kSubtractDomainAssetQty`` +| Usage in Python bindings: ``Role_kSubtractDomainAssetQty`` +| + +.. literalinclude:: ../../../example/python/permissions/can_subtract_domain_asset_qty.py + :language: python + :linenos: + :lines: 1-10 + Domain ------ diff --git a/docs/source/permissions/matrix.csv b/docs/source/permissions/matrix.csv index ed8347e48b..e6303ddc63 100644 --- a/docs/source/permissions/matrix.csv +++ b/docs/source/permissions/matrix.csv @@ -8,6 +8,8 @@ Command,Asset,can_transfer,FALSE,FALSE,Allows sending assets from an account of Command,Asset,can_transfer_my_assets,TRUE,,Permission that allows a specified account to transfer assets of another specified account.,See the example (to be done) for the usage details., ,http://iroha.readthedocs.io/en/latest/api/commands.html#transfer-asset,"Admin creates domain ""test"" that contains can_grant_can_transfer_my_assets, can_receive, can_transfer permissions and two accounts for Alice and Bob in that domain. Admin issues some amount of ""coin"" asset and transfers it to Alice. Alice grants to Bob can_transfer_my_assets permission. Bob can transfer Alice's assets to any account that has can_receive permission, for example, to Admin." Command,Asset Quantity,can_add_asset_qty,FALSE,TRUE,Allows issuing assets.,The corresponding command can be executed only for an account of transaction creator and only if that account has a role with the permission.,,http://iroha.readthedocs.io/en/latest/api/commands.html#add-asset-quantity,"Admin creates domain ""test"" that contains only can_add_asset_qty permission and Alice account in that domain. Admin craetes ""coin"" asset. Alice can add to own account any amount of any asset (e.g. ""coin"" asset)." Command,Asset Quantity,can_subtract_asset_qty,FALSE,TRUE,Allows burning assets.,The corresponding command can be executed only for an account of transaction creator and only if that account has a role with the permission.,,http://iroha.readthedocs.io/en/latest/api/commands.html#subtract-asset-quantity,"Admin creates domain ""test"" that contains only can_subtract_asset_qty permission and Alice account in that domain. Admin issues some amount of ""coin"" asset and transfers some amount of ""coin"" asset to Alice. Alice can burn any amount of ""coin"" assets." +Command,Asset Quantity,can_add_domain_asset_qty,FALSE,TRUE,Allows issuing assets only in own domain.,The corresponding command can be executed only for an account of transaction creator and only if that account has a role with the permission and only for assets in creator’s domain. ,,http://iroha.readthedocs.io/en/latest/api/commands.html#add-asset-quantity, +Command,Asset Quantity,can_subtract_domain_asset_qty,FALSE,TRUE,Allows burning assets only in own domain.,The corresponding command can be executed only for an account of transaction creator and only if that account has a role with the permission and only for assets in creator’s domain.,,http://iroha.readthedocs.io/en/latest/api/commands.html#subtract-asset-quantity, Command,Domain,can_create_domain,FALSE,,Allows creating new domains within the system.,,,http://iroha.readthedocs.io/en/latest/api/commands.html#create-domain,Admin creates domain that contains only can_create_domain permission and Alice account in that domain. Alice can create new domains. Command,Grant,can_grant_can_add_my_signatory,FALSE,,Allows role owners grant `can_add_my_signatory`_ permission.,,,"http://iroha.readthedocs.io/en/latest/api/commands.html#grant-permission diff --git a/example/genesis.block b/example/genesis.block index ee2fd49036..ff3f993787 100644 --- a/example/genesis.block +++ b/example/genesis.block @@ -1,123 +1,125 @@ { - "payload":{ - "transactions":[ - { - "payload":{ - "reducedPayload":{ - "commands":[ - { - "addPeer":{ - "peer":{ - "address":"0.0.0.0:10001", - "peerKey":"vd1YQE0TFeDrJ5AsXXyOsGAsFiOPAFdz30BrwZEwiSk=" - } - } - }, - { - "createRole":{ - "roleName":"admin", - "permissions":[ - "can_add_peer", - "can_add_signatory", - "can_create_account", - "can_create_domain", - "can_get_all_acc_ast", - "can_get_all_acc_ast_txs", - "can_get_all_acc_detail", - "can_get_all_acc_txs", - "can_get_all_accounts", - "can_get_all_signatories", - "can_get_all_txs", - "can_get_blocks", - "can_get_roles", - "can_read_assets", - "can_remove_signatory", - "can_set_quorum" - ] - } - }, - { - "createRole":{ - "roleName":"user", - "permissions":[ - "can_add_signatory", - "can_get_my_acc_ast", - "can_get_my_acc_ast_txs", - "can_get_my_acc_detail", - "can_get_my_acc_txs", - "can_get_my_account", - "can_get_my_signatories", - "can_get_my_txs", - "can_grant_can_add_my_signatory", - "can_grant_can_remove_my_signatory", - "can_grant_can_set_my_account_detail", - "can_grant_can_set_my_quorum", - "can_grant_can_transfer_my_assets", - "can_receive", - "can_remove_signatory", - "can_set_quorum", - "can_transfer" - ] - } - }, - { - "createRole":{ - "roleName":"money_creator", - "permissions":[ - "can_add_asset_qty", - "can_create_asset", - "can_receive", - "can_transfer" - ] - } - }, - { - "createDomain":{ - "domainId":"test", - "defaultRole":"user" - } - }, - { - "createAsset":{ - "assetName":"coin", - "domainId":"test", - "precision":2 - } - }, - { - "createAccount":{ - "accountName":"admin", - "domainId":"test", - "publicKey":"MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA=" - } - }, - { - "createAccount":{ - "accountName":"test", - "domainId":"test", - "publicKey":"cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w=" - } - }, - { - "appendRole":{ - "accountId":"admin@test", - "roleName":"admin" - } - }, - { - "appendRole":{ - "accountId":"admin@test", - "roleName":"money_creator" - } - } - ], - "quorum":1 - } - } - } - ], - "txNumber":1, - "height":"1", - "prevBlockHash":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + "block_v1":{ + "payload":{ + "transactions":[ + { + "payload":{ + "reducedPayload":{ + "commands":[ + { + "addPeer":{ + "peer":{ + "address":"0.0.0.0:10001", + "peerKey":"vd1YQE0TFeDrJ5AsXXyOsGAsFiOPAFdz30BrwZEwiSk=" + } + } + }, + { + "createRole":{ + "roleName":"admin", + "permissions":[ + "can_add_peer", + "can_add_signatory", + "can_create_account", + "can_create_domain", + "can_get_all_acc_ast", + "can_get_all_acc_ast_txs", + "can_get_all_acc_detail", + "can_get_all_acc_txs", + "can_get_all_accounts", + "can_get_all_signatories", + "can_get_all_txs", + "can_get_blocks", + "can_get_roles", + "can_read_assets", + "can_remove_signatory", + "can_set_quorum" + ] + } + }, + { + "createRole":{ + "roleName":"user", + "permissions":[ + "can_add_signatory", + "can_get_my_acc_ast", + "can_get_my_acc_ast_txs", + "can_get_my_acc_detail", + "can_get_my_acc_txs", + "can_get_my_account", + "can_get_my_signatories", + "can_get_my_txs", + "can_grant_can_add_my_signatory", + "can_grant_can_remove_my_signatory", + "can_grant_can_set_my_account_detail", + "can_grant_can_set_my_quorum", + "can_grant_can_transfer_my_assets", + "can_receive", + "can_remove_signatory", + "can_set_quorum", + "can_transfer" + ] + } + }, + { + "createRole":{ + "roleName":"money_creator", + "permissions":[ + "can_add_asset_qty", + "can_create_asset", + "can_receive", + "can_transfer" + ] + } + }, + { + "createDomain":{ + "domainId":"test", + "defaultRole":"user" + } + }, + { + "createAsset":{ + "assetName":"coin", + "domainId":"test", + "precision":2 + } + }, + { + "createAccount":{ + "accountName":"admin", + "domainId":"test", + "publicKey":"MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA=" + } + }, + { + "createAccount":{ + "accountName":"test", + "domainId":"test", + "publicKey":"cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w=" + } + }, + { + "appendRole":{ + "accountId":"admin@test", + "roleName":"admin" + } + }, + { + "appendRole":{ + "accountId":"admin@test", + "roleName":"money_creator" + } + } + ], + "quorum":1 + } + } + } + ], + "txNumber":1, + "height":"1", + "prevBlockHash":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + } } } diff --git a/example/python/permissions/can_add_domain_asset_qty.py b/example/python/permissions/can_add_domain_asset_qty.py new file mode 100644 index 0000000000..e556592766 --- /dev/null +++ b/example/python/permissions/can_add_domain_asset_qty.py @@ -0,0 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +import can_add_asset_qty + +# Please see example for can_add_asset_qty permission. diff --git a/example/python/permissions/can_subtract_domain_asset_qty.py b/example/python/permissions/can_subtract_domain_asset_qty.py new file mode 100644 index 0000000000..1e3ad3c561 --- /dev/null +++ b/example/python/permissions/can_subtract_domain_asset_qty.py @@ -0,0 +1,10 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +import can_subtract_asset_qty + + +# Please see example for can_subtract_asset_qty permission. + diff --git a/iroha-cli/main.cpp b/iroha-cli/main.cpp index 58fa28c810..41b158d65e 100644 --- a/iroha-cli/main.cpp +++ b/iroha-cli/main.cpp @@ -21,9 +21,11 @@ #include #include +#include "backend/protobuf/proto_block_json_converter.hpp" #include "backend/protobuf/queries/proto_query.hpp" #include "backend/protobuf/transaction.hpp" #include "client.hpp" +#include "common/result.hpp" #include "converters/protobuf/json_proto_converter.hpp" #include "crypto/keys_manager_impl.hpp" #include "grpc_response_handler.hpp" @@ -122,9 +124,19 @@ int main(int argc, char *argv[]) { // Convert to json std::ofstream output_file("genesis.block"); auto bl = shared_model::proto::Block( - iroha::model::converters::PbBlockFactory().serialize(block)); - output_file << shared_model::converters::protobuf::modelToJson(bl); - logger->info("File saved to genesis.block"); + iroha::model::converters::PbBlockFactory().serialize(block).block_v1()); + + shared_model::proto::ProtoBlockJsonConverter().serialize(bl).match( + [&logger, + &output_file](const iroha::expected::Value &json) { + output_file << json.value; + logger->info("File saved to genesis.block"); + }, + [&logger](const auto &error) { + // should not get here + logger->error("error while serializing genesis block"); + std::exit(EXIT_FAILURE); + }); } // Create new pub/priv key, register in Iroha Network else if (FLAGS_new_account) { diff --git a/irohad/ametsuchi/impl/postgres_block_index.cpp b/irohad/ametsuchi/impl/postgres_block_index.cpp index 38a954ca64..f5b8f1f7d0 100644 --- a/irohad/ametsuchi/impl/postgres_block_index.cpp +++ b/irohad/ametsuchi/impl/postgres_block_index.cpp @@ -30,11 +30,12 @@ namespace { // make index tx hash -> block where hash is stored std::string makeHashIndex( const shared_model::interface::types::HashType &hash, - shared_model::interface::types::HeightType height) { + shared_model::interface::types::HeightType height, + size_t index) { boost::format base( - "INSERT INTO height_by_hash(hash, height) VALUES ('%s', " - "'%s');"); - return (base % hash.hex() % height).str(); + "INSERT INTO position_by_hash(hash, height, index) VALUES ('%s', " + "'%s', '%s');"); + return (base % hash.hex() % height % index).str(); } std::string makeCommittedTxHashIndex( @@ -104,7 +105,7 @@ namespace { // flat map accounts to unindexed keys for (const auto &id : ids) { boost::format base( - "INSERT INTO index_by_id_height_asset(id, " + "INSERT INTO position_by_account_asset(account_id, " "height, asset_id, " "index) " "VALUES ('%s', '%s', '%s', '%s');"); @@ -136,7 +137,7 @@ namespace iroha { query += makeAccountHeightIndex(creator_id, height); query += makeAccountAssetIndex( creator_id, height, index, tx.value().commands()); - query += makeHashIndex(tx.value().hash(), height); + query += makeHashIndex(tx.value().hash(), height, index); query += makeCommittedTxHashIndex(tx.value().hash()); query += makeCreatorHeightIndex(creator_id, height, index); return query; diff --git a/irohad/ametsuchi/impl/postgres_block_query.cpp b/irohad/ametsuchi/impl/postgres_block_query.cpp index 3e4c7b5a0f..55043713ea 100644 --- a/irohad/ametsuchi/impl/postgres_block_query.cpp +++ b/irohad/ametsuchi/impl/postgres_block_query.cpp @@ -94,7 +94,7 @@ namespace iroha { boost::optional block_str; auto hash_str = hash.hex(); - sql_ << "SELECT height FROM height_by_hash WHERE hash = :hash", + sql_ << "SELECT height FROM position_by_hash WHERE hash = :hash", soci::into(block_str), soci::use(hash_str); if (block_str) { blockId = std::stoull(block_str.get()); @@ -174,9 +174,9 @@ namespace iroha { std::string row; soci::statement st = (sql_.prepare - << "SELECT DISTINCT index FROM index_by_id_height_asset " - "WHERE id = :id AND height = :height AND asset_id = " - ":asset_id", + << "SELECT DISTINCT index FROM position_by_account_asset " + "WHERE account_id = :id AND height = :height " + "AND asset_id = :asset_id", soci::into(row, ind), soci::use(account_id), soci::use(block_id), diff --git a/irohad/ametsuchi/impl/postgres_command_executor.cpp b/irohad/ametsuchi/impl/postgres_command_executor.cpp index 3c6c9c9907..929a867bc4 100644 --- a/irohad/ametsuchi/impl/postgres_command_executor.cpp +++ b/irohad/ametsuchi/impl/postgres_command_executor.cpp @@ -6,6 +6,7 @@ #include "ametsuchi/impl/postgres_command_executor.hpp" #include +#include #include #include "ametsuchi/impl/soci_utils.hpp" #include "cryptography/public_key.hpp" @@ -264,6 +265,30 @@ namespace { return query; } + std::string checkAccountDomainRoleOrGlobalRolePermission( + shared_model::interface::permissions::Role global_permission, + shared_model::interface::permissions::Role domain_permission, + const shared_model::interface::types::AccountIdType &creator_id, + const shared_model::interface::types::AssetIdType + &id_with_target_domain) { + std::string query = (boost::format(R"(WITH + has_global_role_perm AS (%1%), + has_domain_role_perm AS (%2%) + SELECT CASE + WHEN (SELECT * FROM has_global_role_perm) THEN true + WHEN ((split_part(%3%, '@', 2) = split_part(%4%, '#', 2))) THEN + CASE + WHEN (SELECT * FROM has_domain_role_perm) THEN true + ELSE false + END + ELSE false END + )") % checkAccountRolePermission(global_permission, creator_id) + % checkAccountRolePermission(domain_permission, creator_id) + % creator_id % id_with_target_domain) + .str(); + return query; + } + std::string checkAccountHasRoleOrGrantablePerm( shared_model::interface::permissions::Role role, shared_model::interface::permissions::Grantable grantable, @@ -1183,9 +1208,12 @@ namespace iroha { {"addAssetQuantity", addAssetQuantityBase, {(boost::format(R"(has_perm AS (%s),)") - % checkAccountRolePermission( + % checkAccountDomainRoleOrGlobalRolePermission( shared_model::interface::permissions::Role::kAddAssetQty, - "$1")) + shared_model::interface::permissions::Role:: + kAddDomainAssetQty, + "$1", + "$2")) .str(), "AND (SELECT * from has_perm)", "WHEN NOT (SELECT * from has_perm) THEN 2"}}); @@ -1444,17 +1472,20 @@ namespace iroha { WHEN NOT EXISTS (SELECT * FROM check_account_signatories) THEN 5 )"}}); - statements.push_back( - {"subtractAssetQuantity", - subtractAssetQuantityBase, - {(boost::format(R"( + statements.push_back({"subtractAssetQuantity", + subtractAssetQuantityBase, + {(boost::format(R"( has_perm AS (%s),)") - % checkAccountRolePermission(shared_model::interface::permissions:: - Role::kSubtractAssetQty, - "$1")) - .str(), - R"( AND (SELECT * FROM has_perm))", - R"( WHEN NOT (SELECT * FROM has_perm) THEN 2 )"}}); + % checkAccountDomainRoleOrGlobalRolePermission( + shared_model::interface::permissions::Role:: + kSubtractAssetQty, + shared_model::interface::permissions::Role:: + kSubtractDomainAssetQty, + "$1", + "$2")) + .str(), + R"( AND (SELECT * FROM has_perm))", + R"( WHEN NOT (SELECT * FROM has_perm) THEN 2 )"}}); statements.push_back( {"transferAsset", diff --git a/irohad/ametsuchi/impl/postgres_query_executor.cpp b/irohad/ametsuchi/impl/postgres_query_executor.cpp index 69b1f1dd8f..094c010513 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.cpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.cpp @@ -32,6 +32,7 @@ #include "interfaces/queries/get_signatories.hpp" #include "interfaces/queries/get_transactions.hpp" #include "interfaces/queries/query.hpp" +#include "interfaces/queries/tx_pagination_meta.hpp" using namespace shared_model::interface::permissions; @@ -339,6 +340,113 @@ namespace iroha { error_type, error, error_code, query_hash_); } + template + QueryExecutorResult PostgresQueryExecutorVisitor::executeTransactionsQuery( + const Query &q, + const std::string &related_txs, + QueryApplier applier, + Permissions... perms) { + using QueryTuple = QueryType; + using PermissionTuple = boost::tuple; + const auto &pagination_info = q.paginationMeta(); + auto first_hash = pagination_info.firstTxHash(); + // retrieve one extra transaction to populate next_hash + auto query_size = pagination_info.pageSize() + 1u; + + auto base = boost::format(R"(WITH has_perms AS (%s), + my_txs AS (%s), + first_hash AS (%s), + total_size AS ( + SELECT COUNT(*) FROM my_txs + ), + t AS ( + SELECT my_txs.height, my_txs.index + FROM my_txs JOIN + first_hash ON my_txs.height > first_hash.height + OR (my_txs.height = first_hash.height AND + my_txs.index >= first_hash.index) + LIMIT :page_size + ) + SELECT height, index, count, perm FROM t + RIGHT OUTER JOIN has_perms ON TRUE + JOIN total_size ON TRUE + )"); + + // select tx with specified hash + auto first_by_hash = R"(SELECT height, index FROM position_by_hash + WHERE hash = :hash LIMIT 1)"; + + // select first ever tx + auto first_tx = R"(SELECT height, index FROM position_by_hash + ORDER BY height, index ASC LIMIT 1)"; + + auto cmd = base % hasQueryPermission(creator_id_, q.accountId(), perms...) + % related_txs; + if (first_hash) { + cmd = base % first_by_hash; + } else { + cmd = base % first_tx; + } + + auto query = cmd.str(); + + return executeQuery( + applier(query), + [&](auto range, auto &) { + uint64_t total_size = 0; + if (not boost::empty(range)) { + total_size = boost::get<2>(*range.begin()); + } + std::map> index; + // unpack results to get map from block height to index of tx in + // a block + boost::for_each(range, [&index](auto t) { + apply(t, [&index](auto &height, auto &idx, auto &) { + index[height].push_back(idx); + }); + }); + + std::vector> + response_txs; + // get transactions corresponding to indexes + for (auto &block : index) { + auto txs = this->getTransactionsFromBlock( + block.first, + [&block](auto) { return block.second; }, + [](auto &) { return true; }); + std::move( + txs.begin(), txs.end(), std::back_inserter(response_txs)); + } + // If 0 transactions are returned, we assume that hash is invalid. + // Since query with valid hash is guaranteed to return at least one + // transaction + if (first_hash and response_txs.empty()) { + auto error = (boost::format("invalid pagination hash: %s") + % first_hash->hex()) + .str(); + return this->logAndReturnErrorResponse( + QueryErrorType::kStatefulFailed, error, 4); + } + + // if the number of returned transactions is equal to the + // page size + 1, it means that the last transaction is the + // first one in the next page and we need to return it as + // the next hash + if (response_txs.size() == query_size) { + auto next_hash = response_txs.back()->hash(); + response_txs.pop_back(); + return query_response_factory_->createTransactionsPageResponse( + std::move(response_txs), next_hash, total_size, query_hash_); + } + + return query_response_factory_->createTransactionsPageResponse( + std::move(response_txs), total_size, query_hash_); + }, + notEnoughPermissionsResponse(perm_converter_, perms...)); + } + QueryExecutorResult PostgresQueryExecutorVisitor::operator()( const shared_model::interface::GetAccount &q) { using QueryTuple = @@ -447,57 +555,37 @@ namespace iroha { QueryExecutorResult PostgresQueryExecutorVisitor::operator()( const shared_model::interface::GetAccountTransactions &q) { - using QueryTuple = - QueryType; - using PermissionTuple = boost::tuple; - - auto cmd = (boost::format(R"(WITH has_perms AS (%s), - t AS ( - SELECT DISTINCT has.height, index - FROM height_by_account_set AS has - JOIN index_by_creator_height AS ich ON has.height = ich.height - AND has.account_id = ich.creator_id - WHERE account_id = :account_id - ORDER BY has.height, index ASC - ) - SELECT height, index, perm FROM t - RIGHT OUTER JOIN has_perms ON TRUE - )") - % hasQueryPermission(creator_id_, - q.accountId(), - Role::kGetMyAccTxs, - Role::kGetAllAccTxs, - Role::kGetDomainAccTxs)) - .str(); - - return executeQuery( - [&] { return (sql_.prepare << cmd, soci::use(q.accountId())); }, - [&](auto range, auto &) { - std::map> index; - boost::for_each(range, [&index](auto t) { - apply(t, [&index](auto &height, auto &idx) { - index[height].push_back(idx); - }); - }); - - std::vector> - response_txs; - for (auto &block : index) { - auto txs = this->getTransactionsFromBlock( - block.first, - [&block](auto) { return block.second; }, - [](auto &) { return true; }); - std::move( - txs.begin(), txs.end(), std::back_inserter(response_txs)); - } + std::string related_txs = R"(SELECT DISTINCT height, index + FROM index_by_creator_height + WHERE creator_id = :account_id + ORDER BY height, index ASC)"; + + const auto &pagination_info = q.paginationMeta(); + auto first_hash = pagination_info.firstTxHash(); + // retrieve one extra transaction to populate next_hash + auto query_size = pagination_info.pageSize() + 1u; + + auto apply_query = [&](const auto &query) { + return [&] { + if (first_hash) { + return (sql_.prepare << query, + soci::use(q.accountId()), + soci::use(first_hash->hex()), + soci::use(query_size)); + } else { + return (sql_.prepare << query, + soci::use(q.accountId()), + soci::use(query_size)); + } + }; + }; - return query_response_factory_->createTransactionsResponse( - std::move(response_txs), query_hash_); - }, - notEnoughPermissionsResponse(perm_converter_, - Role::kGetMyAccTxs, - Role::kGetAllAccTxs, - Role::kGetDomainAccTxs)); + return executeTransactionsQuery(q, + related_txs, + apply_query, + Role::kGetMyAccTxs, + Role::kGetAllAccTxs, + Role::kGetDomainAccTxs); } QueryExecutorResult PostgresQueryExecutorVisitor::operator()( @@ -516,7 +604,7 @@ namespace iroha { auto cmd = (boost::format(R"(WITH has_my_perm AS (%s), has_all_perm AS (%s), t AS ( - SELECT height, hash FROM height_by_hash WHERE hash IN (%s) + SELECT height, hash FROM position_by_hash WHERE hash IN (%s) ) SELECT height, hash, has_my_perm.perm, has_all_perm.perm FROM t RIGHT OUTER JOIN has_my_perm ON TRUE @@ -565,62 +653,40 @@ namespace iroha { QueryExecutorResult PostgresQueryExecutorVisitor::operator()( const shared_model::interface::GetAccountAssetTransactions &q) { - using QueryTuple = - QueryType; - using PermissionTuple = boost::tuple; - - auto cmd = (boost::format(R"(WITH has_perms AS (%s), - t AS ( - SELECT DISTINCT has.height, index - FROM height_by_account_set AS has - JOIN index_by_id_height_asset AS ich ON has.height = ich.height - AND has.account_id = ich.id + std::string related_txs = R"(SELECT DISTINCT height, index + FROM position_by_account_asset WHERE account_id = :account_id AND asset_id = :asset_id - ORDER BY has.height, index ASC - ) - SELECT height, index, perm FROM t - RIGHT OUTER JOIN has_perms ON TRUE - )") - % hasQueryPermission(creator_id_, - q.accountId(), - Role::kGetMyAccAstTxs, - Role::kGetAllAccAstTxs, - Role::kGetDomainAccAstTxs)) - .str(); - - return executeQuery( - [&] { - return (sql_.prepare << cmd, - soci::use(q.accountId(), "account_id"), - soci::use(q.assetId(), "asset_id")); - }, - [&](auto range, auto &) { - std::map> index; - boost::for_each(range, [&index](auto t) { - apply(t, [&index](auto &height, auto &idx) { - index[height].push_back(idx); - }); - }); - - std::vector> - response_txs; - for (auto &block : index) { - auto txs = this->getTransactionsFromBlock( - block.first, - [&block](auto) { return block.second; }, - [](auto &) { return true; }); - std::move( - txs.begin(), txs.end(), std::back_inserter(response_txs)); - } + ORDER BY height, index ASC)"; + + const auto &pagination_info = q.paginationMeta(); + auto first_hash = pagination_info.firstTxHash(); + // retrieve one extra transaction to populate next_hash + auto query_size = pagination_info.pageSize() + 1u; + + auto apply_query = [&](const auto &query) { + return [&] { + if (first_hash) { + return (sql_.prepare << query, + soci::use(q.accountId()), + soci::use(q.assetId()), + soci::use(first_hash->hex()), + soci::use(query_size)); + } else { + return (sql_.prepare << query, + soci::use(q.accountId()), + soci::use(q.assetId()), + soci::use(query_size)); + } + }; + }; - return query_response_factory_->createTransactionsResponse( - std::move(response_txs), query_hash_); - }, - notEnoughPermissionsResponse(perm_converter_, - Role::kGetMyAccAstTxs, - Role::kGetAllAccAstTxs, - Role::kGetDomainAccAstTxs)); + return executeTransactionsQuery(q, + related_txs, + apply_query, + Role::kGetMyAccAstTxs, + Role::kGetAllAccAstTxs, + Role::kGetDomainAccAstTxs); } QueryExecutorResult PostgresQueryExecutorVisitor::operator()( diff --git a/irohad/ametsuchi/impl/postgres_query_executor.hpp b/irohad/ametsuchi/impl/postgres_query_executor.hpp index ecad31da01..523a2ceac7 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.hpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.hpp @@ -142,6 +142,24 @@ namespace iroha { QueryErrorMessageType error_body, QueryErrorCodeType error_code) const; + /** + * Execute query which returns list of transactions + * uses pagination + * @param query - query object + * @param related_txs - SQL query which returns transaction relevant + * to this query + * @param applier - function which accepts SQL + * and returns another function which executes that query + * @param perms - permissions, necessary to execute the query + * @return Result of a query execution + */ + template + QueryExecutorResult executeTransactionsQuery( + const Query &query, + const std::string &related_txs, + QueryApplier applier, + Permissions... perms); + soci::session &sql_; KeyValueStorage &block_store_; shared_model::interface::types::AccountIdType creator_id_; diff --git a/irohad/ametsuchi/impl/storage_impl.cpp b/irohad/ametsuchi/impl/storage_impl.cpp index b56b8aa70d..bdc38f2ca8 100644 --- a/irohad/ametsuchi/impl/storage_impl.cpp +++ b/irohad/ametsuchi/impl/storage_impl.cpp @@ -520,7 +520,7 @@ DROP TABLE IF EXISTS height_by_hash; DROP TABLE IF EXISTS tx_status_by_hash; DROP TABLE IF EXISTS height_by_account_set; DROP TABLE IF EXISTS index_by_creator_height; -DROP TABLE IF EXISTS index_by_id_height_asset; +DROP TABLE IF EXISTS position_by_account_asset; )"; const std::string &StorageImpl::reset_ = R"( @@ -535,11 +535,11 @@ DELETE FROM domain; DELETE FROM signatory; DELETE FROM peer; DELETE FROM role; -DELETE FROM height_by_hash; +DELETE FROM position_by_hash; DELETE FROM tx_status_by_hash; DELETE FROM height_by_account_set; DELETE FROM index_by_creator_height; -DELETE FROM index_by_id_height_asset; +DELETE FROM position_by_account_asset; )"; const std::string &StorageImpl::init_ = @@ -608,9 +608,10 @@ CREATE TABLE IF NOT EXISTS account_has_grantable_permissions ( + R"() NOT NULL, PRIMARY KEY (permittee_account_id, account_id) ); -CREATE TABLE IF NOT EXISTS height_by_hash ( +CREATE TABLE IF NOT EXISTS position_by_hash ( hash varchar, - height text + height text, + index text ); CREATE TABLE IF NOT EXISTS tx_status_by_hash ( @@ -628,10 +629,10 @@ CREATE TABLE IF NOT EXISTS index_by_creator_height ( height text, index text ); -CREATE TABLE IF NOT EXISTS index_by_id_height_asset ( - id text, - height text, +CREATE TABLE IF NOT EXISTS position_by_account_asset ( + account_id text, asset_id text, + height text, index text ); )"; diff --git a/irohad/consensus/CMakeLists.txt b/irohad/consensus/CMakeLists.txt index f55b9c3757..50cf52ad6b 100644 --- a/irohad/consensus/CMakeLists.txt +++ b/irohad/consensus/CMakeLists.txt @@ -1,26 +1,18 @@ -# -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 add_subdirectory(yac) add_library(consensus_round impl/round.cpp ) - target_link_libraries(consensus_round boost ) + +add_library(gate_object + impl/gate_object.cpp + ) +target_link_libraries(gate_object + boost + ) diff --git a/irohad/consensus/gate_object.hpp b/irohad/consensus/gate_object.hpp new file mode 100644 index 0000000000..42e57bf043 --- /dev/null +++ b/irohad/consensus/gate_object.hpp @@ -0,0 +1,67 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef CONSENSUS_GATE_OBJECT_HPP +#define CONSENSUS_GATE_OBJECT_HPP + +#include +#include "consensus/round.hpp" +#include "cryptography/hash.hpp" +#include "cryptography/public_key.hpp" +#include "interfaces/common_objects/types.hpp" + +namespace shared_model { + namespace interface { + class Block; + } // namespace interface +} // namespace shared_model + +namespace iroha { + namespace consensus { + + /// Current pair is valid + struct PairValid { + std::shared_ptr block; + consensus::Round round; + }; + + /// Network votes for another pair and round + struct VoteOther { + shared_model::interface::types::PublicKeyCollectionType public_keys; + shared_model::interface::types::HashType hash; + consensus::Round round; + }; + + /// Reject on proposal + struct ProposalReject { + consensus::Round round; + }; + + /// Reject on block + struct BlockReject { + consensus::Round round; + }; + + /// Agreement on + struct AgreementOnNone { + consensus::Round round; + }; + + using GateObject = boost::variant; + + } // namespace consensus +} // namespace iroha + +extern template class boost::variant; + +#endif // CONSENSUS_GATE_OBJECT_HPP diff --git a/irohad/consensus/impl/gate_object.cpp b/irohad/consensus/impl/gate_object.cpp new file mode 100644 index 0000000000..1b67d69461 --- /dev/null +++ b/irohad/consensus/impl/gate_object.cpp @@ -0,0 +1,17 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "consensus/gate_object.hpp" + +using GateObject = iroha::consensus::GateObject; + +template GateObject::~variant(); +template GateObject::variant(GateObject &&); +template GateObject::variant(const GateObject &); +template void GateObject::destroy_content(); +template int GateObject::which() const; +template void GateObject::indicate_which(int); +template bool GateObject::using_backup() const; +template GateObject::convert_copy_into::convert_copy_into(void *); diff --git a/irohad/consensus/round.hpp b/irohad/consensus/round.hpp index 211e08ba11..dd320c30eb 100644 --- a/irohad/consensus/round.hpp +++ b/irohad/consensus/round.hpp @@ -10,6 +10,8 @@ #include #include +#include + namespace iroha { namespace consensus { @@ -26,7 +28,7 @@ namespace iroha { /** * Type of proposal round */ - struct Round { + struct Round : public boost::less_than_comparable { BlockRoundType block_round; RejectRoundType reject_round; diff --git a/irohad/consensus/yac/CMakeLists.txt b/irohad/consensus/yac/CMakeLists.txt index 294c7b57ea..29a5d23807 100644 --- a/irohad/consensus/yac/CMakeLists.txt +++ b/irohad/consensus/yac/CMakeLists.txt @@ -42,6 +42,7 @@ target_link_libraries(yac logger hash consensus_round + gate_object ) add_library(yac_transport diff --git a/irohad/consensus/yac/impl/yac.cpp b/irohad/consensus/yac/impl/yac.cpp index dfd7e8f5f3..07c536d989 100644 --- a/irohad/consensus/yac/impl/yac.cpp +++ b/irohad/consensus/yac/impl/yac.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/yac.hpp" @@ -108,13 +96,15 @@ namespace iroha { return; } - log_->info("Vote for round ({}, {}), hash ({}, {})", - vote.hash.vote_round.block_round, - vote.hash.vote_round.reject_round, + const auto ¤t_leader = cluster_order_.currentLeader(); + + log_->info("Vote for round {}, hash ({}, {}) to peer {}", + vote.hash.vote_round, vote.hash.vote_hashes.proposal_hash, - vote.hash.vote_hashes.block_hash); + vote.hash.vote_hashes.block_hash, + current_leader); - network_->sendState(cluster_order_.currentLeader(), {vote}); + network_->sendState(current_leader, {vote}); cluster_order_.switchToNext(); if (cluster_order_.hasNext()) { timer_->invokeAfterDelay([this, vote] { this->votingStep(vote); }); diff --git a/irohad/consensus/yac/impl/yac_gate_impl.cpp b/irohad/consensus/yac/impl/yac_gate_impl.cpp index b0fb1263a7..fbea1623bb 100644 --- a/irohad/consensus/yac/impl/yac_gate_impl.cpp +++ b/irohad/consensus/yac/impl/yac_gate_impl.cpp @@ -5,6 +5,7 @@ #include "consensus/yac/impl/yac_gate_impl.hpp" +#include #include "common/visitor.hpp" #include "consensus/yac/cluster_order.hpp" #include "consensus/yac/messages.hpp" @@ -13,7 +14,7 @@ #include "consensus/yac/yac_peer_orderer.hpp" #include "cryptography/public_key.hpp" #include "interfaces/common_objects/signature.hpp" -#include "network/block_loader.hpp" +#include "interfaces/iroha_internal/block.hpp" #include "simulator/block_creator.hpp" namespace iroha { @@ -25,116 +26,145 @@ namespace iroha { std::shared_ptr orderer, std::shared_ptr hash_provider, std::shared_ptr block_creator, - std::shared_ptr block_loader, std::shared_ptr consensus_result_cache) : hash_gate_(std::move(hash_gate)), orderer_(std::move(orderer)), hash_provider_(std::move(hash_provider)), block_creator_(std::move(block_creator)), - block_loader_(std::move(block_loader)), consensus_result_cache_(std::move(consensus_result_cache)), - log_(logger::log("YacGate")) { - block_creator_->on_block().subscribe( - [this](auto block) { this->vote(block); }); + log_(logger::log("YacGate")), + current_hash_() { + block_creator_->onBlock().subscribe( + [this](const auto &event) { this->vote(event); }); } - void YacGateImpl::vote( - std::shared_ptr block) { - auto hash = hash_provider_->makeHash(*block); - log_->info("vote for block ({}, {})", - hash.vote_hashes.proposal_hash, - block->hash()); - auto order = orderer_->getOrdering(hash); + void YacGateImpl::vote(const simulator::BlockCreatorEvent &event) { + if (current_hash_.vote_round >= event.round) { + log_->info( + "Current round {} is greater than or equal to vote round {}, " + "skipped", + current_hash_.vote_round, + event.round); + return; + } + + current_hash_ = hash_provider_->makeHash(event); + + if (not event.round_data) { + current_block_ = boost::none; + log_->debug("Agreed on nothing to commit"); + } else { + current_block_ = event.round_data->block; + // insert the block we voted for to the consensus cache + consensus_result_cache_->insert(event.round_data->block); + log_->info("vote for (proposal: {}, block: {})", + current_hash_.vote_hashes.proposal_hash, + current_hash_.vote_hashes.block_hash); + } + + auto order = orderer_->getOrdering(current_hash_); if (not order) { log_->error("ordering doesn't provide peers => pass round"); return; } - current_block_ = std::make_pair(hash, block); - hash_gate_->vote(hash, *order); - // insert the block we voted for to the consensus cache - consensus_result_cache_->insert(block); + hash_gate_->vote(current_hash_, *order); } - rxcpp::observable YacGateImpl::on_commit() { + rxcpp::observable YacGateImpl::onOutcome() { return hash_gate_->onOutcome().flat_map([this](auto message) { - // TODO 10.06.2018 andrei: IR-497 Work on reject case - auto commit_message = boost::get(message); - // map commit to block if it is present or loaded from other peer - return rxcpp::observable<>::create( - [this, commit_message](auto subscriber) { - const auto hash = getHash(commit_message.votes); - if (not hash) { - log_->info("Invalid commit message, hashes are different"); - subscriber.on_completed(); - return; - } - // if node has voted for the committed block - if (hash == current_block_.first) { - // append signatures of other nodes - this->copySignatures(commit_message); - log_->info("consensus: commit top block: height {}, hash {}", - current_block_.second->height(), - current_block_.second->hash().hex()); - subscriber.on_next( - network::Commit{current_block_.second, - network::PeerVotedFor::kThisBlock}); - subscriber.on_completed(); - return; - } - // node has voted for another block - load committed block - const auto model_hash = - hash_provider_->toModelHash(hash.value()); - // iterate over peers who voted for the committed block - // TODO [IR-1753] Akvinikym 11.10.18: add exponential backoff - // for each peer iteration and shuffle peers order - rxcpp::observable<>::iterate(commit_message.votes) - // allow other peers to apply commit - .flat_map([this, model_hash](auto vote) { - // map vote to block if it can be loaded - return rxcpp::observable<>::create( - [this, model_hash, vote](auto subscriber) { - auto block = block_loader_->retrieveBlock( - vote.signature->publicKey(), - shared_model::crypto::Hash(model_hash)); - // if load is successful - if (block) { - // update the cache with block consensus voted for - consensus_result_cache_->insert(*block); - subscriber.on_next(network::Commit{ - *block, network::PeerVotedFor::kOtherBlock}); - } else { - log_->error( - "Could not get block from block loader"); - } - subscriber.on_completed(); - }); - }) - // need only the first - .first() - .retry() - .subscribe( - // if load is successful from at least one node - [subscriber](auto block) { - subscriber.on_next(block); - subscriber.on_completed(); - }, - // if load has failed, no peers provided the block - [this, subscriber](std::exception_ptr) { - log_->error("Cannot load committed block"); - subscriber.on_completed(); - }); - }); + return visit_in_place(message, + [this](const CommitMessage &msg) { + return this->handleCommit(msg); + }, + [this](const RejectMessage &msg) { + return this->handleReject(msg); + }); }); } void YacGateImpl::copySignatures(const CommitMessage &commit) { for (const auto &vote : commit.votes) { auto sig = vote.hash.block_signature; - current_block_.second->addSignature(sig->signedData(), - sig->publicKey()); + current_block_.value()->addSignature(sig->signedData(), + sig->publicKey()); + } + } + + rxcpp::observable YacGateImpl::handleCommit( + const CommitMessage &msg) { + const auto hash = getHash(msg.votes).value(); + if (hash.vote_round < current_hash_.vote_round) { + log_->info( + "Current round {} is greater than commit round {}, skipped", + current_hash_.vote_round, + hash.vote_round); + return rxcpp::observable<>::empty(); + } + + if (hash == current_hash_ and current_block_) { + // if node has voted for the committed block + // append signatures of other nodes + this->copySignatures(msg); + auto &block = current_block_.value(); + log_->info("consensus: commit top block: height {}, hash {}", + block->height(), + block->hash().hex()); + return rxcpp::observable<>::just( + PairValid{block, current_hash_.vote_round}); + } + + current_hash_ = hash; + + if (hash.vote_hashes.proposal_hash.empty()) { + // if consensus agreed on nothing for commit + log_->info("Consensus skipped round, voted for nothing"); + current_block_ = boost::none; + return rxcpp::observable<>::just( + AgreementOnNone{current_hash_.vote_round}); + } + + log_->info("Voted for another block, waiting for sync"); + current_block_ = boost::none; + auto public_keys = boost::copy_range< + shared_model::interface::types::PublicKeyCollectionType>( + msg.votes | boost::adaptors::transformed([](auto &vote) { + return vote.signature->publicKey(); + })); + auto model_hash = hash_provider_->toModelHash(hash); + return rxcpp::observable<>::just( + VoteOther{std::move(public_keys), + std::move(model_hash), + current_hash_.vote_round}); + } + + rxcpp::observable YacGateImpl::handleReject( + const RejectMessage &msg) { + const auto hash = getHash(msg.votes).value(); + if (hash.vote_round < current_hash_.vote_round) { + log_->info( + "Current round {} is greater than reject round {}, skipped", + current_hash_.vote_round, + hash.vote_round); + return rxcpp::observable<>::empty(); + } + + auto has_same_proposals = + std::all_of(std::next(msg.votes.begin()), + msg.votes.end(), + [first = msg.votes.begin()](const auto ¤t) { + return first->hash.vote_hashes.proposal_hash + == current.hash.vote_hashes.proposal_hash; + }); + if (not has_same_proposals) { + log_->info("Proposal reject since all hashes are different"); + return rxcpp::observable<>::just( + ProposalReject{current_hash_.vote_round}); } + log_->info("Block reject since proposal hashes match"); + return rxcpp::observable<>::just( + BlockReject{current_hash_.vote_round}); } } // namespace yac } // namespace consensus diff --git a/irohad/consensus/yac/impl/yac_gate_impl.hpp b/irohad/consensus/yac/impl/yac_gate_impl.hpp index 7b4e54a6fa..8ec09c6f4f 100644 --- a/irohad/consensus/yac/impl/yac_gate_impl.hpp +++ b/irohad/consensus/yac/impl/yac_gate_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_GATE_IMPL_HPP @@ -48,16 +36,11 @@ namespace iroha { std::shared_ptr orderer, std::shared_ptr hash_provider, std::shared_ptr block_creator, - std::shared_ptr block_loader, std::shared_ptr consensus_result_cache); - void vote(std::shared_ptr) override; - /** - * Method called when commit received - * assumes to retrieve a block eventually - * @return observable with the committed block - */ - rxcpp::observable on_commit() override; + void vote(const simulator::BlockCreatorEvent &event) override; + + rxcpp::observable onOutcome() override; private: /** @@ -66,19 +49,22 @@ namespace iroha { */ void copySignatures(const CommitMessage &commit); + rxcpp::observable handleCommit(const CommitMessage &msg); + rxcpp::observable handleReject(const RejectMessage &msg); + std::shared_ptr hash_gate_; std::shared_ptr orderer_; std::shared_ptr hash_provider_; std::shared_ptr block_creator_; - std::shared_ptr block_loader_; std::shared_ptr consensus_result_cache_; logger::Logger log_; - std::pair> + boost::optional> current_block_; + YacHash current_hash_; }; } // namespace yac diff --git a/irohad/consensus/yac/impl/yac_hash_provider_impl.cpp b/irohad/consensus/yac/impl/yac_hash_provider_impl.cpp index eae6e06739..29d5eda040 100644 --- a/irohad/consensus/yac/impl/yac_hash_provider_impl.cpp +++ b/irohad/consensus/yac/impl/yac_hash_provider_impl.cpp @@ -5,19 +5,24 @@ #include "consensus/yac/impl/yac_hash_provider_impl.hpp" #include "interfaces/iroha_internal/block.hpp" +#include "interfaces/iroha_internal/proposal.hpp" namespace iroha { namespace consensus { namespace yac { YacHash YacHashProviderImpl::makeHash( - const shared_model::interface::Block &block) const { + const simulator::BlockCreatorEvent &event) const { YacHash result; - auto hex_hash = block.hash().hex(); - result.vote_round = {block.height(), 1}; - result.vote_hashes.proposal_hash = hex_hash; - result.vote_hashes.block_hash = hex_hash; - result.block_signature = clone(block.signatures().front()); + if (event.round_data) { + result.vote_hashes.proposal_hash = + event.round_data->proposal->hash().hex(); + result.vote_hashes.block_hash = event.round_data->block->hash().hex(); + result.block_signature = + clone(event.round_data->block->signatures().front()); + } + result.vote_round = event.round; + return result; } @@ -28,6 +33,7 @@ namespace iroha { auto string_blob = shared_model::crypto::toBinaryString(blob); return shared_model::interface::types::HashType(string_blob); } + } // namespace yac } // namespace consensus } // namespace iroha diff --git a/irohad/consensus/yac/impl/yac_hash_provider_impl.hpp b/irohad/consensus/yac/impl/yac_hash_provider_impl.hpp index 7c4dd4d142..74ba3a1faf 100644 --- a/irohad/consensus/yac/impl/yac_hash_provider_impl.hpp +++ b/irohad/consensus/yac/impl/yac_hash_provider_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_HASH_PROVIDER_IMPL_HPP @@ -26,7 +14,7 @@ namespace iroha { class YacHashProviderImpl : public YacHashProvider { public: YacHash makeHash( - const shared_model::interface::Block &block) const override; + const simulator::BlockCreatorEvent &event) const override; shared_model::interface::types::HashType toModelHash( const YacHash &hash) const override; @@ -34,4 +22,5 @@ namespace iroha { } // namespace yac } // namespace consensus } // namespace iroha + #endif // IROHA_YAC_HASH_PROVIDER_IMPL_HPP diff --git a/irohad/consensus/yac/storage/impl/yac_block_storage.cpp b/irohad/consensus/yac/storage/impl/yac_block_storage.cpp index 510dd2b2fe..78aa26f0f1 100644 --- a/irohad/consensus/yac/storage/impl/yac_block_storage.cpp +++ b/irohad/consensus/yac/storage/impl/yac_block_storage.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/storage/yac_block_storage.hpp" @@ -39,13 +27,14 @@ namespace iroha { if (validScheme(msg) and uniqueVote(msg)) { votes_.push_back(msg); - log_->info("Vote with rounds ({}, {}) and hashes ({}, {}) inserted", - msg.hash.vote_round.block_round, - msg.hash.vote_round.reject_round, - msg.hash.vote_hashes.proposal_hash, - msg.hash.vote_hashes.block_hash); log_->info( - "Votes in storage [{}/{}]", votes_.size(), peers_in_round_); + "Vote with round {} and hashes ({}, {}) inserted, votes in " + "storage [{}/{}]", + msg.hash.vote_round, + msg.hash.vote_hashes.proposal_hash, + msg.hash.vote_hashes.block_hash, + votes_.size(), + peers_in_round_); } return getState(); } diff --git a/irohad/consensus/yac/transport/yac_pb_converters.hpp b/irohad/consensus/yac/transport/yac_pb_converters.hpp index cd3979cc29..c3bc6839ac 100644 --- a/irohad/consensus/yac/transport/yac_pb_converters.hpp +++ b/irohad/consensus/yac/transport/yac_pb_converters.hpp @@ -53,12 +53,14 @@ namespace iroha { static proto::Vote serializeVotePayload(const VoteMessage &vote) { auto pb_vote = serializeRoundAndHashes(vote); - auto block_signature = - pb_vote.mutable_hash()->mutable_block_signature(); - block_signature->set_signature(shared_model::crypto::toBinaryString( - vote.hash.block_signature->signedData())); - block_signature->set_pubkey(shared_model::crypto::toBinaryString( - vote.hash.block_signature->publicKey())); + if (vote.hash.block_signature) { + auto block_signature = + pb_vote.mutable_hash()->mutable_block_signature(); + block_signature->set_signature(shared_model::crypto::toBinaryString( + vote.hash.block_signature->signedData())); + block_signature->set_pubkey(shared_model::crypto::toBinaryString( + vote.hash.block_signature->publicKey())); + } return pb_vote; } @@ -66,12 +68,14 @@ namespace iroha { static proto::Vote serializeVote(const VoteMessage &vote) { auto pb_vote = serializeRoundAndHashes(vote); - auto block_signature = - pb_vote.mutable_hash()->mutable_block_signature(); - block_signature->set_signature(shared_model::crypto::toBinaryString( - vote.hash.block_signature->signedData())); - block_signature->set_pubkey(shared_model::crypto::toBinaryString( - vote.hash.block_signature->publicKey())); + if (vote.hash.block_signature) { + auto block_signature = + pb_vote.mutable_hash()->mutable_block_signature(); + block_signature->set_signature(shared_model::crypto::toBinaryString( + vote.hash.block_signature->signedData())); + block_signature->set_pubkey(shared_model::crypto::toBinaryString( + vote.hash.block_signature->publicKey())); + } auto signature = pb_vote.mutable_signature(); const auto &sig = *vote.signature; @@ -106,10 +110,12 @@ namespace iroha { }); }; - deserialize(pb_vote.hash().block_signature().pubkey(), - pb_vote.hash().block_signature().signature(), - vote.hash.block_signature, - "Cannot build vote hash block signature: {}"); + if (pb_vote.hash().has_block_signature()) { + deserialize(pb_vote.hash().block_signature().pubkey(), + pb_vote.hash().block_signature().signature(), + vote.hash.block_signature, + "Cannot build vote hash block signature: {}"); + } deserialize(pb_vote.signature().pubkey(), pb_vote.signature().signature(), diff --git a/irohad/consensus/yac/yac_hash_provider.hpp b/irohad/consensus/yac/yac_hash_provider.hpp index 80a388e2e6..07bfcb14c4 100644 --- a/irohad/consensus/yac/yac_hash_provider.hpp +++ b/irohad/consensus/yac/yac_hash_provider.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_HASH_PROVIDER_HPP @@ -24,6 +12,7 @@ #include "consensus/round.hpp" #include "consensus/yac/storage/yac_common.hpp" #include "interfaces/common_objects/types.hpp" +#include "simulator/block_creator_common.hpp" #include "utils/string_builder.hpp" namespace shared_model { @@ -104,12 +93,10 @@ namespace iroha { class YacHashProvider { public: /** - * Make hash from block - * @param block - for hashing - * @return hashed value of block + * Make hash from block creator event */ virtual YacHash makeHash( - const shared_model::interface::Block &block) const = 0; + const simulator::BlockCreatorEvent &event) const = 0; /** * Convert YacHash to model hash diff --git a/irohad/main/CMakeLists.txt b/irohad/main/CMakeLists.txt index e819d463ed..91f0975bf5 100644 --- a/irohad/main/CMakeLists.txt +++ b/irohad/main/CMakeLists.txt @@ -19,6 +19,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) add_library(server_runner server_runner.cpp) target_link_libraries(server_runner + logger grpc++ boost common @@ -34,7 +35,9 @@ target_link_libraries(raw_block_loader add_library(application application.cpp - impl/ordering_init.cpp + # TODO andrei 08.11.2018 IR-1851 Create separate targets for initialization + # helpers in application + impl/on_demand_ordering_init.cpp impl/consensus_init.cpp impl/block_loader_init.cpp ) @@ -45,7 +48,11 @@ target_link_libraries(application server_runner ametsuchi networking - ordering_service + on_demand_ordering_service + on_demand_ordering_service_transport_grpc + on_demand_connection_manager + on_demand_ordering_gate + on_demand_common chain_validator stateful_validator processors diff --git a/irohad/main/application.cpp b/irohad/main/application.cpp index 91e81778d6..1408763eca 100644 --- a/irohad/main/application.cpp +++ b/irohad/main/application.cpp @@ -5,7 +5,6 @@ #include "main/application.hpp" -#include "ametsuchi/impl/postgres_ordering_service_persistent_state.hpp" #include "ametsuchi/impl/tx_presence_cache_impl.hpp" #include "ametsuchi/impl/wsv_restorer_impl.hpp" #include "backend/protobuf/common_objects/proto_common_objects_factory.hpp" @@ -27,9 +26,12 @@ #include "multi_sig_transactions/storage/mst_storage_impl.hpp" #include "multi_sig_transactions/transport/mst_transport_grpc.hpp" #include "multi_sig_transactions/transport/mst_transport_stub.hpp" +#include "ordering/impl/on_demand_common.hpp" #include "torii/impl/command_service_impl.hpp" #include "torii/impl/status_bus_impl.hpp" +#include "validators/default_validator.hpp" #include "validators/field_validator.hpp" +#include "validators/protobuf/proto_block_validator.hpp" #include "validators/protobuf/proto_query_validator.hpp" #include "validators/protobuf/proto_transaction_validator.hpp" @@ -89,11 +91,11 @@ void Irohad::init() { initValidators(); initNetworkClient(); initFactories(); + initPersistentCache(); initOrderingGate(); initSimulator(); initConsensusCache(); initBlockLoader(); - initPersistentCache(); initConsensusGate(); initSynchronizer(); initPeerCommunicationService(); @@ -111,8 +113,6 @@ void Irohad::init() { */ void Irohad::dropStorage() { storage->reset(); - storage->createOsPersistentState() | - [](const auto &state) { state->resetState(); }; } /** @@ -140,12 +140,6 @@ void Irohad::initStorage() { log_->info("[Init] => storage", logger::logBool(storage)); } -void Irohad::resetOrderingService() { - if (not(storage->createOsPersistentState() | - [](const auto &state) { return state->resetState(); })) - log_->error("cannot reset ordering service storage"); -} - bool Irohad::restoreWsv() { return wsv_restorer_->restoreWsv(*storage).match( [](iroha::expected::Value v) { return true; }, @@ -235,17 +229,55 @@ void Irohad::initFactories() { log_->info("[Init] => factories"); } +/** + * Initializing persistent cache + */ +void Irohad::initPersistentCache() { + persistent_cache = std::make_shared(storage); + + log_->info("[Init] => persistent cache"); +} + /** * Initializing ordering gate */ void Irohad::initOrderingGate() { - ordering_gate = ordering_init.initOrderingGate(storage, - max_proposal_size_, + auto block_query = storage->createBlockQuery(); + if (not block_query) { + log_->error("Failed to create block query"); + return; + } + // since delay is 2, it is required to get two more hashes from block store, + // in addition to top block + const size_t kNumBlocks = 3; + auto blocks = (*block_query)->getTopBlocks(kNumBlocks); + auto hash_stub = shared_model::interface::types::HashType{std::string( + shared_model::crypto::DefaultCryptoAlgorithmType::kHashLength, '0')}; + auto hashes = std::accumulate( + blocks.begin(), + std::prev(blocks.end()), + // add hash stubs if there are not enough blocks in storage + std::vector{ + kNumBlocks - blocks.size(), hash_stub}, + [](auto &acc, const auto &val) { + acc.push_back(val->hash()); + return acc; + }); + + auto factory = std::make_unique>(); + + ordering_gate = ordering_init.initOrderingGate(max_proposal_size_, proposal_delay_, + std::move(hashes), storage, - storage, + transaction_factory, + batch_parser, transaction_batch_factory_, - async_call_); + async_call_, + std::move(factory), + persistent_cache, + {blocks.back()->height(), 1}); log_->info("[Init] => init ordering gate - [{}]", logger::logBool(ordering_gate)); } @@ -262,7 +294,8 @@ void Irohad::initSimulator() { // are validated in the ordering gate, where they are received from the // ordering service. std::make_unique< - shared_model::validation::DefaultUnsignedBlockValidator>()); + shared_model::validation::DefaultUnsignedBlockValidator>(), + std::make_unique()); simulator = std::make_shared(ordering_gate, stateful_validator, storage, @@ -292,15 +325,6 @@ void Irohad::initBlockLoader() { log_->info("[Init] => block loader"); } -/** - * Initializing persistent cache - */ -void Irohad::initPersistentCache() { - persistent_cache = std::make_shared(storage); - - log_->info("[Init] => persistent cache"); -} - /** * Initializing consensus gate */ @@ -334,15 +358,12 @@ void Irohad::initPeerCommunicationService() { pcs = std::make_shared( ordering_gate, synchronizer, simulator); - pcs->on_proposal().subscribe( + pcs->onProposal().subscribe( [this](auto) { log_->info("~~~~~~~~~| PROPOSAL ^_^ |~~~~~~~~~ "); }); pcs->on_commit().subscribe( [this](auto) { log_->info("~~~~~~~~~| COMMIT =^._.^= |~~~~~~~~~ "); }); - // complete initialization of ordering gate - ordering_gate->setPcs(*pcs); - log_->info("[Init] => pcs"); } @@ -432,6 +453,7 @@ void Irohad::initWsvRestorer() { */ Irohad::RunResult Irohad::run() { using iroha::expected::operator|; + using iroha::operator|; // Initializing torii server torii_server = std::make_unique( @@ -453,9 +475,7 @@ Irohad::RunResult Irohad::run() { std::static_pointer_cast(mst_transport)); } // Run internal server - return internal_server - ->append(ordering_init.ordering_gate_transport) - .append(ordering_init.ordering_service_transport) + return internal_server->append(ordering_init.service) .append(yac_init.consensus_network) .append(loader_init.service) .run(); @@ -464,6 +484,27 @@ Irohad::RunResult Irohad::run() { [&](const auto &port) -> RunResult { log_->info("Internal server bound on port {}", port.value); log_->info("===> iroha initialized"); + // initiate first round + auto block_query = storage->createBlockQuery(); + if (not block_query) { + return expected::makeError("Failed to create block query"); + } + auto block_var = (*block_query)->getTopBlock(); + if (auto e = boost::get>(&block_var)) { + return expected::makeError("Failed to get the top block: " + + e->error); + } + + auto block = boost::get>>(&block_var) + ->value; + + pcs->on_commit() + .start_with(synchronizer::SynchronizationEvent{ + rxcpp::observable<>::just(block), + SynchronizationOutcomeType::kCommit, + {block->height(), ordering::kFirstRejectRound}}) + .subscribe(ordering_init.notifier.get_subscriber()); return {}; }, [&](const expected::Error &e) -> RunResult { diff --git a/irohad/main/application.hpp b/irohad/main/application.hpp index 1654b47b19..83ff43837d 100644 --- a/irohad/main/application.hpp +++ b/irohad/main/application.hpp @@ -17,7 +17,7 @@ #include "logger/logger.hpp" #include "main/impl/block_loader_init.hpp" #include "main/impl/consensus_init.hpp" -#include "main/impl/ordering_init.hpp" +#include "main/impl/on_demand_ordering_init.hpp" #include "main/server_runner.hpp" #include "multi_sig_transactions/gossip_propagation_strategy_params.hpp" #include "multi_sig_transactions/mst_processor.hpp" @@ -87,11 +87,6 @@ class Irohad { */ virtual void init(); - /** - * Reset oredering service storage state to default - */ - void resetOrderingService(); - /** * Restore World State View * @return true on success, false otherwise @@ -126,6 +121,8 @@ class Irohad { virtual void initFactories(); + virtual void initPersistentCache(); + virtual void initOrderingGate(); virtual void initSimulator(); @@ -134,8 +131,6 @@ class Irohad { virtual void initBlockLoader(); - virtual void initPersistentCache(); - virtual void initConsensusGate(); virtual void initSynchronizer(); @@ -197,6 +192,9 @@ class Irohad { std::shared_ptr transaction_batch_factory_; + // persistent cache + std::shared_ptr persistent_cache; + // ordering gate std::shared_ptr ordering_gate; @@ -210,9 +208,6 @@ class Irohad { // block loader std::shared_ptr block_loader; - // persistent cache - std::shared_ptr persistent_cache; - // consensus gate std::shared_ptr consensus_gate; @@ -258,7 +253,7 @@ class Irohad { std::unique_ptr internal_server; // initialization objects - iroha::network::OrderingInit ordering_init; + iroha::network::OnDemandOrderingInit ordering_init; iroha::consensus::yac::YacInit yac_init; iroha::network::BlockLoaderInit loader_init; diff --git a/irohad/main/impl/block_loader_init.cpp b/irohad/main/impl/block_loader_init.cpp index 6a5f086e9b..4d39b9df45 100644 --- a/irohad/main/impl/block_loader_init.cpp +++ b/irohad/main/impl/block_loader_init.cpp @@ -5,6 +5,7 @@ #include "main/impl/block_loader_init.hpp" #include "validators/default_validator.hpp" +#include "validators/protobuf/proto_block_validator.hpp" using namespace iroha; using namespace iroha::ametsuchi; @@ -20,8 +21,8 @@ auto BlockLoaderInit::createService( auto BlockLoaderInit::createLoader( std::shared_ptr peer_query_factory) { shared_model::proto::ProtoBlockFactory factory( - std::make_unique< - shared_model::validation::DefaultSignedBlockValidator>()); + std::make_unique(), + std::make_unique()); return std::make_shared(std::move(peer_query_factory), std::move(factory)); } diff --git a/irohad/main/impl/consensus_init.cpp b/irohad/main/impl/consensus_init.cpp index 202f3e221a..e2ec97896d 100644 --- a/irohad/main/impl/consensus_init.cpp +++ b/irohad/main/impl/consensus_init.cpp @@ -129,7 +129,6 @@ namespace iroha { std::move(peer_orderer), hash_provider, block_creator, - block_loader, std::move(consensus_result_cache)); } } // namespace yac diff --git a/irohad/main/impl/on_demand_ordering_init.cpp b/irohad/main/impl/on_demand_ordering_init.cpp new file mode 100644 index 0000000000..0f8c56357d --- /dev/null +++ b/irohad/main/impl/on_demand_ordering_init.cpp @@ -0,0 +1,306 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "main/impl/on_demand_ordering_init.hpp" + +#include "common/bind.hpp" +#include "common/delay.hpp" +#include "cryptography/crypto_provider/crypto_defaults.hpp" +#include "datetime/time.hpp" +#include "interfaces/common_objects/peer.hpp" +#include "interfaces/common_objects/types.hpp" +#include "ordering/impl/on_demand_common.hpp" +#include "ordering/impl/on_demand_connection_manager.hpp" +#include "ordering/impl/on_demand_ordering_gate.hpp" +#include "ordering/impl/on_demand_ordering_service_impl.hpp" +#include "ordering/impl/on_demand_os_client_grpc.hpp" +#include "ordering/impl/on_demand_os_server_grpc.hpp" +#include "ordering/impl/ordering_gate_cache/on_demand_cache.hpp" + +namespace { + /// match event and call corresponding lambda depending on sync_outcome + template + auto matchEvent(const iroha::synchronizer::SynchronizationEvent &event, + OnBlocks &&on_blocks, + OnNothing &&on_nothing) { + using iroha::synchronizer::SynchronizationOutcomeType; + switch (event.sync_outcome) { + case SynchronizationOutcomeType::kCommit: + return std::forward(on_blocks)(event); + case SynchronizationOutcomeType::kReject: + case SynchronizationOutcomeType::kNothing: + return std::forward(on_nothing)(event); + default: + BOOST_ASSERT_MSG(false, "Unknown value"); + } + } +} // namespace + +namespace iroha { + namespace network { + + auto OnDemandOrderingInit::createNotificationFactory( + std::shared_ptr> + async_call, + std::chrono::milliseconds delay) { + return std::make_shared( + std::move(async_call), + [] { return std::chrono::system_clock::now(); }, + delay); + } + + auto OnDemandOrderingInit::createConnectionManager( + std::shared_ptr peer_query_factory, + std::shared_ptr> + async_call, + std::chrono::milliseconds delay, + std::vector initial_hashes) { + // since top block will be the first in notifier observable, hashes of + // two previous blocks are prepended + const size_t kBeforePreviousTop = 0, kPreviousTop = 1; + + // flat map hashes from committed blocks + auto all_hashes = notifier.get_observable() + .flat_map([](auto commit) { + return commit.synced_blocks.map( + [](auto block) { return block->hash(); }); + }) + // prepend hashes for the first two rounds + .start_with(initial_hashes.at(kBeforePreviousTop), + initial_hashes.at(kPreviousTop)); + + // emit last k + 1 hashes, where k is the delay parameter + // current implementation assumes k = 2 + // first hash is used for kCurrentRound + // second hash is used for kNextRound + // third hash is used for kRoundAfterNext + auto latest_hashes = + all_hashes.zip(all_hashes.skip(1), all_hashes.skip(2)); + + auto map_peers = [this, peer_query_factory](auto &&latest_data) + -> ordering::OnDemandConnectionManager::CurrentPeers { + auto &latest_commit = std::get<0>(latest_data); + auto ¤t_hashes = std::get<1>(latest_data); + + consensus::Round current_round = latest_commit.round; + + auto on_blocks = [this, + peer_query_factory, + current_hashes, + ¤t_round](const auto &commit) { + current_round = ordering::nextCommitRound(current_round); + + // retrieve peer list from database + // TODO lebdron 08.11.2018 IR-1853 Refactor PeerQuery without + // database access and optional + peer_query_factory->createPeerQuery() | [](auto &&query) { + return query->getLedgerPeers(); + } | [this](auto &&peers) { current_peers_ = std::move(peers); }; + + // generate permutation of peers list from corresponding round + // hash + auto generate_permutation = [&](auto round) { + auto &hash = std::get(current_hashes); + log_->debug("Using hash: {}", hash.toString()); + auto &permutation = permutations_[round()]; + + std::seed_seq seed(hash.blob().begin(), hash.blob().end()); + gen_.seed(seed); + + permutation.resize(current_peers_.size()); + std::iota(permutation.begin(), permutation.end(), 0); + + std::shuffle(permutation.begin(), permutation.end(), gen_); + }; + + generate_permutation(RoundTypeConstant{}); + generate_permutation(RoundTypeConstant{}); + generate_permutation(RoundTypeConstant{}); + }; + auto on_nothing = [¤t_round](const auto &) { + current_round = ordering::nextRejectRound(current_round); + }; + + matchEvent(latest_commit, on_blocks, on_nothing); + + auto getOsPeer = [this, ¤t_round](auto block_round_advance, + auto reject_round) { + auto &permutation = permutations_[block_round_advance]; + // since reject round can be greater than number of peers, wrap it + // with number of peers + auto &peer = + current_peers_[permutation[reject_round % permutation.size()]]; + log_->debug("For round {}, using OS on peer: {}", + consensus::Round{current_round.block_round, reject_round}, + peer->toString()); + return peer; + }; + + using ordering::OnDemandConnectionManager; + OnDemandConnectionManager::CurrentPeers peers; + /* + * See detailed description in + * irohad/ordering/impl/on_demand_connection_manager.cpp + * + * 0 1 2 + * 0 o x v + * 1 x v . + * 2 v . . + * + * v, round 0 - kCurrentRoundRejectConsumer + * v, round 1 - kNextRoundRejectConsumer + * v, round 2 - kNextRoundCommitConsumer + * o, round 0 - kIssuer + */ + peers.peers.at(OnDemandConnectionManager::kCurrentRoundRejectConsumer) = + getOsPeer(kCurrentRound, + ordering::currentRejectRoundConsumer( + current_round.reject_round)); + peers.peers.at(OnDemandConnectionManager::kNextRoundRejectConsumer) = + getOsPeer(kNextRound, ordering::kNextRejectRoundConsumer); + peers.peers.at(OnDemandConnectionManager::kNextRoundCommitConsumer) = + getOsPeer(kRoundAfterNext, ordering::kNextCommitRoundConsumer); + peers.peers.at(OnDemandConnectionManager::kIssuer) = + getOsPeer(kCurrentRound, current_round.reject_round); + return peers; + }; + + auto peers = notifier.get_observable() + .with_latest_from(latest_hashes) + .map(map_peers); + + return std::make_shared( + createNotificationFactory(std::move(async_call), delay), peers); + } + + auto OnDemandOrderingInit::createGate( + std::shared_ptr ordering_service, + std::shared_ptr network_client, + std::shared_ptr cache, + std::shared_ptr + proposal_factory, + std::shared_ptr tx_cache, + consensus::Round initial_round) { + // TODO andrei 06.12.18 IR-75 Make counter and generator parametrizable + const uint64_t kCounter = 0, kMaxLocalCounter = 2; + auto time_generator = [](auto reject_counter) { + return std::chrono::seconds(reject_counter); + }; + // reject_counter and local_counter are local mutable variables of lambda + auto delay = [reject_counter = kCounter, + local_counter = kCounter, + &time_generator, + kMaxLocalCounter](const auto &commit) mutable { + using iroha::synchronizer::SynchronizationOutcomeType; + if (commit.sync_outcome == SynchronizationOutcomeType::kReject + or commit.sync_outcome == SynchronizationOutcomeType::kNothing) { + // Increment reject_counter each local_counter calls of function + ++local_counter; + if (local_counter == kMaxLocalCounter) { + local_counter = 0; + if (reject_counter + < std::numeric_limits::max()) { + reject_counter++; + } + } + } else { + reject_counter = 0; + } + return time_generator(reject_counter); + }; + + auto map = [](auto commit) { + return matchEvent( + commit, + [](const auto &commit) + -> ordering::OnDemandOrderingGate::BlockRoundEventType { + ordering::cache::OrderingGateCache::HashesSetType hashes; + commit.synced_blocks.as_blocking().subscribe( + [&hashes](const auto &block) { + const auto &committed = block->transactions(); + std::transform(committed.begin(), + committed.end(), + std::inserter(hashes, hashes.end()), + [](const auto &transaction) { + return transaction.hash(); + }); + const auto &rejected = + block->rejected_transactions_hashes(); + std::copy(rejected.begin(), + rejected.end(), + std::inserter(hashes, hashes.end())); + }); + return ordering::OnDemandOrderingGate::BlockEvent{ + ordering::nextCommitRound(commit.round), hashes}; + }, + [](const auto ¬hing) + -> ordering::OnDemandOrderingGate::BlockRoundEventType { + return ordering::OnDemandOrderingGate::EmptyEvent{ + ordering::nextRejectRound(nothing.round)}; + }); + }; + + return std::make_shared( + std::move(ordering_service), + std::move(network_client), + notifier.get_observable() + .lift( + iroha::makeDelay( + delay, rxcpp::identity_current_thread())) + .map(map), + std::move(cache), + std::move(proposal_factory), + std::move(tx_cache), + initial_round); + } + + auto OnDemandOrderingInit::createService( + size_t max_size, + std::shared_ptr + proposal_factory, + std::shared_ptr tx_cache) { + return std::make_shared( + max_size, std::move(proposal_factory), std::move(tx_cache)); + } + + std::shared_ptr + OnDemandOrderingInit::initOrderingGate( + size_t max_size, + std::chrono::milliseconds delay, + std::vector initial_hashes, + std::shared_ptr peer_query_factory, + std::shared_ptr< + ordering::transport::OnDemandOsServerGrpc::TransportFactoryType> + transaction_factory, + std::shared_ptr + batch_parser, + std::shared_ptr + transaction_batch_factory, + std::shared_ptr> + async_call, + std::shared_ptr + proposal_factory, + std::shared_ptr tx_cache, + consensus::Round initial_round) { + auto ordering_service = + createService(max_size, proposal_factory, tx_cache); + service = std::make_shared( + ordering_service, + std::move(transaction_factory), + std::move(batch_parser), + std::move(transaction_batch_factory)); + return createGate(ordering_service, + createConnectionManager(std::move(peer_query_factory), + std::move(async_call), + delay, + std::move(initial_hashes)), + std::make_shared(), + std::move(proposal_factory), + std::move(tx_cache), + initial_round); + } + + } // namespace network +} // namespace iroha diff --git a/irohad/main/impl/on_demand_ordering_init.hpp b/irohad/main/impl/on_demand_ordering_init.hpp new file mode 100644 index 0000000000..5309c59222 --- /dev/null +++ b/irohad/main/impl/on_demand_ordering_init.hpp @@ -0,0 +1,150 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_ON_DEMAND_ORDERING_INIT_HPP +#define IROHA_ON_DEMAND_ORDERING_INIT_HPP + +#include + +#include "ametsuchi/peer_query_factory.hpp" +#include "ametsuchi/tx_presence_cache.hpp" +#include "interfaces/iroha_internal/unsafe_proposal_factory.hpp" +#include "logger/logger.hpp" +#include "network/impl/async_grpc_client.hpp" +#include "network/ordering_gate.hpp" +#include "network/peer_communication_service.hpp" +#include "ordering.grpc.pb.h" +#include "ordering/impl/on_demand_os_server_grpc.hpp" +#include "ordering/impl/ordering_gate_cache/ordering_gate_cache.hpp" +#include "ordering/on_demand_ordering_service.hpp" +#include "ordering/on_demand_os_transport.hpp" + +namespace iroha { + namespace network { + + /** + * Encapsulates initialization logic for on-demand ordering gate and service + */ + class OnDemandOrderingInit { + private: + /** + * Creates notification factory for individual connections to peers with + * gRPC backend. \see initOrderingGate for parameters + */ + auto createNotificationFactory( + std::shared_ptr> + async_call, + std::chrono::milliseconds delay); + + /** + * Creates connection manager which redirects requests to appropriate + * ordering services in the current round. \see initOrderingGate for + * parameters + */ + auto createConnectionManager( + std::shared_ptr peer_query_factory, + std::shared_ptr> + async_call, + std::chrono::milliseconds delay, + std::vector initial_hashes); + + /** + * Creates on-demand ordering gate. \see initOrderingGate for parameters + * TODO andrei 31.10.18 IR-1825 Refactor ordering gate observable + */ + auto createGate( + std::shared_ptr ordering_service, + std::shared_ptr network_client, + std::shared_ptr cache, + std::shared_ptr + proposal_factory, + std::shared_ptr tx_cache, + consensus::Round initial_round); + + /** + * Creates on-demand ordering service. \see initOrderingGate for + * parameters + */ + auto createService( + size_t max_size, + std::shared_ptr + proposal_factory, + std::shared_ptr tx_cache); + + public: + /** + * Initializes on-demand ordering gate and ordering sevice components + * + * @param max_size maximum number of transaction in a proposal + * @param delay timeout for ordering service response on proposal request + * @param initial_hashes seeds for peer list permutations for first k + * rounds they are required since hash of block i defines round i + k + * @param peer_query_factory factory for getLedgerPeers query required by + * connection manager + * @param transaction_factory transport factory for transactions required + * by ordering service network endpoint + * @param batch_parser transaction batch parser required by ordering + * service network endpoint + * @param transaction_batch_factory transport factory for transaction + * batch candidates produced by parser + * @param async_call asynchronous gRPC client required for sending batches + * requests to ordering service and processing responses + * @param proposal_factory factory required by ordering service to produce + * proposals + * @param initial_round initial value for current round used in + * OnDemandOrderingGate + * @return initialized ordering gate + */ + std::shared_ptr initOrderingGate( + size_t max_size, + std::chrono::milliseconds delay, + std::vector initial_hashes, + std::shared_ptr peer_query_factory, + std::shared_ptr< + ordering::transport::OnDemandOsServerGrpc::TransportFactoryType> + transaction_factory, + std::shared_ptr + batch_parser, + std::shared_ptr + transaction_batch_factory, + std::shared_ptr> + async_call, + std::shared_ptr + proposal_factory, + std::shared_ptr tx_cache, + consensus::Round initial_round); + + /// gRPC service for ordering service + std::shared_ptr service; + + /// commit notifier from peer communication service + rxcpp::subjects::subject().on_commit())::value_type> + notifier; + + private: + logger::Logger log_ = logger::log("OnDemandOrderingInit"); + + std::vector> + current_peers_; + + /// indexes to permutations for corresponding rounds + enum RoundType { kCurrentRound, kNextRound, kRoundAfterNext, kCount }; + + template + using RoundTypeConstant = std::integral_constant; + + /// permutations for peers lists + std::array, kCount> permutations_; + + /// random generator for peer list permutations + // TODO andrei 08.11.2018 IR-1850 Refactor default_random_engine usages + // with platform-independent class + std::default_random_engine gen_; + }; + } // namespace network +} // namespace iroha + +#endif // IROHA_ON_DEMAND_ORDERING_INIT_HPP diff --git a/irohad/main/impl/raw_block_loader.cpp b/irohad/main/impl/raw_block_loader.cpp index 58c2743fd0..62bd943c9c 100644 --- a/irohad/main/impl/raw_block_loader.cpp +++ b/irohad/main/impl/raw_block_loader.cpp @@ -35,7 +35,7 @@ namespace iroha { const std::string &data) { return jsonToProto(data) | [](auto &&block) { return boost::optional>( - std::make_shared(std::move(block))); + std::make_shared(std::move(block.block_v1()))); }; } diff --git a/irohad/main/irohad.cpp b/irohad/main/irohad.cpp index 63842d50f5..ddd77ed416 100644 --- a/irohad/main/irohad.cpp +++ b/irohad/main/irohad.cpp @@ -96,6 +96,9 @@ DEFINE_validator(verbosity, validateVerbosity); std::promise exit_requested; int main(int argc, char *argv[]) { + // Parsing command line arguments + gflags::ParseCommandLineFlags(&argc, &argv, true); + spdlog::set_level(spdlog::level::level_enum(FLAGS_verbosity)); auto log = logger::log("MAIN"); @@ -111,10 +114,6 @@ int main(int argc, char *argv[]) { namespace mbr = config_members; - // Parsing command line arguments - gflags::ParseCommandLineFlags(&argc, &argv, true); - gflags::ShutDownCommandLineFlags(); - // Reading iroha configuration file auto config = parse_iroha_config(FLAGS_config); log->info("config initialized"); @@ -200,8 +199,6 @@ int main(int argc, char *argv[]) { // clear previous storage if any irohad.dropStorage(); - // reset ordering service persistent counter - irohad.resetOrderingService(); irohad.storage->insertBlock(*block.value()); log->info("Genesis block inserted, number of transactions: {}", @@ -254,5 +251,7 @@ int main(int argc, char *argv[]) { // They do all necessary work in their destructors log->info("shutting down..."); + gflags::ShutDownCommandLineFlags(); + return 0; } diff --git a/irohad/main/server_runner.cpp b/irohad/main/server_runner.cpp index c7b2a1db1e..5b0eedbaef 100644 --- a/irohad/main/server_runner.cpp +++ b/irohad/main/server_runner.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "main/server_runner.hpp" @@ -22,7 +10,9 @@ const auto kPortBindError = "Cannot bind server to address %s"; ServerRunner::ServerRunner(const std::string &address, bool reuse) - : serverAddress_(address), reuse_(reuse) {} + : log_(logger::log("ServerRunner")), + serverAddress_(address), + reuse_(reuse) {} ServerRunner &ServerRunner::append(std::shared_ptr service) { services_.push_back(service); @@ -69,5 +59,16 @@ void ServerRunner::waitForServersReady() { void ServerRunner::shutdown() { if (serverInstance_) { serverInstance_->Shutdown(); + } else { + log_->warn("Tried to shutdown without a server instance"); + } +} + +void ServerRunner::shutdown( + const std::chrono::system_clock::time_point &deadline) { + if (serverInstance_) { + serverInstance_->Shutdown(deadline); + } else { + log_->warn("Tried to shutdown without a server instance"); } } diff --git a/irohad/main/server_runner.hpp b/irohad/main/server_runner.hpp index d633d89f03..e4d3890e5f 100644 --- a/irohad/main/server_runner.hpp +++ b/irohad/main/server_runner.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef MAIN_SERVER_RUNNER_HPP @@ -20,8 +8,8 @@ #include #include - #include "common/result.hpp" +#include "logger/logger.hpp" /** * Class runs Torii server for handling queries and commands. @@ -58,7 +46,14 @@ class ServerRunner { */ void shutdown(); + /** + * Shutdown gRPC server with force on given deadline + */ + void shutdown(const std::chrono::system_clock::time_point &deadline); + private: + logger::Logger log_; + std::unique_ptr serverInstance_; std::mutex waitForServer_; std::condition_variable serverInstanceCV_; diff --git a/irohad/model/converters/impl/pb_block_factory.cpp b/irohad/model/converters/impl/pb_block_factory.cpp index 2f46b94097..181408346c 100644 --- a/irohad/model/converters/impl/pb_block_factory.cpp +++ b/irohad/model/converters/impl/pb_block_factory.cpp @@ -15,8 +15,10 @@ * limitations under the License. */ -#include #include "model/converters/pb_block_factory.hpp" + +#include + #include "model/converters/pb_common.hpp" #include "model/converters/pb_transaction_factory.hpp" @@ -27,15 +29,16 @@ namespace iroha { protocol::Block PbBlockFactory::serialize( const model::Block &block) const { protocol::Block pb_block{}; + auto *pb_block_v1 = pb_block.mutable_block_v1(); - auto pl = pb_block.mutable_payload(); + auto *pl = pb_block_v1->mutable_payload(); pl->set_tx_number(block.txs_number); pl->set_height(block.height); pl->set_prev_block_hash(block.prev_hash.to_string()); pl->set_created_time(block.created_ts); for (const auto &sig_obj : block.sigs) { - auto sig = pb_block.add_signatures(); + auto sig = pb_block_v1->add_signatures(); sig->set_public_key(sig_obj.pubkey.to_string()); sig->set_signature(sig_obj.signature.to_string()); } @@ -56,7 +59,9 @@ namespace iroha { model::Block PbBlockFactory::deserialize( protocol::Block const &pb_block) const { model::Block block{}; - const auto &pl = pb_block.payload(); + BOOST_ASSERT_MSG(pb_block.has_block_v1(), + "Incompatible version of the block is used"); + const auto &pl = pb_block.block_v1().payload(); // in proto we use uint32, but txs_number is uint16 auto txn_max = std::numeric_limits::max(); @@ -69,7 +74,7 @@ namespace iroha { block.prev_hash = hash256_t::from_string(pl.prev_block_hash()); block.created_ts = pl.created_time(); - for (const auto &pb_sig : pb_block.signatures()) { + for (const auto &pb_sig : pb_block.block_v1().signatures()) { model::Signature sig; sig.signature = sig_t::from_string(pb_sig.signature()); sig.pubkey = pubkey_t::from_string(pb_sig.public_key()); @@ -91,7 +96,7 @@ namespace iroha { block.rejected_transactions_hashes.back().begin()); } - block.hash = iroha::hash(pb_block); + block.hash = iroha::hash(pb_block.block_v1()); return block; } diff --git a/irohad/model/sha3_hash.cpp b/irohad/model/sha3_hash.cpp index d6ec30c45a..2922cf6865 100644 --- a/irohad/model/sha3_hash.cpp +++ b/irohad/model/sha3_hash.cpp @@ -33,7 +33,7 @@ namespace iroha { hash256_t hash(const model::Block &block) { auto &&pb_dat = block_factory.serialize(block); - return hash(pb_dat); + return hash(pb_dat.block_v1()); } hash256_t hash(const model::Query &query) { diff --git a/irohad/network/CMakeLists.txt b/irohad/network/CMakeLists.txt index ad7240623b..425cba342e 100644 --- a/irohad/network/CMakeLists.txt +++ b/irohad/network/CMakeLists.txt @@ -33,3 +33,10 @@ target_link_libraries(block_loader_service loader_grpc ametsuchi ) + +add_library(ordering_gate_common + ordering_gate_common.cpp + ) +target_link_libraries(ordering_gate_common + boost + ) diff --git a/irohad/network/consensus_gate.hpp b/irohad/network/consensus_gate.hpp index babd1c1799..d5c200fa04 100644 --- a/irohad/network/consensus_gate.hpp +++ b/irohad/network/consensus_gate.hpp @@ -1,69 +1,52 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CONSENSUS_GATE_HPP #define IROHA_CONSENSUS_GATE_HPP #include +#include "consensus/gate_object.hpp" namespace shared_model { namespace interface { class Block; - } + class Proposal; + } // namespace interface } // namespace shared_model namespace iroha { - namespace network { - /// Shows whether the peer has voted for the block in the commit - enum class PeerVotedFor { - kThisBlock, - kOtherBlock - }; - /** - * Commit message which contains commited block and information about - * whether or not the peer has voted for this block - */ - struct Commit { - std::shared_ptr block; - PeerVotedFor type; - }; + namespace simulator { + struct BlockCreatorEvent; + } // namespace simulator + + namespace network { /** * Public api of consensus module */ class ConsensusGate { public: + using Round = consensus::Round; + /** - * Providing data for consensus for voting - * @param block is the block for which current node is voting + * Vote for given block creator event in consensus */ - virtual void vote( - std::shared_ptr block) = 0; + virtual void vote(const simulator::BlockCreatorEvent &event) = 0; + + using GateObject = consensus::GateObject; /** - * Emit committed blocks - * Note: committed block may be not satisfy for top block in ledger - * because synchronization reasons + * @return emit gate responses */ - virtual rxcpp::observable on_commit() = 0; + virtual rxcpp::observable onOutcome() = 0; virtual ~ConsensusGate() = default; }; + } // namespace network } // namespace iroha + #endif // IROHA_CONSENSUS_GATE_HPP diff --git a/irohad/network/impl/block_loader_service.cpp b/irohad/network/impl/block_loader_service.cpp index a27e8ca7f9..b975665a4a 100644 --- a/irohad/network/impl/block_loader_service.cpp +++ b/irohad/network/impl/block_loader_service.cpp @@ -40,8 +40,12 @@ grpc::Status BlockLoaderService::retrieveBlocks( return block_query->getBlocksFrom(height); }; std::for_each(blocks.begin(), blocks.end(), [&writer](const auto &block) { - writer->Write(std::dynamic_pointer_cast(block) - ->getTransport()); + protocol::Block proto_block; + *proto_block.mutable_block_v1() = + std::dynamic_pointer_cast(block) + ->getTransport(); + + writer->Write(proto_block); }); return grpc::Status::OK; } @@ -61,8 +65,10 @@ grpc::Status BlockLoaderService::retrieveBlock( auto block = consensus_result_cache_->get(); if (block) { if (block->hash() == hash) { - *response = std::static_pointer_cast(block) - ->getTransport(); + auto block_v1 = + std::static_pointer_cast(block) + ->getTransport(); + *response->mutable_block_v1() = block_v1; return grpc::Status::OK; } else { log_->info( @@ -100,7 +106,9 @@ grpc::Status BlockLoaderService::retrieveBlock( return grpc::Status(grpc::StatusCode::NOT_FOUND, "Block not found"); } - *response = std::static_pointer_cast(*found_block) - ->getTransport(); + auto block_v1 = + std::static_pointer_cast(*found_block) + ->getTransport(); + *response->mutable_block_v1() = block_v1; return grpc::Status::OK; } diff --git a/irohad/network/impl/peer_communication_service_impl.cpp b/irohad/network/impl/peer_communication_service_impl.cpp index b3dadc5899..dc2534391a 100644 --- a/irohad/network/impl/peer_communication_service_impl.cpp +++ b/irohad/network/impl/peer_communication_service_impl.cpp @@ -1,22 +1,14 @@ -/* -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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include "network/impl/peer_communication_service_impl.hpp" #include "interfaces/iroha_internal/transaction_batch.hpp" +#include "network/ordering_gate.hpp" +#include "simulator/verified_proposal_creator.hpp" +#include "synchronizer/synchronizer.hpp" namespace iroha { namespace network { @@ -38,15 +30,14 @@ namespace iroha { ordering_gate_->propagateBatch(batch); } - rxcpp::observable> - PeerCommunicationServiceImpl::on_proposal() const { - return ordering_gate_->on_proposal(); + rxcpp::observable PeerCommunicationServiceImpl::onProposal() + const { + return ordering_gate_->onProposal(); } - rxcpp::observable< - std::shared_ptr> - PeerCommunicationServiceImpl::on_verified_proposal() const { - return proposal_creator_->on_verified_proposal(); + rxcpp::observable + PeerCommunicationServiceImpl::onVerifiedProposal() const { + return proposal_creator_->onVerifiedProposal(); } rxcpp::observable diff --git a/irohad/network/impl/peer_communication_service_impl.hpp b/irohad/network/impl/peer_communication_service_impl.hpp index cde8518862..fd8a9f02ac 100644 --- a/irohad/network/impl/peer_communication_service_impl.hpp +++ b/irohad/network/impl/peer_communication_service_impl.hpp @@ -1,33 +1,27 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PEER_COMMUNICATION_SERVICE_IMPL_HPP #define IROHA_PEER_COMMUNICATION_SERVICE_IMPL_HPP -#include "network/ordering_gate.hpp" #include "network/peer_communication_service.hpp" -#include "simulator/verified_proposal_creator.hpp" -#include "synchronizer/synchronizer.hpp" -#include "validation/stateful_validator_common.hpp" #include "logger/logger.hpp" namespace iroha { + namespace simulator { + class VerifiedProposalCreator; + } // namespace simulator + + namespace synchronizer { + class Synchronizer; + } // namespace synchronizer + namespace network { + class OrderingGate; + class PeerCommunicationServiceImpl : public PeerCommunicationService { public: PeerCommunicationServiceImpl( @@ -39,12 +33,10 @@ namespace iroha { std::shared_ptr batch) const override; - rxcpp::observable> - on_proposal() const override; + rxcpp::observable onProposal() const override; - rxcpp::observable< - std::shared_ptr> - on_verified_proposal() const override; + rxcpp::observable + onVerifiedProposal() const override; rxcpp::observable on_commit() const override; diff --git a/irohad/network/ordering_gate.hpp b/irohad/network/ordering_gate.hpp index 978adf7a5b..b04ce481ed 100644 --- a/irohad/network/ordering_gate.hpp +++ b/irohad/network/ordering_gate.hpp @@ -1,25 +1,15 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ -#ifndef IROHA_ORDERING_SERVICE_HPP -#define IROHA_ORDERING_SERVICE_HPP +#ifndef IROHA_ORDERING_GATE_HPP +#define IROHA_ORDERING_GATE_HPP -#include +#include +#include +#include "network/ordering_gate_common.hpp" #include "network/peer_communication_service.hpp" namespace shared_model { @@ -48,9 +38,7 @@ namespace iroha { * Return observable of all proposals in the consensus * @return observable with notifications */ - virtual rxcpp::observable< - std::shared_ptr> - on_proposal() = 0; + virtual rxcpp::observable onProposal() = 0; /** * Set peer communication service for commit notification @@ -66,4 +54,4 @@ namespace iroha { } // namespace network } // namespace iroha -#endif // IROHA_ORDERING_SERVICE_HPP +#endif // IROHA_ORDERING_GATE_HPP diff --git a/irohad/network/ordering_gate_common.cpp b/irohad/network/ordering_gate_common.cpp new file mode 100644 index 0000000000..4b940c2f13 --- /dev/null +++ b/irohad/network/ordering_gate_common.cpp @@ -0,0 +1,17 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "network/ordering_gate_common.hpp" + +namespace iroha { + namespace network { + + std::shared_ptr getProposalUnsafe( + const OrderingEvent &event) { + return *event.proposal; + } + + } // namespace network +} // namespace iroha diff --git a/irohad/network/ordering_gate_common.hpp b/irohad/network/ordering_gate_common.hpp new file mode 100644 index 0000000000..3a3c21c3c3 --- /dev/null +++ b/irohad/network/ordering_gate_common.hpp @@ -0,0 +1,38 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_ORDERING_GATE_COMMON_HPP +#define IROHA_ORDERING_GATE_COMMON_HPP + +#include + +#include +#include "consensus/round.hpp" + +namespace shared_model { + namespace interface { + class Proposal; + } // namespace interface +} // namespace shared_model + +namespace iroha { + namespace network { + + /** + * Event, which is emitted by ordering gate, when it requests a proposal + */ + struct OrderingEvent { + boost::optional> + proposal; + consensus::Round round; + }; + + std::shared_ptr getProposalUnsafe( + const OrderingEvent &event); + + } // namespace network +} // namespace iroha + +#endif // IROHA_ORDERING_GATE_COMMON_HPP diff --git a/irohad/network/peer_communication_service.hpp b/irohad/network/peer_communication_service.hpp index c4e8d0a7d5..c67056d062 100644 --- a/irohad/network/peer_communication_service.hpp +++ b/irohad/network/peer_communication_service.hpp @@ -1,27 +1,15 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PEER_COMMUNICATION_SERVICE_HPP #define IROHA_PEER_COMMUNICATION_SERVICE_HPP #include - +#include "network/ordering_gate_common.hpp" +#include "simulator/verified_proposal_creator_common.hpp" #include "synchronizer/synchronizer_common.hpp" -#include "validation/stateful_validator_common.hpp" namespace shared_model { namespace interface { @@ -31,7 +19,6 @@ namespace shared_model { } // namespace shared_model namespace iroha { - namespace network { /** @@ -52,17 +39,14 @@ namespace iroha { * @return observable with Proposals. * (List of Proposals) */ - virtual rxcpp::observable< - std::shared_ptr> - on_proposal() const = 0; + virtual rxcpp::observable onProposal() const = 0; /** * Event is triggered when verified proposal arrives * @return verified proposal and list of stateful validation errors */ - virtual rxcpp::observable< - std::shared_ptr> - on_verified_proposal() const = 0; + virtual rxcpp::observable + onVerifiedProposal() const = 0; /** * Event is triggered when commit block arrives. @@ -77,6 +61,8 @@ namespace iroha { virtual ~PeerCommunicationService() = default; }; + } // namespace network } // namespace iroha + #endif // IROHA_PEER_COMMUNICATION_SERVICE_HPP diff --git a/irohad/ordering/CMakeLists.txt b/irohad/ordering/CMakeLists.txt index 4eb7773b38..80c3325e5e 100644 --- a/irohad/ordering/CMakeLists.txt +++ b/irohad/ordering/CMakeLists.txt @@ -20,11 +20,20 @@ target_link_libraries(ordering_service shared_model_interfaces_factories ) +add_library(on_demand_common + impl/on_demand_common.cpp + ) + +target_link_libraries(on_demand_common + consensus_round + ) + add_library(on_demand_ordering_service impl/on_demand_ordering_service_impl.cpp ) target_link_libraries(on_demand_ordering_service + on_demand_common tbb shared_model_interfaces consensus_round @@ -50,10 +59,12 @@ add_library(on_demand_connection_manager impl/on_demand_connection_manager.cpp ) target_link_libraries(on_demand_connection_manager + on_demand_common shared_model_interfaces consensus_round rxcpp boost + logger ) add_library(on_demand_ordering_gate @@ -62,8 +73,10 @@ add_library(on_demand_ordering_gate impl/ordering_gate_cache/on_demand_cache.cpp ) target_link_libraries(on_demand_ordering_gate + on_demand_common consensus_round rxcpp boost + logger common ) diff --git a/irohad/ordering/impl/on_demand_common.cpp b/irohad/ordering/impl/on_demand_common.cpp new file mode 100644 index 0000000000..ba31014a09 --- /dev/null +++ b/irohad/ordering/impl/on_demand_common.cpp @@ -0,0 +1,33 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "ordering/impl/on_demand_common.hpp" + +namespace iroha { + namespace ordering { + + const consensus::RejectRoundType kFirstRejectRound = 0; + + consensus::RejectRoundType currentRejectRoundConsumer( + consensus::RejectRoundType round) { + return round + 2; + } + + const consensus::RejectRoundType kNextRejectRoundConsumer = + kFirstRejectRound + 1; + + const consensus::RejectRoundType kNextCommitRoundConsumer = + kFirstRejectRound; + + consensus::Round nextCommitRound(const consensus::Round &round) { + return {round.block_round + 1, kFirstRejectRound}; + } + + consensus::Round nextRejectRound(const consensus::Round &round) { + return {round.block_round, round.reject_round + 1}; + } + + } // namespace ordering +} // namespace iroha diff --git a/irohad/ordering/impl/on_demand_common.hpp b/irohad/ordering/impl/on_demand_common.hpp new file mode 100644 index 0000000000..8b1b43df5d --- /dev/null +++ b/irohad/ordering/impl/on_demand_common.hpp @@ -0,0 +1,30 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_ON_DEMAND_COMMON_HPP +#define IROHA_ON_DEMAND_COMMON_HPP + +#include "consensus/round.hpp" + +namespace iroha { + namespace ordering { + + extern const consensus::RejectRoundType kFirstRejectRound; + + consensus::RejectRoundType currentRejectRoundConsumer( + consensus::RejectRoundType round); + + extern const consensus::RejectRoundType kNextRejectRoundConsumer; + + extern const consensus::RejectRoundType kNextCommitRoundConsumer; + + consensus::Round nextCommitRound(const consensus::Round &round); + + consensus::Round nextRejectRound(const consensus::Round &round); + + } // namespace ordering +} // namespace iroha + +#endif // IROHA_ON_DEMAND_COMMON_HPP diff --git a/irohad/ordering/impl/on_demand_connection_manager.cpp b/irohad/ordering/impl/on_demand_connection_manager.cpp index e5813daae1..a2932b02d1 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.cpp +++ b/irohad/ordering/impl/on_demand_connection_manager.cpp @@ -7,32 +7,35 @@ #include #include "interfaces/iroha_internal/proposal.hpp" +#include "ordering/impl/on_demand_common.hpp" using namespace iroha::ordering; OnDemandConnectionManager::OnDemandConnectionManager( std::shared_ptr factory, - CurrentPeers initial_peers, rxcpp::observable peers) - : factory_(std::move(factory)), + : log_(logger::log("OnDemandConnectionManager")), + factory_(std::move(factory)), subscription_(peers.subscribe([this](const auto &peers) { // exclusive lock std::lock_guard lock(mutex_); this->initializeConnections(peers); - })) { + })) {} + +OnDemandConnectionManager::OnDemandConnectionManager( + std::shared_ptr factory, + rxcpp::observable peers, + CurrentPeers initial_peers) + : OnDemandConnectionManager(std::move(factory), peers) { // using start_with(initial_peers) results in deadlock initializeConnections(initial_peers); } void OnDemandConnectionManager::onBatches(consensus::Round round, CollectionType batches) { - // shared lock std::shared_lock lock(mutex_); - const PeerType types[] = {kCurrentRoundRejectConsumer, - kNextRoundRejectConsumer, - kNextRoundCommitConsumer}; /* * Transactions are always sent to the round after the next round (+2) * There are 3 possibilities - next reject in the current round, first reject @@ -45,22 +48,31 @@ void OnDemandConnectionManager::onBatches(consensus::Round round, * 1 x v . * 2 v . . */ - const consensus::Round rounds[] = { - {round.block_round, round.reject_round + 2}, - {round.block_round + 1, 2}, - {round.block_round + 2, 1}}; - - for (auto &&pair : boost::combine(types, rounds)) { - connections_.peers[boost::get<0>(pair)]->onBatches(boost::get<1>(pair), - batches); - } + + auto propagate = [this, batches](PeerType type, consensus::Round round) { + log_->debug( + "onTransactions, round[{}, {}]", round.block_round, round.reject_round); + + connections_.peers[type]->onBatches(round, batches); + }; + + propagate( + kCurrentRoundRejectConsumer, + {round.block_round, currentRejectRoundConsumer(round.reject_round)}); + propagate(kNextRoundRejectConsumer, + {round.block_round + 1, kNextRejectRoundConsumer}); + propagate(kNextRoundCommitConsumer, + {round.block_round + 2, kNextCommitRoundConsumer}); } boost::optional OnDemandConnectionManager::onRequestProposal(consensus::Round round) { - // shared lock std::shared_lock lock(mutex_); + log_->debug("onRequestProposal, round[{}, {}]", + round.block_round, + round.reject_round); + return connections_.peers[kIssuer]->onRequestProposal(round); } diff --git a/irohad/ordering/impl/on_demand_connection_manager.hpp b/irohad/ordering/impl/on_demand_connection_manager.hpp index 86f152a2e5..fabe97ab1a 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.hpp +++ b/irohad/ordering/impl/on_demand_connection_manager.hpp @@ -11,6 +11,7 @@ #include #include +#include "logger/logger.hpp" namespace iroha { namespace ordering { @@ -50,9 +51,13 @@ namespace iroha { OnDemandConnectionManager( std::shared_ptr factory, - CurrentPeers initial_peers, rxcpp::observable peers); + OnDemandConnectionManager( + std::shared_ptr factory, + rxcpp::observable peers, + CurrentPeers initial_peers); + void onBatches(consensus::Round round, CollectionType batches) override; boost::optional onRequestProposal( @@ -73,6 +78,7 @@ namespace iroha { */ void initializeConnections(const CurrentPeers &peers); + logger::Logger log_; std::shared_ptr factory_; rxcpp::composite_subscription subscription_; diff --git a/irohad/ordering/impl/on_demand_ordering_gate.cpp b/irohad/ordering/impl/on_demand_ordering_gate.cpp index 7794f4ccb8..31c17398a4 100644 --- a/irohad/ordering/impl/on_demand_ordering_gate.cpp +++ b/irohad/ordering/impl/on_demand_ordering_gate.cpp @@ -9,6 +9,7 @@ #include #include "ametsuchi/tx_presence_cache.hpp" #include "common/visitor.hpp" +#include "ordering/impl/on_demand_common.hpp" using namespace iroha; using namespace iroha::ordering; @@ -18,10 +19,11 @@ OnDemandOrderingGate::OnDemandOrderingGate( std::shared_ptr network_client, rxcpp::observable events, std::shared_ptr cache, - std::unique_ptr factory, + std::shared_ptr factory, std::shared_ptr tx_cache, consensus::Round initial_round) - : ordering_service_(std::move(ordering_service)), + : log_(logger::log("OnDemandOrderingGate")), + ordering_service_(std::move(ordering_service)), network_client_(std::move(network_client)), events_subscription_(events.subscribe([this](auto event) { // exclusive lock @@ -30,31 +32,40 @@ OnDemandOrderingGate::OnDemandOrderingGate( visit_in_place(event, [this](const BlockEvent &block_event) { // block committed, increment block round + log_->debug("BlockEvent. round [{}, {}]", + block_event.round.block_round, + block_event.round.reject_round); current_round_ = block_event.round; cache_->remove(block_event.hashes); }, - [this](const EmptyEvent &empty) { + [this](const EmptyEvent &empty_event) { // no blocks committed, increment reject round - current_round_ = {current_round_.block_round, - current_round_.reject_round + 1}; + log_->debug("EmptyEvent"); + current_round_ = empty_event.round; }); + log_->debug("Current round: [{}, {}]", + current_round_.block_round, + current_round_.reject_round); auto batches = cache_->pop(); cache_->addToBack(batches); - network_client_->onBatches(current_round_, - transport::OdOsNotification::CollectionType{ - batches.begin(), batches.end()}); + if (not batches.empty()) { + network_client_->onBatches( + current_round_, + transport::OdOsNotification::CollectionType{batches.begin(), + batches.end()}); + } // notify our ordering service about new round ordering_service_->onCollaborationOutcome(current_round_); // request proposal for the current round - auto proposal = network_client_->onRequestProposal(current_round_); - - auto final_proposal = this->processProposalRequest(std::move(proposal)); + auto proposal = this->processProposalRequest( + network_client_->onRequestProposal(current_round_)); // vote for the object received from the network - proposal_notifier_.get_subscriber().on_next(std::move(final_proposal)); + proposal_notifier_.get_subscriber().on_next( + network::OrderingEvent{proposal, current_round_}); })), cache_(std::move(cache)), proposal_factory_(std::move(factory)), @@ -70,8 +81,7 @@ void OnDemandOrderingGate::propagateBatch( current_round_, transport::OdOsNotification::CollectionType{batch}); } -rxcpp::observable> -OnDemandOrderingGate::on_proposal() { +rxcpp::observable OnDemandOrderingGate::onProposal() { return proposal_notifier_.get_observable(); } @@ -81,21 +91,20 @@ void OnDemandOrderingGate::setPcs( "Method is deprecated. PCS observable should be set in ctor"); } -std::unique_ptr +boost::optional> OnDemandOrderingGate::processProposalRequest( boost::optional &&proposal) const { if (not proposal) { - return proposal_factory_->unsafeCreateProposal( - current_round_.block_round, current_round_.reject_round, {}); + return boost::none; } // no need to check empty proposal if (boost::empty(proposal.value()->transactions())) { - return std::move(proposal.value()); + return boost::none; } return removeReplays(std::move(**std::move(proposal))); } -std::unique_ptr +boost::optional> OnDemandOrderingGate::removeReplays( shared_model::interface::Proposal &&proposal) const { auto tx_is_not_processed = [this](const auto &tx) { @@ -118,6 +127,13 @@ OnDemandOrderingGate::removeReplays( auto unprocessed_txs = boost::adaptors::filter(proposal.transactions(), tx_is_not_processed); - return proposal_factory_->unsafeCreateProposal( + auto result = proposal_factory_->unsafeCreateProposal( proposal.height(), proposal.createdTime(), unprocessed_txs); + + if (boost::empty(result->transactions())) { + return boost::none; + } + + return boost::make_optional< + std::shared_ptr>(std::move(result)); } diff --git a/irohad/ordering/impl/on_demand_ordering_gate.hpp b/irohad/ordering/impl/on_demand_ordering_gate.hpp index 41544eb37e..e2c1c8b533 100644 --- a/irohad/ordering/impl/on_demand_ordering_gate.hpp +++ b/irohad/ordering/impl/on_demand_ordering_gate.hpp @@ -15,6 +15,7 @@ #include "interfaces/common_objects/types.hpp" #include "interfaces/iroha_internal/proposal.hpp" #include "interfaces/iroha_internal/unsafe_proposal_factory.hpp" +#include "logger/logger.hpp" #include "ordering/impl/ordering_gate_cache/ordering_gate_cache.hpp" #include "ordering/on_demand_ordering_service.hpp" @@ -35,14 +36,19 @@ namespace iroha { * Represents storage modification. Proposal round increment */ struct BlockEvent { + /// next round number consensus::Round round; + /// hashes of processed transactions cache::OrderingGateCache::HashesSetType hashes; }; /** * Represents no storage modification. Reject round increment */ - struct EmptyEvent {}; + struct EmptyEvent { + /// next round number + consensus::Round round; + }; using BlockRoundEventType = boost::variant; @@ -53,7 +59,7 @@ namespace iroha { std::shared_ptr cache, // TODO: IR-1863 12.11.18 kamilsa change cache to // unique_ptr - std::unique_ptr + std::shared_ptr factory, std::shared_ptr tx_cache, consensus::Round initial_round); @@ -62,8 +68,7 @@ namespace iroha { std::shared_ptr batch) override; - rxcpp::observable> - on_proposal() override; + rxcpp::observable onProposal() override; [[deprecated("Use ctor")]] void setPcs( const iroha::network::PeerCommunicationService &pcs) override; @@ -72,29 +77,28 @@ namespace iroha { /** * Handle an incoming proposal from ordering service */ - std::unique_ptr processProposalRequest( - boost::optional - &&proposal) const; + boost::optional> + processProposalRequest( + boost::optional &&proposal) + const; /** * remove already processed transactions from proposal */ - std::unique_ptr removeReplays( - shared_model::interface::Proposal &&proposal) const; + boost::optional> + removeReplays(shared_model::interface::Proposal &&proposal) const; + logger::Logger log_; std::shared_ptr ordering_service_; std::shared_ptr network_client_; rxcpp::composite_subscription events_subscription_; std::shared_ptr cache_; - std::unique_ptr + std::shared_ptr proposal_factory_; std::shared_ptr tx_cache_; consensus::Round current_round_; - rxcpp::subjects::subject< - std::shared_ptr> - proposal_notifier_; - + rxcpp::subjects::subject proposal_notifier_; mutable std::shared_timed_mutex mutex_; }; diff --git a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp index 6af2ba3e60..1ba1ba8e55 100644 --- a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp +++ b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp @@ -22,14 +22,9 @@ using namespace iroha::ordering; -/** - * First round after successful committing block - */ -const iroha::consensus::RejectRoundType kFirstRound = 1; - OnDemandOrderingServiceImpl::OnDemandOrderingServiceImpl( size_t transaction_limit, - std::unique_ptr + std::shared_ptr proposal_factory, std::shared_ptr tx_cache, size_t number_of_proposals, @@ -51,7 +46,7 @@ void OnDemandOrderingServiceImpl::onCollaborationOutcome( round.reject_round); // exclusive write lock std::lock_guard guard(lock_); - log_->info("onCollaborationOutcome => write lock is acquired"); + log_->debug("onCollaborationOutcome => write lock is acquired"); packNextProposals(round); tryErase(); @@ -75,12 +70,26 @@ void OnDemandOrderingServiceImpl::onBatches(consensus::Round round, return not this->batchAlreadyProcessed(*batch); }); auto it = current_proposals_.find(round); - if (it != current_proposals_.end()) { - std::for_each(unprocessed_batches.begin(), - unprocessed_batches.end(), - [&it](auto &obj) { it->second.push(std::move(obj)); }); - log_->info("onTransactions => collection is inserted"); + if (it == current_proposals_.end()) { + it = + std::find_if(current_proposals_.begin(), + current_proposals_.end(), + [&round](const auto &p) { + auto request_reject_round = round.reject_round; + auto reject_round = p.first.reject_round; + return request_reject_round == reject_round + or (request_reject_round >= 2 and reject_round >= 2); + }); + BOOST_ASSERT_MSG(it != current_proposals_.end(), + "No place to store the batches!"); + log_->debug("onBatches => collection will be inserted to [{}, {}]", + it->first.block_round, + it->first.reject_round); } + std::for_each(unprocessed_batches.begin(), + unprocessed_batches.end(), + [&it](auto &obj) { it->second.push(std::move(obj)); }); + log_->debug("onBatches => collection is inserted"); } boost::optional @@ -88,6 +97,10 @@ OnDemandOrderingServiceImpl::onRequestProposal(consensus::Round round) { // read lock std::shared_lock guard(lock_); auto proposal = proposal_map_.find(round); + log_->debug("onRequestProposal, round[{}, {}], {}returning a proposal.", + round.block_round, + round.reject_round, + (proposal == proposal_map_.end()) ? "NOT " : ""); if (proposal != proposal_map_.end()) { return clone(*proposal->second); } else { @@ -100,19 +113,27 @@ OnDemandOrderingServiceImpl::onRequestProposal(consensus::Round round) { void OnDemandOrderingServiceImpl::packNextProposals( const consensus::Round &round) { auto close_round = [this](consensus::Round round) { + log_->debug("close round[{}, {}]", round.block_round, round.reject_round); + auto it = current_proposals_.find(round); if (it != current_proposals_.end()) { + log_->debug("proposal found"); if (not it->second.empty()) { proposal_map_.emplace(round, emitProposal(round)); - log_->info("packNextProposal: data has been fetched for round[{}, {}]", - round.block_round, - round.reject_round); + log_->debug("packNextProposal: data has been fetched for round[{}, {}]", + round.block_round, + round.reject_round); round_queue_.push(round); } current_proposals_.erase(it); } }; + auto open_round = [this](consensus::Round round) { + log_->debug("open round[{}, {}]", round.block_round, round.reject_round); + current_proposals_[round]; + }; + /* * The possible cases can be visualised as a diagram, where: * o - current round, x - next round, v - target round @@ -147,27 +168,27 @@ void OnDemandOrderingServiceImpl::packNextProposals( // close next reject round close_round({round.block_round, round.reject_round + 1}); - if (round.reject_round == kFirstRound) { + if (round.reject_round == kFirstRejectRound) { // new block round close_round({round.block_round + 1, round.reject_round}); // remove current queues current_proposals_.clear(); // initialize the 3 diagonal rounds from the commit case diagram - for (uint32_t i = 0; i <= 2; ++i) { - current_proposals_[{round.block_round + i, round.reject_round + 2 - i}]; - } - } else { - // new reject round - current_proposals_[{round.block_round, round.reject_round + 2}]; + open_round({round.block_round + 1, kNextRejectRoundConsumer}); + open_round({round.block_round + 2, kNextCommitRoundConsumer}); } + + // new reject round + open_round( + {round.block_round, currentRejectRoundConsumer(round.reject_round)}); } OnDemandOrderingServiceImpl::ProposalType OnDemandOrderingServiceImpl::emitProposal(const consensus::Round &round) { - log_->info("Mutable proposal generation, round[{}, {}]", - round.block_round, - round.reject_round); + log_->debug("Mutable proposal generation, round[{}, {}]", + round.block_round, + round.reject_round); TransactionBatchType batch; std::vector> collection; @@ -185,7 +206,9 @@ OnDemandOrderingServiceImpl::emitProposal(const consensus::Round &round) { std::make_move_iterator(std::begin(batch->transactions())), std::make_move_iterator(std::end(batch->transactions()))); } - log_->info("Number of transactions in proposal = {}", collection.size()); + log_->debug("Number of transactions in proposal = {}", collection.size()); + log_->debug("Number of lost transactions = {}", + current_proposal.unsafe_size()); auto txs = collection | boost::adaptors::indirected; return proposal_factory_->unsafeCreateProposal( diff --git a/irohad/ordering/impl/on_demand_ordering_service_impl.hpp b/irohad/ordering/impl/on_demand_ordering_service_impl.hpp index 19ce7990bc..35f503784a 100644 --- a/irohad/ordering/impl/on_demand_ordering_service_impl.hpp +++ b/irohad/ordering/impl/on_demand_ordering_service_impl.hpp @@ -15,6 +15,7 @@ #include #include "interfaces/iroha_internal/unsafe_proposal_factory.hpp" #include "logger/logger.hpp" +#include "ordering/impl/on_demand_common.hpp" namespace iroha { namespace ametsuchi { @@ -27,18 +28,19 @@ namespace iroha { * Create on_demand ordering service with following options: * @param transaction_limit - number of maximum transactions in one * proposal + * @param proposal_factory - used to generate proposals * @param number_of_proposals - number of stored proposals, older will be * removed. Default value is 3 * @param initial_round - first round of agreement. - * Default value is {2, 1} since genesis block height is 1 + * Default value is {2, kFirstRejectRound} since genesis block height is 1 */ OnDemandOrderingServiceImpl( size_t transaction_limit, - std::unique_ptr + std::shared_ptr proposal_factory, std::shared_ptr tx_cache, size_t number_of_proposals = 3, - const consensus::Round &initial_round = {2, 1}); + const consensus::Round &initial_round = {2, kFirstRejectRound}); // --------------------- | OnDemandOrderingService |_--------------------- @@ -113,7 +115,7 @@ namespace iroha { */ std::shared_timed_mutex lock_; - std::unique_ptr + std::shared_ptr proposal_factory_; /** diff --git a/irohad/ordering/impl/on_demand_os_client_grpc.hpp b/irohad/ordering/impl/on_demand_os_client_grpc.hpp index a8bc49c8fc..1128adeb37 100644 --- a/irohad/ordering/impl/on_demand_os_client_grpc.hpp +++ b/irohad/ordering/impl/on_demand_os_client_grpc.hpp @@ -3,8 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef IROHA_ON_DEMAND_OS_TRANSPORT_SERVER_GRPC_HPP -#define IROHA_ON_DEMAND_OS_TRANSPORT_SERVER_GRPC_HPP +#ifndef IROHA_ON_DEMAND_OS_TRANSPORT_CLIENT_GRPC_HPP +#define IROHA_ON_DEMAND_OS_TRANSPORT_CLIENT_GRPC_HPP #include "ordering/on_demand_os_transport.hpp" @@ -76,4 +76,4 @@ namespace iroha { } // namespace ordering } // namespace iroha -#endif // IROHA_ON_DEMAND_OS_TRANSPORT_SERVER_GRPC_HPP +#endif // IROHA_ON_DEMAND_OS_TRANSPORT_CLIENT_GRPC_HPP diff --git a/irohad/ordering/impl/ordering_gate_cache/on_demand_cache.cpp b/irohad/ordering/impl/ordering_gate_cache/on_demand_cache.cpp index ded0f2aad3..142058e515 100644 --- a/irohad/ordering/impl/ordering_gate_cache/on_demand_cache.cpp +++ b/irohad/ordering/impl/ordering_gate_cache/on_demand_cache.cpp @@ -6,6 +6,7 @@ #include "ordering/impl/ordering_gate_cache/on_demand_cache.hpp" #include "interfaces/iroha_internal/transaction_batch.hpp" +#include "interfaces/transaction.hpp" using namespace iroha::ordering::cache; @@ -22,7 +23,11 @@ void OnDemandCache::remove(const OrderingGateCache::HashesSetType &hashes) { std::unique_lock lock(mutex_); for (auto &batches : circ_buffer) { for (auto it = batches.begin(); it != batches.end();) { - if (hashes.find(it->get()->reducedHash()) != hashes.end()) { + if (std::any_of(it->get()->transactions().begin(), + it->get()->transactions().end(), + [&hashes](const auto &tx) { + return hashes.find(tx->hash()) != hashes.end(); + })) { // returns iterator following the last removed element // hence there is no increment in loop iteration_expression it = batches.erase(it); diff --git a/irohad/ordering/impl/ordering_gate_impl.cpp b/irohad/ordering/impl/ordering_gate_impl.cpp index 28f2604a4c..3abbe4b6b0 100644 --- a/irohad/ordering/impl/ordering_gate_impl.cpp +++ b/irohad/ordering/impl/ordering_gate_impl.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "ordering/impl/ordering_gate_impl.hpp" @@ -23,6 +11,7 @@ #include "interfaces/iroha_internal/block.hpp" #include "interfaces/iroha_internal/proposal.hpp" #include "interfaces/iroha_internal/transaction_batch.hpp" +#include "ordering/impl/on_demand_common.hpp" namespace iroha { namespace ordering { @@ -54,8 +43,7 @@ namespace iroha { transport_->propagateBatch(batch); } - rxcpp::observable> - OrderingGateImpl::on_proposal() { + rxcpp::observable OrderingGateImpl::onProposal() { return proposals_.get_observable(); } @@ -129,7 +117,8 @@ namespace iroha { } log_->info("Pass the proposal to pipeline height {}", next_proposal->height()); - proposals_.get_subscriber().on_next(next_proposal); + proposals_.get_subscriber().on_next(network::OrderingEvent{ + next_proposal, {next_proposal->height(), kFirstRejectRound}}); } } diff --git a/irohad/ordering/impl/ordering_gate_impl.hpp b/irohad/ordering/impl/ordering_gate_impl.hpp index d5fb2a9b43..4ffd99f225 100644 --- a/irohad/ordering/impl/ordering_gate_impl.hpp +++ b/irohad/ordering/impl/ordering_gate_impl.hpp @@ -71,8 +71,7 @@ namespace iroha { std::shared_ptr batch) override; - rxcpp::observable> - on_proposal() override; + rxcpp::observable onProposal() override; void setPcs(const iroha::network::PeerCommunicationService &pcs) override; @@ -92,9 +91,7 @@ namespace iroha { void tryNextRound( shared_model::interface::types::HeightType last_block_height); - rxcpp::subjects::subject< - std::shared_ptr> - proposals_; + rxcpp::subjects::subject proposals_; /** * Notification subject which is used only for notification purposes diff --git a/irohad/simulator/CMakeLists.txt b/irohad/simulator/CMakeLists.txt index 105c3aa70d..d39bb15598 100644 --- a/irohad/simulator/CMakeLists.txt +++ b/irohad/simulator/CMakeLists.txt @@ -1,10 +1,31 @@ +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + add_library(simulator impl/simulator.cpp ) target_link_libraries(simulator + consensus_round shared_model_interfaces rxcpp logger common + ordering_gate_common + verified_proposal_creator_common + block_creator_common + ) + +add_library(verified_proposal_creator_common + verified_proposal_creator_common.cpp + ) +target_link_libraries(verified_proposal_creator_common + boost + ) + +add_library(block_creator_common + block_creator_common.cpp + ) +target_link_libraries(block_creator_common + boost ) diff --git a/irohad/simulator/block_creator.hpp b/irohad/simulator/block_creator.hpp index 2735e1eb06..4ca4582665 100644 --- a/irohad/simulator/block_creator.hpp +++ b/irohad/simulator/block_creator.hpp @@ -1,31 +1,13 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_BLOCK_CREATOR_HPP #define IROHA_BLOCK_CREATOR_HPP #include - -namespace shared_model { - namespace interface { - class Block; - class Proposal; - } // namespace interface -} // namespace shared_model +#include "simulator/block_creator_common.hpp" namespace iroha { namespace validation { @@ -40,22 +22,21 @@ namespace iroha { class BlockCreator { public: /** - * Processing proposal for making stateful validation - * @param proposal - object for validation + * Creates a block from given proposal and round */ - virtual void process_verified_proposal( + virtual void processVerifiedProposal( const std::shared_ptr - &verified_proposal_and_errors) = 0; + &verified_proposal_and_errors, + const consensus::Round &round) = 0; /** * Emit blocks made from proposals - * @return */ - virtual rxcpp::observable> - on_block() = 0; + virtual rxcpp::observable onBlock() = 0; virtual ~BlockCreator() = default; }; } // namespace simulator } // namespace iroha + #endif // IROHA_BLOCK_CREATOR_HPP diff --git a/irohad/simulator/block_creator_common.cpp b/irohad/simulator/block_creator_common.cpp new file mode 100644 index 0000000000..b613929897 --- /dev/null +++ b/irohad/simulator/block_creator_common.cpp @@ -0,0 +1,17 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "simulator/block_creator_common.hpp" + +namespace iroha { + namespace simulator { + + std::shared_ptr getBlockUnsafe( + const BlockCreatorEvent &event) { + return event.round_data->block; + } + + } // namespace simulator +} // namespace iroha diff --git a/irohad/simulator/block_creator_common.hpp b/irohad/simulator/block_creator_common.hpp new file mode 100644 index 0000000000..cf701818f4 --- /dev/null +++ b/irohad/simulator/block_creator_common.hpp @@ -0,0 +1,44 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_BLOCK_CREATOR_COMMON_HPP +#define IROHA_BLOCK_CREATOR_COMMON_HPP + +#include + +#include +#include "consensus/round.hpp" + +namespace shared_model { + namespace interface { + class Block; + class Proposal; + } // namespace interface +} // namespace shared_model + +namespace iroha { + namespace simulator { + + struct RoundData { + std::shared_ptr proposal; + std::shared_ptr block; + }; + + /** + * Event, which is emitted by block creator, when it receives and processes + * a verified proposal + */ + struct BlockCreatorEvent { + boost::optional round_data; + consensus::Round round; + }; + + std::shared_ptr getBlockUnsafe( + const BlockCreatorEvent &event); + + } // namespace simulator +} // namespace iroha + +#endif // IROHA_BLOCK_CREATOR_COMMON_HPP diff --git a/irohad/simulator/impl/simulator.cpp b/irohad/simulator/impl/simulator.cpp index ef1b11fb8f..02ffb3acfc 100644 --- a/irohad/simulator/impl/simulator.cpp +++ b/irohad/simulator/impl/simulator.cpp @@ -7,7 +7,6 @@ #include #include - #include "common/bind.hpp" #include "interfaces/iroha_internal/block.hpp" #include "interfaces/iroha_internal/proposal.hpp" @@ -30,17 +29,26 @@ namespace iroha { crypto_signer_(std::move(crypto_signer)), block_factory_(std::move(block_factory)), log_(logger::log("Simulator")) { - ordering_gate->on_proposal().subscribe( - proposal_subscription_, - [this](std::shared_ptr proposal) { - this->process_proposal(*proposal); + ordering_gate->onProposal().subscribe( + proposal_subscription_, [this](const network::OrderingEvent &event) { + if (event.proposal) { + this->processProposal(*getProposalUnsafe(event), event.round); + } else { + notifier_.get_subscriber().on_next( + VerifiedProposalCreatorEvent{boost::none, event.round}); + } }); notifier_.get_observable().subscribe( verified_proposal_subscription_, - [this](std::shared_ptr - verified_proposal_and_errors) { - this->process_verified_proposal(verified_proposal_and_errors); + [this](const VerifiedProposalCreatorEvent &event) { + if (event.verified_proposal_result) { + this->processVerifiedProposal(getVerifiedProposalUnsafe(event), + event.round); + } else { + block_notifier_.get_subscriber().on_next( + BlockCreatorEvent{boost::none, event.round}); + } }); } @@ -49,35 +57,32 @@ namespace iroha { verified_proposal_subscription_.unsubscribe(); } - rxcpp::observable< - std::shared_ptr> - Simulator::on_verified_proposal() { + rxcpp::observable + Simulator::onVerifiedProposal() { return notifier_.get_observable(); } - void Simulator::process_proposal( - const shared_model::interface::Proposal &proposal) { + void Simulator::processProposal( + const shared_model::interface::Proposal &proposal, + const consensus::Round &round) { log_->info("process proposal"); // Get last block from local ledger - auto block_query_opt = block_query_factory_->createBlockQuery(); - if (not block_query_opt) { + if (auto block_query_opt = block_query_factory_->createBlockQuery()) { + auto block_var = block_query_opt.value()->getTopBlock(); + if (auto e = boost::get>(&block_var)) { + log_->warn("Could not fetch last block: " + e->error); + return; + } + + last_block = boost::get>>(&block_var) + ->value; + } else { log_->error("could not create block query"); return; } - auto block_var = block_query_opt.value()->getTopBlock(); - if (auto e = boost::get>(&block_var)) { - log_->warn("Could not fetch last block: " + e->error); - return; - } - - last_block = - boost::get< - expected::Value>>( - &block_var) - ->value; - if (last_block->height() + 1 != proposal.height()) { log_->warn("Last block height: {}, proposal height: {}", last_block->height(), @@ -103,12 +108,13 @@ namespace iroha { ametsuchi_factory_->prepareBlock(std::move(storage)); notifier_.get_subscriber().on_next( - std::move(validated_proposal_and_errors)); + VerifiedProposalCreatorEvent{validated_proposal_and_errors, round}); } - void Simulator::process_verified_proposal( + void Simulator::processVerifiedProposal( const std::shared_ptr - &verified_proposal_and_errors) { + &verified_proposal_and_errors, + const consensus::Round &round) { log_->info("process verified proposal"); auto height = block_query_factory_->createBlockQuery() | @@ -130,11 +136,11 @@ namespace iroha { proposal->transactions(), rejected_tx_hashes); crypto_signer_->sign(*block); - block_notifier_.get_subscriber().on_next(block); + block_notifier_.get_subscriber().on_next( + BlockCreatorEvent{RoundData{proposal, block}, round}); } - rxcpp::observable> - Simulator::on_block() { + rxcpp::observable Simulator::onBlock() { return block_notifier_.get_observable(); } diff --git a/irohad/simulator/impl/simulator.hpp b/irohad/simulator/impl/simulator.hpp index 32ad367a18..c5da5fcc32 100644 --- a/irohad/simulator/impl/simulator.hpp +++ b/irohad/simulator/impl/simulator.hpp @@ -35,27 +35,23 @@ namespace iroha { ~Simulator() override; - void process_proposal( - const shared_model::interface::Proposal &proposal) override; + void processProposal(const shared_model::interface::Proposal &proposal, + const consensus::Round &round) override; - rxcpp::observable< - std::shared_ptr> - on_verified_proposal() override; + rxcpp::observable onVerifiedProposal() + override; - void process_verified_proposal( + void processVerifiedProposal( const std::shared_ptr - &verified_proposal_and_errors) override; + &verified_proposal_and_errors, + const consensus::Round &round) override; - rxcpp::observable> - on_block() override; + rxcpp::observable onBlock() override; private: // internal - rxcpp::subjects::subject< - std::shared_ptr> - notifier_; - rxcpp::subjects::subject> - block_notifier_; + rxcpp::subjects::subject notifier_; + rxcpp::subjects::subject block_notifier_; rxcpp::composite_subscription proposal_subscription_; rxcpp::composite_subscription verified_proposal_subscription_; diff --git a/irohad/simulator/verified_proposal_creator.hpp b/irohad/simulator/verified_proposal_creator.hpp index c770bf5875..87e5fcdde1 100644 --- a/irohad/simulator/verified_proposal_creator.hpp +++ b/irohad/simulator/verified_proposal_creator.hpp @@ -1,33 +1,25 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_VERIFIED_PROPOSAL_CREATOR_HPP #define IROHA_VERIFIED_PROPOSAL_CREATOR_HPP #include -#include "validation/stateful_validator_common.hpp" +#include "simulator/verified_proposal_creator_common.hpp" namespace shared_model { namespace interface { class Proposal; - } + } // namespace interface } // namespace shared_model namespace iroha { + namespace consensus { + struct Round; + } // namespace consensus + namespace simulator { /** @@ -36,19 +28,17 @@ namespace iroha { class VerifiedProposalCreator { public: /** - * Processing proposal for making stateful validation - * @param proposal - object for validation + * Execute stateful validation for given proposal and round */ - virtual void process_proposal( - const shared_model::interface::Proposal &proposal) = 0; + virtual void processProposal( + const shared_model::interface::Proposal &proposal, + const consensus::Round &round) = 0; /** - * Emit proposals that was verified by validation - * @return + * Emit proposals which were verified by stateful validator */ - virtual rxcpp::observable< - std::shared_ptr> - on_verified_proposal() = 0; + virtual rxcpp::observable + onVerifiedProposal() = 0; virtual ~VerifiedProposalCreator() = default; }; diff --git a/irohad/simulator/verified_proposal_creator_common.cpp b/irohad/simulator/verified_proposal_creator_common.cpp new file mode 100644 index 0000000000..a17c9ae490 --- /dev/null +++ b/irohad/simulator/verified_proposal_creator_common.cpp @@ -0,0 +1,19 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "simulator/verified_proposal_creator_common.hpp" + +#include "cryptography/hash.hpp" + +namespace iroha { + namespace simulator { + + std::shared_ptr + getVerifiedProposalUnsafe(const VerifiedProposalCreatorEvent &event) { + return *event.verified_proposal_result; + } + + } // namespace simulator +} // namespace iroha diff --git a/irohad/simulator/verified_proposal_creator_common.hpp b/irohad/simulator/verified_proposal_creator_common.hpp new file mode 100644 index 0000000000..f5af7477da --- /dev/null +++ b/irohad/simulator/verified_proposal_creator_common.hpp @@ -0,0 +1,32 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_VERIFIED_PROPOSAL_CREATOR_COMMON_HPP +#define IROHA_VERIFIED_PROPOSAL_CREATOR_COMMON_HPP + +#include +#include "consensus/round.hpp" +#include "validation/stateful_validator_common.hpp" + +namespace iroha { + namespace simulator { + + /** + * Event, which is emitted by verified proposal creator, when it receives + * and processes a proposal + */ + struct VerifiedProposalCreatorEvent { + boost::optional> + verified_proposal_result; + consensus::Round round; + }; + + std::shared_ptr + getVerifiedProposalUnsafe(const VerifiedProposalCreatorEvent &event); + + } // namespace simulator +} // namespace iroha + +#endif // IROHA_VERIFIED_PROPOSAL_CREATOR_COMMON_HPP diff --git a/irohad/synchronizer/CMakeLists.txt b/irohad/synchronizer/CMakeLists.txt index 2f57f08626..591e6dd56b 100644 --- a/irohad/synchronizer/CMakeLists.txt +++ b/irohad/synchronizer/CMakeLists.txt @@ -6,4 +6,5 @@ target_link_libraries(synchronizer ametsuchi rxcpp logger + gate_object ) diff --git a/irohad/synchronizer/impl/synchronizer_impl.cpp b/irohad/synchronizer/impl/synchronizer_impl.cpp index 6791f65038..17896e2650 100644 --- a/irohad/synchronizer/impl/synchronizer_impl.cpp +++ b/irohad/synchronizer/impl/synchronizer_impl.cpp @@ -9,7 +9,7 @@ #include "ametsuchi/block_query_factory.hpp" #include "ametsuchi/mutable_storage.hpp" -#include "common/bind.hpp" +#include "common/visitor.hpp" #include "interfaces/iroha_internal/block.hpp" namespace iroha { @@ -26,24 +26,55 @@ namespace iroha { block_query_factory_(std::move(block_query_factory)), block_loader_(std::move(block_loader)), log_(logger::log("synchronizer")) { - consensus_gate->on_commit().subscribe( - subscription_, - [&](network::Commit commit) { this->process_commit(commit); }); + consensus_gate->onOutcome().subscribe( + subscription_, [this](consensus::GateObject object) { + this->processOutcome(object); + }); + } + + void SynchronizerImpl::processOutcome(consensus::GateObject object) { + log_->info("processing consensus outcome"); + visit_in_place( + object, + [this](const consensus::PairValid &msg) { this->processNext(msg); }, + [this](const consensus::VoteOther &msg) { + this->processDifferent(msg); + }, + [this](const consensus::ProposalReject &msg) { + notifier_.get_subscriber().on_next(SynchronizationEvent{ + rxcpp::observable<>::empty< + std::shared_ptr>(), + SynchronizationOutcomeType::kReject, + msg.round}); + }, + [this](const consensus::BlockReject &msg) { + notifier_.get_subscriber().on_next(SynchronizationEvent{ + rxcpp::observable<>::empty< + std::shared_ptr>(), + SynchronizationOutcomeType::kReject, + msg.round}); + }, + [this](const consensus::AgreementOnNone &msg) { + notifier_.get_subscriber().on_next(SynchronizationEvent{ + rxcpp::observable<>::empty< + std::shared_ptr>(), + SynchronizationOutcomeType::kNothing, + msg.round}); + }); } SynchronizationEvent SynchronizerImpl::downloadMissingBlocks( - std::shared_ptr commit_message, + const consensus::VoteOther &msg, std::unique_ptr storage, const shared_model::interface::types::HeightType height) { - auto expected_height = commit_message->height(); + auto expected_height = msg.round.block_round; // while blocks are not loaded and not committed while (true) { // TODO andrei 17.10.18 IR-1763 Add delay strategy for loading blocks - for (const auto &peer_signature : commit_message->signatures()) { - auto network_chain = block_loader_->retrieveBlocks( - height, - shared_model::crypto::PublicKey(peer_signature.publicKey())); + for (const auto &public_key : msg.public_keys) { + auto network_chain = + block_loader_->retrieveBlocks(height, public_key); std::vector> blocks; network_chain.as_blocking().subscribe( @@ -57,18 +88,52 @@ namespace iroha { auto chain = rxcpp::observable<>::iterate(blocks, rxcpp::identity_immediate()); + if (blocks.back()->height() >= expected_height and validator_->validateAndApply(chain, *storage)) { mutable_factory_->commit(std::move(storage)); - return {chain, SynchronizationOutcomeType::kCommit}; + return {chain, SynchronizationOutcomeType::kCommit, msg.round}; } } } } - void SynchronizerImpl::process_commit(network::Commit commit_message) { - log_->info("processing commit"); + boost::optional> + SynchronizerImpl::getStorage() { + auto mutable_storage_var = mutable_factory_->createMutableStorage(); + if (auto e = + boost::get>(&mutable_storage_var)) { + log_->error("could not create mutable storage: {}", e->error); + return {}; + } + return {std::move( + boost::get< + expected::Value>>( + &mutable_storage_var) + ->value)}; + } + + void SynchronizerImpl::processNext(const consensus::PairValid &msg) { + log_->info("at handleNext"); + if (not mutable_factory_->commitPrepared(*msg.block)) { + auto opt_storage = getStorage(); + if (opt_storage == boost::none) { + return; + } + std::unique_ptr storage = + std::move(opt_storage.value()); + storage->apply(*msg.block); + mutable_factory_->commit(std::move(storage)); + } + notifier_.get_subscriber().on_next( + SynchronizationEvent{rxcpp::observable<>::just(msg.block), + SynchronizationOutcomeType::kCommit, + msg.round}); + } + + void SynchronizerImpl::processDifferent(const consensus::VoteOther &msg) { + log_->info("at handleDifferent"); shared_model::interface::types::HeightType top_block_height{0}; if (auto block_query = block_query_factory_->createBlockQuery()) { @@ -79,51 +144,21 @@ namespace iroha { return; } - const auto &block = commit_message.block; - - if (top_block_height >= block->height()) { + if (top_block_height >= msg.round.block_round) { log_->info( "Storage is already in synchronized state. Top block height is {}", top_block_height); return; } - auto commit = rxcpp::observable<>::just(block); - - // if already voted for commit, try to apply prepared block - if (commit_message.type == network::PeerVotedFor::kThisBlock) { - bool block_applied = mutable_factory_->commitPrepared(*block); - if (block_applied) { - notifier_.get_subscriber().on_next(SynchronizationEvent{ - commit, SynchronizationOutcomeType::kCommit}); - return; - } - } - - auto mutable_storage_var = mutable_factory_->createMutableStorage(); - if (auto e = - boost::get>(&mutable_storage_var)) { - log_->error("could not create mutable storage: {}", e->error); + auto opt_storage = getStorage(); + if (opt_storage == boost::none) { return; } - auto storage = - std::move( - boost::get< - expected::Value>>( - mutable_storage_var)) - .value; - - SynchronizationEvent result; - - if (validator_->validateAndApply(commit, *storage)) { - mutable_factory_->commit(std::move(storage)); - - result = {commit, SynchronizationOutcomeType::kCommit}; - } else { - result = downloadMissingBlocks( - std::move(block), std::move(storage), top_block_height); - } - + std::unique_ptr storage = + std::move(opt_storage.value()); + SynchronizationEvent result = + downloadMissingBlocks(msg, std::move(storage), top_block_height); notifier_.get_subscriber().on_next(result); } diff --git a/irohad/synchronizer/impl/synchronizer_impl.hpp b/irohad/synchronizer/impl/synchronizer_impl.hpp index 264bb356bf..bd0d4458ba 100644 --- a/irohad/synchronizer/impl/synchronizer_impl.hpp +++ b/irohad/synchronizer/impl/synchronizer_impl.hpp @@ -6,11 +6,12 @@ #ifndef IROHA_SYNCHRONIZER_IMPL_HPP #define IROHA_SYNCHRONIZER_IMPL_HPP +#include "synchronizer/synchronizer.hpp" + #include "ametsuchi/mutable_factory.hpp" #include "logger/logger.hpp" #include "network/block_loader.hpp" #include "network/consensus_gate.hpp" -#include "synchronizer/synchronizer.hpp" #include "validation/chain_validator.hpp" namespace iroha { @@ -32,8 +33,7 @@ namespace iroha { ~SynchronizerImpl() override; - void process_commit(network::Commit commit_message) override; - + void processOutcome(consensus::GateObject object) override; rxcpp::observable on_commit_chain() override; private: @@ -47,10 +47,15 @@ namespace iroha { * synchronized */ SynchronizationEvent downloadMissingBlocks( - std::shared_ptr commit_message, + const consensus::VoteOther &msg, std::unique_ptr storage, const shared_model::interface::types::HeightType height); + void processNext(const consensus::PairValid &msg); + void processDifferent(const consensus::VoteOther &msg); + + boost::optional> getStorage(); + std::shared_ptr validator_; std::shared_ptr mutable_factory_; std::shared_ptr block_query_factory_; diff --git a/irohad/synchronizer/synchronizer.hpp b/irohad/synchronizer/synchronizer.hpp index 320ab12b59..de3dcfe6f4 100644 --- a/irohad/synchronizer/synchronizer.hpp +++ b/irohad/synchronizer/synchronizer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SYNCHRONIZER_HPP @@ -20,14 +8,10 @@ #include -#include "network/peer_communication_service.hpp" +#include "consensus/gate_object.hpp" #include "synchronizer/synchronizer_common.hpp" namespace iroha { - namespace network { - struct Commit; - } - namespace synchronizer { /** * Synchronizer is interface for fetching missed blocks @@ -35,9 +19,9 @@ namespace iroha { class Synchronizer { public: /** - * Processing last committed block + * Processing entry point for consensus outcome */ - virtual void process_commit(network::Commit commit_message) = 0; + virtual void processOutcome(consensus::GateObject object) = 0; /** * After synchronization this observable emits zero or more blocks plus diff --git a/irohad/synchronizer/synchronizer_common.hpp b/irohad/synchronizer/synchronizer_common.hpp index bf4ae8a32c..de339b2d99 100644 --- a/irohad/synchronizer/synchronizer_common.hpp +++ b/irohad/synchronizer/synchronizer_common.hpp @@ -10,6 +10,7 @@ #include +#include "consensus/round.hpp" #include "interfaces/iroha_internal/block.hpp" namespace iroha { @@ -27,15 +28,18 @@ namespace iroha { * Outcome, which was decided by synchronizer based on consensus result and * current local ledger state */ - enum class SynchronizationOutcomeType { kCommit, kReject }; + enum class SynchronizationOutcomeType { kCommit, kReject, kNothing }; /** * Event, which is emitted by synchronizer, when it receives and processes * commit */ struct SynchronizationEvent { + // TODO andrei 08.11.2018 IR-1852 Rework blocks collection from + // synchronizer with iterable Chain synced_blocks; SynchronizationOutcomeType sync_outcome; + consensus::Round round; }; } // namespace synchronizer diff --git a/irohad/torii/processor/CMakeLists.txt b/irohad/torii/processor/CMakeLists.txt index 64629cba24..121455b4fd 100644 --- a/irohad/torii/processor/CMakeLists.txt +++ b/irohad/torii/processor/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + add_library(processors impl/transaction_processor_impl.cpp impl/query_processor_impl.cpp @@ -11,4 +14,5 @@ target_link_libraries(processors PUBLIC shared_model_proto_builders status_bus common + verified_proposal_creator_common ) diff --git a/irohad/torii/processor/impl/transaction_processor_impl.cpp b/irohad/torii/processor/impl/transaction_processor_impl.cpp index 2dac3757af..12fa604725 100644 --- a/irohad/torii/processor/impl/transaction_processor_impl.cpp +++ b/irohad/torii/processor/impl/transaction_processor_impl.cpp @@ -54,9 +54,14 @@ namespace iroha { status_factory_(std::move(status_factory)), log_(logger::log("TxProcessor")) { // process stateful validation results - pcs_->on_verified_proposal().subscribe( - [this](std::shared_ptr - proposal_and_errors) { + pcs_->onVerifiedProposal().subscribe( + [this](const simulator::VerifiedProposalCreatorEvent &event) { + if (not event.verified_proposal_result) { + return; + } + + const auto &proposal_and_errors = getVerifiedProposalUnsafe(event); + // notify about failed txs const auto &errors = proposal_and_errors->rejected_transactions; std::lock_guard lock(notifier_mutex_); diff --git a/irohad/validation/stateful_validator_common.hpp b/irohad/validation/stateful_validator_common.hpp index 6735ca5c24..d48710e338 100644 --- a/irohad/validation/stateful_validator_common.hpp +++ b/irohad/validation/stateful_validator_common.hpp @@ -57,7 +57,7 @@ namespace iroha { // TODO mboldyrev 27.10.2018: create a special class for VerifiedProposal // IR-1849 which will include the rejected tx hashes struct VerifiedProposalAndErrors { - std::unique_ptr verified_proposal; + std::shared_ptr verified_proposal; TransactionsErrors rejected_transactions; }; diff --git a/libs/common/delay.hpp b/libs/common/delay.hpp new file mode 100644 index 0000000000..1a4fd75ebb --- /dev/null +++ b/libs/common/delay.hpp @@ -0,0 +1,188 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_DELAY_HPP +#define IROHA_DELAY_HPP + +#include + +namespace iroha { + + /** + * This class is mostly the same as rxcpp::operators::delay, + * the only change is that it accepts a selector lambda which generates + * a duration based on observable value instead of a fixed duration + * Return an observable that emits each item emitted by the source observable + * after the specified delay + * Delay is generated with selector from the last received value + * @tparam T value type + * @tparam Selector the type of the transforming function + * which returns time interval + * @tparam Coordination the type of the scheduler + */ + template + struct delay { + typedef rxcpp::util::decay_t source_value_type; + typedef rxcpp::util::decay_t coordination_type; + typedef typename coordination_type::coordinator_type coordinator_type; + typedef rxcpp::util::decay_t select_type; + + struct delay_values { + delay_values(select_type s, coordination_type c) + : selector(std::move(s)), coordination(c) {} + + select_type selector; + coordination_type coordination; + }; + delay_values initial; + + delay(select_type s, coordination_type coordination) + : initial(std::move(s), coordination) {} + + template + struct delay_observer { + typedef delay_observer this_type; + typedef rxcpp::util::decay_t value_type; + typedef rxcpp::util::decay_t dest_type; + typedef rxcpp::observer observer_type; + + struct delay_subscriber_values : public delay_values { + delay_subscriber_values(rxcpp::composite_subscription cs, + dest_type d, + delay_values v, + coordinator_type c) + : delay_values(v), + cs(std::move(cs)), + dest(std::move(d)), + coordinator(std::move(c)), + worker(coordinator.get_worker()), + expected(worker.now()) {} + + rxcpp::composite_subscription cs; + dest_type dest; + coordinator_type coordinator; + rxcpp::schedulers::worker worker; + rxcpp::schedulers::scheduler::clock_type::time_point expected; + }; + std::shared_ptr state; + + delay_observer(rxcpp::composite_subscription cs, + dest_type d, + delay_values v, + coordinator_type c) + : state(std::make_shared( + delay_subscriber_values( + std::move(cs), std::move(d), v, std::move(c)))) { + auto localState = state; + + auto disposer = [=](const rxcpp::schedulers::schedulable &) { + localState->cs.unsubscribe(); + localState->dest.unsubscribe(); + localState->worker.unsubscribe(); + }; + auto selectedDisposer = on_exception( + [&]() { return localState->coordinator.act(disposer); }, + localState->dest); + if (selectedDisposer.empty()) { + return; + } + + localState->dest.add( + [=]() { localState->worker.schedule(selectedDisposer.get()); }); + localState->cs.add( + [=]() { localState->worker.schedule(selectedDisposer.get()); }); + } + + template + void on_next(Value &&v) const { + auto localState = state; + + auto selected = on_exception( + [&]() { return localState->selector(std::forward(v)); }, + localState->dest); + if (selected.empty()) { + return; + } + + auto work = [v, localState](const rxcpp::schedulers::schedulable &) { + localState->dest.on_next(v); + }; + auto selectedWork = + on_exception([&]() { return localState->coordinator.act(work); }, + localState->dest); + if (selectedWork.empty()) { + return; + } + localState->worker.schedule(localState->worker.now() + selected.get(), + selectedWork.get()); + } + + void on_error(std::exception_ptr e) const { + auto localState = state; + auto work = [e, localState](const rxcpp::schedulers::schedulable &) { + localState->dest.on_error(e); + }; + auto selectedWork = + on_exception([&]() { return localState->coordinator.act(work); }, + localState->dest); + if (selectedWork.empty()) { + return; + } + localState->worker.schedule(selectedWork.get()); + } + + void on_completed() const { + auto localState = state; + auto work = [localState](const rxcpp::schedulers::schedulable &) { + localState->dest.on_completed(); + }; + auto selectedWork = + on_exception([&]() { return localState->coordinator.act(work); }, + localState->dest); + if (selectedWork.empty()) { + return; + } + localState->worker.schedule(selectedWork.get()); + } + + static rxcpp::subscriber make(dest_type d, + delay_values v) { + auto cs = rxcpp::composite_subscription(); + auto coordinator = v.coordination.create_coordinator(); + + return rxcpp::make_subscriber( + cs, + observer_type(this_type( + cs, std::move(d), std::move(v), std::move(coordinator)))); + } + }; + + template + auto operator()(Subscriber dest) const + -> decltype(delay_observer::make(std::move(dest), + initial)) { + return delay_observer::make(std::move(dest), initial); + } + }; + + template , + class Duration = decltype(std::declval()( + (std::declval>()))), + class Enabled = rxcpp::util::enable_if_all_true_type_t< + rxcpp::is_coordination, + rxcpp::util::is_duration>, + class Delay = + delay>> + static auto makeDelay(Selector &&s, Coordination &&cn) { + return Delay(std::forward(s), std::forward(cn)); + } + +} // namespace iroha + +#endif // IROHA_DELAY_HPP diff --git a/libs/common/timeout.hpp b/libs/common/timeout.hpp index fb66605758..0581abd9cd 100644 --- a/libs/common/timeout.hpp +++ b/libs/common/timeout.hpp @@ -209,7 +209,7 @@ namespace iroha { timeout>> static auto makeTimeout(Selector &&s, Coordination &&cn) { return Timeout(std::forward(s), std::forward(cn)); - }; + } } // namespace iroha diff --git a/libs/logger/logger.hpp b/libs/logger/logger.hpp index 110ebbc671..03e0404a76 100644 --- a/libs/logger/logger.hpp +++ b/libs/logger/logger.hpp @@ -10,9 +10,6 @@ #include // for std::accumulate #include -#include -#include - /// Allows to log objects, which have toString() method without calling it, e.g. /// log.info("{}", myObject) template @@ -21,6 +18,9 @@ auto operator<<(StreamType &os, const T &object) return os << object.toString(); } +#include +#include + namespace logger { using Logger = std::shared_ptr; diff --git a/shared_model/backend/protobuf/CMakeLists.txt b/shared_model/backend/protobuf/CMakeLists.txt index 63eb61b082..52d1db960b 100644 --- a/shared_model/backend/protobuf/CMakeLists.txt +++ b/shared_model/backend/protobuf/CMakeLists.txt @@ -44,6 +44,7 @@ add_library(shared_model_proto_backend queries/impl/proto_get_pending_transactions.cpp queries/impl/proto_blocks_query.cpp queries/impl/proto_query_payload_meta.cpp + queries/impl/proto_tx_pagination_meta.cpp ) if (IROHA_ROOT_PROJECT) @@ -58,6 +59,7 @@ if (IROHA_ROOT_PROJECT) query_responses/impl/proto_roles_response.cpp query_responses/impl/proto_signatories_response.cpp query_responses/impl/proto_transaction_response.cpp + query_responses/impl/proto_transaction_page_response.cpp query_responses/impl/proto_block_query_response.cpp query_responses/impl/proto_block_response.cpp query_responses/impl/proto_block_error_response.cpp diff --git a/shared_model/backend/protobuf/block.hpp b/shared_model/backend/protobuf/block.hpp index 97c7bff50e..092c75c572 100644 --- a/shared_model/backend/protobuf/block.hpp +++ b/shared_model/backend/protobuf/block.hpp @@ -27,7 +27,7 @@ namespace shared_model { namespace proto { class Block final : public interface::Block { public: - using TransportType = iroha::protocol::Block; + using TransportType = iroha::protocol::Block_v1; Block(Block &&o) noexcept; Block &operator=(Block &&o) noexcept = default; @@ -59,7 +59,7 @@ namespace shared_model { typename interface::Block::ModelType *clone() const override; - const iroha::protocol::Block &getTransport() const; + const iroha::protocol::Block_v1 &getTransport() const; ~Block() override; diff --git a/shared_model/backend/protobuf/impl/block.cpp b/shared_model/backend/protobuf/impl/block.cpp index 3770ae1f3b..639468075c 100644 --- a/shared_model/backend/protobuf/impl/block.cpp +++ b/shared_model/backend/protobuf/impl/block.cpp @@ -23,7 +23,7 @@ namespace shared_model { Impl &operator=(Impl &&o) noexcept = delete; TransportType proto_; - iroha::protocol::Block::Payload &payload_{*proto_.mutable_payload()}; + iroha::protocol::Block_v1::Payload &payload_{*proto_.mutable_payload()}; std::vector transactions_{[this] { return std::vector( @@ -134,7 +134,7 @@ namespace shared_model { return impl_->payload_blob_; } - const iroha::protocol::Block &Block::getTransport() const { + const iroha::protocol::Block_v1 &Block::getTransport() const { return impl_->proto_; } diff --git a/shared_model/backend/protobuf/impl/proto_block_factory.cpp b/shared_model/backend/protobuf/impl/proto_block_factory.cpp index 49ee9db8b6..36b1b2cab1 100644 --- a/shared_model/backend/protobuf/impl/proto_block_factory.cpp +++ b/shared_model/backend/protobuf/impl/proto_block_factory.cpp @@ -11,8 +11,12 @@ using namespace shared_model::proto; ProtoBlockFactory::ProtoBlockFactory( std::unique_ptr> validator) - : validator_(std::move(validator)){}; + shared_model::interface::Block>> interface_validator, + std::unique_ptr< + shared_model::validation::AbstractValidator> + proto_validator) + : interface_validator_{std::move(interface_validator)}, + proto_validator_{std::move(proto_validator)} {} std::unique_ptr ProtoBlockFactory::unsafeCreateBlock( @@ -21,7 +25,7 @@ ProtoBlockFactory::unsafeCreateBlock( interface::types::TimestampType created_time, const interface::types::TransactionsCollectionType &txs, const interface::types::HashCollectionType &rejected_hashes) { - iroha::protocol::Block block; + iroha::protocol::Block_v1 block; auto *block_payload = block.mutable_payload(); block_payload->set_height(height); block_payload->set_prev_block_hash(crypto::toBinaryString(prev_hash)); @@ -49,12 +53,15 @@ ProtoBlockFactory::unsafeCreateBlock( iroha::expected::Result, std::string> ProtoBlockFactory::createBlock(iroha::protocol::Block block) { - std::unique_ptr proto_block = - std::make_unique(std::move(block)); + if (auto errors = proto_validator_->validate(block)) { + return iroha::expected::makeError(errors.reason()); + } - auto errors = validator_->validate(*proto_block); - if (errors) { + std::unique_ptr proto_block = + std::make_unique(std::move(block.block_v1())); + if (auto errors = interface_validator_->validate(*proto_block)) { return iroha::expected::makeError(errors.reason()); } + return iroha::expected::makeValue(std::move(proto_block)); } diff --git a/shared_model/backend/protobuf/impl/proto_block_json_converter.cpp b/shared_model/backend/protobuf/impl/proto_block_json_converter.cpp index 89aae89ae2..e428e10fb8 100644 --- a/shared_model/backend/protobuf/impl/proto_block_json_converter.cpp +++ b/shared_model/backend/protobuf/impl/proto_block_json_converter.cpp @@ -16,7 +16,9 @@ using namespace shared_model::proto; iroha::expected::Result ProtoBlockJsonConverter::serialize(const interface::Block &block) const noexcept { - const auto &proto_block = static_cast(block).getTransport(); + const auto &proto_block_v1 = static_cast(block).getTransport(); + iroha::protocol::Block proto_block; + *proto_block.mutable_block_v1() = proto_block_v1; std::string result; auto status = google::protobuf::util::MessageToJsonString(proto_block, &result); @@ -36,6 +38,6 @@ ProtoBlockJsonConverter::deserialize( return iroha::expected::makeError(status.error_message()); } std::unique_ptr result = - std::make_unique(std::move(block)); + std::make_unique(std::move(block.block_v1())); return iroha::expected::makeValue(std::move(result)); } diff --git a/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp b/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp index 4a5a410222..b9ee917731 100644 --- a/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp +++ b/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp @@ -202,6 +202,54 @@ shared_model::proto::ProtoQueryResponseFactory::createTransactionsResponse( query_hash); } +std::unique_ptr +shared_model::proto::ProtoQueryResponseFactory::createTransactionsPageResponse( + std::vector> + transactions, + const crypto::Hash &next_tx_hash, + interface::types::TransactionsNumberType all_transactions_size, + const crypto::Hash &query_hash) const { + return createQueryResponse( + [transactions = std::move(transactions), + &next_tx_hash, + &all_transactions_size]( + iroha::protocol::QueryResponse &protocol_query_response) { + auto *protocol_specific_response = + protocol_query_response.mutable_transactions_page_response(); + for (const auto &tx : transactions) { + *protocol_specific_response->add_transactions() = + static_cast(tx.get()) + ->getTransport(); + } + protocol_specific_response->set_next_tx_hash(next_tx_hash.hex()); + protocol_specific_response->set_all_transactions_size( + all_transactions_size); + }, + query_hash); +} + +std::unique_ptr +shared_model::proto::ProtoQueryResponseFactory::createTransactionsPageResponse( + std::vector> + transactions, + interface::types::TransactionsNumberType all_transactions_size, + const crypto::Hash &query_hash) const { + return createQueryResponse( + [transactions = std::move(transactions), &all_transactions_size]( + iroha::protocol::QueryResponse &protocol_query_response) { + iroha::protocol::TransactionsPageResponse *protocol_specific_response = + protocol_query_response.mutable_transactions_page_response(); + for (const auto &tx : transactions) { + *protocol_specific_response->add_transactions() = + static_cast(tx.get()) + ->getTransport(); + } + protocol_specific_response->set_all_transactions_size( + all_transactions_size); + }, + query_hash); +} + std::unique_ptr shared_model::proto::ProtoQueryResponseFactory::createAssetResponse( const interface::types::AssetIdType asset_id, @@ -266,7 +314,7 @@ shared_model::proto::ProtoQueryResponseFactory::createBlockQueryResponse( &protocol_query_response) { iroha::protocol::BlockResponse *protocol_specific_response = protocol_query_response.mutable_block_response(); - *protocol_specific_response->mutable_block() = + *protocol_specific_response->mutable_block()->mutable_block_v1() = static_cast(block.get())->getTransport(); }); } diff --git a/shared_model/backend/protobuf/proto_block_factory.hpp b/shared_model/backend/protobuf/proto_block_factory.hpp index 4a07389a33..61dee679de 100644 --- a/shared_model/backend/protobuf/proto_block_factory.hpp +++ b/shared_model/backend/protobuf/proto_block_factory.hpp @@ -19,9 +19,11 @@ namespace shared_model { */ class ProtoBlockFactory : public interface::UnsafeBlockFactory { public: - explicit ProtoBlockFactory( + ProtoBlockFactory( std::unique_ptr> validator); + shared_model::interface::Block>> interface_validator, + std::unique_ptr> proto_validator); std::unique_ptr unsafeCreateBlock( interface::types::HeightType height, @@ -34,7 +36,7 @@ namespace shared_model { * Create block variant * * @param block - proto block from which block variant is created - * @return BlockVariant with block. + * @return Pointer to block. * Error if block is invalid */ iroha::expected::Result, std::string> @@ -43,7 +45,10 @@ namespace shared_model { private: std::unique_ptr> - validator_; + interface_validator_; + std::unique_ptr< + shared_model::validation::AbstractValidator> + proto_validator_; }; } // namespace proto } // namespace shared_model diff --git a/shared_model/backend/protobuf/proto_query_response_factory.hpp b/shared_model/backend/protobuf/proto_query_response_factory.hpp index f524d845a6..fab03233f7 100644 --- a/shared_model/backend/protobuf/proto_query_response_factory.hpp +++ b/shared_model/backend/protobuf/proto_query_response_factory.hpp @@ -46,6 +46,19 @@ namespace shared_model { transactions, const crypto::Hash &query_hash) const override; + std::unique_ptr createTransactionsPageResponse( + std::vector> + transactions, + const crypto::Hash &next_tx_hash, + interface::types::TransactionsNumberType all_transactions_size, + const crypto::Hash &query_hash) const override; + + std::unique_ptr createTransactionsPageResponse( + std::vector> + transactions, + interface::types::TransactionsNumberType all_transactions_size, + const crypto::Hash &query_hash) const override; + std::unique_ptr createAssetResponse( interface::types::AssetIdType asset_id, interface::types::DomainIdType domain_id, diff --git a/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp b/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp index 52b78415c5..b4f1f73fa3 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp @@ -12,15 +12,15 @@ namespace shared_model { template BlocksQuery::BlocksQuery(BlocksQueryType &&query) : CopyableProto(std::forward(query)), - blob_{[this] { return makeBlob(*proto_); }}, - payload_{[this] { return makeBlob(proto_->meta()); }}, + blob_{makeBlob(*proto_)}, + payload_{makeBlob(proto_->meta())}, signatures_{[this] { SignatureSetType set; if (proto_->has_signature()) { set.emplace(proto_->signature()); } return set; - }} {} + }()} {} template BlocksQuery::BlocksQuery(BlocksQuery::TransportType &); template BlocksQuery::BlocksQuery(const BlocksQuery::TransportType &); @@ -41,15 +41,15 @@ namespace shared_model { } const interface::types::BlobType &BlocksQuery::blob() const { - return *blob_; + return blob_; } const interface::types::BlobType &BlocksQuery::payload() const { - return *payload_; + return payload_; } interface::types::SignatureRangeType BlocksQuery::signatures() const { - return *signatures_; + return signatures_; } bool BlocksQuery::addSignature(const crypto::Signed &signed_blob, @@ -61,6 +61,8 @@ namespace shared_model { auto sig = proto_->mutable_signature(); sig->set_signature(crypto::toBinaryString(signed_blob)); sig->set_public_key(crypto::toBinaryString(public_key)); + // TODO: nickaleks IR-120 12.12.2018 remove set + signatures_.emplace(proto_->signature()); return true; } diff --git a/shared_model/backend/protobuf/queries/impl/proto_get_account_asset_transactions.cpp b/shared_model/backend/protobuf/queries/impl/proto_get_account_asset_transactions.cpp index 74abccd5e9..fee9e577d6 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_get_account_asset_transactions.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_get_account_asset_transactions.cpp @@ -5,6 +5,8 @@ #include "backend/protobuf/queries/proto_get_account_asset_transactions.hpp" +#include "backend/protobuf/queries/proto_tx_pagination_meta.hpp" + namespace shared_model { namespace proto { @@ -12,7 +14,8 @@ namespace shared_model { GetAccountAssetTransactions::GetAccountAssetTransactions(QueryType &&query) : CopyableProto(std::forward(query)), account_asset_transactions_{ - proto_->payload().get_account_asset_transactions()} {} + proto_->payload().get_account_asset_transactions()}, + pagination_meta_{account_asset_transactions_.pagination_meta()} {} template GetAccountAssetTransactions::GetAccountAssetTransactions( GetAccountAssetTransactions::TransportType &); @@ -39,5 +42,10 @@ namespace shared_model { return account_asset_transactions_.asset_id(); } + const interface::TxPaginationMeta & + GetAccountAssetTransactions::paginationMeta() const { + return pagination_meta_; + } + } // namespace proto } // namespace shared_model diff --git a/shared_model/backend/protobuf/queries/impl/proto_get_account_transactions.cpp b/shared_model/backend/protobuf/queries/impl/proto_get_account_transactions.cpp index 91da415aaf..42951cb81c 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_get_account_transactions.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_get_account_transactions.cpp @@ -5,13 +5,16 @@ #include "backend/protobuf/queries/proto_get_account_transactions.hpp" +#include "backend/protobuf/queries/proto_tx_pagination_meta.hpp" + namespace shared_model { namespace proto { template GetAccountTransactions::GetAccountTransactions(QueryType &&query) : CopyableProto(std::forward(query)), - account_transactions_{proto_->payload().get_account_transactions()} {} + account_transactions_{proto_->payload().get_account_transactions()}, + pagination_meta_{account_transactions_.pagination_meta()} {} template GetAccountTransactions::GetAccountTransactions( GetAccountTransactions::TransportType &); @@ -33,5 +36,10 @@ namespace shared_model { return account_transactions_.account_id(); } + const interface::TxPaginationMeta &GetAccountTransactions::paginationMeta() + const { + return pagination_meta_; + } + } // namespace proto } // namespace shared_model diff --git a/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp b/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp index d4bb9ae327..58ffbd0f12 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp @@ -13,17 +13,15 @@ namespace shared_model { GetTransactions::GetTransactions(QueryType &&query) : CopyableProto(std::forward(query)), get_transactions_{proto_->payload().get_transactions()}, - transaction_hashes_{[this] { - return boost::accumulate(get_transactions_.tx_hashes(), - TransactionHashesType{}, - [](auto &&acc, const auto &hash) { - acc.emplace_back(hash); - return std::forward(acc); - }); - }} {} - - template GetTransactions::GetTransactions( - GetTransactions::TransportType &); + transaction_hashes_{ + boost::accumulate(get_transactions_.tx_hashes(), + TransactionHashesType{}, + [](auto &&acc, const auto &hash) { + acc.emplace_back(hash); + return std::forward(acc); + })} {} + + template GetTransactions::GetTransactions(GetTransactions::TransportType &); template GetTransactions::GetTransactions( const GetTransactions::TransportType &); template GetTransactions::GetTransactions( @@ -37,7 +35,7 @@ namespace shared_model { const GetTransactions::TransactionHashesType & GetTransactions::transactionHashes() const { - return *transaction_hashes_; + return transaction_hashes_; } } // namespace proto diff --git a/shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp b/shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp new file mode 100644 index 0000000000..c2673cbd39 --- /dev/null +++ b/shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp @@ -0,0 +1,36 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "backend/protobuf/queries/proto_tx_pagination_meta.hpp" + +#include "cryptography/hash.hpp" + +namespace types = shared_model::interface::types; + +using namespace shared_model::proto; + +TxPaginationMeta::TxPaginationMeta(const TransportType &query) + : CopyableProto(query) {} + +TxPaginationMeta::TxPaginationMeta(TransportType &&query) + : CopyableProto(std::move(query)) {} + +TxPaginationMeta::TxPaginationMeta(const TxPaginationMeta &o) + : TxPaginationMeta(*o.proto_) {} + +TxPaginationMeta::TxPaginationMeta(TxPaginationMeta &&o) noexcept + : CopyableProto(std::move(*o.proto_)) {} + +types::TransactionsNumberType TxPaginationMeta::pageSize() const { + return proto_->page_size(); +} + +boost::optional TxPaginationMeta::firstTxHash() const { + if (proto_->opt_first_tx_hash_case() + == TransportType::OptFirstTxHashCase::OPT_FIRST_TX_HASH_NOT_SET) { + return boost::none; + } + return types::HashType(proto_->first_tx_hash()); +} diff --git a/shared_model/backend/protobuf/queries/proto_blocks_query.hpp b/shared_model/backend/protobuf/queries/proto_blocks_query.hpp index 9700804b2b..f4469ef493 100644 --- a/shared_model/backend/protobuf/queries/proto_blocks_query.hpp +++ b/shared_model/backend/protobuf/queries/proto_blocks_query.hpp @@ -9,7 +9,6 @@ #include "backend/protobuf/common_objects/signature.hpp" #include "interfaces/queries/blocks_query.hpp" #include "queries.pb.h" -#include "utils/lazy_initializer.hpp" #include "backend/protobuf/util.hpp" namespace shared_model { @@ -17,10 +16,6 @@ namespace shared_model { class BlocksQuery FINAL : public CopyableProto { - private: - template - using Lazy = detail::LazyInitializer; - public: template explicit BlocksQuery(BlocksQueryType &&query); @@ -47,12 +42,11 @@ namespace shared_model { private: // ------------------------------| fields |------------------------------- - // lazy - const Lazy blob_; + const interface::types::BlobType blob_; - const Lazy payload_; + const interface::types::BlobType payload_; - const Lazy> signatures_; + SignatureSetType signatures_; }; } // namespace proto } // namespace shared_model diff --git a/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp b/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp index 72661a4491..fc780aa283 100644 --- a/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp @@ -19,6 +19,7 @@ #define IROHA_GET_ACCOUNT_ASSET_TRANSACTIONS_H #include "backend/protobuf/common_objects/trivial_proto.hpp" +#include "backend/protobuf/queries/proto_tx_pagination_meta.hpp" #include "interfaces/queries/get_account_asset_transactions.hpp" #include "queries.pb.h" @@ -40,11 +41,14 @@ namespace shared_model { const interface::types::AssetIdType &assetId() const override; + const interface::TxPaginationMeta &paginationMeta() const override; + private: // ------------------------------| fields |------------------------------- const iroha::protocol::GetAccountAssetTransactions &account_asset_transactions_; + const TxPaginationMeta pagination_meta_; }; } // namespace proto diff --git a/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp b/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp index 604900ad74..25f78a21f2 100644 --- a/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp @@ -19,6 +19,7 @@ #define IROHA_GET_ACCOUNT_TRANSACTIONS_H #include "backend/protobuf/common_objects/trivial_proto.hpp" +#include "backend/protobuf/queries/proto_tx_pagination_meta.hpp" #include "interfaces/queries/get_account_transactions.hpp" #include "queries.pb.h" @@ -38,10 +39,13 @@ namespace shared_model { const interface::types::AccountIdType &accountId() const override; + const interface::TxPaginationMeta &paginationMeta() const override; + private: // ------------------------------| fields |------------------------------- const iroha::protocol::GetAccountTransactions &account_transactions_; + const TxPaginationMeta pagination_meta_; }; } // namespace proto diff --git a/shared_model/backend/protobuf/queries/proto_get_transactions.hpp b/shared_model/backend/protobuf/queries/proto_get_transactions.hpp index 296af53075..6240217d4e 100644 --- a/shared_model/backend/protobuf/queries/proto_get_transactions.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_transactions.hpp @@ -45,10 +45,7 @@ namespace shared_model { const iroha::protocol::GetTransactions &get_transactions_; - template - using Lazy = detail::LazyInitializer; - - const Lazy transaction_hashes_; + const TransactionHashesType transaction_hashes_; }; } // namespace proto diff --git a/shared_model/backend/protobuf/queries/proto_tx_pagination_meta.hpp b/shared_model/backend/protobuf/queries/proto_tx_pagination_meta.hpp new file mode 100644 index 0000000000..e01fa4d0c9 --- /dev/null +++ b/shared_model/backend/protobuf/queries/proto_tx_pagination_meta.hpp @@ -0,0 +1,35 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_SHARED_PROTO_MODEL_QUERY_TX_PAGINATION_META_HPP +#define IROHA_SHARED_PROTO_MODEL_QUERY_TX_PAGINATION_META_HPP + +#include "backend/protobuf/common_objects/trivial_proto.hpp" +#include "interfaces/common_objects/types.hpp" +#include "interfaces/queries/tx_pagination_meta.hpp" +#include "queries.pb.h" + +namespace shared_model { + namespace proto { + + /// Provides query metadata for any transaction list pagination. + class TxPaginationMeta final + : public CopyableProto { + public: + explicit TxPaginationMeta(const TransportType &query); + explicit TxPaginationMeta(TransportType &&query); + TxPaginationMeta(const TxPaginationMeta &o); + TxPaginationMeta(TxPaginationMeta &&o) noexcept; + + interface::types::TransactionsNumberType pageSize() const override; + + boost::optional firstTxHash() const override; + }; + } // namespace proto +} // namespace shared_model + +#endif // IROHA_SHARED_PROTO_MODEL_QUERY_TX_PAGINATION_META_HPP diff --git a/shared_model/backend/protobuf/query_responses/impl/proto_block_response.cpp b/shared_model/backend/protobuf/query_responses/impl/proto_block_response.cpp index 5aed730253..5f0b9904a4 100644 --- a/shared_model/backend/protobuf/query_responses/impl/proto_block_response.cpp +++ b/shared_model/backend/protobuf/query_responses/impl/proto_block_response.cpp @@ -12,7 +12,7 @@ namespace shared_model { BlockResponse::BlockResponse(QueryResponseType &&queryResponse) : CopyableProto(std::forward(queryResponse)), block_response_{proto_->block_response()}, - block_{block_response_.block()} {} + block_{block_response_.block().block_v1()} {} template BlockResponse::BlockResponse(BlockResponse::TransportType &); template BlockResponse::BlockResponse(const BlockResponse::TransportType &); diff --git a/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp b/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp index cc44d99a55..20d13e5543 100644 --- a/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp +++ b/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp @@ -13,6 +13,7 @@ #include "backend/protobuf/query_responses/proto_role_permissions_response.hpp" #include "backend/protobuf/query_responses/proto_roles_response.hpp" #include "backend/protobuf/query_responses/proto_signatories_response.hpp" +#include "backend/protobuf/query_responses/proto_transactions_page_response.hpp" #include "backend/protobuf/query_responses/proto_transaction_response.hpp" #include "common/byteutils.hpp" #include "utils/variant_deserializer.hpp" @@ -28,7 +29,8 @@ namespace { shared_model::proto::TransactionsResponse, shared_model::proto::AssetResponse, shared_model::proto::RolesResponse, - shared_model::proto::RolePermissionsResponse>; + shared_model::proto::RolePermissionsResponse, + shared_model::proto::TransactionsPageResponse>; /// list of types in variant using ProtoQueryResponseListType = ProtoQueryResponseVariantType::types; diff --git a/shared_model/backend/protobuf/query_responses/impl/proto_transaction_page_response.cpp b/shared_model/backend/protobuf/query_responses/impl/proto_transaction_page_response.cpp new file mode 100644 index 0000000000..4fcc81a84f --- /dev/null +++ b/shared_model/backend/protobuf/query_responses/impl/proto_transaction_page_response.cpp @@ -0,0 +1,60 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "backend/protobuf/query_responses/proto_transactions_page_response.hpp" +#include "common/byteutils.hpp" + +namespace shared_model { + namespace proto { + + template + TransactionsPageResponse::TransactionsPageResponse( + QueryResponseType &&queryResponse) + : CopyableProto(std::forward(queryResponse)), + transactionPageResponse_{proto_->transactions_page_response()}, + transactions_{transactionPageResponse_.transactions().begin(), + transactionPageResponse_.transactions().end()}, + next_hash_{[this]() -> boost::optional { + switch (transactionPageResponse_.next_page_tag_case()) { + case iroha::protocol::TransactionsPageResponse::kNextTxHash: + return crypto::Hash::fromHexString( + transactionPageResponse_.next_tx_hash()); + default: + return boost::none; + } + }()} {} + + template TransactionsPageResponse::TransactionsPageResponse( + TransactionsPageResponse::TransportType &); + template TransactionsPageResponse::TransactionsPageResponse( + const TransactionsPageResponse::TransportType &); + template TransactionsPageResponse::TransactionsPageResponse( + TransactionsPageResponse::TransportType &&); + + TransactionsPageResponse::TransactionsPageResponse( + const TransactionsPageResponse &o) + : TransactionsPageResponse(o.proto_) {} + + TransactionsPageResponse::TransactionsPageResponse( + TransactionsPageResponse &&o) + : TransactionsPageResponse(std::move(o.proto_)) {} + + interface::types::TransactionsCollectionType + TransactionsPageResponse::transactions() const { + return transactions_; + } + + boost::optional + TransactionsPageResponse::nextTxHash() const { + return next_hash_; + } + + interface::types::TransactionsNumberType + TransactionsPageResponse::allTransactionsSize() const { + return transactionPageResponse_.all_transactions_size(); + } + + } // namespace proto +} // namespace shared_model diff --git a/shared_model/backend/protobuf/query_responses/proto_query_response.hpp b/shared_model/backend/protobuf/query_responses/proto_query_response.hpp index ed4bd559da..9b4abc60af 100644 --- a/shared_model/backend/protobuf/query_responses/proto_query_response.hpp +++ b/shared_model/backend/protobuf/query_responses/proto_query_response.hpp @@ -7,6 +7,7 @@ #define IROHA_SHARED_MODEL_PROTO_QUERY_RESPONSE_HPP #include "interfaces/query_responses/query_response.hpp" + #include "qry_responses.pb.h" namespace shared_model { diff --git a/shared_model/backend/protobuf/query_responses/proto_transactions_page_response.hpp b/shared_model/backend/protobuf/query_responses/proto_transactions_page_response.hpp new file mode 100644 index 0000000000..3dfb11e830 --- /dev/null +++ b/shared_model/backend/protobuf/query_responses/proto_transactions_page_response.hpp @@ -0,0 +1,46 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_SHARED_MODEL_PROTO_TRANSACTION_PAGE_RESPONSE_HPP +#define IROHA_SHARED_MODEL_PROTO_TRANSACTION_PAGE_RESPONSE_HPP + +#include "interfaces/query_responses/transactions_page_response.hpp" + +#include "backend/protobuf/common_objects/trivial_proto.hpp" +#include "backend/protobuf/transaction.hpp" +#include "interfaces/common_objects/types.hpp" +#include "qry_responses.pb.h" + +namespace shared_model { + namespace proto { + class TransactionsPageResponse final + : public CopyableProto { + public: + template + explicit TransactionsPageResponse(QueryResponseType &&queryResponse); + + TransactionsPageResponse(const TransactionsPageResponse &o); + + TransactionsPageResponse(TransactionsPageResponse &&o); + + interface::types::TransactionsCollectionType transactions() + const override; + + boost::optional nextTxHash() const override; + + interface::types::TransactionsNumberType allTransactionsSize() + const override; + + private: + const iroha::protocol::TransactionsPageResponse &transactionPageResponse_; + const std::vector transactions_; + boost::optional next_hash_; + }; + } // namespace proto +} // namespace shared_model + +#endif // IROHA_SHARED_MODEL_PROTO_TRANSACTION_PAGE_RESPONSE_HPP diff --git a/shared_model/bindings/model_query_builder.cpp b/shared_model/bindings/model_query_builder.cpp index 58e5e37d3e..69d78f5d0f 100644 --- a/shared_model/bindings/model_query_builder.cpp +++ b/shared_model/bindings/model_query_builder.cpp @@ -37,15 +37,20 @@ namespace shared_model { } ModelQueryBuilder ModelQueryBuilder::getAccountTransactions( - const interface::types::AccountIdType &account_id) { - return ModelQueryBuilder(builder_.getAccountTransactions(account_id)); + const interface::types::AccountIdType &account_id, + interface::types::TransactionsNumberType page_size, + const boost::optional &first_hash) { + return ModelQueryBuilder( + builder_.getAccountTransactions(account_id, page_size, first_hash)); } ModelQueryBuilder ModelQueryBuilder::getAccountAssetTransactions( const interface::types::AccountIdType &account_id, - const interface::types::AssetIdType &asset_id) { - return ModelQueryBuilder( - builder_.getAccountAssetTransactions(account_id, asset_id)); + const interface::types::AssetIdType &asset_id, + interface::types::TransactionsNumberType page_size, + const boost::optional &first_hash) { + return ModelQueryBuilder(builder_.getAccountAssetTransactions( + account_id, asset_id, page_size, first_hash)); } ModelQueryBuilder ModelQueryBuilder::getAccountAssets( diff --git a/shared_model/bindings/model_query_builder.hpp b/shared_model/bindings/model_query_builder.hpp index ed7d256aef..7c672bcbc8 100644 --- a/shared_model/bindings/model_query_builder.hpp +++ b/shared_model/bindings/model_query_builder.hpp @@ -6,6 +6,7 @@ #ifndef IROHA_SHARED_MODEL_MODEL_QUERY_BUILDER_HPP #define IROHA_SHARED_MODEL_MODEL_QUERY_BUILDER_HPP +#include #include "builders/protobuf/queries.hpp" #include "builders/protobuf/unsigned_proto.hpp" @@ -70,7 +71,10 @@ namespace shared_model { * @return builder with getAccountTransactions query inside */ ModelQueryBuilder getAccountTransactions( - const interface::types::AccountIdType &account_id); + const interface::types::AccountIdType &account_id, + interface::types::TransactionsNumberType page_size, + const boost::optional &first_hash = + boost::none); /** * Queries account transaction collection for a given asset @@ -80,7 +84,10 @@ namespace shared_model { */ ModelQueryBuilder getAccountAssetTransactions( const interface::types::AccountIdType &account_id, - const interface::types::AssetIdType &asset_id); + const interface::types::AssetIdType &asset_id, + interface::types::TransactionsNumberType page_size, + const boost::optional &first_hash = + boost::none); /** * Queries balance of specific asset for given account diff --git a/shared_model/builders/protobuf/builder_templates/query_template.hpp b/shared_model/builders/protobuf/builder_templates/query_template.hpp index 8ff3172428..a27d5efd02 100644 --- a/shared_model/builders/protobuf/builder_templates/query_template.hpp +++ b/shared_model/builders/protobuf/builder_templates/query_template.hpp @@ -6,6 +6,7 @@ #ifndef IROHA_PROTO_QUERY_BUILDER_TEMPLATE_HPP #define IROHA_PROTO_QUERY_BUILDER_TEMPLATE_HPP +#include #include #include "backend/protobuf/queries/proto_query.hpp" @@ -77,6 +78,19 @@ namespace shared_model { return copy; } + /// Set tx pagination meta + template + static auto setTxPaginationMeta( + PageMetaPayload *page_meta_payload, + interface::types::TransactionsNumberType page_size, + const boost::optional &first_hash = + boost::none) { + page_meta_payload->set_page_size(page_size); + if (first_hash) { + page_meta_payload->set_first_tx_hash(toBinaryString(*first_hash)); + } + } + public: TemplateQueryBuilder(const SV &validator = SV()) : stateless_validator_(validator) {} @@ -118,20 +132,30 @@ namespace shared_model { } auto getAccountTransactions( - const interface::types::AccountIdType &account_id) const { + const interface::types::AccountIdType &account_id, + interface::types::TransactionsNumberType page_size, + const boost::optional &first_hash = + boost::none) const { return queryField([&](auto proto_query) { auto query = proto_query->mutable_get_account_transactions(); query->set_account_id(account_id); + setTxPaginationMeta( + query->mutable_pagination_meta(), page_size, first_hash); }); } auto getAccountAssetTransactions( const interface::types::AccountIdType &account_id, - const interface::types::AssetIdType &asset_id) const { + const interface::types::AssetIdType &asset_id, + interface::types::TransactionsNumberType page_size, + const boost::optional &first_hash = + boost::none) const { return queryField([&](auto proto_query) { auto query = proto_query->mutable_get_account_asset_transactions(); query->set_account_id(account_id); query->set_asset_id(asset_id); + setTxPaginationMeta( + query->mutable_pagination_meta(), page_size, first_hash); }); } diff --git a/shared_model/interfaces/CMakeLists.txt b/shared_model/interfaces/CMakeLists.txt index 2805509977..8062b314bc 100644 --- a/shared_model/interfaces/CMakeLists.txt +++ b/shared_model/interfaces/CMakeLists.txt @@ -37,6 +37,7 @@ add_library(shared_model_interfaces queries/impl/get_pending_transactions.cpp queries/impl/blocks_query.cpp queries/impl/query_payload_meta.cpp + queries/impl/tx_pagination_meta.cpp common_objects/impl/amount.cpp common_objects/impl/signature.cpp common_objects/impl/peer.cpp @@ -57,6 +58,7 @@ if (IROHA_ROOT_PROJECT) query_responses/impl/block_error_response.cpp query_responses/impl/block_query_response.cpp query_responses/impl/block_response.cpp + query_responses/impl/transactions_page_response.cpp transaction_responses/impl/tx_response.cpp iroha_internal/transaction_sequence.cpp iroha_internal/transaction_batch_impl.cpp diff --git a/shared_model/interfaces/common_objects/amount.hpp b/shared_model/interfaces/common_objects/amount.hpp index 3d54da2b35..58da073af6 100644 --- a/shared_model/interfaces/common_objects/amount.hpp +++ b/shared_model/interfaces/common_objects/amount.hpp @@ -10,7 +10,6 @@ #include #include "interfaces/common_objects/types.hpp" -#include "utils/lazy_initializer.hpp" namespace shared_model { namespace interface { diff --git a/shared_model/interfaces/common_objects/types.hpp b/shared_model/interfaces/common_objects/types.hpp index 46ba2c6d42..21587f5dc3 100644 --- a/shared_model/interfaces/common_objects/types.hpp +++ b/shared_model/interfaces/common_objects/types.hpp @@ -75,7 +75,7 @@ namespace shared_model { using AccountDetailKeyType = std::string; /// Type of account detail value using AccountDetailValueType = std::string; - /// Type of a number of transactions in block + /// Type of a number of transactions in block and query response page using TransactionsNumberType = uint16_t; /// Type of the transfer message using DescriptionType = std::string; diff --git a/shared_model/interfaces/iroha_internal/query_response_factory.hpp b/shared_model/interfaces/iroha_internal/query_response_factory.hpp index a28db1d580..d2e278c217 100644 --- a/shared_model/interfaces/iroha_internal/query_response_factory.hpp +++ b/shared_model/interfaces/iroha_internal/query_response_factory.hpp @@ -12,8 +12,8 @@ #include "interfaces/common_objects/asset.hpp" #include "interfaces/permissions.hpp" #include "interfaces/query_responses/block_query_response.hpp" -#include "interfaces/query_responses/query_response.hpp" #include "interfaces/query_responses/error_query_response.hpp" +#include "interfaces/query_responses/query_response.hpp" namespace shared_model { namespace crypto { @@ -124,6 +124,37 @@ namespace shared_model { transactions, const crypto::Hash &query_hash) const = 0; + /** + * Create response for transactions pagination query + * @param transactions - list of transactions in this page + * @param next_tx_hash - hash of the transaction after + * the last in the page + * @param all_transactions_size - total number of transactions + * for this query + * @param query_hash - hash of the query, for which response is created + * @return transactions response + */ + virtual std::unique_ptr createTransactionsPageResponse( + std::vector> + transactions, + const crypto::Hash &next_tx_hash, + interface::types::TransactionsNumberType all_transactions_size, + const crypto::Hash &query_hash) const = 0; + + /** + * Create response for transactions pagination query without next hash + * @param transactions - list of transactions in this page + * @param all_transactions_size - total number of transactions + * for this query + * @param query_hash - hash of the query, for which response is created + * @return transactions response + */ + virtual std::unique_ptr createTransactionsPageResponse( + std::vector> + transactions, + interface::types::TransactionsNumberType all_transactions_size, + const crypto::Hash &query_hash) const = 0; + /** * Create response for asset query * @param asset_id of asset to be inserted into the response diff --git a/shared_model/interfaces/permissions.hpp b/shared_model/interfaces/permissions.hpp index d1cded019f..3868844632 100644 --- a/shared_model/interfaces/permissions.hpp +++ b/shared_model/interfaces/permissions.hpp @@ -58,7 +58,8 @@ namespace shared_model { kTransferMyAssets, kSetMyAccountDetail, kGetBlocks, - + kAddDomainAssetQty, + kSubtractDomainAssetQty, COUNT }; diff --git a/shared_model/interfaces/queries/get_account_asset_transactions.hpp b/shared_model/interfaces/queries/get_account_asset_transactions.hpp index ede2505594..aa747f1e0d 100644 --- a/shared_model/interfaces/queries/get_account_asset_transactions.hpp +++ b/shared_model/interfaces/queries/get_account_asset_transactions.hpp @@ -18,11 +18,14 @@ #ifndef IROHA_SHARED_MODEL_GET_ACCOUNT_ASSET_TRANSACTIONS_HPP #define IROHA_SHARED_MODEL_GET_ACCOUNT_ASSET_TRANSACTIONS_HPP +#include + #include "interfaces/base/model_primitive.hpp" #include "interfaces/common_objects/types.hpp" namespace shared_model { namespace interface { + class TxPaginationMeta; /** * Query for getting transactions of given asset of an account @@ -39,6 +42,9 @@ namespace shared_model { */ virtual const types::AccountIdType &assetId() const = 0; + /// Get the query pagination metadata. + virtual const TxPaginationMeta &paginationMeta() const = 0; + std::string toString() const override; bool operator==(const ModelType &rhs) const override; diff --git a/shared_model/interfaces/queries/get_account_transactions.hpp b/shared_model/interfaces/queries/get_account_transactions.hpp index ba166e87db..fc5cd59f3d 100644 --- a/shared_model/interfaces/queries/get_account_transactions.hpp +++ b/shared_model/interfaces/queries/get_account_transactions.hpp @@ -18,11 +18,15 @@ #ifndef IROHA_SHARED_MODEL_GET_ACCOUNT_TRANSACTIONS_HPP #define IROHA_SHARED_MODEL_GET_ACCOUNT_TRANSACTIONS_HPP +#include + #include "interfaces/base/model_primitive.hpp" #include "interfaces/common_objects/types.hpp" namespace shared_model { namespace interface { + class TxPaginationMeta; + /** * Query for getting transactions of account */ @@ -34,6 +38,9 @@ namespace shared_model { */ virtual const types::AccountIdType &accountId() const = 0; + /// Get the query pagination metadata. + virtual const TxPaginationMeta &paginationMeta() const = 0; + std::string toString() const override; bool operator==(const ModelType &rhs) const override; diff --git a/shared_model/interfaces/queries/impl/get_account_asset_transactions.cpp b/shared_model/interfaces/queries/impl/get_account_asset_transactions.cpp index 4e242d5ad5..7817263ad4 100644 --- a/shared_model/interfaces/queries/impl/get_account_asset_transactions.cpp +++ b/shared_model/interfaces/queries/impl/get_account_asset_transactions.cpp @@ -5,6 +5,8 @@ #include "interfaces/queries/get_account_asset_transactions.hpp" +#include "interfaces/queries/tx_pagination_meta.hpp" + namespace shared_model { namespace interface { @@ -13,6 +15,7 @@ namespace shared_model { .init("GetAccountAssetTransactions") .append("account_id", accountId()) .append("asset_id", assetId()) + .append("pagination_meta", paginationMeta().toString()) .finalize(); } diff --git a/shared_model/interfaces/queries/impl/get_account_transactions.cpp b/shared_model/interfaces/queries/impl/get_account_transactions.cpp index 24297cf13f..477a1c69d0 100644 --- a/shared_model/interfaces/queries/impl/get_account_transactions.cpp +++ b/shared_model/interfaces/queries/impl/get_account_transactions.cpp @@ -5,6 +5,8 @@ #include "interfaces/queries/get_account_transactions.hpp" +#include "interfaces/queries/tx_pagination_meta.hpp" + namespace shared_model { namespace interface { @@ -12,6 +14,7 @@ namespace shared_model { return detail::PrettyStringBuilder() .init("GetAccountTransactions") .append("account_id", accountId()) + .append("pagination_meta", paginationMeta().toString()) .finalize(); } diff --git a/shared_model/interfaces/queries/impl/tx_pagination_meta.cpp b/shared_model/interfaces/queries/impl/tx_pagination_meta.cpp new file mode 100644 index 0000000000..7ae8509314 --- /dev/null +++ b/shared_model/interfaces/queries/impl/tx_pagination_meta.cpp @@ -0,0 +1,25 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "interfaces/queries/tx_pagination_meta.hpp" + +#include "cryptography/hash.hpp" + +using namespace shared_model::interface; + +bool TxPaginationMeta::operator==(const ModelType &rhs) const { + return pageSize() == rhs.pageSize() and firstTxHash() == rhs.firstTxHash(); +} + +std::string TxPaginationMeta::toString() const { + auto pretty_builder = detail::PrettyStringBuilder() + .init("TxPaginationMeta") + .append("page_size", std::to_string(pageSize())); + auto first_tx_hash = firstTxHash(); + if (first_tx_hash) { + pretty_builder.append("first_tx_hash", first_tx_hash->toString()); + } + return pretty_builder.finalize(); +} diff --git a/shared_model/interfaces/queries/tx_pagination_meta.hpp b/shared_model/interfaces/queries/tx_pagination_meta.hpp new file mode 100644 index 0000000000..b57a274dd6 --- /dev/null +++ b/shared_model/interfaces/queries/tx_pagination_meta.hpp @@ -0,0 +1,34 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_SHARED_INTERFACE_MODEL_QUERY_TX_PAGINATION_META_HPP +#define IROHA_SHARED_INTERFACE_MODEL_QUERY_TX_PAGINATION_META_HPP + +#include +#include "interfaces/base/model_primitive.hpp" +#include "interfaces/common_objects/types.hpp" + +namespace shared_model { + namespace interface { + + /// Provides query metadata for any transaction list pagination. + class TxPaginationMeta : public ModelPrimitive { + public: + + /// Get the requested page size. + virtual types::TransactionsNumberType pageSize() const = 0; + + /// Get the first requested transaction hash, if provided. + virtual boost::optional firstTxHash() const = 0; + + std::string toString() const override; + + bool operator==(const ModelType &rhs) const override; + }; + + } // namespace interface +} // namespace shared_model + +#endif // IROHA_SHARED_INTERFACE_MODEL_QUERY_TX_PAGINATION_META_HPP diff --git a/shared_model/interfaces/query_responses/impl/query_response.cpp b/shared_model/interfaces/query_responses/impl/query_response.cpp index e6a7a8e863..3e44e50478 100644 --- a/shared_model/interfaces/query_responses/impl/query_response.cpp +++ b/shared_model/interfaces/query_responses/impl/query_response.cpp @@ -13,6 +13,7 @@ #include "interfaces/query_responses/role_permissions.hpp" #include "interfaces/query_responses/roles_response.hpp" #include "interfaces/query_responses/signatories_response.hpp" +#include "interfaces/query_responses/transactions_page_response.hpp" #include "interfaces/query_responses/transactions_response.hpp" #include "utils/visitor_apply_for_all.hpp" diff --git a/shared_model/interfaces/query_responses/impl/transactions_page_response.cpp b/shared_model/interfaces/query_responses/impl/transactions_page_response.cpp new file mode 100644 index 0000000000..4939d78b8b --- /dev/null +++ b/shared_model/interfaces/query_responses/impl/transactions_page_response.cpp @@ -0,0 +1,33 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "interfaces/query_responses/transactions_page_response.hpp" +#include "interfaces/transaction.hpp" + +namespace shared_model { + namespace interface { + + std::string TransactionsPageResponse::toString() const { + auto builder = detail::PrettyStringBuilder() + .init("TransactionsPageResponse") + .appendAll("transactions", + transactions(), + [](auto &tx) { return tx.toString(); }) + .append("all transactions size", + std::to_string(allTransactionsSize())); + if (nextTxHash()) { + return builder.append("next tx hash", nextTxHash()->hex()).finalize(); + } + return builder.finalize(); + } + + bool TransactionsPageResponse::operator==(const ModelType &rhs) const { + return transactions() == rhs.transactions() + and nextTxHash() == rhs.nextTxHash() + and allTransactionsSize() == rhs.allTransactionsSize(); + } + + } // namespace interface +} // namespace shared_model diff --git a/shared_model/interfaces/query_responses/query_response.hpp b/shared_model/interfaces/query_responses/query_response.hpp index 5568b5d910..46f5880815 100644 --- a/shared_model/interfaces/query_responses/query_response.hpp +++ b/shared_model/interfaces/query_responses/query_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_QUERY_RESPONSE_HPP @@ -35,6 +23,7 @@ namespace shared_model { class AssetResponse; class RolesResponse; class RolePermissionsResponse; + class TransactionsPageResponse; /** * Class QueryResponse(qr) provides container with concrete query responses * available in the system. @@ -56,7 +45,8 @@ namespace shared_model { TransactionsResponse, AssetResponse, RolesResponse, - RolePermissionsResponse>; + RolePermissionsResponse, + TransactionsPageResponse>; /** * @return reference to const variant with concrete qr diff --git a/shared_model/interfaces/query_responses/transactions_page_response.hpp b/shared_model/interfaces/query_responses/transactions_page_response.hpp new file mode 100644 index 0000000000..e0bff09246 --- /dev/null +++ b/shared_model/interfaces/query_responses/transactions_page_response.hpp @@ -0,0 +1,46 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_SHARED_MODEL_TRANSACTIONS_PAGE_RESPONSE_HPP +#define IROHA_SHARED_MODEL_TRANSACTIONS_PAGE_RESPONSE_HPP + +#include + +#include "interfaces/base/model_primitive.hpp" +#include "interfaces/common_objects/range_types.hpp" +#include "interfaces/common_objects/types.hpp" + +namespace shared_model { + namespace interface { + /** + * Response for paginated queries + */ + class TransactionsPageResponse + : public ModelPrimitive { + public: + /** + * @return transactions from this page + */ + virtual types::TransactionsCollectionType transactions() const = 0; + + /** + * @return hash of the first transaction from the next page + */ + virtual boost::optional nextTxHash() + const = 0; + + /** + * @return total number of transactions for the query + */ + virtual interface::types::TransactionsNumberType allTransactionsSize() + const = 0; + + std::string toString() const override; + + bool operator==(const ModelType &rhs) const override; + }; + } // namespace interface +} // namespace shared_model +#endif // IROHA_SHARED_MODEL_TRANSACTIONS_PAGE_RESPONSE_HPP diff --git a/shared_model/schema/block.proto b/shared_model/schema/block.proto index f49480a5e3..d70ef64ecb 100644 --- a/shared_model/schema/block.proto +++ b/shared_model/schema/block.proto @@ -8,7 +8,7 @@ package iroha.protocol; import "primitive.proto"; import "transaction.proto"; -message Block { +message Block_v1 { // everything that should be signed: message Payload { repeated Transaction transactions = 1; @@ -27,3 +27,9 @@ message Block { Payload payload = 1; repeated Signature signatures = 2; } + +message Block { + oneof block_version { + Block_v1 block_v1 = 1; + } +} diff --git a/shared_model/schema/primitive.proto b/shared_model/schema/primitive.proto index 3d839c5632..b50c7c0ad8 100644 --- a/shared_model/schema/primitive.proto +++ b/shared_model/schema/primitive.proto @@ -43,6 +43,8 @@ enum RolePermission { can_transfer = 12; can_receive = 13; can_create_domain = 14; + can_add_domain_asset_qty = 43; + can_subtract_domain_asset_qty = 44; // Query permissions can_read_assets = 15; diff --git a/shared_model/schema/qry_responses.proto b/shared_model/schema/qry_responses.proto index da74974870..47c342bd5e 100644 --- a/shared_model/schema/qry_responses.proto +++ b/shared_model/schema/qry_responses.proto @@ -85,6 +85,14 @@ message TransactionsResponse { repeated Transaction transactions = 1; } +message TransactionsPageResponse { + repeated Transaction transactions = 1; + uint32 all_transactions_size = 2; + oneof next_page_tag { + string next_tx_hash = 3; + } +} + message QueryResponse { oneof response { AccountAssetResponse account_assets_response = 1; @@ -96,6 +104,7 @@ message QueryResponse { AssetResponse asset_response = 7; RolesResponse roles_response = 8; RolePermissionsResponse role_permissions_response = 9; + TransactionsPageResponse transactions_page_response = 11; } string query_hash = 10; } diff --git a/shared_model/schema/queries.proto b/shared_model/schema/queries.proto index 7ca49225e5..69cb74ce15 100644 --- a/shared_model/schema/queries.proto +++ b/shared_model/schema/queries.proto @@ -8,6 +8,13 @@ package iroha.protocol; import "primitive.proto"; +message TxPaginationMeta { + uint32 page_size = 1; + oneof opt_first_tx_hash { + string first_tx_hash = 2; + } +} + message GetAccount { string account_id = 1; } @@ -18,11 +25,13 @@ message GetSignatories { message GetAccountTransactions { string account_id = 1; + TxPaginationMeta pagination_meta = 2; } message GetAccountAssetTransactions { string account_id = 1; string asset_id = 2; + TxPaginationMeta pagination_meta = 3; } message GetTransactions { diff --git a/shared_model/utils/lazy_initializer.hpp b/shared_model/utils/lazy_initializer.hpp deleted file mode 100644 index f299bde6c8..0000000000 --- a/shared_model/utils/lazy_initializer.hpp +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef IROHA_LAZY_INITIALIZER_HPP -#define IROHA_LAZY_INITIALIZER_HPP - -#include -#include - -namespace shared_model { - namespace detail { - - /** - * Lazy class for lazy converting one type to another - * @tparam Target - output type - */ - template - class LazyInitializer { - private: - /// Type of generator function - using GeneratorType = std::function; - - public: - /** - * Default constructor prevents compilation error in pre 7.2 gcc. - * - * Short explanation: gcc needs default constructor - * when the constructor is inherited (via using Base::Base) - * if the inherited class has default initalizers for any of its members. - * This can be found in shared_model/backend/protobuf/protobuf/block.hpp - * where Lazy fields are initialized via default initializers. - * - * Note that this does not result in default constructor being called, so - * the resulting code is still correct. This is an issue of gcc compiler - * which is resolved in 7.2 - * - * For more details: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054 - */ - LazyInitializer(); - - template - explicit LazyInitializer(T &&generator) - : generator_(std::forward(generator)) {} - - using PointerType = typename std::add_pointer_t; - - const Target &operator*() const { - return *ptr(); - } - - const PointerType ptr() const { - if (target_value_ == boost::none) { - // Use type move constructor with emplace - // since Target copy assignment operator could be deleted - - target_value_.emplace(generator_()); - } - return target_value_.get_ptr(); - } - - const PointerType operator->() const { - return ptr(); - } - - /** - * Remove generated value. Next ptr() call will generate new value - */ - void invalidate() const { - target_value_ = boost::none; - } - - private: - GeneratorType generator_; - mutable boost::optional target_value_; - }; - - /** - * Function for creating lazy object - * @tparam Generator - type of generator - * @param generator - instance of Generator - * @return initialized lazy value - */ - template - auto makeLazyInitializer(Generator &&generator) { - using targetType = decltype(generator()); - return LazyInitializer(std::forward(generator)); - } - } // namespace detail -} // namespace shared_model -#endif // IROHA_LAZY_INITIALIZER_HPP diff --git a/shared_model/utils/query_error_response_visitor.hpp b/shared_model/utils/query_error_response_visitor.hpp index 23154219f1..aefcd79279 100644 --- a/shared_model/utils/query_error_response_visitor.hpp +++ b/shared_model/utils/query_error_response_visitor.hpp @@ -38,6 +38,13 @@ namespace shared_model { return false; } }; + + template + bool checkForQueryError(QueryVariant &&query) { + return boost::apply_visitor( + shared_model::interface::QueryErrorResponseChecker(), + std::forward(query)); + } } // namespace interface } // namespace shared_model diff --git a/shared_model/utils/reference_holder.hpp b/shared_model/utils/reference_holder.hpp index 99a19531b4..3aabaafe10 100644 --- a/shared_model/utils/reference_holder.hpp +++ b/shared_model/utils/reference_holder.hpp @@ -7,7 +7,6 @@ #define IROHA_REFERENCE_HOLDER_HPP #include -#include "utils/lazy_initializer.hpp" namespace shared_model { namespace detail { diff --git a/shared_model/utils/string_builder.cpp b/shared_model/utils/string_builder.cpp index a9d3bca104..407c8a3061 100644 --- a/shared_model/utils/string_builder.cpp +++ b/shared_model/utils/string_builder.cpp @@ -8,6 +8,13 @@ namespace shared_model { namespace detail { + const std::string PrettyStringBuilder::beginBlockMarker = "["; + const std::string PrettyStringBuilder::endBlockMarker = "]"; + const std::string PrettyStringBuilder::keyValueSeparator = "="; + const std::string PrettyStringBuilder::singleFieldsSeparator = ","; + const std::string PrettyStringBuilder::initSeparator = ":"; + const std::string PrettyStringBuilder::spaceSeparator = " "; + PrettyStringBuilder &PrettyStringBuilder::init(const std::string &name) { result_.append(name); result_.append(initSeparator); diff --git a/shared_model/utils/string_builder.hpp b/shared_model/utils/string_builder.hpp index 0b877cbb2e..d61ed15bed 100644 --- a/shared_model/utils/string_builder.hpp +++ b/shared_model/utils/string_builder.hpp @@ -89,12 +89,12 @@ namespace shared_model { private: std::string result_; - const std::string beginBlockMarker = "["; - const std::string endBlockMarker = "]"; - const std::string keyValueSeparator = "="; - const std::string singleFieldsSeparator = ","; - const std::string initSeparator = ":"; - const std::string spaceSeparator = " "; + static const std::string beginBlockMarker; + static const std::string endBlockMarker; + static const std::string keyValueSeparator; + static const std::string singleFieldsSeparator; + static const std::string initSeparator; + static const std::string spaceSeparator; }; } // namespace detail } // namespace shared_model diff --git a/shared_model/validators/CMakeLists.txt b/shared_model/validators/CMakeLists.txt index a4ac9692ca..7ce9e4b6d0 100644 --- a/shared_model/validators/CMakeLists.txt +++ b/shared_model/validators/CMakeLists.txt @@ -5,6 +5,7 @@ add_library(shared_model_stateless_validation field_validator.cpp transactions_collection/transactions_collection_validator.cpp transactions_collection/batch_order_validator.cpp + protobuf/proto_block_validator.cpp ) target_link_libraries(shared_model_stateless_validation diff --git a/shared_model/validators/field_validator.cpp b/shared_model/validators/field_validator.cpp index 2e42e57db6..3fb352db5b 100644 --- a/shared_model/validators/field_validator.cpp +++ b/shared_model/validators/field_validator.cpp @@ -14,6 +14,7 @@ #include "interfaces/common_objects/amount.hpp" #include "interfaces/common_objects/peer.hpp" #include "interfaces/queries/query_payload_meta.hpp" +#include "interfaces/queries/tx_pagination_meta.hpp" #include "validators/field_validator.hpp" // TODO: 15.02.18 nickaleks Change structure to compositional IR-978 @@ -382,5 +383,22 @@ namespace shared_model { return boost::none; } + void FieldValidator::validateTxPaginationMeta( + ReasonsGroupType &reason, + const interface::TxPaginationMeta &tx_pagination_meta) const { + const auto page_size = tx_pagination_meta.pageSize(); + if (page_size <= 0) { + reason.second.push_back( + (boost::format( + "Page size is %s (%d), while it must be a non-zero positive.") + % (page_size == 0 ? "zero" : "negative") % page_size) + .str()); + } + const auto first_hash = tx_pagination_meta.firstTxHash(); + if (first_hash) { + validateHash(reason, *first_hash); + } + } + } // namespace validation } // namespace shared_model diff --git a/shared_model/validators/field_validator.hpp b/shared_model/validators/field_validator.hpp index 306b566ed9..456e2220fc 100644 --- a/shared_model/validators/field_validator.hpp +++ b/shared_model/validators/field_validator.hpp @@ -20,6 +20,7 @@ namespace shared_model { class Amount; class BatchMeta; class Peer; + class TxPaginationMeta; } // namespace interface namespace validation { @@ -160,6 +161,10 @@ namespace shared_model { void validateHash(ReasonsGroupType &reason, const crypto::Hash &hash) const; + void validateTxPaginationMeta( + ReasonsGroupType &reason, + const interface::TxPaginationMeta &tx_pagination_meta) const; + private: const static std::string account_name_pattern_; const static std::string asset_name_pattern_; diff --git a/shared_model/validators/protobuf/proto_block_validator.cpp b/shared_model/validators/protobuf/proto_block_validator.cpp new file mode 100644 index 0000000000..5b41ef9a3c --- /dev/null +++ b/shared_model/validators/protobuf/proto_block_validator.cpp @@ -0,0 +1,27 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "validators/protobuf/proto_block_validator.hpp" + +namespace shared_model { + namespace validation { + Answer ProtoBlockValidator::validate( + const iroha::protocol::Block &block) const { + Answer answer; + std::string tx_reason_name = "Protobuf Block"; + ReasonsGroupType reason{tx_reason_name, GroupedReasons()}; + + // make sure version one_of field of the Block is set + if (block.block_version_case() + == iroha::protocol::Block::BLOCK_VERSION_NOT_SET) { + reason.second.emplace_back("Block version is not set"); + answer.addReason(std::move(reason)); + return answer; + } + + return answer; + } + } // namespace validation +} // namespace shared_model diff --git a/shared_model/validators/protobuf/proto_block_validator.hpp b/shared_model/validators/protobuf/proto_block_validator.hpp new file mode 100644 index 0000000000..8a9a718f3f --- /dev/null +++ b/shared_model/validators/protobuf/proto_block_validator.hpp @@ -0,0 +1,22 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_PROTO_BLOCK_VALIDATOR_HPP +#define IROHA_PROTO_BLOCK_VALIDATOR_HPP + +#include "block.pb.h" +#include "validators/abstract_validator.hpp" + +namespace shared_model { + namespace validation { + class ProtoBlockValidator + : public AbstractValidator { + public: + Answer validate(const iroha::protocol::Block &block) const override; + }; + } // namespace validation +} // namespace shared_model + +#endif // IROHA_PROTO_BLOCK_VALIDATOR_HPP diff --git a/shared_model/validators/query_validator.hpp b/shared_model/validators/query_validator.hpp index 3f030b161b..7657cd8305 100644 --- a/shared_model/validators/query_validator.hpp +++ b/shared_model/validators/query_validator.hpp @@ -20,6 +20,7 @@ #include "backend/protobuf/queries/proto_get_signatories.hpp" #include "backend/protobuf/queries/proto_get_transactions.hpp" #include "backend/protobuf/queries/proto_query.hpp" +#include "interfaces/queries/tx_pagination_meta.hpp" #include "validators/abstract_validator.hpp" #include "validators/answer.hpp" @@ -61,6 +62,7 @@ namespace shared_model { reason.first = "GetAccountTransactions"; validator_.validateAccountId(reason, qry.accountId()); + validator_.validateTxPaginationMeta(reason, qry.paginationMeta()); return reason; } @@ -72,6 +74,7 @@ namespace shared_model { validator_.validateAccountId(reason, qry.accountId()); validator_.validateAssetId(reason, qry.assetId()); + validator_.validateTxPaginationMeta(reason, qry.paginationMeta()); return reason; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 15fb956b03..ce617e3bc9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,19 +1,5 @@ -# -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test_bin) diff --git a/test/framework/CMakeLists.txt b/test/framework/CMakeLists.txt index 557467580f..08dd1c99bb 100644 --- a/test/framework/CMakeLists.txt +++ b/test/framework/CMakeLists.txt @@ -20,7 +20,6 @@ target_link_libraries(test_subscriber_testing rxcpp ) - add_library(integration_framework integration_framework/integration_test_framework.cpp integration_framework/iroha_instance.cpp @@ -34,6 +33,7 @@ target_link_libraries(integration_framework integration_framework_config_helper command_client query_client + ordering_gate_common yac_transport shared_model_cryptography_model server_runner diff --git a/test/framework/integration_framework/integration_test_framework.cpp b/test/framework/integration_framework/integration_test_framework.cpp index d190231ac4..ed7418e49c 100644 --- a/test/framework/integration_framework/integration_test_framework.cpp +++ b/test/framework/integration_framework/integration_test_framework.cpp @@ -117,7 +117,8 @@ namespace integration_framework { } // the code below should be executed anyway in order to prevent app hang if (iroha_instance_ and iroha_instance_->getIrohaInstance()) { - iroha_instance_->getIrohaInstance()->terminate(); + iroha_instance_->getIrohaInstance()->terminate( + std::chrono::system_clock::now()); } } @@ -251,7 +252,6 @@ namespace integration_framework { iroha_instance_->initPipeline(keypair, maximum_proposal_size_); log_->info("created pipeline"); - iroha_instance_->getIrohaInstance()->resetOrderingService(); makeFakePeers(); } @@ -259,20 +259,33 @@ namespace integration_framework { void IntegrationTestFramework::subscribeQueuesAndRun() { // subscribing for components - iroha_instance_->getIrohaInstance() - ->getPeerCommunicationService() - ->on_proposal() - .subscribe([this](auto proposal) { - proposal_queue_.push(proposal); + auto proposals = iroha_instance_->getIrohaInstance() + ->getPeerCommunicationService() + ->onProposal(); + + proposals.filter([](const auto &event) { return event.proposal; }) + .subscribe([this](const auto &event) { + proposal_queue_.push(getProposalUnsafe(event)); log_->info("proposal"); queue_cond.notify_all(); }); + auto proposal_flat_map = + [](auto t) -> rxcpp::observable> { + if (std::get<1>(t).proposal) { + return rxcpp::observable<>::just(std::get<0>(t)); + } + return rxcpp::observable<>::empty>(); + }; + iroha_instance_->getIrohaInstance() ->getPeerCommunicationService() - ->on_verified_proposal() + ->onVerifiedProposal() + .zip(proposals) + .flat_map(proposal_flat_map) .subscribe([this](auto verified_proposal_and_errors) { - verified_proposal_queue_.push(verified_proposal_and_errors); + verified_proposal_queue_.push( + getVerifiedProposalUnsafe(verified_proposal_and_errors)); log_->info("verified proposal"); queue_cond.notify_all(); }); @@ -280,6 +293,8 @@ namespace integration_framework { iroha_instance_->getIrohaInstance() ->getPeerCommunicationService() ->on_commit() + .zip(proposals) + .flat_map(proposal_flat_map) .subscribe([this](auto commit_event) { commit_event.synced_blocks.subscribe([this](auto committed_block) { block_queue_.push(committed_block); @@ -328,9 +343,9 @@ namespace integration_framework { ->onExpiredBatches(); } - rxcpp::observable + rxcpp::observable IntegrationTestFramework::getYacOnCommitObservable() { - return iroha_instance_->getIrohaInstance()->getConsensusGate()->on_commit(); + return iroha_instance_->getIrohaInstance()->getConsensusGate()->onOutcome(); } IntegrationTestFramework & diff --git a/test/framework/integration_framework/integration_test_framework.hpp b/test/framework/integration_framework/integration_test_framework.hpp index f6d17d7fed..06b1a47c3b 100644 --- a/test/framework/integration_framework/integration_test_framework.hpp +++ b/test/framework/integration_framework/integration_test_framework.hpp @@ -326,7 +326,8 @@ namespace integration_framework { rxcpp::observable getMstExpiredBatchesObservable(); - rxcpp::observable getYacOnCommitObservable(); + rxcpp::observable + getYacOnCommitObservable(); IntegrationTestFramework &subscribeForAllMstNotifications( std::shared_ptr notification); diff --git a/test/framework/integration_framework/test_irohad.hpp b/test/framework/integration_framework/test_irohad.hpp index c000310736..e1c28ea4cc 100644 --- a/test/framework/integration_framework/test_irohad.hpp +++ b/test/framework/integration_framework/test_irohad.hpp @@ -84,6 +84,16 @@ namespace integration_framework { void terminate() { if (internal_server) { internal_server->shutdown(); + } else { + log_->warn("Tried to terminate without internal server"); + } + } + + void terminate(const std::chrono::system_clock::time_point &deadline) { + if (internal_server) { + internal_server->shutdown(deadline); + } else { + log_->warn("Tried to terminate without internal server"); } } }; diff --git a/test/fuzzing/status_fuzz.cpp b/test/fuzzing/status_fuzz.cpp index 661eaef30c..413fe7b29f 100644 --- a/test/fuzzing/status_fuzz.cpp +++ b/test/fuzzing/status_fuzz.cpp @@ -36,11 +36,11 @@ struct CommandFixture { CommandFixture() { pcs_ = std::make_shared(); - EXPECT_CALL(*pcs_, on_proposal()) + EXPECT_CALL(*pcs_, onProposal()) .WillRepeatedly(Return(prop_notifier_.get_observable())); EXPECT_CALL(*pcs_, on_commit()) .WillRepeatedly(Return(commit_notifier_.get_observable())); - EXPECT_CALL(*pcs_, on_verified_proposal()) + EXPECT_CALL(*pcs_, onVerifiedProposal()) .WillRepeatedly(Return(vprop_notifier_.get_observable())); mst_processor_ = std::make_shared(); diff --git a/test/fuzzing/torii_fuzz.cpp b/test/fuzzing/torii_fuzz.cpp index b09ee7d30e..581efbe9d8 100644 --- a/test/fuzzing/torii_fuzz.cpp +++ b/test/fuzzing/torii_fuzz.cpp @@ -33,11 +33,11 @@ struct CommandFixture { CommandFixture() { pcs_ = std::make_shared(); - EXPECT_CALL(*pcs_, on_proposal()) + EXPECT_CALL(*pcs_, onProposal()) .WillRepeatedly(Return(prop_notifier_.get_observable())); EXPECT_CALL(*pcs_, on_commit()) .WillRepeatedly(Return(commit_notifier_.get_observable())); - EXPECT_CALL(*pcs_, on_verified_proposal()) + EXPECT_CALL(*pcs_, onVerifiedProposal()) .WillRepeatedly(Return(vprop_notifier_.get_observable())); mst_processor_ = std::make_shared(); diff --git a/test/integration/acceptance/acceptance_fixture.hpp b/test/integration/acceptance/acceptance_fixture.hpp index 8f84e3ef64..0417f9068c 100644 --- a/test/integration/acceptance/acceptance_fixture.hpp +++ b/test/integration/acceptance/acceptance_fixture.hpp @@ -22,7 +22,7 @@ namespace { template void checkTransactionResponse( const shared_model::interface::TransactionResponse &resp) { - ASSERT_NO_THROW(boost::get(resp.get())); + ASSERT_NO_THROW(boost::get(resp.get())) << resp.toString(); } #define BASE_CHECK_RESPONSE(type) \ @@ -43,6 +43,8 @@ namespace { #define CHECK_STATEFUL_VALID BASE_CHECK_RESPONSE(StatefulValidTxResponse) #define CHECK_COMMITTED BASE_CHECK_RESPONSE(CommittedTxResponse) + +#define CHECK_MST_PENDING BASE_CHECK_RESPONSE(MstPendingResponse) } // namespace /** diff --git a/test/integration/acceptance/get_account_asset_txs_test.cpp b/test/integration/acceptance/get_account_asset_txs_test.cpp index e8fccdcc40..52dafe755f 100644 --- a/test/integration/acceptance/get_account_asset_txs_test.cpp +++ b/test/integration/acceptance/get_account_asset_txs_test.cpp @@ -9,6 +9,9 @@ using namespace common_constants; using AccountAssetTxsFixture = QueryPermissionFixture; +static constexpr shared_model::interface::types::TransactionsNumberType + kTxPageSize(10); + /** * C346 Pass an empty asset id * @given a user with kGetAllAccAstTxs permission @@ -19,9 +22,9 @@ using AccountAssetTxsFixture = QueryPermissionFixture; TEST_F(AccountAssetTxsFixture, ReadEmptyAssetHavingAllTxsPermission) { const interface::types::AssetIdType empty = ""; impl_.prepareState(*this, {Role::kGetAllAccAstTxs}) - .sendQuery( - complete(baseQry().getAccountAssetTransactions(kUserId, empty)), - getQueryStatelesslyInvalidChecker()); + .sendQuery(complete(baseQry().getAccountAssetTransactions( + kUserId, empty, kTxPageSize)), + getQueryStatelesslyInvalidChecker()); } /** @@ -38,8 +41,8 @@ TEST_F(AccountAssetTxsFixture, DISABLED_ReadNonExistingAssetHavingAllTxsPermission) { const interface::types::AssetIdType non_existing = "nonexisting#" + kDomain; impl_.prepareState(*this, {Role::kGetAllAccAstTxs}) - .sendQuery(complete(baseQry().getAccountAssetTransactions(kUserId, - non_existing)), + .sendQuery(complete(baseQry().getAccountAssetTransactions( + kUserId, non_existing, kTxPageSize)), getQueryStatefullyInvalidChecker()); } @@ -58,9 +61,9 @@ TEST_F(AccountAssetTxsFixture, DISABLED_OwnTxsIncludingAddAssetQuantity) { impl_.prepareState(*this, {Role::kGetAllAccAstTxs}) .sendTxAwait( tx, [](auto &block) { ASSERT_EQ(block->transactions().size(), 1); }) - .sendQuery( - complete(baseQry().getAccountAssetTransactions(kUserId, kAssetId)), - impl_.getGeneralResponseChecker()); + .sendQuery(complete(baseQry().getAccountAssetTransactions( + kUserId, kAssetId, kTxPageSize)), + impl_.getGeneralResponseChecker()); } /** @@ -80,7 +83,7 @@ TEST_F(AccountAssetTxsFixture, DISABLED_OwnTxsIncludingSubtractAssetQuantity) { impl_.prepareState(*this, {Role::kGetAllAccAstTxs}) .sendTxAwait( tx, [](auto &block) { ASSERT_EQ(block->transactions().size(), 1); }) - .sendQuery( - complete(baseQry().getAccountAssetTransactions(kUserId, kAssetId)), - impl_.getGeneralResponseChecker()); + .sendQuery(complete(baseQry().getAccountAssetTransactions( + kUserId, kAssetId, kTxPageSize)), + impl_.getGeneralResponseChecker()); } diff --git a/test/integration/acceptance/get_account_test.cpp b/test/integration/acceptance/get_account_test.cpp index 0ba3995e24..580aa66a03 100644 --- a/test/integration/acceptance/get_account_test.cpp +++ b/test/integration/acceptance/get_account_test.cpp @@ -11,6 +11,7 @@ #include "integration/acceptance/acceptance_fixture.hpp" #include "interfaces/query_responses/account_response.hpp" #include "utils/query_error_response_visitor.hpp" +#include "interfaces/query_responses/account_response.hpp" using namespace integration_framework; using namespace shared_model; diff --git a/test/integration/acceptance/query_permission_test_ast_txs.cpp b/test/integration/acceptance/query_permission_test_ast_txs.cpp index 5bdc63fc9f..980b985289 100644 --- a/test/integration/acceptance/query_permission_test_ast_txs.cpp +++ b/test/integration/acceptance/query_permission_test_ast_txs.cpp @@ -5,10 +5,13 @@ #include "integration/acceptance/query_permission_test_ast_txs.hpp" -#include "interfaces/query_responses/transactions_response.hpp" +#include "interfaces/query_responses/transactions_page_response.hpp" using namespace common_constants; +static constexpr shared_model::interface::types::TransactionsNumberType + kTxPageSize(10); + QueryPermissionAssetTxs::QueryPermissionAssetTxs() : QueryPermissionTestBase({Role::kGetMyAccAstTxs}, {Role::kGetDomainAccAstTxs}, @@ -48,7 +51,8 @@ QueryPermissionAssetTxs::getGeneralResponseChecker() { return [this](const proto::QueryResponse &response) { ASSERT_NO_THROW({ const auto &resp = - boost::get(response.get()); + boost::get( + response.get()); const auto &transactions = resp.transactions(); ASSERT_EQ(boost::size(transactions), tx_hashes_.size()); @@ -76,6 +80,7 @@ shared_model::proto::Query QueryPermissionAssetTxs::makeQuery( const interface::types::AccountIdType &spectator, const crypto::Keypair &spectator_keypair) { return fixture.complete( - fixture.baseQry(spectator).getAccountAssetTransactions(target, kAssetId), + fixture.baseQry(spectator).getAccountAssetTransactions( + target, kAssetId, kTxPageSize), spectator_keypair); } diff --git a/test/integration/acceptance/query_permission_test_txs.cpp b/test/integration/acceptance/query_permission_test_txs.cpp index 4fe3531706..98cbbdc455 100644 --- a/test/integration/acceptance/query_permission_test_txs.cpp +++ b/test/integration/acceptance/query_permission_test_txs.cpp @@ -5,10 +5,13 @@ #include "integration/acceptance/query_permission_test_txs.hpp" -#include "interfaces/query_responses/transactions_response.hpp" +#include "interfaces/query_responses/transactions_page_response.hpp" using namespace common_constants; +static constexpr shared_model::interface::types::TransactionsNumberType + kTxPageSize(10); + QueryPermissionTxs::QueryPermissionTxs() : QueryPermissionTestBase({Role::kGetMyAccTxs}, {Role::kGetDomainAccTxs}, @@ -56,7 +59,8 @@ QueryPermissionTxs::getGeneralResponseChecker() { return [this](const proto::QueryResponse &response) { ASSERT_NO_THROW({ const auto &resp = - boost::get(response.get()); + boost::get( + response.get()); const auto &transactions = resp.transactions(); ASSERT_EQ(boost::size(transactions), tx_hashes_.size()); @@ -86,6 +90,6 @@ shared_model::proto::Query QueryPermissionTxs::makeQuery( const interface::types::AccountIdType &spectator, const crypto::Keypair &spectator_keypair) { return fixture.complete( - fixture.baseQry(spectator).getAccountTransactions(target), + fixture.baseQry(spectator).getAccountTransactions(target, kTxPageSize), spectator_keypair); } diff --git a/test/integration/pipeline/multisig_tx_pipeline_test.cpp b/test/integration/pipeline/multisig_tx_pipeline_test.cpp index c7ad77d174..cb0e913e82 100644 --- a/test/integration/pipeline/multisig_tx_pipeline_test.cpp +++ b/test/integration/pipeline/multisig_tx_pipeline_test.cpp @@ -146,23 +146,17 @@ TEST_F(MstPipelineTest, OnePeerSendsTest) { auto tx = baseTx() .setAccountDetail(kUserId, "fav_meme", "doge") .quorum(kSignatories + 1); - auto check_mst_pending_tx_status = - [](const proto::TransactionResponse &resp) { - ASSERT_NO_THROW( - boost::get(resp.get())); - }; - auto check_enough_signatures_collected_tx_status = - [](const proto::TransactionResponse &resp) { - ASSERT_NO_THROW( - boost::get( - resp.get())); - }; + auto hash = tx.build().hash(); auto &mst_itf = prepareMstItf(); - mst_itf.sendTx(complete(tx, kUserKeypair), check_mst_pending_tx_status) - .sendTx(complete(tx, signatories[0]), check_mst_pending_tx_status) - .sendTx(complete(tx, signatories[1]), - check_enough_signatures_collected_tx_status) + mst_itf.sendTx(complete(tx, kUserKeypair)) + .sendTx(complete(tx, signatories[0])) + .sendTx(complete(tx, signatories[1])) + .checkStatus(hash, CHECK_MST_PENDING) + .checkStatus(hash, CHECK_STATELESS_VALID) + .checkStatus(hash, CHECK_MST_PENDING) + .checkStatus(hash, CHECK_STATELESS_VALID) + .checkStatus(hash, CHECK_ENOUGH_SIGNATURES) .skipProposal() .skipVerifiedProposal() .checkBlock([](auto &proposal) { diff --git a/test/integration/pipeline/pipeline_test.cpp b/test/integration/pipeline/pipeline_test.cpp index b73d1e05f9..104a0b9de1 100644 --- a/test/integration/pipeline/pipeline_test.cpp +++ b/test/integration/pipeline/pipeline_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include @@ -143,8 +131,9 @@ TEST_F(PipelineIntegrationTest, SendTx) { * @then receive STATELESS_VALIDATION_SUCCESS status on that transactions, * all transactions are passed to proposal and appear in verified proposal and * block + * TODO andrei 31.10.18 IR-1784 Refactor MST to batches */ -TEST_F(PipelineIntegrationTest, SendTxSequence) { +TEST_F(PipelineIntegrationTest, DISABLED_SendTxSequence) { size_t tx_size = 5; const auto &tx_sequence = prepareTransactionSequence(tx_size); @@ -179,8 +168,9 @@ TEST_F(PipelineIntegrationTest, SendTxSequence) { * @when sending transaction sequence with stateful valid transactions to the * ledger using sendTxSequence await method * @then all transactions appear in the block + * TODO andrei 31.10.18 IR-1784 Refactor MST to batches */ -TEST_F(PipelineIntegrationTest, SendTxSequenceAwait) { +TEST_F(PipelineIntegrationTest, DISABLED_SendTxSequenceAwait) { size_t tx_size = 5; const auto &tx_sequence = prepareTransactionSequence(tx_size); diff --git a/test/module/iroha-cli/client_test.cpp b/test/module/iroha-cli/client_test.cpp index b1642c3ad4..9baa49c529 100644 --- a/test/module/iroha-cli/client_test.cpp +++ b/test/module/iroha-cli/client_test.cpp @@ -82,15 +82,14 @@ class ClientServerTest : public testing::Test { query_executor = std::make_shared(); storage = std::make_shared(); - rxcpp::subjects::subject> - prop_notifier; + rxcpp::subjects::subject prop_notifier; rxcpp::subjects::subject commit_notifier; - EXPECT_CALL(*pcsMock, on_proposal()) + EXPECT_CALL(*pcsMock, onProposal()) .WillRepeatedly(Return(prop_notifier.get_observable())); EXPECT_CALL(*pcsMock, on_commit()) .WillRepeatedly(Return(commit_notifier.get_observable())); - EXPECT_CALL(*pcsMock, on_verified_proposal()) + EXPECT_CALL(*pcsMock, onVerifiedProposal()) .WillRepeatedly(Return(verified_prop_notifier.get_observable())); EXPECT_CALL(*mst, onStateUpdateImpl()) @@ -202,8 +201,7 @@ class ClientServerTest : public testing::Test { std::shared_ptr query_response_factory; - rxcpp::subjects::subject< - std::shared_ptr> + rxcpp::subjects::subject verified_prop_notifier; rxcpp::subjects::subject> mst_update_notifier; @@ -215,6 +213,7 @@ class ClientServerTest : public testing::Test { std::shared_ptr query_executor; std::shared_ptr storage; + iroha::consensus::Round round; const std::string ip = "127.0.0.1"; int port; }; @@ -332,7 +331,9 @@ TEST_F(ClientServerTest, SendTxWhenStatefulInvalid) { std::make_pair(tx.hash(), iroha::validation::CommandError{ cmd_name, error_code, "", true, cmd_index})); - verified_prop_notifier.get_subscriber().on_next(verified_proposal_and_errors); + verified_prop_notifier.get_subscriber().on_next( + iroha::simulator::VerifiedProposalCreatorEvent{ + verified_proposal_and_errors, round}); auto getAnswer = [&]() { return client.getTxStatus(shared_model::crypto::toBinaryString(tx.hash())) diff --git a/test/module/irohad/CMakeLists.txt b/test/module/irohad/CMakeLists.txt index df7925e792..69315d8101 100644 --- a/test/module/irohad/CMakeLists.txt +++ b/test/module/irohad/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2018 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # Reusable tests add_subdirectory(ametsuchi) diff --git a/test/module/irohad/ametsuchi/CMakeLists.txt b/test/module/irohad/ametsuchi/CMakeLists.txt index 2855430222..579ac18dfe 100644 --- a/test/module/irohad/ametsuchi/CMakeLists.txt +++ b/test/module/irohad/ametsuchi/CMakeLists.txt @@ -50,13 +50,16 @@ target_link_libraries(postgres_options_test addtest(postgres_executor_test postgres_executor_test.cpp) target_link_libraries(postgres_executor_test - integration_framework + integration_framework_config_helper + shared_model_proto_backend + shared_model_default_builders ametsuchi commands_mocks_factory ) addtest(postgres_query_executor_test postgres_query_executor_test.cpp) target_link_libraries(postgres_query_executor_test + shared_model_proto_backend ametsuchi_fixture ametsuchi commands_mocks_factory diff --git a/test/module/irohad/ametsuchi/ametsuchi_fixture.hpp b/test/module/irohad/ametsuchi/ametsuchi_fixture.hpp index 2b3ef8c645..d3bb5cf968 100644 --- a/test/module/irohad/ametsuchi/ametsuchi_fixture.hpp +++ b/test/module/irohad/ametsuchi/ametsuchi_fixture.hpp @@ -152,9 +152,10 @@ CREATE TABLE IF NOT EXISTS account_has_grantable_permissions ( permission_id character varying(45), PRIMARY KEY (permittee_account_id, account_id, permission_id) ); -CREATE TABLE IF NOT EXISTS height_by_hash ( +CREATE TABLE IF NOT EXISTS position_by_hash ( hash varchar, - height text + height text, + index text ); CREATE TABLE IF NOT EXISTS tx_status_by_hash ( diff --git a/test/module/irohad/ametsuchi/block_query_test.cpp b/test/module/irohad/ametsuchi/block_query_test.cpp index 2e2d347fef..b9feb2c08c 100644 --- a/test/module/irohad/ametsuchi/block_query_test.cpp +++ b/test/module/irohad/ametsuchi/block_query_test.cpp @@ -81,11 +81,13 @@ class BlockQueryTest : public AmetsuchiTest { .build(); for (const auto &b : {std::move(block1), std::move(block2)}) { - file->add(b.height(), - iroha::stringToBytes( - shared_model::converters::protobuf::modelToJson(b))); - index->index(b); - blocks_total++; + converter->serialize(b).match( + [this, &b](const iroha::expected::Value &json) { + file->add(b.height(), iroha::stringToBytes(json.value)); + index->index(b); + blocks_total++; + }, + [](const auto &error) { FAIL() << error.error; }); } } diff --git a/test/module/irohad/ametsuchi/block_query_transfer_test.cpp b/test/module/irohad/ametsuchi/block_query_transfer_test.cpp index a79a220fde..2addf98055 100644 --- a/test/module/irohad/ametsuchi/block_query_transfer_test.cpp +++ b/test/module/irohad/ametsuchi/block_query_transfer_test.cpp @@ -43,7 +43,7 @@ namespace iroha { sql = std::make_unique(soci::postgresql, pgopt_); index = std::make_shared(*sql); - auto converter = + converter = std::make_shared(); blocks = std::make_shared(*sql, *file, converter); @@ -51,10 +51,12 @@ namespace iroha { } void insert(const shared_model::proto::Block &block) { - file->add(block.height(), - iroha::stringToBytes( - shared_model::converters::protobuf::modelToJson(block))); - index->index(block); + converter->serialize(block).match( + [this, &block](const iroha::expected::Value &json) { + file->add(block.height(), iroha::stringToBytes(json.value)); + index->index(block); + }, + [](const auto &error) { FAIL() << error.error; }); } void TearDown() override { @@ -71,6 +73,7 @@ namespace iroha { std::string creator2 = "user2@test"; std::string creator3 = "user3@test"; std::string asset = "coin#test"; + std::shared_ptr converter; }; auto zero_string = std::string(32, '0'); diff --git a/test/module/irohad/ametsuchi/postgres_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_executor_test.cpp index 2823c504d6..310bb35a54 100644 --- a/test/module/irohad/ametsuchi/postgres_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_executor_test.cpp @@ -111,6 +111,26 @@ namespace iroha { true); } + /** + * Add one specific permission for account + * @param perm - role permission to add + * @param account_id - tester account_id, by default "id@domain" + * @param role_id - name of the role for tester, by default "all" + */ + void addOnePerm( + const shared_model::interface::permissions::Role perm, + const shared_model::interface::types::AccountIdType account_id = + "id@domain", + const shared_model::interface::types::RoleIdType role_id = "all") { + shared_model::interface::RolePermissionSet permissions; + permissions.set(perm); + execute( + *mock_command_factory->constructCreateRole(role_id, permissions), + true); + execute(*mock_command_factory->constructAppendRole(account_id, role_id), + true); + } + /** * Check that command result contains specific error code and error * message @@ -192,10 +212,11 @@ namespace iroha { /** * Add default asset and check that it is done */ - void addAsset() { - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1), - true); + void addAsset(const shared_model::interface::types::DomainIdType + &domain_id = "domain") { + execute( + *mock_command_factory->constructCreateAsset("coin", domain_id, 1), + true); } shared_model::interface::types::AssetIdType asset_id = @@ -203,8 +224,8 @@ namespace iroha { }; /** - * @given command - * @when trying to add account asset + * @given addAccountAsset command + * @when trying to add asset to account * @then account asset is successfully added */ TEST_F(AddAccountAssetTest, Valid) { @@ -227,6 +248,71 @@ namespace iroha { ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); } + /** + * @given addAccountAsset command + * @when trying to add asset to account with a domain permission + * @then account asset is successfully added + */ + TEST_F(AddAccountAssetTest, DomainPermValid) { + addAsset(); + addOnePerm( + shared_model::interface::permissions::Role::kAddDomainAssetQty); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero)); + + auto account_asset = + query->getAccountAsset(account->accountId(), asset_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero)); + + account_asset = query->getAccountAsset(account->accountId(), asset_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); + } + + /** + * @given addAccountAsset command and invalid domain permission + * @when trying to add asset + * @then account asset is not added + */ + TEST_F(AddAccountAssetTest, DomainPermInvalid) { + std::unique_ptr domain2; + domain2 = clone( + TestDomainBuilder().domainId("domain2").defaultRole(role).build()); + execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), + role), + true); + addAsset(domain2->domainId()); + addOnePerm( + shared_model::interface::permissions::Role::kAddDomainAssetQty); + + auto asset2_id = "coin#" + domain2->domainId(); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset2_id, asset_amount_one_zero), + true); + + auto account_asset = + query->getAccountAsset(account->accountId(), asset2_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ(asset_amount_one_zero, + account_asset.get()->balance()); + + auto cmd_result = + execute(*mock_command_factory->constructAddAssetQuantity( + asset2_id, asset_amount_one_zero)); + + std::vector query_args{account->accountId(), + asset_amount_one_zero.toStringRepr(), + asset2_id, + "1"}; + CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); + } + /** * @given command * @when trying to add account asset without permission @@ -1499,16 +1585,17 @@ namespace iroha { /** * Add default asset and check that it is done */ - void addAsset() { + void addAsset(const shared_model::interface::types::DomainIdType + &domain_id = "domain") { auto asset = clone(TestAccountAssetBuilder() - .domainId(domain->domainId()) + .domainId(domain_id) .assetId(asset_id) .precision(1) .build()); - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1), - true); + execute( + *mock_command_factory->constructCreateAsset("coin", domain_id, 1), + true); } shared_model::interface::types::AssetIdType asset_id = @@ -1573,6 +1660,86 @@ namespace iroha { ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } + /** + * @given command and domain permission + * @when trying to subtract account asset + * @then account asset is successfully subtracted + */ + TEST_F(SubtractAccountAssetTest, DomainPermValid) { + addAsset(); + addOnePerm( + shared_model::interface::permissions::Role::kSubtractDomainAssetQty); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); + + auto account_asset = + query->getAccountAsset(account->accountId(), asset_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ(asset_amount_one_zero, + account_asset.get()->balance()); + + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); + + account_asset = query->getAccountAsset(account->accountId(), asset_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); + + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, asset_amount_one_zero), + true); + + account_asset = query->getAccountAsset(account->accountId(), asset_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ(asset_amount_one_zero, + account_asset.get()->balance()); + } + + /** + * @given command and invalid domain permission/ permission in other domain + * @when trying to subtract asset + * @then no account asset is subtracted + */ + TEST_F(SubtractAccountAssetTest, DomainPermInvalid) { + std::unique_ptr domain2; + domain2 = clone( + TestDomainBuilder().domainId("domain2").defaultRole(role).build()); + execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), + role), + true); + addAsset(domain2->domainId()); + addOnePerm( + shared_model::interface::permissions::Role::kSubtractDomainAssetQty); + + auto asset2_id = "coin#" + domain2->domainId(); + execute(*mock_command_factory->constructAddAssetQuantity( + asset2_id, asset_amount_one_zero), + true); + auto account_asset = + query->getAccountAsset(account->accountId(), asset2_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ(asset_amount_one_zero, + account_asset.get()->balance()); + + auto cmd_result = + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset2_id, asset_amount_one_zero)); + + std::vector query_args{account->accountId(), + asset2_id, + asset_amount_one_zero.toStringRepr(), + "1"}; + CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); + + account_asset = query->getAccountAsset(account->accountId(), asset2_id); + ASSERT_TRUE(account_asset); + ASSERT_EQ(asset_amount_one_zero, + account_asset.get()->balance()); + } + /** * @given command * @when trying to subtract account asset with non-existing asset diff --git a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp index c77a193f39..8ae6a1b961 100644 --- a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp @@ -5,11 +5,22 @@ #include "ametsuchi/impl/postgres_query_executor.hpp" +#include +#include +#include +#include +#include + +#include +#include #include "ametsuchi/impl/flat_file/flat_file.hpp" #include "ametsuchi/impl/postgres_command_executor.hpp" #include "ametsuchi/impl/postgres_wsv_query.hpp" #include "backend/protobuf/proto_query_response_factory.hpp" +#include "datetime/time.hpp" #include "framework/result_fixture.hpp" +#include "interfaces/common_objects/types.hpp" +#include "interfaces/permissions.hpp" #include "interfaces/query_responses/account_asset_response.hpp" #include "interfaces/query_responses/account_detail_response.hpp" #include "interfaces/query_responses/account_response.hpp" @@ -17,6 +28,7 @@ #include "interfaces/query_responses/role_permissions.hpp" #include "interfaces/query_responses/roles_response.hpp" #include "interfaces/query_responses/signatories_response.hpp" +#include "interfaces/query_responses/transactions_page_response.hpp" #include "interfaces/query_responses/transactions_response.hpp" #include "module/irohad/ametsuchi/ametsuchi_fixture.hpp" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" @@ -30,23 +42,90 @@ #include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" #include "module/shared_model/mock_objects_factories/mock_command_factory.hpp" +using namespace framework::expected; +using namespace shared_model::interface; + +namespace shared_model { + namespace crypto { + void PrintTo(const shared_model::crypto::Hash &hash, std::ostream *os) { + *os << hash.toString(); + } + } // namespace crypto +} // namespace shared_model + +namespace { + constexpr types::TransactionsNumberType kTxPageSize(10); + constexpr types::PrecisionType kAssetPrecision(1); + // TODO mboldyrev 05.12.2018 IR-57 unify the common constants. + constexpr size_t kHashLength = 32; + const std::string zero_string{kHashLength, '0'}; + const std::string asset_id = "coin#domain"; + const std::string role = "role"; + const std::unique_ptr domain = + clone(TestDomainBuilder().domainId("domain").defaultRole(role).build()); + const std::unique_ptr account = + clone(TestAccountBuilder() + .domainId(domain->domainId()) + .accountId("id@" + domain->domainId()) + .quorum(1) + .jsonData(R"({"id@domain": {"key": "value"}})") + .build()); + const std::unique_ptr account2 = + clone(TestAccountBuilder() + .domainId(domain->domainId()) + .accountId("id2@" + domain->domainId()) + .quorum(1) + .jsonData(R"({"id@domain": {"key": "value"}})") + .build()); +} // namespace + namespace iroha { namespace ametsuchi { - using namespace framework::expected; + /** + * Check that query response meets defined requirements + * @tparam ExpectedQueryResponseType - expected type of that query + * response + * @tparam QueryResultCheckCallable - type of callable, which checks query + * response + * @param exec_result to be checked + * @param check_callable - that check callable + */ + template + void checkSuccessfulResult(QueryExecutorResult exec_result, + QueryResultCheckCallable check_callable) { + ASSERT_NO_THROW({ + const auto &cast_resp = + boost::get(exec_result->get()); + check_callable(cast_resp); + }) << exec_result->toString(); + } + + /** + * Check that stateful error in query response is the one expected + * @tparam ExpectedQueryErrorType - expected sub-type of that query + * response + * @param exec_result to be checked + * @param expected_code, which is to be in the query response + */ + template + void checkStatefulError( + QueryExecutorResult exec_result, + shared_model::interface::ErrorQueryResponse::ErrorCodeType + expected_code) { + ASSERT_NO_THROW({ + const auto &error_qry_rsp = + boost::get( + exec_result->get()); + ASSERT_EQ(error_qry_rsp.errorCode(), expected_code); + boost::get(error_qry_rsp.get()); + }) << exec_result->toString(); + } class QueryExecutorTest : public AmetsuchiTest { public: QueryExecutorTest() { - domain = clone( - TestDomainBuilder().domainId("domain").defaultRole(role).build()); - - account = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); role_permissions.set( shared_model::interface::permissions::Role::kAddMySignatory); grantable_permission = @@ -153,47 +232,8 @@ namespace iroha { ErrorCodeType kNoStatefulError = 0; static constexpr shared_model::interface::ErrorQueryResponse:: ErrorCodeType kNoPermissions = 2; - - /** - * Check that query response meets defined requirements - * @tparam ExpectedQueryResponseType - expected type of that query - * response - * @tparam QueryResultCheckCallable - type of callable, which checks query - * response - * @param exec_result to be checked - * @param check_callable - that check callable - */ - template - void checkSuccessfulResult(QueryExecutorResult exec_result, - QueryResultCheckCallable check_callable) { - ASSERT_NO_THROW({ - const auto &cast_resp = - boost::get(exec_result->get()); - check_callable(cast_resp); - }) << exec_result->toString(); - } - - /** - * Check that stateful error in query response is the one expected - * @tparam ExpectedQueryErrorType - expected sub-type of that query - * response - * @param exec_result to be checked - * @param expected_code, which is to be in the query response - */ - template - void checkStatefulError( - QueryExecutorResult exec_result, - shared_model::interface::ErrorQueryResponse::ErrorCodeType - expected_code) { - ASSERT_NO_THROW({ - const auto &error_qry_rsp = - boost::get( - exec_result->get()); - ASSERT_EQ(error_qry_rsp.errorCode(), expected_code); - boost::get(error_qry_rsp.get()); - }) << exec_result->toString(); - } + static constexpr shared_model::interface::ErrorQueryResponse:: + ErrorCodeType kInvalidPagination = 4; void createDefaultAccount() { execute(*mock_command_factory->constructCreateAccount( @@ -210,9 +250,8 @@ namespace iroha { std::string role = "role"; shared_model::interface::RolePermissionSet role_permissions; shared_model::interface::permissions::Grantable grantable_permission; - std::unique_ptr account, - another_account; - std::unique_ptr domain, another_domain; + std::unique_ptr another_account; + std::unique_ptr another_domain; std::unique_ptr pubkey; std::unique_ptr pubkey2; @@ -302,7 +341,7 @@ namespace iroha { .build(); auto result = executeQuery(query); checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { + std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.account().accountId(), account->accountId()); }); } @@ -390,6 +429,11 @@ namespace iroha { createDefaultAccount(); } + // TODO mboldyrev 05.12.2018 IR-57 unify the common constants. + // Some of them, like account2, are defined multiple times, but seem + // contain the same and never modified. Looks like a global constant. + // Also, there is another_account, which seems forgotten by the creators + // of account2's (probably due to the same reason). std::unique_ptr account2; }; @@ -976,12 +1020,6 @@ namespace iroha { ASSERT_TRUE(block_store); this->block_store = std::move(block_store.get()); - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); createDefaultAccount(); createDefaultAsset(); } @@ -1007,7 +1045,6 @@ namespace iroha { } void commitBlocks() { - auto zero_string = std::string(32, '0'); auto fake_hash = shared_model::crypto::Hash(zero_string); auto fake_pubkey = shared_model::crypto::PublicKey(zero_string); @@ -1065,15 +1102,203 @@ namespace iroha { hash3 = txs2.at(0).hash(); } - const std::string asset_id = "coin#domain"; - std::unique_ptr account2; + shared_model::crypto::Hash fake_hash{zero_string}; + shared_model::crypto::PublicKey fake_pubkey{zero_string}; shared_model::crypto::Hash hash1; shared_model::crypto::Hash hash2; shared_model::crypto::Hash hash3; }; - class GetAccountTransactionsExecutorTest - : public GetTransactionsExecutorTest {}; + template + class GetPagedTransactionsExecutorTest + : public GetTransactionsExecutorTest { + protected: + using Impl = QueryTxPaginationTest; + + // create valid transactions and commit them + void createTransactionsAndCommit(size_t transactions_amount) { + addPerms(Impl::getUserPermissions()); + + auto initial_txs = Impl::makeInitialTransactions(transactions_amount); + auto target_txs = Impl::makeTargetTransactions(transactions_amount); + + tx_hashes_.reserve(target_txs.size()); + initial_txs.reserve(initial_txs.size() + target_txs.size()); + for (auto &tx : target_txs) { + tx_hashes_.emplace_back(tx.hash()); + initial_txs.emplace_back(std::move(tx)); + } + + auto block = TestBlockBuilder() + .transactions(initial_txs) + .height(1) + .prevHash(fake_hash) + .build(); + + apply(storage, block); + } + + auto queryPage( + types::TransactionsNumberType page_size, + const boost::optional &first_hash = boost::none) { + auto query = Impl::makeQuery(page_size, first_hash); + return executeQuery(query); + } + + /** + * Check the transactions pagination response compliance to general rules: + * - total transactions number is equal to the number of target + * transactions + * - the number of transactions in response is equal to the requested + * amount if there are enough, otherwie equal to the available amount + * - the returned transactions' and the target transactions' hashes match + * - next transaction hash in response is unset if the last transaction is + * in the response, otherwise it matches the next target transaction hash + */ + void generalTransactionsPageResponseCheck( + const TransactionsPageResponse &tx_page_response, + types::TransactionsNumberType page_size, + const boost::optional &first_hash = + boost::none) const { + EXPECT_EQ(tx_page_response.allTransactionsSize(), tx_hashes_.size()) + << "Wrong `total transactions' number."; + auto resp_tx_hashes = tx_page_response.transactions() + | boost::adaptors::transformed( + [](const auto &tx) { return tx.hash(); }); + const auto page_start = first_hash + ? std::find(tx_hashes_.cbegin(), tx_hashes_.cend(), *first_hash) + : tx_hashes_.cbegin(); + if (first_hash and page_start == tx_hashes_.cend()) { + // Should never reach here as a non-existing first_hash in the + // pagination metadata must cause an error query response instead of + // transaction page response. If we get here, it is a problem of wrong + // test logic. + BOOST_THROW_EXCEPTION( + std::runtime_error("Checking response that does not match " + "the provided query pagination data.")); + return; + } + const auto expected_txs_amount = + std::min(page_size, tx_hashes_.cend() - page_start); + const auto response_txs_amount = boost::size(resp_tx_hashes); + EXPECT_EQ(response_txs_amount, expected_txs_amount) + << "Wrong number of transactions returned."; + auto expected_hash = page_start; + auto response_hash = resp_tx_hashes.begin(); + const auto page_end = + page_start + std::min(response_txs_amount, expected_txs_amount); + while (expected_hash != page_end) { + EXPECT_EQ(*expected_hash++, *response_hash++) + << "Wrong transaction returned."; + } + if (page_end == tx_hashes_.cend()) { + EXPECT_EQ(tx_page_response.nextTxHash(), boost::none) + << "Next transaction hash value must be unset."; + } else { + EXPECT_TRUE(tx_page_response.nextTxHash()); + if (tx_page_response.nextTxHash()) { + EXPECT_EQ(*tx_page_response.nextTxHash(), *page_end) + << "Wrong next transaction hash value."; + } + } + } + + std::vector tx_hashes_; + }; + + struct GetAccountTxPaginationImpl { + static std::initializer_list getUserPermissions() { + return {permissions::Role::kSetDetail, permissions::Role::kGetMyAccTxs}; + } + + static std::vector + makeInitialTransactions(size_t transactions_amount) { + return {}; + } + + static auto makeTargetTransactions(size_t transactions_amount) { + std::vector transactions; + transactions.reserve(transactions_amount); + for (size_t i = 0; i < transactions_amount; ++i) { + transactions.emplace_back( + TestTransactionBuilder() + .creatorAccountId(account->accountId()) + .createdTime(iroha::time::now(std::chrono::milliseconds(i))) + .setAccountDetail(account->accountId(), + "key_" + std::to_string(i), + "val_" + std::to_string(i)) + .build()); + } + return transactions; + } + + static shared_model::proto::Query makeQuery( + types::TransactionsNumberType page_size, + const boost::optional &first_hash = boost::none) { + return TestQueryBuilder() + .creatorAccountId(account->accountId()) + .createdTime(iroha::time::now()) + .getAccountTransactions(account->accountId(), page_size, first_hash) + .build(); + } + }; + + template + static std::string assetAmount(T mantissa, types::PrecisionType precision) { + std::stringstream ss; + ss << std::setprecision(precision) << mantissa; + return ss.str(); + } + + struct GetAccountAssetTxPaginationImpl { + static std::initializer_list getUserPermissions() { + return {permissions::Role::kReceive, + permissions::Role::kGetMyAccAstTxs}; + } + + static std::vector + makeInitialTransactions(size_t transactions_amount) { + return { + TestTransactionBuilder() + .creatorAccountId(account->accountId()) + .createdTime(iroha::time::now()) + .addAssetQuantity( + asset_id, assetAmount(transactions_amount, kAssetPrecision)) + .build()}; + } + + static auto makeTargetTransactions(size_t transactions_amount) { + std::vector transactions; + transactions.reserve(transactions_amount); + for (size_t i = 0; i < transactions_amount; ++i) { + transactions.emplace_back( + TestTransactionBuilder() + .creatorAccountId(account->accountId()) + .createdTime(iroha::time::now(std::chrono::milliseconds(i))) + .transferAsset(account->accountId(), + account2->accountId(), + asset_id, + "tx #" + std::to_string(i), + assetAmount(1, kAssetPrecision)) + .build()); + } + return transactions; + } + + static shared_model::proto::Query makeQuery( + types::TransactionsNumberType page_size, + const boost::optional &first_hash = boost::none) { + return TestQueryBuilder() + .creatorAccountId(account->accountId()) + .createdTime(iroha::time::now()) + .getAccountAssetTransactions( + account->accountId(), asset_id, page_size, first_hash) + .build(); + } + }; + + using GetAccountTransactionsExecutorTest = + GetPagedTransactionsExecutorTest; /** * @given initialized storage, permission to his/her account @@ -1085,13 +1310,14 @@ namespace iroha { commitBlocks(); - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(account->accountId()) - .build(); + auto query = + TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountTransactions(account->accountId(), kTxPageSize) + .build(); auto result = executeQuery(query); - checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { + checkSuccessfulResult( + std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 3); for (const auto &tx : cast_resp.transactions()) { static size_t i = 0; @@ -1112,13 +1338,14 @@ namespace iroha { commitBlocks(); - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(account2->accountId()) - .build(); + auto query = + TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountTransactions(account2->accountId(), kTxPageSize) + .build(); auto result = executeQuery(query); - checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { + checkSuccessfulResult( + std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 2); for (const auto &tx : cast_resp.transactions()) { EXPECT_EQ(account2->accountId(), tx.creatorAccountId()) @@ -1137,13 +1364,14 @@ namespace iroha { commitBlocks(); - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(account2->accountId()) - .build(); + auto query = + TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountTransactions(account2->accountId(), kTxPageSize) + .build(); auto result = executeQuery(query); - checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { + checkSuccessfulResult( + std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 2); for (const auto &tx : cast_resp.transactions()) { EXPECT_EQ(account2->accountId(), tx.creatorAccountId()) @@ -1159,10 +1387,11 @@ namespace iroha { */ TEST_F(GetAccountTransactionsExecutorTest, InvalidDifferentDomain) { addPerms({shared_model::interface::permissions::Role::kGetDomainAccTxs}); - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(another_account->accountId()) - .build(); + auto query = + TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountTransactions(another_account->accountId(), kTxPageSize) + .build(); auto result = executeQuery(query); checkStatefulError( std::move(result), kNoPermissions); @@ -1178,13 +1407,124 @@ namespace iroha { auto query = TestQueryBuilder() .creatorAccountId(account->accountId()) - .getAccountTransactions("some@domain") + .getAccountTransactions("some@domain", kTxPageSize) .build(); auto result = executeQuery(query); checkStatefulError( std::move(result), kNoStatefulError); } + // ------------------------/ tx pagination tests \----------------------- // + + using QueryTxPaginationTestingTypes = + ::testing::Types; + TYPED_TEST_CASE(GetPagedTransactionsExecutorTest, + QueryTxPaginationTestingTypes); + + /** + * @given initialized storage, user has 3 transactions committed + * @when query contains second transaction as a starting + * hash @and 2 transactions page size + * @then response contains exactly 2 transaction + * @and list of transactions starts from second transaction + * @and next transaction hash is not present + */ + TYPED_TEST(GetPagedTransactionsExecutorTest, ValidPagination) { + this->createTransactionsAndCommit(3); + auto &hash = this->tx_hashes_.at(1); + auto size = 2; + auto query_response = this->queryPage(size, hash); + checkSuccessfulResult( + std::move(query_response), + [this, &hash, size](const auto &tx_page_response) { + EXPECT_EQ(tx_page_response.transactions().begin()->hash(), hash); + EXPECT_FALSE(tx_page_response.nextTxHash()); + this->generalTransactionsPageResponseCheck( + tx_page_response, size, hash); + }); + } + + /** + * @given initialized storage, user has 3 transactions committed + * @when query contains 2 transactions page size without starting hash + * @then response contains exactly 2 transactions + * @and starts from the first one + * @and next transaction hash is equal to last committed transaction + * @and total number of transactions equal to 3 + */ + TYPED_TEST(GetPagedTransactionsExecutorTest, ValidPaginationNoHash) { + this->createTransactionsAndCommit(3); + auto size = 2; + auto query_response = this->queryPage(size); + checkSuccessfulResult( + std::move(query_response), + [this, size](const auto &tx_page_response) { + EXPECT_EQ(tx_page_response.transactions().begin()->hash(), + this->tx_hashes_.at(0)); + ASSERT_TRUE(tx_page_response.nextTxHash()); + this->generalTransactionsPageResponseCheck(tx_page_response, size); + }); + } + + /** + * @given initialized storage, user has 3 transactions committed + * @when query contains 10 page size + * @then response contains only 3 committed transactions + */ + TYPED_TEST(GetPagedTransactionsExecutorTest, + PaginationPageBiggerThanTotal) { + this->createTransactionsAndCommit(3); + auto size = 10; + auto query_response = this->queryPage(size); + + checkSuccessfulResult( + std::move(query_response), + [this, size](const auto &tx_page_response) { + this->generalTransactionsPageResponseCheck(tx_page_response, size); + }); + } + + /** + * @given initialized storage, user has 3 transactions committed + * @when query contains non-existent starting hash + * @then error response is returned + */ + TYPED_TEST(GetPagedTransactionsExecutorTest, InvalidHashInPagination) { + this->createTransactionsAndCommit(3); + auto size = 2; + char unknown_hash_string[kHashLength]; + zero_string.copy(unknown_hash_string, kHashLength); + std::strcpy(unknown_hash_string, "no such hash!"); + auto query_response = + this->queryPage(size, types::HashType(unknown_hash_string)); + + checkStatefulError( + std::move(query_response), + BlocksQueryExecutorTest::kInvalidPagination); + } + + /** + * @given initialized storage, user has no committed transactions + * @when query contains 2 transactions page size + * @then response does not contain any transactions + * @and total size is 0 + * @and next hash is not present + */ + TYPED_TEST(GetPagedTransactionsExecutorTest, PaginationNoTransactions) { + this->createTransactionsAndCommit(0); + auto size = 2; + auto query_response = this->queryPage(size); + + checkSuccessfulResult( + std::move(query_response), + [this, size](const auto &tx_page_response) { + this->generalTransactionsPageResponseCheck(tx_page_response, size); + }); + } + + // --------------------\ end of tx pagination tests /-------------------- // + class GetTransactionsHashExecutorTest : public GetTransactionsExecutorTest { }; @@ -1241,8 +1581,8 @@ namespace iroha { }); } - class GetAccountAssetTransactionsExecutorTest - : public GetTransactionsExecutorTest {}; + using GetAccountAssetTransactionsExecutorTest = + GetPagedTransactionsExecutorTest; /** * @given initialized storage, permission to his/her account @@ -1254,13 +1594,13 @@ namespace iroha { commitBlocks(); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssetTransactions(account->accountId(), asset_id) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountAssetTransactions( + account->accountId(), asset_id, kTxPageSize) + .build(); auto result = executeQuery(query); - checkSuccessfulResult( + checkSuccessfulResult( std::move(result), [this](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 2); ASSERT_EQ(cast_resp.transactions()[0].hash(), hash2); @@ -1278,13 +1618,13 @@ namespace iroha { commitBlocks(); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssetTransactions(account2->accountId(), asset_id) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountAssetTransactions( + account2->accountId(), asset_id, kTxPageSize) + .build(); auto result = executeQuery(query); - checkSuccessfulResult( + checkSuccessfulResult( std::move(result), [this](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 2); ASSERT_EQ(cast_resp.transactions()[0].hash(), hash2); @@ -1303,13 +1643,13 @@ namespace iroha { commitBlocks(); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssetTransactions(account2->accountId(), asset_id) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountAssetTransactions( + account2->accountId(), asset_id, kTxPageSize) + .build(); auto result = executeQuery(query); - checkSuccessfulResult( + checkSuccessfulResult( std::move(result), [this](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 2); ASSERT_EQ(cast_resp.transactions()[0].hash(), hash2); @@ -1326,10 +1666,11 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainAccAstTxs}); - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(another_account->accountId()) - .build(); + auto query = + TestQueryBuilder() + .creatorAccountId(account->accountId()) + .getAccountTransactions(another_account->accountId(), kTxPageSize) + .build(); auto result = executeQuery(query); checkStatefulError( std::move(result), kNoPermissions); diff --git a/test/module/irohad/common/raw_block_loader_test.cpp b/test/module/irohad/common/raw_block_loader_test.cpp index b05e9aa7ce..d7fc96ba0d 100644 --- a/test/module/irohad/common/raw_block_loader_test.cpp +++ b/test/module/irohad/common/raw_block_loader_test.cpp @@ -20,13 +20,15 @@ TEST(BlockLoaderTest, BlockLoaderJsonParsing) { BlockLoader loader; auto str = R"({ -"payload": { - "transactions": [], - "height": 1, - "prev_block_hash": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=", - "created_time": 0 - }, -"signatures": [] +"block_v1": { + "payload": { + "transactions": [], + "height": 1, + "prev_block_hash": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=", + "created_time": 0 + }, + "signatures": [] +} })"; auto block = loader.parseBlock(str); diff --git a/test/module/irohad/consensus/yac/yac_gate_test.cpp b/test/module/irohad/consensus/yac/yac_gate_test.cpp index da7dbcb128..cfee5f8b00 100644 --- a/test/module/irohad/consensus/yac/yac_gate_test.cpp +++ b/test/module/irohad/consensus/yac/yac_gate_test.cpp @@ -3,11 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "consensus/yac/impl/yac_gate_impl.hpp" + #include #include #include "consensus/consensus_block_cache.hpp" -#include "consensus/yac/impl/yac_gate_impl.hpp" #include "consensus/yac/storage/yac_proposal_storage.hpp" #include "cryptography/crypto_provider/crypto_defaults.hpp" #include "framework/test_subscriber.hpp" @@ -21,7 +22,6 @@ using namespace iroha::network; using namespace iroha::simulator; using namespace framework::test_subscriber; using namespace shared_model::crypto; -using namespace std; using iroha::consensus::ConsensusResultCache; using ::testing::_; @@ -36,12 +36,25 @@ class YacGateTest : public ::testing::Test { auto keypair = shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair(); - expected_hash = YacHash(iroha::consensus::Round{1, 1}, "proposal", "block"); + expected_hash = YacHash(round, "proposal", "block"); auto block = std::make_shared(); EXPECT_CALL(*block, payload()) .WillRepeatedly(ReturnRefOfCopy(Blob(std::string()))); EXPECT_CALL(*block, addSignature(_, _)).WillRepeatedly(Return(true)); + EXPECT_CALL(*block, height()).WillRepeatedly(Return(1)); + EXPECT_CALL(*block, txsNumber()).WillRepeatedly(Return(0)); + EXPECT_CALL(*block, createdTime()).WillRepeatedly(Return(1)); + EXPECT_CALL(*block, transactions()) + .WillRepeatedly( + Return( + {})); + EXPECT_CALL(*block, signatures()) + .WillRepeatedly( + Return({})); + auto prev_hash = Hash("prev hash"); + EXPECT_CALL(*block, prevHash()) + .WillRepeatedly(testing::ReturnRefOfCopy(prev_hash)); expected_block = block; auto signature = std::make_shared(); @@ -54,41 +67,49 @@ class YacGateTest : public ::testing::Test { message.hash = expected_hash; message.signature = signature; commit_message = CommitMessage({message}); - expected_commit = rxcpp::observable<>::just(Answer(commit_message)); - - hash_gate = make_unique(); - peer_orderer = make_unique(); - hash_provider = make_shared(); - block_creator = make_shared(); - block_loader = make_shared(); - block_cache = make_shared(); - } + expected_commit = commit_message; - void init() { - gate = std::make_shared(std::move(hash_gate), - std::move(peer_orderer), + auto hash_gate_ptr = std::make_unique(); + hash_gate = hash_gate_ptr.get(); + auto peer_orderer_ptr = std::make_unique(); + peer_orderer = peer_orderer_ptr.get(); + hash_provider = std::make_shared(); + block_creator = std::make_shared(); + block_cache = std::make_shared(); + + ON_CALL(*hash_gate, onOutcome()) + .WillByDefault(Return(outcome_notifier.get_observable())); + + ON_CALL(*block_creator, onBlock()) + .WillByDefault(Return(block_notifier.get_observable())); + + gate = std::make_shared(std::move(hash_gate_ptr), + std::move(peer_orderer_ptr), hash_provider, block_creator, - block_loader, block_cache); } + iroha::consensus::Round round{1, 1}; PublicKey expected_pubkey{"expected_pubkey"}; Signed expected_signed{"expected_signed"}; + Hash prev_hash{"prev hash"}; YacHash expected_hash; + std::shared_ptr expected_proposal; std::shared_ptr expected_block; VoteMessage message; CommitMessage commit_message; - rxcpp::observable expected_commit; + Answer expected_commit{commit_message}; + rxcpp::subjects::subject block_notifier; + rxcpp::subjects::subject outcome_notifier; - unique_ptr hash_gate; - unique_ptr peer_orderer; - shared_ptr hash_provider; - shared_ptr block_creator; - shared_ptr block_loader; - shared_ptr block_cache; + MockHashGate *hash_gate; + MockYacPeerOrderer *peer_orderer; + std::shared_ptr hash_provider; + std::shared_ptr block_creator; + std::shared_ptr block_cache; - shared_ptr gate; + std::shared_ptr gate; protected: YacGateTest() : commit_message(std::vector{}) {} @@ -103,8 +124,6 @@ TEST_F(YacGateTest, YacGateSubscriptionTest) { // yac consensus EXPECT_CALL(*hash_gate, vote(expected_hash, _)).Times(1); - EXPECT_CALL(*hash_gate, onOutcome()).WillOnce(Return(expected_commit)); - // generate order of peers EXPECT_CALL(*peer_orderer, getOrdering(_)) .WillOnce(Return(ClusterOrdering::create({mk_peer("fake_node")}))); @@ -112,26 +131,26 @@ TEST_F(YacGateTest, YacGateSubscriptionTest) { // make hash from block EXPECT_CALL(*hash_provider, makeHash(_)).WillOnce(Return(expected_hash)); - // make blocks - EXPECT_CALL(*block_creator, on_block()) - .WillOnce(Return(rxcpp::observable<>::just(expected_block))); - - init(); + block_notifier.get_subscriber().on_next( + BlockCreatorEvent{RoundData{expected_proposal, expected_block}, round}); // verify that block we voted for is in the cache auto cache_block = block_cache->get(); ASSERT_EQ(cache_block, expected_block); // verify that yac gate emit expected block - auto gate_wrapper = make_test_subscriber(gate->on_commit(), 1); - gate_wrapper.subscribe([this](auto commit) { - ASSERT_EQ(commit.block, expected_block); + auto gate_wrapper = make_test_subscriber(gate->onOutcome(), 1); + gate_wrapper.subscribe([this](auto outcome) { + auto block = boost::get(outcome).block; + ASSERT_EQ(block, expected_block); // verify that gate has put to cache block received from consensus auto cache_block = block_cache->get(); - ASSERT_EQ(commit.block, cache_block); + ASSERT_EQ(block, cache_block); }); + outcome_notifier.get_subscriber().on_next(expected_commit); + ASSERT_TRUE(gate_wrapper.validate()); } @@ -144,31 +163,40 @@ TEST_F(YacGateTest, YacGateSubscribtionTestFailCase) { // yac consensus EXPECT_CALL(*hash_gate, vote(_, _)).Times(0); - EXPECT_CALL(*hash_gate, onOutcome()).Times(0); - // generate order of peers EXPECT_CALL(*peer_orderer, getOrdering(_)).WillOnce(Return(boost::none)); // make hash from block EXPECT_CALL(*hash_provider, makeHash(_)).WillOnce(Return(expected_hash)); - // make blocks - EXPECT_CALL(*block_creator, on_block()) - .WillOnce(Return(rxcpp::observable<>::just(expected_block))); + block_notifier.get_subscriber().on_next( + BlockCreatorEvent{RoundData{expected_proposal, expected_block}, round}); +} - init(); +/** + * @given yac gate + * @when voted on nothing + * @then cache isn't changed + */ +TEST_F(YacGateTest, AgreementOnNone) { + EXPECT_CALL(*hash_gate, vote(_, _)).Times(1); + + EXPECT_CALL(*peer_orderer, getOrdering(_)) + .WillOnce(Return(ClusterOrdering::create({mk_peer("fake_node")}))); + + ASSERT_EQ(block_cache->get(), nullptr); + + gate->vote({boost::none, round}); + + ASSERT_EQ(block_cache->get(), nullptr); } /** * @given yac gate * @when voting for one block @and receiving another - * @then yac gate will load the block, for which consensus voted, @and emit it + * @then yac gate will emit the data of block, for which consensus voted */ -TEST_F(YacGateTest, LoadBlockWhenDifferentCommit) { - // make blocks - EXPECT_CALL(*block_creator, on_block()) - .WillOnce(Return(rxcpp::observable<>::just(expected_block))); - +TEST_F(YacGateTest, DifferentCommit) { // make hash from block EXPECT_CALL(*hash_provider, makeHash(_)).WillOnce(Return(expected_hash)); @@ -178,10 +206,11 @@ TEST_F(YacGateTest, LoadBlockWhenDifferentCommit) { EXPECT_CALL(*hash_gate, vote(expected_hash, _)).Times(1); + block_notifier.get_subscriber().on_next( + BlockCreatorEvent{RoundData{expected_proposal, expected_block}, round}); + // create another block, which will be "received", and generate a commit // message with it - auto keypair = - shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair(); decltype(expected_block) actual_block = std::make_shared(); Hash actual_hash("actual_hash"); PublicKey actual_pubkey("actual_pubkey"); @@ -189,199 +218,119 @@ TEST_F(YacGateTest, LoadBlockWhenDifferentCommit) { EXPECT_CALL(*signature, publicKey()) .WillRepeatedly(ReturnRefOfCopy(actual_pubkey)); - message.hash = - YacHash(iroha::consensus::Round{1, 1}, "actual_proposal", "actual_block"); + message.hash = YacHash(round, "actual_proposal", "actual_block"); message.signature = signature; commit_message = CommitMessage({message}); - expected_commit = rxcpp::observable<>::just(Answer(commit_message)); - - // yac consensus - EXPECT_CALL(*hash_gate, onOutcome()).WillOnce(Return(expected_commit)); + expected_commit = commit_message; // convert yac hash to model hash EXPECT_CALL(*hash_provider, toModelHash(message.hash)) .WillOnce(Return(actual_hash)); - // load different block - EXPECT_CALL(*block_loader, retrieveBlock(actual_pubkey, actual_hash)) - .WillOnce(Return(actual_block)); - - init(); - // verify that block we voted for is in the cache auto cache_block = block_cache->get(); ASSERT_EQ(cache_block, expected_block); // verify that yac gate emit expected block - std::shared_ptr yac_emitted_block; - auto gate_wrapper = make_test_subscriber(gate->on_commit(), 1); - gate_wrapper.subscribe([actual_block, &yac_emitted_block](auto commit) { - ASSERT_EQ(commit.block, actual_block); - - // memorize the block came from the consensus for future - yac_emitted_block = commit.block; + auto gate_wrapper = make_test_subscriber(gate->onOutcome(), 1); + gate_wrapper.subscribe([actual_hash, actual_pubkey](auto outcome) { + auto concrete_outcome = boost::get(outcome); + auto public_keys = concrete_outcome.public_keys; + auto hash = concrete_outcome.hash; + + ASSERT_EQ(1, public_keys.size()); + ASSERT_EQ(actual_pubkey, public_keys.front()); + ASSERT_EQ(hash, actual_hash); }); - // verify that block, which was received from consensus, is now in the - // cache - ASSERT_EQ(block_cache->get(), yac_emitted_block); + outcome_notifier.get_subscriber().on_next(expected_commit); ASSERT_TRUE(gate_wrapper.validate()); } -/** - * @given yac gate - * @when receives new commit different to the one it voted for - * @then polls nodes for the block with corresponding hash until it succeed, - * (receiving none on the first poll) - */ -TEST_F(YacGateTest, LoadBlockWhenDifferentCommitFailFirst) { - // Vote for block => receive different block => load committed block - - // make blocks - EXPECT_CALL(*block_creator, on_block()) - .WillOnce(Return(rxcpp::observable<>::just(expected_block))); - - // make hash from block - EXPECT_CALL(*hash_provider, makeHash(_)).WillOnce(Return(expected_hash)); - - // generate order of peers - EXPECT_CALL(*peer_orderer, getOrdering(_)) - .WillOnce(Return(ClusterOrdering::create({mk_peer("fake_node")}))); - - EXPECT_CALL(*hash_gate, vote(expected_hash, _)).Times(1); - - // expected values - expected_hash = - YacHash(iroha::consensus::Round{1, 1}, "actual_proposal", "actual_block"); - - Hash actual_hash("actual_hash"); - message.hash = expected_hash; - - commit_message = CommitMessage({message}); - expected_commit = rxcpp::observable<>::just(Answer(commit_message)); - - // yac consensus - EXPECT_CALL(*hash_gate, onOutcome()).WillOnce(Return(expected_commit)); - - // convert yac hash to model hash - EXPECT_CALL(*hash_provider, toModelHash(expected_hash)) - .WillOnce(Return(actual_hash)); - - // load block - EXPECT_CALL(*block_loader, retrieveBlock(expected_pubkey, actual_hash)) - .WillOnce(Return(boost::none)) - .WillOnce(Return(expected_block)); +class YacGateOlderTest : public YacGateTest { + void SetUp() override { + YacGateTest::SetUp(); - init(); + // generate order of peers + ON_CALL(*peer_orderer, getOrdering(_)) + .WillByDefault(Return(ClusterOrdering::create({mk_peer("fake_node")}))); - // verify that yac gate emit expected block - auto gate_wrapper = make_test_subscriber(gate->on_commit(), 1); - gate_wrapper.subscribe( - [this](auto commit) { ASSERT_EQ(commit.block, expected_block); }); + // make hash from block + ON_CALL(*hash_provider, makeHash(_)).WillByDefault(Return(expected_hash)); - ASSERT_TRUE(gate_wrapper.validate()); -} + block_notifier.get_subscriber().on_next( + BlockCreatorEvent{RoundData{expected_proposal, expected_block}, round}); + } +}; /** - * @given yac gate - * @when voting for the block @and receiving it on commit - * @then yac gate will emit this block with the indication that it is the same + * @given yac gate with current round initialized + * @when vote for older round is called + * @then vote is ignored */ -TEST_F(YacGateTest, ProperCommitTypeWhenSameCommit) { - // yac consensus - EXPECT_CALL(*hash_gate, vote(expected_hash, _)).Times(1); - - EXPECT_CALL(*hash_gate, onOutcome()).WillOnce(Return(expected_commit)); - - // generate order of peers - EXPECT_CALL(*peer_orderer, getOrdering(_)) - .WillOnce(Return(ClusterOrdering::create({mk_peer("fake_node")}))); - - // make hash from block - EXPECT_CALL(*hash_provider, makeHash(_)).WillOnce(Return(expected_hash)); - - // make blocks - EXPECT_CALL(*block_creator, on_block()) - .WillOnce(Return(rxcpp::observable<>::just(expected_block))); +TEST_F(YacGateOlderTest, OlderVote) { + EXPECT_CALL(*hash_gate, vote(expected_hash, _)).Times(0); - init(); + EXPECT_CALL(*peer_orderer, getOrdering(_)).Times(0); - // verify that block we voted for is in the cache - auto cache_block = block_cache->get(); - ASSERT_EQ(cache_block, expected_block); + EXPECT_CALL(*hash_provider, makeHash(_)).Times(0); - // verify that yac gate emit expected block - auto gate_wrapper = make_test_subscriber(gate->on_commit(), 1); - gate_wrapper.subscribe([this](auto commit) { - EXPECT_EQ(commit.block, expected_block); - ASSERT_EQ(commit.type, PeerVotedFor::kThisBlock); - }); - - ASSERT_TRUE(gate_wrapper.validate()); + block_notifier.get_subscriber().on_next(BlockCreatorEvent{ + boost::none, {round.block_round - 1, round.reject_round}}); } /** - * @given yac gate - * @when voting for one block @and receiving another - * @then emited commit will have indication that the block is different from - * the one we voted for + * @given yac gate with current round initialized + * @when commit for older round is received + * @then commit is ignored */ -TEST_F(YacGateTest, ProperCommitTypeWhenDifferentBlock) { - // make blocks - EXPECT_CALL(*block_creator, on_block()) - .WillOnce(Return(rxcpp::observable<>::just(expected_block))); - - // make hash from block - EXPECT_CALL(*hash_provider, makeHash(_)).WillOnce(Return(expected_hash)); - - // generate order of peers - EXPECT_CALL(*peer_orderer, getOrdering(_)) - .WillOnce(Return(ClusterOrdering::create({mk_peer("fake_node")}))); - - EXPECT_CALL(*hash_gate, vote(expected_hash, _)).Times(1); - - // create another block, which will be "received", and generate a commit - // message with it - auto keypair = - shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair(); - decltype(expected_block) actual_block = std::make_shared(); - Hash actual_hash("actual_hash"); - PublicKey actual_pubkey("actual_pubkey"); +TEST_F(YacGateOlderTest, OlderCommit) { auto signature = std::make_shared(); EXPECT_CALL(*signature, publicKey()) - .WillRepeatedly(ReturnRefOfCopy(actual_pubkey)); - - message.hash = - YacHash(iroha::consensus::Round{1, 1}, "actual_proposal", "actual_block"); - message.signature = signature; - commit_message = CommitMessage({message}); - expected_commit = rxcpp::observable<>::just(Answer(commit_message)); + .WillRepeatedly(ReturnRefOfCopy(PublicKey("actual_pubkey"))); - // yac consensus - EXPECT_CALL(*hash_gate, onOutcome()).WillOnce(Return(expected_commit)); + VoteMessage message{YacHash({round.block_round - 1, round.reject_round}, + "actual_proposal", + "actual_block"), + signature}; + Answer commit{CommitMessage({message})}; - // convert yac hash to model hash - EXPECT_CALL(*hash_provider, toModelHash(message.hash)) - .WillOnce(Return(actual_hash)); + auto gate_wrapper = make_test_subscriber(gate->onOutcome(), 0); + gate_wrapper.subscribe(); - // load different block - EXPECT_CALL(*block_loader, retrieveBlock(actual_pubkey, actual_hash)) - .WillOnce(Return(actual_block)); + outcome_notifier.get_subscriber().on_next(commit); - init(); + ASSERT_TRUE(gate_wrapper.validate()); +} - // verify that block we voted for is in the cache - auto cache_block = block_cache->get(); - ASSERT_EQ(cache_block, expected_block); +/** + * @given yac gate with current round initialized + * @when reject for older round is received + * @then reject is ignored + */ +TEST_F(YacGateOlderTest, OlderReject) { + auto signature1 = std::make_shared(), + signature2 = std::make_shared(); + EXPECT_CALL(*signature1, publicKey()) + .WillRepeatedly(ReturnRefOfCopy(PublicKey("actual_pubkey1"))); + EXPECT_CALL(*signature2, publicKey()) + .WillRepeatedly(ReturnRefOfCopy(PublicKey("actual_pubkey2"))); + + VoteMessage message1{YacHash({round.block_round - 1, round.reject_round}, + "actual_proposal1", + "actual_block1"), + signature1}, + message2{YacHash({round.block_round - 1, round.reject_round}, + "actual_proposal2", + "actual_block2"), + signature2}; + Answer reject{RejectMessage({message1, message2})}; + + auto gate_wrapper = make_test_subscriber(gate->onOutcome(), 0); + gate_wrapper.subscribe(); + + outcome_notifier.get_subscriber().on_next(reject); - // verify that yac gate emit expected block - std::shared_ptr yac_emitted_block; - auto gate_wrapper = make_test_subscriber(gate->on_commit(), 1); - gate_wrapper.subscribe([actual_block, &yac_emitted_block](auto commit) { - EXPECT_EQ(commit.block, actual_block); - ASSERT_EQ(commit.type, PeerVotedFor::kOtherBlock); - // memorize the block came from the consensus for future - yac_emitted_block = commit.block; - }); + ASSERT_TRUE(gate_wrapper.validate()); } diff --git a/test/module/irohad/consensus/yac/yac_hash_provider_test.cpp b/test/module/irohad/consensus/yac/yac_hash_provider_test.cpp index a47ab3d3fc..ae6d47179c 100644 --- a/test/module/irohad/consensus/yac/yac_hash_provider_test.cpp +++ b/test/module/irohad/consensus/yac/yac_hash_provider_test.cpp @@ -37,6 +37,11 @@ auto signature() { TEST(YacHashProviderTest, MakeYacHashTest) { YacHashProviderImpl hash_provider; + iroha::consensus::Round round{1, 0}; + auto proposal = std::make_shared(); + EXPECT_CALL(*proposal, hash()) + .WillRepeatedly( + ReturnRefOfCopy(shared_model::crypto::Hash(std::string()))); auto block = std::make_shared(); EXPECT_CALL(*block, payload()) .WillRepeatedly( @@ -50,16 +55,24 @@ TEST(YacHashProviderTest, MakeYacHashTest) { 1, signature())) | boost::adaptors::indirected)); - auto hex_test_hash = block->hash().hex(); + auto hex_proposal_hash = proposal->hash().hex(); + auto hex_block_hash = block->hash().hex(); - auto yac_hash = hash_provider.makeHash(*block); + auto yac_hash = hash_provider.makeHash(iroha::simulator::BlockCreatorEvent{ + iroha::simulator::RoundData{proposal, block}, round}); - ASSERT_EQ(hex_test_hash, yac_hash.vote_hashes.proposal_hash); - ASSERT_EQ(hex_test_hash, yac_hash.vote_hashes.block_hash); + ASSERT_EQ(round, yac_hash.vote_round); + ASSERT_EQ(hex_proposal_hash, yac_hash.vote_hashes.proposal_hash); + ASSERT_EQ(hex_block_hash, yac_hash.vote_hashes.block_hash); } TEST(YacHashProviderTest, ToModelHashTest) { YacHashProviderImpl hash_provider; + iroha::consensus::Round round{1, 0}; + auto proposal = std::make_shared(); + EXPECT_CALL(*proposal, hash()) + .WillRepeatedly( + ReturnRefOfCopy(shared_model::crypto::Hash(std::string()))); auto block = std::make_shared(); EXPECT_CALL(*block, payload()) .WillRepeatedly( @@ -73,7 +86,8 @@ TEST(YacHashProviderTest, ToModelHashTest) { 1, signature())) | boost::adaptors::indirected)); - auto yac_hash = hash_provider.makeHash(*block); + auto yac_hash = hash_provider.makeHash(iroha::simulator::BlockCreatorEvent{ + iroha::simulator::RoundData{proposal, block}, round}); auto model_hash = hash_provider.toModelHash(yac_hash); diff --git a/test/module/irohad/consensus/yac/yac_mocks.hpp b/test/module/irohad/consensus/yac/yac_mocks.hpp index 73083824a7..d461e233cd 100644 --- a/test/module/irohad/consensus/yac/yac_mocks.hpp +++ b/test/module/irohad/consensus/yac/yac_mocks.hpp @@ -181,7 +181,7 @@ namespace iroha { class MockYacHashProvider : public YacHashProvider { public: MOCK_CONST_METHOD1(makeHash, - YacHash(const shared_model::interface::Block &)); + YacHash(const simulator::BlockCreatorEvent &event)); MOCK_CONST_METHOD1( toModelHash, diff --git a/test/module/irohad/network/block_loader_test.cpp b/test/module/irohad/network/block_loader_test.cpp index cc96182a74..368e0c229c 100644 --- a/test/module/irohad/network/block_loader_test.cpp +++ b/test/module/irohad/network/block_loader_test.cpp @@ -55,7 +55,9 @@ class BlockLoaderTest : public testing::Test { validator = validator_ptr.get(); loader = std::make_shared( peer_query_factory, - shared_model::proto::ProtoBlockFactory(std::move(validator_ptr))); + shared_model::proto::ProtoBlockFactory( + std::move(validator_ptr), + std::make_unique>())); service = std::make_shared(block_query_factory, block_cache); diff --git a/test/module/irohad/network/network_mocks.hpp b/test/module/irohad/network/network_mocks.hpp index d9d2ff1b6a..c26ac058ab 100644 --- a/test/module/irohad/network/network_mocks.hpp +++ b/test/module/irohad/network/network_mocks.hpp @@ -12,6 +12,7 @@ #include "network/consensus_gate.hpp" #include "network/ordering_gate.hpp" #include "network/peer_communication_service.hpp" +#include "simulator/block_creator_common.hpp" #include "synchronizer/synchronizer_common.hpp" namespace shared_model { @@ -32,18 +33,14 @@ namespace iroha { propagate_batch, void(std::shared_ptr)); - MOCK_CONST_METHOD0( - on_proposal, - rxcpp::observable< - std::shared_ptr>()); + MOCK_CONST_METHOD0(onProposal, rxcpp::observable()); MOCK_CONST_METHOD0( on_commit, rxcpp::observable()); MOCK_CONST_METHOD0( - on_verified_proposal, - rxcpp::observable< - std::shared_ptr>()); + onVerifiedProposal, + rxcpp::observable()); }; class MockBlockLoader : public BlockLoader { @@ -71,18 +68,16 @@ namespace iroha { propagateBatch, void(std::shared_ptr)); - MOCK_METHOD0(on_proposal, - rxcpp::observable< - std::shared_ptr>()); + MOCK_METHOD0(onProposal, rxcpp::observable()); MOCK_METHOD1(setPcs, void(const PeerCommunicationService &)); }; class MockConsensusGate : public ConsensusGate { public: - MOCK_METHOD1(vote, void(std::shared_ptr)); + MOCK_METHOD1(vote, void(const simulator::BlockCreatorEvent &)); - MOCK_METHOD0(on_commit, rxcpp::observable()); + MOCK_METHOD0(onOutcome, rxcpp::observable()); }; } // namespace network diff --git a/test/module/irohad/ordering/CMakeLists.txt b/test/module/irohad/ordering/CMakeLists.txt index 495947ea3d..678aad4916 100644 --- a/test/module/irohad/ordering/CMakeLists.txt +++ b/test/module/irohad/ordering/CMakeLists.txt @@ -1,16 +1,5 @@ -# Copyright 2017 Soramitsu Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 addtest(ordering_service_test ordering_service_test.cpp) target_link_libraries(ordering_service_test @@ -24,6 +13,9 @@ target_link_libraries(ordering_gate_test ordering_service shared_model_cryptography_model shared_model_stateless_validation + consensus_round + ordering_gate_common + on_demand_common ) addtest(on_demand_os_test on_demand_os_test.cpp) @@ -51,6 +43,7 @@ target_link_libraries(on_demand_connection_manager_test addtest(on_demand_ordering_gate_test on_demand_ordering_gate_test.cpp) target_link_libraries(on_demand_ordering_gate_test on_demand_ordering_gate + ordering_gate_common shared_model_interfaces_factories ) diff --git a/test/module/irohad/ordering/on_demand_cache_test.cpp b/test/module/irohad/ordering/on_demand_cache_test.cpp index 69f402c940..88d349ae34 100644 --- a/test/module/irohad/ordering/on_demand_cache_test.cpp +++ b/test/module/irohad/ordering/on_demand_cache_test.cpp @@ -103,9 +103,10 @@ TEST(OnDemandCache, Pop) { } /** - * @given cache with batch1, batch2, and batch3 on the top - * @when remove({batch2, batch3}) is invoked - * @then only batch1 remains on the head of the queue + * @given cache with batch1 and batch2 on the top + * @when remove({hash1}) is invoked, where hash1 is the hash of transactions + * from batch1 + * @then only batch2 remains on the head of the queue */ TEST(OnDemandCache, Remove) { OnDemandCache cache; @@ -114,25 +115,28 @@ TEST(OnDemandCache, Remove) { shared_model::interface::types::HashType hash2("hash2"); shared_model::interface::types::HashType hash3("hash3"); - auto batch1 = createMockBatchWithHash(hash1); - auto batch2 = createMockBatchWithHash(hash2); - auto batch3 = createMockBatchWithHash(hash3); + auto tx1 = createMockTransactionWithHash(hash1); + auto tx2 = createMockTransactionWithHash(hash2); + auto tx3 = createMockTransactionWithHash(hash3); - cache.addToBack({batch1, batch2, batch3}); + auto batch1 = createMockBatchWithTransactions({tx1, tx2}, "abc"); + auto batch2 = createMockBatchWithTransactions({tx3}, "123"); + + cache.addToBack({batch1, batch2}); cache.pop(); cache.pop(); /** - * 1. {batch1, batch2, batch3} + * 1. {batch1, batch2} * 2. * 3. */ - ASSERT_THAT(cache.head(), UnorderedElementsAre(batch1, batch2, batch3)); + ASSERT_THAT(cache.head(), UnorderedElementsAre(batch1, batch2)); - cache.remove({hash2, hash3}); + cache.remove({hash1}); /** - * 1. {batch1} + * 1. {batch2} * 2. * 3. */ - ASSERT_THAT(cache.head(), ElementsAre(batch1)); + ASSERT_THAT(cache.head(), ElementsAre(batch2)); } diff --git a/test/module/irohad/ordering/on_demand_connection_manager_test.cpp b/test/module/irohad/ordering/on_demand_connection_manager_test.cpp index 65f9f4364f..e3205fc620 100644 --- a/test/module/irohad/ordering/on_demand_connection_manager_test.cpp +++ b/test/module/irohad/ordering/on_demand_connection_manager_test.cpp @@ -10,6 +10,7 @@ #include "interfaces/iroha_internal/proposal.hpp" #include "module/irohad/ordering/ordering_mocks.hpp" #include "module/shared_model/interface_mocks.hpp" +#include "ordering/impl/on_demand_common.hpp" using namespace iroha; using namespace iroha::ordering; @@ -44,7 +45,7 @@ struct OnDemandConnectionManagerTest : public ::testing::Test { } manager = std::make_shared( - factory, cpeers, peers.get_observable()); + factory, peers.get_observable(), cpeers); } OnDemandConnectionManager::CurrentPeers cpeers; @@ -75,19 +76,19 @@ TEST_F(OnDemandConnectionManagerTest, FactoryUsed) { TEST_F(OnDemandConnectionManagerTest, onBatches) { OdOsNotification::CollectionType collection; consensus::Round round{1, 2}; - const OnDemandConnectionManager::PeerType types[] = { + + auto set_expect = [&](OnDemandConnectionManager::PeerType type, + consensus::Round round) { + EXPECT_CALL(*connections[type], onBatches(round, collection)).Times(1); + }; + + set_expect( OnDemandConnectionManager::kCurrentRoundRejectConsumer, - OnDemandConnectionManager::kNextRoundRejectConsumer, - OnDemandConnectionManager::kNextRoundCommitConsumer}; - const consensus::Round rounds[] = { - {round.block_round, round.reject_round + 2}, - {round.block_round + 1, 2}, - {round.block_round + 2, 1}}; - for (auto &&pair : boost::combine(types, rounds)) { - EXPECT_CALL(*connections[boost::get<0>(pair)], - onBatches(boost::get<1>(pair), collection)) - .Times(1); - } + {round.block_round, currentRejectRoundConsumer(round.reject_round)}); + set_expect(OnDemandConnectionManager::kNextRoundRejectConsumer, + {round.block_round + 1, kNextRejectRoundConsumer}); + set_expect(OnDemandConnectionManager::kNextRoundCommitConsumer, + {round.block_round + 2, kNextCommitRoundConsumer}); manager->onBatches(round, collection); } diff --git a/test/module/irohad/ordering/on_demand_ordering_gate_test.cpp b/test/module/irohad/ordering/on_demand_ordering_gate_test.cpp index 41d010692b..5332ee2b7e 100644 --- a/test/module/irohad/ordering/on_demand_ordering_gate_test.cpp +++ b/test/module/irohad/ordering/on_demand_ordering_gate_test.cpp @@ -12,6 +12,7 @@ #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/ordering/ordering_mocks.hpp" #include "module/shared_model/interface_mocks.hpp" +#include "ordering/impl/on_demand_common.hpp" using namespace iroha; using namespace iroha::ordering; @@ -23,6 +24,7 @@ using ::testing::_; using ::testing::ByMove; using ::testing::NiceMock; using ::testing::Return; +using ::testing::ReturnRefOfCopy; using ::testing::Truly; using ::testing::UnorderedElementsAre; using ::testing::UnorderedElementsAreArray; @@ -60,7 +62,8 @@ class OnDemandOrderingGateTest : public ::testing::Test { std::shared_ptr cache; - const consensus::Round initial_round = {2, 1}; + const consensus::Round initial_round = {1, kFirstRejectRound}, + round = {2, kFirstRejectRound}; }; /** @@ -86,20 +89,33 @@ TEST_F(OnDemandOrderingGateTest, propagateBatch) { * @then new proposal round based on the received height is initiated */ TEST_F(OnDemandOrderingGateTest, BlockEvent) { - consensus::Round round{3, 1}; - + auto mproposal = std::make_unique(); + auto proposal = mproposal.get(); boost::optional oproposal( - std::make_unique()); - auto proposal = oproposal.value().get(); + std::move(mproposal)); + std::vector> txs{ + std::make_shared()}; + ON_CALL(*txs[0], hash()) + .WillByDefault(ReturnRefOfCopy(shared_model::crypto::Hash(""))); + ON_CALL(*proposal, transactions()) + .WillByDefault(Return(txs | boost::adaptors::indirected)); EXPECT_CALL(*ordering_service, onCollaborationOutcome(round)).Times(1); EXPECT_CALL(*notification, onRequestProposal(round)) .WillOnce(Return(ByMove(std::move(oproposal)))); - EXPECT_CALL(*factory, unsafeCreateProposal(_, _, _)).Times(0); + + auto ufactory_proposal = std::make_unique(); + auto factory_proposal = ufactory_proposal.get(); + EXPECT_CALL(*factory, unsafeCreateProposal(_, _, _)) + .WillOnce(Return(ByMove(std::move(ufactory_proposal)))); + ON_CALL(*factory_proposal, transactions()) + .WillByDefault(Return(txs | boost::adaptors::indirected)); auto gate_wrapper = - make_test_subscriber(ordering_gate->on_proposal(), 1); - gate_wrapper.subscribe([&](auto val) { ASSERT_EQ(val.get(), proposal); }); + make_test_subscriber(ordering_gate->onProposal(), 1); + gate_wrapper.subscribe([&](auto val) { + ASSERT_EQ(factory_proposal, getProposalUnsafe(val).get()); + }); rounds.get_subscriber().on_next(OnDemandOrderingGate::BlockEvent{round, {}}); @@ -113,23 +129,35 @@ TEST_F(OnDemandOrderingGateTest, BlockEvent) { * @then new proposal round based on the received height is initiated */ TEST_F(OnDemandOrderingGateTest, EmptyEvent) { - consensus::Round round{initial_round.block_round, - initial_round.reject_round + 1}; - + auto mproposal = std::make_unique(); + auto proposal = mproposal.get(); boost::optional oproposal( - std::make_unique()); - auto proposal = oproposal.value().get(); + std::move(mproposal)); + std::vector> txs{ + std::make_shared()}; + ON_CALL(*txs[0], hash()) + .WillByDefault(ReturnRefOfCopy(shared_model::crypto::Hash(""))); + ON_CALL(*proposal, transactions()) + .WillByDefault(Return(txs | boost::adaptors::indirected)); EXPECT_CALL(*ordering_service, onCollaborationOutcome(round)).Times(1); EXPECT_CALL(*notification, onRequestProposal(round)) .WillOnce(Return(ByMove(std::move(oproposal)))); - EXPECT_CALL(*factory, unsafeCreateProposal(_, _, _)).Times(0); + + auto ufactory_proposal = std::make_unique(); + auto factory_proposal = ufactory_proposal.get(); + EXPECT_CALL(*factory, unsafeCreateProposal(_, _, _)) + .WillOnce(Return(ByMove(std::move(ufactory_proposal)))); + ON_CALL(*factory_proposal, transactions()) + .WillByDefault(Return(txs | boost::adaptors::indirected)); auto gate_wrapper = - make_test_subscriber(ordering_gate->on_proposal(), 1); - gate_wrapper.subscribe([&](auto val) { ASSERT_EQ(val.get(), proposal); }); + make_test_subscriber(ordering_gate->onProposal(), 1); + gate_wrapper.subscribe([&](auto val) { + ASSERT_EQ(factory_proposal, getProposalUnsafe(val).get()); + }); - rounds.get_subscriber().on_next(OnDemandOrderingGate::EmptyEvent{}); + rounds.get_subscriber().on_next(OnDemandOrderingGate::EmptyEvent{round}); ASSERT_TRUE(gate_wrapper.validate()); } @@ -141,23 +169,15 @@ TEST_F(OnDemandOrderingGateTest, EmptyEvent) { * @then new empty proposal round based on the received height is initiated */ TEST_F(OnDemandOrderingGateTest, BlockEventNoProposal) { - consensus::Round round{3, 1}; - - boost::optional oproposal; + boost::optional proposal; EXPECT_CALL(*ordering_service, onCollaborationOutcome(round)).Times(1); EXPECT_CALL(*notification, onRequestProposal(round)) - .WillOnce(Return(ByMove(std::move(oproposal)))); - - OdOsNotification::ProposalType uproposal; - auto proposal = uproposal.get(); - - EXPECT_CALL(*factory, unsafeCreateProposal(_, _, _)) - .WillOnce(Return(ByMove(std::move(uproposal)))); + .WillOnce(Return(ByMove(std::move(proposal)))); auto gate_wrapper = - make_test_subscriber(ordering_gate->on_proposal(), 1); - gate_wrapper.subscribe([&](auto val) { ASSERT_EQ(val.get(), proposal); }); + make_test_subscriber(ordering_gate->onProposal(), 1); + gate_wrapper.subscribe([&](auto val) { ASSERT_FALSE(val.proposal); }); rounds.get_subscriber().on_next(OnDemandOrderingGate::BlockEvent{round, {}}); @@ -171,26 +191,17 @@ TEST_F(OnDemandOrderingGateTest, BlockEventNoProposal) { * @then new empty proposal round based on the received height is initiated */ TEST_F(OnDemandOrderingGateTest, EmptyEventNoProposal) { - consensus::Round round{initial_round.block_round, - initial_round.reject_round + 1}; - - boost::optional oproposal; + boost::optional proposal; EXPECT_CALL(*ordering_service, onCollaborationOutcome(round)).Times(1); EXPECT_CALL(*notification, onRequestProposal(round)) - .WillOnce(Return(ByMove(std::move(oproposal)))); - - OdOsNotification::ProposalType uproposal; - auto proposal = uproposal.get(); - - EXPECT_CALL(*factory, unsafeCreateProposal(_, _, _)) - .WillOnce(Return(ByMove(std::move(uproposal)))); + .WillOnce(Return(ByMove(std::move(proposal)))); auto gate_wrapper = - make_test_subscriber(ordering_gate->on_proposal(), 1); - gate_wrapper.subscribe([&](auto val) { ASSERT_EQ(val.get(), proposal); }); + make_test_subscriber(ordering_gate->onProposal(), 1); + gate_wrapper.subscribe([&](auto val) { ASSERT_FALSE(val.proposal); }); - rounds.get_subscriber().on_next(OnDemandOrderingGate::EmptyEvent{}); + rounds.get_subscriber().on_next(OnDemandOrderingGate::EmptyEvent{round}); ASSERT_TRUE(gate_wrapper.validate()); } @@ -202,7 +213,7 @@ TEST_F(OnDemandOrderingGateTest, EmptyEventNoProposal) { * this transaction */ TEST_F(OnDemandOrderingGateTest, ReplayedTransactionInProposal) { - OnDemandOrderingGate::BlockEvent event = {initial_round, {}}; + OnDemandOrderingGate::BlockEvent event = {round, {}}; // initialize mock transaction auto tx1 = std::make_shared>(); @@ -218,9 +229,8 @@ TEST_F(OnDemandOrderingGateTest, ReplayedTransactionInProposal) { std::unique_ptr(std::move(proposal)); // set expectations for ordering service - EXPECT_CALL(*ordering_service, onCollaborationOutcome(initial_round)) - .Times(1); - EXPECT_CALL(*notification, onRequestProposal(initial_round)) + EXPECT_CALL(*ordering_service, onCollaborationOutcome(round)).Times(1); + EXPECT_CALL(*notification, onRequestProposal(round)) .WillOnce(Return(ByMove(std::move(arriving_proposal)))); EXPECT_CALL(*tx_cache, check(testing::Matcher(_))) @@ -228,14 +238,21 @@ TEST_F(OnDemandOrderingGateTest, ReplayedTransactionInProposal) { iroha::ametsuchi::tx_cache_status_responses::Committed()))); // expect proposal to be created without any transactions because it was // removed by tx cache + auto ufactory_proposal = std::make_unique(); + auto factory_proposal = ufactory_proposal.get(); + + ON_CALL(*factory_proposal, transactions()) + .WillByDefault( + Return( + {})); EXPECT_CALL( *factory, unsafeCreateProposal( _, _, MockUnsafeProposalFactory::TransactionsCollectionType())) - .Times(1); + .WillOnce(Return(ByMove(std::move(ufactory_proposal)))); auto gate_wrapper = - make_test_subscriber(ordering_gate->on_proposal(), 1); + make_test_subscriber(ordering_gate->onProposal(), 1); gate_wrapper.subscribe([&](auto proposal) {}); rounds.get_subscriber().on_next(event); @@ -248,7 +265,7 @@ TEST_F(OnDemandOrderingGateTest, ReplayedTransactionInProposal) { * batch2 on the head * @then batch1 and batch2 are propagated to network */ -TEST_F(OnDemandOrderingGateTest, SendBatchesFromTheCache) { +TEST_F(OnDemandOrderingGateTest, PopNonEmptyBatchesFromTheCache) { // prepare hashes for mock batches shared_model::interface::types::HashType hash1("hash1"); shared_model::interface::types::HashType hash2("hash2"); @@ -264,11 +281,27 @@ TEST_F(OnDemandOrderingGateTest, SendBatchesFromTheCache) { EXPECT_CALL(*cache, addToBack(UnorderedElementsAreArray(collection))) .Times(1); EXPECT_CALL(*notification, - onBatches(initial_round, UnorderedElementsAreArray(collection))) + onBatches(round, UnorderedElementsAreArray(collection))) .Times(1); - rounds.get_subscriber().on_next( - OnDemandOrderingGate::BlockEvent{initial_round, {}}); + rounds.get_subscriber().on_next(OnDemandOrderingGate::BlockEvent{round, {}}); +} + +/** + * @given initialized ordering gate + * @when block event with no batches is emitted @and cache contains no batches + * on the head + * @then nothing is propagated to the network + */ +TEST_F(OnDemandOrderingGateTest, PopEmptyBatchesFromTheCache) { + cache::OrderingGateCache::BatchesSetType empty_collection{}; + + EXPECT_CALL(*cache, pop()).WillOnce(Return(empty_collection)); + EXPECT_CALL(*cache, addToBack(UnorderedElementsAreArray(empty_collection))) + .Times(1); + EXPECT_CALL(*notification, onBatches(_, _)).Times(0); + + rounds.get_subscriber().on_next(OnDemandOrderingGate::BlockEvent{round, {}}); } /** @@ -289,5 +322,5 @@ TEST_F(OnDemandOrderingGateTest, BatchesRemoveFromCache) { EXPECT_CALL(*cache, remove(UnorderedElementsAre(hash1, hash2))).Times(1); rounds.get_subscriber().on_next( - OnDemandOrderingGate::BlockEvent{initial_round, {hash1, hash2}}); + OnDemandOrderingGate::BlockEvent{round, {hash1, hash2}}); } diff --git a/test/module/irohad/ordering/on_demand_os_test.cpp b/test/module/irohad/ordering/on_demand_os_test.cpp index 6c3878edeb..4fb4be9293 100644 --- a/test/module/irohad/ordering/on_demand_os_test.cpp +++ b/test/module/irohad/ordering/on_demand_os_test.cpp @@ -16,6 +16,7 @@ #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/shared_model/interface_mocks.hpp" #include "module/shared_model/validators/validators.hpp" +#include "ordering/impl/on_demand_common.hpp" using namespace iroha; using namespace iroha::ordering; @@ -39,8 +40,10 @@ class OnDemandOsTest : public ::testing::Test { std::shared_ptr os; const uint64_t transaction_limit = 20; const uint32_t proposal_limit = 5; - const consensus::Round initial_round = {2, 1}, target_round = {4, 1}, - commit_round = {3, 1}, reject_round = {2, 2}; + const consensus::Round initial_round = {2, kFirstRejectRound}, + target_round = {4, kNextCommitRoundConsumer}, + commit_round = {3, kFirstRejectRound}, + reject_round = {2, kNextRejectRoundConsumer}; NiceMock *mock_cache; void SetUp() override { diff --git a/test/module/irohad/ordering/ordering_gate_test.cpp b/test/module/irohad/ordering/ordering_gate_test.cpp index 679c85283a..4619115d60 100644 --- a/test/module/irohad/ordering/ordering_gate_test.cpp +++ b/test/module/irohad/ordering/ordering_gate_test.cpp @@ -89,7 +89,7 @@ class OrderingGateTest : public ::testing::Test { * @then Round starts <==> proposal is emitted to subscribers */ TEST_F(OrderingGateTest, ProposalReceivedByGateWhenSent) { - auto wrapper = make_test_subscriber(gate_impl->on_proposal(), 1); + auto wrapper = make_test_subscriber(gate_impl->onProposal(), 1); wrapper.subscribe(); auto pcs = std::make_shared(); @@ -136,7 +136,7 @@ class QueueBehaviorTest : public ::testing::Test { .WillOnce(Return(commit_subject.get_observable())); ordering_gate.setPcs(*pcs); - ordering_gate.on_proposal().subscribe( + ordering_gate.onProposal().subscribe( [&](auto val) { messages.push_back(val); }); } @@ -144,7 +144,7 @@ class QueueBehaviorTest : public ::testing::Test { std::shared_ptr pcs; rxcpp::subjects::subject commit_subject; OrderingGateImpl ordering_gate; - std::vector messages; + std::vector messages; void pushCommit(HeightType height) { commit_subject.get_subscriber().on_next(SynchronizationEvent{ @@ -152,7 +152,8 @@ class QueueBehaviorTest : public ::testing::Test { std::static_pointer_cast( std::make_shared( TestBlockBuilder().height(height).build()))), - SynchronizationOutcomeType::kCommit}); + SynchronizationOutcomeType::kCommit, + {height, 1}}); } void pushProposal(HeightType height) { @@ -170,10 +171,10 @@ class QueueBehaviorTest : public ::testing::Test { */ TEST_F(QueueBehaviorTest, SendManyProposals) { auto wrapper_before = - make_test_subscriber(ordering_gate.on_proposal(), 1); + make_test_subscriber(ordering_gate.onProposal(), 1); wrapper_before.subscribe(); auto wrapper_after = - make_test_subscriber(ordering_gate.on_proposal(), 2); + make_test_subscriber(ordering_gate.onProposal(), 2); wrapper_after.subscribe(); std::vector txs; @@ -209,8 +210,10 @@ TEST_F(QueueBehaviorTest, SendManyProposals) { std::make_shared( TestBlockBuilder().height(2).build()); - commit_subject.get_subscriber().on_next(SynchronizationEvent{ - rxcpp::observable<>::just(block), SynchronizationOutcomeType::kCommit}); + commit_subject.get_subscriber().on_next( + SynchronizationEvent{rxcpp::observable<>::just(block), + SynchronizationOutcomeType::kCommit, + {block->height(), 1}}); ASSERT_TRUE(wrapper_after.validate()); } @@ -219,7 +222,7 @@ TEST_F(QueueBehaviorTest, SendManyProposals) { * @given Initialized OrderingGate * AND MockPeerCommunicationService * @when Receive proposals in random order - * @then on_proposal output is ordered + * @then onProposal output is ordered */ TEST_F(QueueBehaviorTest, ReceiveUnordered) { // this will set unlock_next_ to false, so proposals 3 and 4 are enqueued @@ -232,16 +235,16 @@ TEST_F(QueueBehaviorTest, ReceiveUnordered) { pushCommit(3); ASSERT_EQ(3, messages.size()); - ASSERT_EQ(2, messages.at(0)->height()); - ASSERT_EQ(3, messages.at(1)->height()); - ASSERT_EQ(4, messages.at(2)->height()); + ASSERT_EQ(2, getProposalUnsafe(messages.at(0))->height()); + ASSERT_EQ(3, getProposalUnsafe(messages.at(1))->height()); + ASSERT_EQ(4, getProposalUnsafe(messages.at(2))->height()); } /** * @given Initialized OrderingGate * AND MockPeerCommunicationService * @when Receive commits which are newer than existing proposals - * @then on_proposal is not invoked on proposals + * @then onProposal is not invoked on proposals * which are older than last committed block */ TEST_F(QueueBehaviorTest, DiscardOldProposals) { @@ -254,8 +257,8 @@ TEST_F(QueueBehaviorTest, DiscardOldProposals) { // proposals 2 and 3 must not be forwarded down the pipeline. EXPECT_EQ(2, messages.size()); - ASSERT_EQ(2, messages.at(0)->height()); - ASSERT_EQ(5, messages.at(1)->height()); + ASSERT_EQ(2, getProposalUnsafe(messages.at(0))->height()); + ASSERT_EQ(5, getProposalUnsafe(messages.at(1))->height()); } /** @@ -273,13 +276,13 @@ TEST_F(QueueBehaviorTest, KeepNewerProposals) { // proposal 3 must be forwarded down the pipeline, 4 kept in queue. EXPECT_EQ(2, messages.size()); - EXPECT_EQ(2, messages.at(0)->height()); - EXPECT_EQ(3, messages.at(1)->height()); + EXPECT_EQ(2, getProposalUnsafe(messages.at(0))->height()); + EXPECT_EQ(3, getProposalUnsafe(messages.at(1))->height()); pushCommit(3); // Now proposal 4 is forwarded to the pipeline EXPECT_EQ(3, messages.size()); - EXPECT_EQ(4, messages.at(2)->height()); + EXPECT_EQ(4, getProposalUnsafe(messages.at(2))->height()); } /** @@ -305,7 +308,7 @@ TEST_F(QueueBehaviorTest, CommitBeforeProposal) { pushProposal(6); EXPECT_EQ(1, messages.size()); - EXPECT_EQ(5, messages.at(0)->height()); + EXPECT_EQ(5, getProposalUnsafe(messages.at(0))->height()); } /** @@ -322,5 +325,5 @@ TEST_F(QueueBehaviorTest, CommitNewerThanAllProposals) { pushCommit(4); EXPECT_EQ(1, messages.size()); - EXPECT_EQ(2, messages.at(0)->height()); + EXPECT_EQ(2, getProposalUnsafe(messages.at(0))->height()); } diff --git a/test/module/irohad/simulator/simulator_mocks.hpp b/test/module/irohad/simulator/simulator_mocks.hpp index ad272c5875..0c1abb7cd5 100644 --- a/test/module/irohad/simulator/simulator_mocks.hpp +++ b/test/module/irohad/simulator/simulator_mocks.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SIMULATOR_MOCKS_HPP @@ -25,12 +13,11 @@ namespace iroha { namespace simulator { class MockBlockCreator : public BlockCreator { public: - MOCK_METHOD1(process_verified_proposal, + MOCK_METHOD2(processVerifiedProposal, void(const std::shared_ptr< - iroha::validation::VerifiedProposalAndErrors> &)); - MOCK_METHOD0( - on_block, - rxcpp::observable>()); + iroha::validation::VerifiedProposalAndErrors> &, + const consensus::Round &)); + MOCK_METHOD0(onBlock, rxcpp::observable()); }; } // namespace simulator } // namespace iroha diff --git a/test/module/irohad/simulator/simulator_test.cpp b/test/module/irohad/simulator/simulator_test.cpp index 85fd918221..16e5789c4f 100644 --- a/test/module/irohad/simulator/simulator_test.cpp +++ b/test/module/irohad/simulator/simulator_test.cpp @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "simulator/impl/simulator.hpp" + #include #include @@ -19,7 +21,6 @@ #include "module/shared_model/builders/protobuf/test_proposal_builder.hpp" #include "module/shared_model/cryptography/crypto_model_signer_mock.hpp" #include "module/shared_model/validators/validators.hpp" -#include "simulator/impl/simulator.hpp" using namespace iroha; using namespace iroha::validation; @@ -31,9 +32,9 @@ using namespace framework::test_subscriber; using ::testing::_; using ::testing::A; using ::testing::Invoke; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnArg; -using ::testing::NiceMock; using wBlock = std::shared_ptr; @@ -55,7 +56,9 @@ class SimulatorTest : public ::testing::Test { std::shared_ptr(query)))); block_factory = std::make_unique( std::make_unique>()); + shared_model::interface::Block>>(), + std::make_unique< + shared_model::validation::MockValidator>()); } void TearDown() override { @@ -71,6 +74,8 @@ class SimulatorTest : public ::testing::Test { std::move(block_factory)); } + consensus::Round round; + std::shared_ptr validator; std::shared_ptr factory; std::shared_ptr query; @@ -90,7 +95,7 @@ shared_model::proto::Block makeBlock(int height) { .build(); } -shared_model::proto::Proposal makeProposal(int height) { +auto makeProposal(int height) { auto tx = shared_model::proto::TransactionBuilder() .createdTime(iroha::time::now()) .creatorAccountId("admin@ru") @@ -107,14 +112,13 @@ shared_model::proto::Proposal makeProposal(int height) { .createdTime(iroha::time::now()) .transactions(txs) .build(); - return proposal; + return std::make_shared(std::move(proposal)); } TEST_F(SimulatorTest, ValidWhenInitialized) { - // simulator constructor => on_proposal subscription called - EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty< - std::shared_ptr>())); + // simulator constructor => onProposal subscription called + EXPECT_CALL(*ordering_gate, onProposal()) + .WillOnce(Return(rxcpp::observable<>::empty())); init(); } @@ -155,9 +159,8 @@ TEST_F(SimulatorTest, ValidWhenPreviousBlock) { return std::move(validation_result); })); - EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty< - std::shared_ptr>())); + EXPECT_CALL(*ordering_gate, onProposal()) + .WillOnce(Return(rxcpp::observable<>::empty())); EXPECT_CALL(*shared_model::crypto::crypto_signer_expecter, sign(A())) @@ -166,8 +169,10 @@ TEST_F(SimulatorTest, ValidWhenPreviousBlock) { init(); auto proposal_wrapper = - make_test_subscriber(simulator->on_verified_proposal(), 1); - proposal_wrapper.subscribe([&proposal](auto verified_proposal) { + make_test_subscriber(simulator->onVerifiedProposal(), 1); + proposal_wrapper.subscribe([&proposal](auto event) { + auto verified_proposal = getVerifiedProposalUnsafe(event); + ASSERT_EQ(verified_proposal->verified_proposal->height(), proposal->height()); ASSERT_EQ(verified_proposal->verified_proposal->transactions(), @@ -175,14 +180,15 @@ TEST_F(SimulatorTest, ValidWhenPreviousBlock) { ASSERT_TRUE(verified_proposal->rejected_transactions.empty()); }); - auto block_wrapper = - make_test_subscriber(simulator->on_block(), 1); - block_wrapper.subscribe([&proposal](const auto block) { + auto block_wrapper = make_test_subscriber(simulator->onBlock(), 1); + block_wrapper.subscribe([&proposal](const auto &event) { + auto block = getBlockUnsafe(event); + ASSERT_EQ(block->height(), proposal->height()); ASSERT_EQ(block->transactions(), proposal->transactions()); }); - simulator->process_proposal(*proposal); + simulator->processProposal(*proposal, round); ASSERT_TRUE(proposal_wrapper.validate()); ASSERT_TRUE(block_wrapper.validate()); @@ -198,9 +204,8 @@ TEST_F(SimulatorTest, FailWhenNoBlock) { EXPECT_CALL(*validator, validate(_, _)).Times(0); - EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty< - std::shared_ptr>())); + EXPECT_CALL(*ordering_gate, onProposal()) + .WillOnce(Return(rxcpp::observable<>::empty())); EXPECT_CALL(*shared_model::crypto::crypto_signer_expecter, sign(A())) @@ -209,14 +214,13 @@ TEST_F(SimulatorTest, FailWhenNoBlock) { init(); auto proposal_wrapper = - make_test_subscriber(simulator->on_verified_proposal(), 0); + make_test_subscriber(simulator->onVerifiedProposal(), 0); proposal_wrapper.subscribe(); - auto block_wrapper = - make_test_subscriber(simulator->on_block(), 0); + auto block_wrapper = make_test_subscriber(simulator->onBlock(), 0); block_wrapper.subscribe(); - simulator->process_proposal(proposal); + simulator->processProposal(*proposal, round); ASSERT_TRUE(proposal_wrapper.validate()); ASSERT_TRUE(block_wrapper.validate()); @@ -226,7 +230,7 @@ TEST_F(SimulatorTest, FailWhenSameAsProposalHeight) { // proposal with height 2 => height 2 block present => no validated proposal auto proposal = makeProposal(2); - auto block = makeBlock(proposal.height()); + auto block = makeBlock(proposal->height()); EXPECT_CALL(*factory, createTemporaryWsv()).Times(0); @@ -235,9 +239,8 @@ TEST_F(SimulatorTest, FailWhenSameAsProposalHeight) { EXPECT_CALL(*validator, validate(_, _)).Times(0); - EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty< - std::shared_ptr>())); + EXPECT_CALL(*ordering_gate, onProposal()) + .WillOnce(Return(rxcpp::observable<>::empty())); EXPECT_CALL(*shared_model::crypto::crypto_signer_expecter, sign(A())) @@ -246,14 +249,13 @@ TEST_F(SimulatorTest, FailWhenSameAsProposalHeight) { init(); auto proposal_wrapper = - make_test_subscriber(simulator->on_verified_proposal(), 0); + make_test_subscriber(simulator->onVerifiedProposal(), 0); proposal_wrapper.subscribe(); - auto block_wrapper = - make_test_subscriber(simulator->on_block(), 0); + auto block_wrapper = make_test_subscriber(simulator->onBlock(), 0); block_wrapper.subscribe(); - simulator->process_proposal(proposal); + simulator->processProposal(*proposal, round); ASSERT_TRUE(proposal_wrapper.validate()); ASSERT_TRUE(block_wrapper.validate()); @@ -306,7 +308,8 @@ TEST_F(SimulatorTest, SomeFailingTxs) { for (auto rejected_tx = txs.begin() + 1; rejected_tx != txs.end(); ++rejected_tx) { verified_proposal_and_errors->rejected_transactions.emplace( - rejected_tx->hash(), validation::CommandError{"SomeCommand", 1, "", true}); + rejected_tx->hash(), + validation::CommandError{"SomeCommand", 1, "", true}); } shared_model::proto::Block block = makeBlock(proposal->height() - 1); @@ -321,9 +324,8 @@ TEST_F(SimulatorTest, SomeFailingTxs) { return std::move(verified_proposal_and_errors); })); - EXPECT_CALL(*ordering_gate, on_proposal()) - .WillOnce(Return(rxcpp::observable<>::empty< - std::shared_ptr>())); + EXPECT_CALL(*ordering_gate, onProposal()) + .WillOnce(Return(rxcpp::observable<>::empty())); EXPECT_CALL(*shared_model::crypto::crypto_signer_expecter, sign(A())) @@ -332,8 +334,10 @@ TEST_F(SimulatorTest, SomeFailingTxs) { init(); auto proposal_wrapper = - make_test_subscriber(simulator->on_verified_proposal(), 1); - proposal_wrapper.subscribe([&](auto verified_proposal_) { + make_test_subscriber(simulator->onVerifiedProposal(), 1); + proposal_wrapper.subscribe([&](auto event) { + auto verified_proposal_ = getVerifiedProposalUnsafe(event); + // ensure that txs in verified proposal do not include failed ones ASSERT_EQ(verified_proposal_->verified_proposal->height(), verified_proposal_height); @@ -352,7 +356,7 @@ TEST_F(SimulatorTest, SomeFailingTxs) { } }); - simulator->process_proposal(*proposal); + simulator->processProposal(*proposal, round); ASSERT_TRUE(proposal_wrapper.validate()); } diff --git a/test/module/irohad/synchronizer/CMakeLists.txt b/test/module/irohad/synchronizer/CMakeLists.txt index 2cc1287ba7..e7922f88df 100644 --- a/test/module/irohad/synchronizer/CMakeLists.txt +++ b/test/module/irohad/synchronizer/CMakeLists.txt @@ -6,4 +6,5 @@ target_link_libraries(synchronizer_test shared_model_stateless_validation shared_model_interfaces_factories shared_model_default_builders + consensus_round ) diff --git a/test/module/irohad/synchronizer/synchronizer_test.cpp b/test/module/irohad/synchronizer/synchronizer_test.cpp index 0898f1e27c..976a130ed1 100644 --- a/test/module/irohad/synchronizer/synchronizer_test.cpp +++ b/test/module/irohad/synchronizer/synchronizer_test.cpp @@ -3,8 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include "synchronizer/impl/synchronizer_impl.hpp" +#include +#include #include "backend/protobuf/block.hpp" #include "framework/test_subscriber.hpp" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" @@ -12,9 +14,7 @@ #include "module/irohad/validation/validation_mocks.hpp" #include "module/shared_model/builders/protobuf/block.hpp" #include "module/shared_model/builders/protobuf/test_block_builder.hpp" -#include "synchronizer/impl/synchronizer_impl.hpp" #include "validation/chain_validator.hpp" -#include "validators/answer.hpp" using namespace iroha; using namespace iroha::ametsuchi; @@ -28,24 +28,6 @@ using ::testing::ByMove; using ::testing::DefaultValue; using ::testing::Return; -class MockBlockValidator { - public: - MOCK_CONST_METHOD1( - validate, - shared_model::validation::Answer(const shared_model::interface::Block &)); -}; - -template -class TemplateMockBlockValidator { - public: - std::shared_ptr validator; - TemplateMockBlockValidator() : validator(std::make_shared()) {} - shared_model::validation::Answer validate( - const shared_model::interface::Block &block) const { - return validator->validate(block); - } -}; - class SynchronizerTest : public ::testing::Test { public: void SetUp() override { @@ -56,33 +38,46 @@ class SynchronizerTest : public ::testing::Test { block_loader = std::make_shared(); consensus_gate = std::make_shared(); block_query = std::make_shared<::testing::NiceMock>(); - } - void init() { + commit_message = makeCommit(); + public_keys = boost::copy_range< + shared_model::interface::types::PublicKeyCollectionType>( + commit_message->signatures() + | boost::adaptors::transformed( + [](auto &signature) { return signature.publicKey(); })); + hash = commit_message->hash(); + + EXPECT_CALL(*consensus_gate, onOutcome()) + .WillOnce(Return(gate_outcome.get_observable())); + + ON_CALL(*block_query_factory, createBlockQuery()) + .WillByDefault(Return(boost::make_optional( + std::shared_ptr(block_query)))); + ON_CALL(*block_query, getTopBlockHeight()) + .WillByDefault(Return(kHeight - 1)); + synchronizer = std::make_shared(consensus_gate, chain_validator, mutable_factory, block_query_factory, block_loader); - ON_CALL(*block_query_factory, createBlockQuery()) - .WillByDefault(Return(boost::make_optional( - std::shared_ptr(block_query)))); } - Commit makeCommit(size_t time = iroha::time::now(), - PeerVotedFor type = PeerVotedFor::kOtherBlock) const { + std::shared_ptr makeCommit( + size_t time = iroha::time::now()) const { auto block = TestUnsignedBlockBuilder() - .height(commit_height) + .height(kHeight) .createdTime(time) .build() .signAndAddSignature( shared_model::crypto::DefaultCryptoAlgorithmType:: generateKeypair()) .finish(); - return {std::make_shared(std::move(block)), - type}; + return std::make_shared(std::move(block)); } + const shared_model::interface::types::HeightType kHeight{5}; + std::shared_ptr chain_validator; std::shared_ptr mutable_factory; std::shared_ptr block_query_factory; @@ -90,60 +85,43 @@ class SynchronizerTest : public ::testing::Test { std::shared_ptr consensus_gate; std::shared_ptr block_query; - const shared_model::interface::types::HeightType commit_height{5}; + std::shared_ptr commit_message; + shared_model::interface::types::PublicKeyCollectionType public_keys; + shared_model::interface::types::HashType hash; + + rxcpp::subjects::subject gate_outcome; std::shared_ptr synchronizer; }; -TEST_F(SynchronizerTest, ValidWhenInitialized) { - // synchronizer constructor => on_commit subscription called - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); - - init(); -} - /** * @given A commit from consensus and initialized components * @when a valid block that can be applied * @then Successful commit */ TEST_F(SynchronizerTest, ValidWhenSingleCommitSynchronized) { - std::shared_ptr test_block = - std::make_shared( - TestBlockBuilder().height(5).build()); - rxcpp::observable> - test_blocks = rxcpp::observable<>::just(test_block); - DefaultValue, std::string>>:: SetFactory(&createMockMutableStorage); EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(1); - EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); - - EXPECT_CALL(*chain_validator, validateAndApply(_, _)).WillOnce(Return(true)); - + EXPECT_CALL(*chain_validator, validateAndApply(_, _)).Times(0); EXPECT_CALL(*block_loader, retrieveBlocks(_, _)).Times(0); - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); - - init(); - auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 1); - wrapper.subscribe([test_block](auto commit_event) { + wrapper.subscribe([this](auto commit_event) { auto block_wrapper = make_test_subscriber(commit_event.synced_blocks, 1); - block_wrapper.subscribe([test_block](auto block) { + block_wrapper.subscribe([this](auto block) { // Check commit block - ASSERT_EQ(block->height(), test_block->height()); + ASSERT_EQ(block->height(), commit_message->height()); }); ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kCommit); ASSERT_TRUE(block_wrapper.validate()); }); - synchronizer->process_commit(Commit{test_block, PeerVotedFor::kOtherBlock}); + gate_outcome.get_subscriber().on_next( + consensus::PairValid{commit_message, consensus::Round{kHeight, 1}}); ASSERT_TRUE(wrapper.validate()); } @@ -154,97 +132,69 @@ TEST_F(SynchronizerTest, ValidWhenSingleCommitSynchronized) { * @then No commit should be passed */ TEST_F(SynchronizerTest, ValidWhenBadStorage) { - std::shared_ptr test_block = - std::make_shared(TestBlockBuilder().build()); - DefaultValue< expected::Result, std::string>>::Clear(); - EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(0); - + EXPECT_CALL(*mutable_factory, createMutableStorage()) + .WillOnce(Return(ByMove(expected::makeError("Connection was closed")))); EXPECT_CALL(*mutable_factory, commit_(_)).Times(0); - EXPECT_CALL(*chain_validator, validateAndApply(_, _)).Times(0); - EXPECT_CALL(*block_loader, retrieveBlocks(_, _)).Times(0); - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); - - init(); - auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 0); wrapper.subscribe(); - synchronizer->process_commit(Commit{test_block, PeerVotedFor::kOtherBlock}); + gate_outcome.get_subscriber().on_next( + consensus::PairValid{commit_message, consensus::Round{kHeight, 1}}); ASSERT_TRUE(wrapper.validate()); } /** * @given A commit from consensus and initialized components - * @when A valid chain with expected ending + * @when gate have voted for other block * @then Successful commit */ TEST_F(SynchronizerTest, ValidWhenValidChain) { - auto commit_message = makeCommit(); - rxcpp::observable> - commit_message_blocks = rxcpp::observable<>::just(commit_message.block); - DefaultValue, std::string>>:: SetFactory(&createMockMutableStorage); EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(1); EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); - - EXPECT_CALL(*chain_validator, validateAndApply(_, _)) - .WillOnce(Return(false)) - .WillOnce(Return(true)); - + EXPECT_CALL(*chain_validator, validateAndApply(_, _)).WillOnce(Return(true)); EXPECT_CALL(*block_loader, retrieveBlocks(_, _)) - .WillOnce(Return(commit_message_blocks)); - - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); - - init(); + .WillOnce(Return(rxcpp::observable<>::just(commit_message))); auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 1); - wrapper.subscribe([commit_message](auto commit_event) { + wrapper.subscribe([this](auto commit_event) { auto block_wrapper = make_test_subscriber(commit_event.synced_blocks, 1); - block_wrapper.subscribe([commit_message](auto block) { + block_wrapper.subscribe([this](auto block) { // Check commit block - ASSERT_EQ(block->height(), commit_message.block->height()); + ASSERT_EQ(block->height(), commit_message->height()); }); ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kCommit); ASSERT_TRUE(block_wrapper.validate()); }); - synchronizer->process_commit(commit_message); + gate_outcome.get_subscriber().on_next( + consensus::VoteOther{public_keys, hash, consensus::Round{kHeight, 1}}); ASSERT_TRUE(wrapper.validate()); } /** - * @given A valid block that cannot be applied directly - * @when process_commit is called - * @then observable of retrieveBlocks must be evaluated four times: - * - to validate whole chain - * - to validate last block of chain (x2) - * - to create a vector + * @given A commit from consensus and initialized components + * @when gate have voted for other block + * @then retrieveBlocks called again after unsuccessful download attempt */ TEST_F(SynchronizerTest, ExactlyThreeRetrievals) { - auto commit_message = makeCommit(); - DefaultValue, std::string>>:: SetFactory(&createMockMutableStorage); EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(1); EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); EXPECT_CALL(*chain_validator, validateAndApply(_, _)) .WillOnce(Return(false)) .WillOnce(testing::Invoke([](auto chain, auto &) { @@ -253,24 +203,17 @@ TEST_F(SynchronizerTest, ExactlyThreeRetrievals) { return true; })); EXPECT_CALL(*block_loader, retrieveBlocks(_, _)) - .WillOnce(Return(rxcpp::observable<>::create>([commit_message]( - auto s) { - static int times = 0; - if (times++ > 4) { - FAIL() << "Observable of retrieveBlocks must be evaluated four times"; - } - s.on_next(commit_message.block); - s.on_completed(); - }))); - - init(); + .WillOnce(Return(rxcpp::observable<>::empty< + std::shared_ptr>())) + .WillOnce(Return(rxcpp::observable<>::just(commit_message))) + .WillOnce(Return(rxcpp::observable<>::just(commit_message))); auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 1); wrapper.subscribe(); - synchronizer->process_commit(commit_message); + gate_outcome.get_subscriber().on_next( + consensus::VoteOther{public_keys, hash, consensus::Round{kHeight, 1}}); ASSERT_TRUE(wrapper.validate()); } @@ -281,18 +224,12 @@ TEST_F(SynchronizerTest, ExactlyThreeRetrievals) { * @then it will try until success */ TEST_F(SynchronizerTest, RetrieveBlockTwoFailures) { - auto commit_message = makeCommit(); - rxcpp::observable> - commit_message_blocks = rxcpp::observable<>::just(commit_message.block); - DefaultValue, std::string>>:: SetFactory(&createMockMutableStorage); EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(1); - EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); - EXPECT_CALL(*block_loader, retrieveBlocks(_, _)) - .WillRepeatedly(Return(commit_message_blocks)); + .WillRepeatedly(Return(rxcpp::observable<>::just(commit_message))); // fail the chain validation two times so that synchronizer will try more EXPECT_CALL(*chain_validator, validateAndApply(_, _)) @@ -301,25 +238,87 @@ TEST_F(SynchronizerTest, RetrieveBlockTwoFailures) { .WillOnce(Return(false)) .WillOnce(Return(true)); - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); - - init(); - auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 1); - wrapper.subscribe([commit_message](auto commit_event) { + wrapper.subscribe([this](auto commit_event) { auto block_wrapper = make_test_subscriber(commit_event.synced_blocks, 1); - block_wrapper.subscribe([commit_message](auto block) { + block_wrapper.subscribe([this](auto block) { // Check commit block - ASSERT_EQ(block->height(), commit_message.block->height()); + ASSERT_EQ(block->height(), commit_message->height()); }); ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kCommit); ASSERT_TRUE(block_wrapper.validate()); }); - synchronizer->process_commit(commit_message); + gate_outcome.get_subscriber().on_next( + consensus::VoteOther{public_keys, hash, consensus::Round{kHeight, 1}}); + + ASSERT_TRUE(wrapper.validate()); +} + +/** + * @given initialized components + * @when gate have got reject on proposal + * @then synchronizer output is also reject + */ +TEST_F(SynchronizerTest, ProposalRejectOutcome) { + auto wrapper = + make_test_subscriber(synchronizer->on_commit_chain(), 1); + wrapper.subscribe([](auto commit_event) { + auto block_wrapper = + make_test_subscriber(commit_event.synced_blocks, 0); + block_wrapper.subscribe(); + ASSERT_TRUE(block_wrapper.validate()); + ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kReject); + }); + + gate_outcome.get_subscriber().on_next( + consensus::ProposalReject{consensus::Round{kHeight, 1}}); + + ASSERT_TRUE(wrapper.validate()); +} + +/** + * @given initialized components + * @when gate have got reject on block + * @then synchronizer output is also reject + */ +TEST_F(SynchronizerTest, BlockRejectOutcome) { + auto wrapper = + make_test_subscriber(synchronizer->on_commit_chain(), 1); + wrapper.subscribe([](auto commit_event) { + auto block_wrapper = + make_test_subscriber(commit_event.synced_blocks, 0); + block_wrapper.subscribe(); + ASSERT_TRUE(block_wrapper.validate()); + ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kReject); + }); + + gate_outcome.get_subscriber().on_next( + consensus::BlockReject{consensus::Round{kHeight, 1}}); + + ASSERT_TRUE(wrapper.validate()); +} + +/** + * @given initialized components + * @when gate have got agreement on none + * @then synchronizer output is also none + */ +TEST_F(SynchronizerTest, NoneOutcome) { + auto wrapper = + make_test_subscriber(synchronizer->on_commit_chain(), 1); + wrapper.subscribe([](auto commit_event) { + auto block_wrapper = + make_test_subscriber(commit_event.synced_blocks, 0); + block_wrapper.subscribe(); + ASSERT_TRUE(block_wrapper.validate()); + ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kNothing); + }); + + gate_outcome.get_subscriber().on_next( + consensus::AgreementOnNone{consensus::Round{kHeight, 1}}); ASSERT_TRUE(wrapper.validate()); } @@ -330,34 +329,25 @@ TEST_F(SynchronizerTest, RetrieveBlockTwoFailures) { * @then commitPrepared is called @and commit is not called */ TEST_F(SynchronizerTest, VotedForBlockCommitPrepared) { - auto commit_message = - makeCommit(iroha::time::now(), PeerVotedFor::kThisBlock); - rxcpp::observable> - commit_message_blocks = rxcpp::observable<>::just(commit_message.block); - EXPECT_CALL(*mutable_factory, commitPrepared(_)).WillOnce(Return(true)); EXPECT_CALL(*mutable_factory, commit_(_)).Times(0); - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); - - init(); - auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 1); - wrapper.subscribe([commit_message](auto commit_event) { + wrapper.subscribe([this](auto commit_event) { auto block_wrapper = make_test_subscriber(commit_event.synced_blocks, 1); - block_wrapper.subscribe([commit_message](auto block) { + block_wrapper.subscribe([this](auto block) { // Check commit block - ASSERT_EQ(block->height(), commit_message.block->height()); + ASSERT_EQ(block->height(), commit_message->height()); }); ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kCommit); ASSERT_TRUE(block_wrapper.validate()); }); - synchronizer->process_commit(commit_message); + gate_outcome.get_subscriber().on_next( + consensus::PairValid{commit_message, consensus::Round{kHeight, 1}}); } /** @@ -366,10 +356,6 @@ TEST_F(SynchronizerTest, VotedForBlockCommitPrepared) { * @then commitPrepared is not called @and commit is called */ TEST_F(SynchronizerTest, VotedForOtherCommitPrepared) { - auto commit_message = makeCommit(); - rxcpp::observable> - commit_message_blocks = rxcpp::observable<>::just(commit_message.block); - DefaultValue, std::string>>:: SetFactory(&createMockMutableStorage); @@ -379,27 +365,26 @@ TEST_F(SynchronizerTest, VotedForOtherCommitPrepared) { EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); - EXPECT_CALL(*chain_validator, validateAndApply(_, _)).WillOnce(Return(true)); - - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); + EXPECT_CALL(*block_loader, retrieveBlocks(_, _)) + .WillRepeatedly(Return(rxcpp::observable<>::just(commit_message))); - init(); + EXPECT_CALL(*chain_validator, validateAndApply(_, _)).WillOnce(Return(true)); auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 1); - wrapper.subscribe([commit_message](auto commit_event) { + wrapper.subscribe([this](auto commit_event) { auto block_wrapper = make_test_subscriber(commit_event.synced_blocks, 1); - block_wrapper.subscribe([commit_message](auto block) { + block_wrapper.subscribe([this](auto block) { // Check commit block - ASSERT_EQ(block->height(), commit_message.block->height()); + ASSERT_EQ(block->height(), commit_message->height()); }); ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kCommit); ASSERT_TRUE(block_wrapper.validate()); }); - synchronizer->process_commit(commit_message); + gate_outcome.get_subscriber().on_next( + consensus::VoteOther{public_keys, hash, consensus::Round{kHeight, 1}}); } /** @@ -408,39 +393,35 @@ TEST_F(SynchronizerTest, VotedForOtherCommitPrepared) { * @then commit is called and synchronizer works as expected */ TEST_F(SynchronizerTest, VotedForThisCommitPreparedFailure) { - auto commit_message = - makeCommit(iroha::time::now(), PeerVotedFor::kThisBlock); - rxcpp::observable> - commit_message_blocks = rxcpp::observable<>::just(commit_message.block); + auto ustorage = std::make_unique(); - DefaultValue, std::string>>:: - SetFactory(&createMockMutableStorage); + auto storage = ustorage.get(); - EXPECT_CALL(*mutable_factory, commitPrepared(_)).WillOnce(Return(false)); + auto storage_value = + expected::makeValue>(std::move(ustorage)); - EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(1); - - EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); + EXPECT_CALL(*mutable_factory, commitPrepared(_)).WillOnce(Return(false)); - EXPECT_CALL(*chain_validator, validateAndApply(_, _)).WillOnce(Return(true)); + EXPECT_CALL(*mutable_factory, createMutableStorage()) + .WillOnce(Return(ByMove(std::move(storage_value)))); - EXPECT_CALL(*consensus_gate, on_commit()) - .WillOnce(Return(rxcpp::observable<>::empty())); + EXPECT_CALL(*storage, apply(_)).WillOnce(Return(true)); - init(); + EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); auto wrapper = make_test_subscriber(synchronizer->on_commit_chain(), 1); - wrapper.subscribe([commit_message](auto commit_event) { + wrapper.subscribe([this](auto commit_event) { auto block_wrapper = make_test_subscriber(commit_event.synced_blocks, 1); - block_wrapper.subscribe([commit_message](auto block) { + block_wrapper.subscribe([this](auto block) { // Check commit block - ASSERT_EQ(block->height(), commit_message.block->height()); + ASSERT_EQ(block->height(), commit_message->height()); }); ASSERT_EQ(commit_event.sync_outcome, SynchronizationOutcomeType::kCommit); ASSERT_TRUE(block_wrapper.validate()); }); - synchronizer->process_commit(commit_message); + gate_outcome.get_subscriber().on_next( + consensus::PairValid{commit_message, consensus::Round{kHeight, 1}}); } diff --git a/test/module/irohad/torii/CMakeLists.txt b/test/module/irohad/torii/CMakeLists.txt index 3f5bd36887..a1f6aac95d 100644 --- a/test/module/irohad/torii/CMakeLists.txt +++ b/test/module/irohad/torii/CMakeLists.txt @@ -22,6 +22,8 @@ target_link_libraries(torii_service_test query_client server_runner processors + consensus_round + on_demand_common ) addtest(torii_queries_test torii_queries_test.cpp) diff --git a/test/module/irohad/torii/processor/transaction_processor_test.cpp b/test/module/irohad/torii/processor/transaction_processor_test.cpp index bc99e7b9b6..0bfcb00d11 100644 --- a/test/module/irohad/torii/processor/transaction_processor_test.cpp +++ b/test/module/irohad/torii/processor/transaction_processor_test.cpp @@ -44,7 +44,7 @@ class TransactionProcessorTest : public ::testing::Test { EXPECT_CALL(*pcs, on_commit()) .WillRepeatedly(Return(commit_notifier.get_observable())); - EXPECT_CALL(*pcs, on_verified_proposal()) + EXPECT_CALL(*pcs, onVerifiedProposal()) .WillRepeatedly(Return(verified_prop_notifier.get_observable())); EXPECT_CALL(*mst, onStateUpdateImpl()) @@ -135,10 +135,10 @@ class TransactionProcessorTest : public ::testing::Test { status_builder; rxcpp::subjects::subject commit_notifier; - rxcpp::subjects::subject< - std::shared_ptr> + rxcpp::subjects::subject verified_prop_notifier; + consensus::Round round; const size_t proposal_size = 5; const size_t block_size = 3; }; @@ -266,7 +266,8 @@ TEST_F(TransactionProcessorTest, TransactionProcessorBlockCreatedTest) { TestProposalBuilder().transactions(txs).build()); // empty transactions errors - all txs are valid - verified_prop_notifier.get_subscriber().on_next(validation_result); + verified_prop_notifier.get_subscriber().on_next( + simulator::VerifiedProposalCreatorEvent{validation_result, round}); auto block = TestBlockBuilder().transactions(txs).build(); @@ -274,8 +275,10 @@ TEST_F(TransactionProcessorTest, TransactionProcessorBlockCreatedTest) { rxcpp::subjects::subject> blocks_notifier; - commit_notifier.get_subscriber().on_next(SynchronizationEvent{ - blocks_notifier.get_observable(), SynchronizationOutcomeType::kCommit}); + commit_notifier.get_subscriber().on_next( + SynchronizationEvent{blocks_notifier.get_observable(), + SynchronizationOutcomeType::kCommit, + {}}); blocks_notifier.get_subscriber().on_next( std::shared_ptr(clone(block))); @@ -322,7 +325,8 @@ TEST_F(TransactionProcessorTest, TransactionProcessorOnCommitTest) { TestProposalBuilder().transactions(txs).build()); // empty transactions errors - all txs are valid - verified_prop_notifier.get_subscriber().on_next(validation_result); + verified_prop_notifier.get_subscriber().on_next( + simulator::VerifiedProposalCreatorEvent{validation_result, round}); auto block = TestBlockBuilder().transactions(txs).build(); @@ -330,7 +334,8 @@ TEST_F(TransactionProcessorTest, TransactionProcessorOnCommitTest) { SynchronizationEvent commit_event{ rxcpp::observable<>::just( std::shared_ptr(clone(block))), - SynchronizationOutcomeType::kCommit}; + SynchronizationOutcomeType::kCommit, + {}}; commit_notifier.get_subscriber().on_next(commit_event); SCOPED_TRACE("Committed status verification"); @@ -393,14 +398,16 @@ TEST_F(TransactionProcessorTest, TransactionProcessorInvalidTxsTest) { invalid_txs[i].hash(), iroha::validation::CommandError{"SomeCommandName", 1, "", true, i}); } - verified_prop_notifier.get_subscriber().on_next(validation_result); + verified_prop_notifier.get_subscriber().on_next( + simulator::VerifiedProposalCreatorEvent{validation_result, round}); auto block = TestBlockBuilder().transactions(block_txs).build(); SynchronizationEvent commit_event{ rxcpp::observable<>::just( std::shared_ptr(clone(block))), - SynchronizationOutcomeType::kCommit}; + SynchronizationOutcomeType::kCommit, + {}}; commit_notifier.get_subscriber().on_next(commit_event); { diff --git a/test/module/irohad/torii/torii_queries_test.cpp b/test/module/irohad/torii/torii_queries_test.cpp index e562149bef..e8d205f874 100644 --- a/test/module/irohad/torii/torii_queries_test.cpp +++ b/test/module/irohad/torii/torii_queries_test.cpp @@ -30,6 +30,8 @@ #include "utils/query_error_response_visitor.hpp" constexpr size_t TimesFind = 1; +static constexpr shared_model::interface::types::TransactionsNumberType + kTxPageSize(10); using ::testing::_; using ::testing::A; @@ -532,7 +534,7 @@ TEST_F(ToriiQueriesTest, FindTransactionsWhenValid) { .creatorAccountId(creator) .queryCounter(1) .createdTime(iroha::time::now()) - .getAccountTransactions(creator) + .getAccountTransactions(creator, kTxPageSize) .build() .signAndAddSignature(pair) .finish(); @@ -582,7 +584,7 @@ TEST_F(ToriiQueriesTest, FindManyTimesWhereQueryServiceSync) { .creatorAccountId("a@domain") .queryCounter(i) .createdTime(iroha::time::now()) - .getAccountTransactions("a@2domain") + .getAccountTransactions("a@2domain", kTxPageSize) .build(); auto stat = client.Find(model_query.getTransport(), response); diff --git a/test/module/irohad/torii/torii_service_query_test.cpp b/test/module/irohad/torii/torii_service_query_test.cpp index 77b51d28ce..bdea9e4b27 100644 --- a/test/module/irohad/torii/torii_service_query_test.cpp +++ b/test/module/irohad/torii/torii_service_query_test.cpp @@ -100,8 +100,9 @@ TEST_F(ToriiQueryServiceTest, FetchBlocksWhenValidQuery) { .finish()); iroha::protocol::Block block; - block.mutable_payload()->set_height(123); - auto proto_block = std::make_unique(block); + block.mutable_block_v1()->mutable_payload()->set_height(123); + auto proto_block = + std::make_unique(block.block_v1()); std::shared_ptr block_response = shared_model::proto::ProtoQueryResponseFactory().createBlockQueryResponse( std::move(proto_block)); diff --git a/test/module/irohad/torii/torii_service_test.cpp b/test/module/irohad/torii/torii_service_test.cpp index 1aa6d4aede..5663668184 100644 --- a/test/module/irohad/torii/torii_service_test.cpp +++ b/test/module/irohad/torii/torii_service_test.cpp @@ -18,6 +18,7 @@ #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/on_demand_common.hpp" #include "torii/command_client.hpp" #include "torii/impl/command_service_impl.hpp" #include "torii/impl/command_service_transport_grpc.hpp" @@ -55,11 +56,9 @@ constexpr uint32_t resubscribe_attempts = 3; class CustomPeerCommunicationServiceMock : public PeerCommunicationService { public: CustomPeerCommunicationServiceMock( - rxcpp::subjects::subject< - std::shared_ptr> prop_notifier, + rxcpp::subjects::subject prop_notifier, rxcpp::subjects::subject commit_notifier, - rxcpp::subjects::subject< - std::shared_ptr> + rxcpp::subjects::subject verified_prop_notifier) : prop_notifier_(prop_notifier), commit_notifier_(commit_notifier), @@ -69,8 +68,7 @@ class CustomPeerCommunicationServiceMock : public PeerCommunicationService { std::shared_ptr batch) const override {} - rxcpp::observable> - on_proposal() const override { + rxcpp::observable onProposal() const override { return prop_notifier_.get_observable(); } @@ -78,18 +76,15 @@ class CustomPeerCommunicationServiceMock : public PeerCommunicationService { return commit_notifier_.get_observable(); } - rxcpp::observable< - std::shared_ptr> - on_verified_proposal() const override { + rxcpp::observable + onVerifiedProposal() const override { return verified_prop_notifier_.get_observable(); } private: - rxcpp::subjects::subject> - prop_notifier_; + rxcpp::subjects::subject prop_notifier_; rxcpp::subjects::subject commit_notifier_; - rxcpp::subjects::subject< - std::shared_ptr> + rxcpp::subjects::subject verified_prop_notifier_; }; @@ -175,11 +170,9 @@ class ToriiServiceTest : public testing::Test { std::shared_ptr block_query; std::shared_ptr storage; - rxcpp::subjects::subject> - prop_notifier_; + rxcpp::subjects::subject prop_notifier_; rxcpp::subjects::subject commit_notifier_; - rxcpp::subjects::subject< - std::shared_ptr> + rxcpp::subjects::subject verified_prop_notifier_; rxcpp::subjects::subject> mst_update_notifier; @@ -192,6 +185,7 @@ class ToriiServiceTest : public testing::Test { shared_model::crypto::Keypair keypair = shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair(); + iroha::consensus::Round round; const std::string ip = "127.0.0.1"; int port; }; @@ -295,13 +289,15 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { } // create proposal from these transactions - auto proposal = std::make_shared( - TestProposalBuilder() - .height(1) - .createdTime(iroha::time::now()) - .transactions(txs) - .build()); - prop_notifier_.get_subscriber().on_next(proposal); + std::shared_ptr proposal = + std::make_shared( + TestProposalBuilder() + .height(1) + .createdTime(iroha::time::now()) + .transactions(txs) + .build()); + prop_notifier_.get_subscriber().on_next(OrderingEvent{ + proposal, {proposal->height(), iroha::ordering::kFirstRejectRound}}); torii::CommandSyncClient client2(client1); @@ -347,13 +343,15 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { failed_tx_hash, iroha::validation::CommandError{ cmd_name, error_code, "", true, cmd_index}); - verified_prop_notifier_.get_subscriber().on_next(validation_result); + verified_prop_notifier_.get_subscriber().on_next( + iroha::simulator::VerifiedProposalCreatorEvent{validation_result, round}); // create commit from block notifier's observable rxcpp::subjects::subject> block_notifier_; SynchronizationEvent commit{block_notifier_.get_observable(), - SynchronizationOutcomeType::kCommit}; + SynchronizationOutcomeType::kCommit, + {}}; // invoke on next of commit_notifier by sending new block to commit commit_notifier_.get_subscriber().on_next(commit); @@ -480,22 +478,20 @@ TEST_F(ToriiServiceTest, StreamingFullPipelineTest) { std::vector txs; txs.push_back(iroha_tx); - auto proposal = + std::shared_ptr proposal = std::make_shared(proto::ProposalBuilder() .createdTime(iroha::time::now()) .transactions(txs) .height(1) .build()); - prop_notifier_.get_subscriber().on_next(proposal); + prop_notifier_.get_subscriber().on_next(OrderingEvent{ + proposal, {proposal->height(), iroha::ordering::kFirstRejectRound}}); auto validation_result = std::make_shared(); - // a dirty hack: now the proposal object is kept also by unique_ptr. - // both shared and unique ptrs will live till the end of this function, - // and there the unique_ptr is released. - validation_result->verified_proposal = - std::unique_ptr(proposal.get()); - verified_prop_notifier_.get_subscriber().on_next(validation_result); + validation_result->verified_proposal = proposal; + verified_prop_notifier_.get_subscriber().on_next( + iroha::simulator::VerifiedProposalCreatorEvent{validation_result, round}); auto block = clone(proto::BlockBuilder() .height(1) @@ -510,7 +506,8 @@ TEST_F(ToriiServiceTest, StreamingFullPipelineTest) { rxcpp::subjects::subject> block_notifier_; SynchronizationEvent commit{block_notifier_.get_observable(), - SynchronizationOutcomeType::kCommit}; + SynchronizationOutcomeType::kCommit, + {}}; // invoke on next of commit_notifier by sending new block to commit commit_notifier_.get_subscriber().on_next(commit); @@ -523,8 +520,6 @@ TEST_F(ToriiServiceTest, StreamingFullPipelineTest) { // it can be only one or to follow by some non-final ASSERT_EQ(torii_response.back().tx_status(), iroha::protocol::TxStatus::COMMITTED); - - validation_result->verified_proposal.release(); // see initialization above } /** diff --git a/test/module/shared_model/CMakeLists.txt b/test/module/shared_model/CMakeLists.txt index 403d157a46..b72ec30def 100644 --- a/test/module/shared_model/CMakeLists.txt +++ b/test/module/shared_model/CMakeLists.txt @@ -8,13 +8,6 @@ add_subdirectory(builders) add_subdirectory(validators) add_subdirectory(cryptography) -AddTest(lazy_test - lazy_test.cpp - ) -target_link_libraries(lazy_test - boost - ) - AddTest(reference_holder_test reference_holder_test.cpp ) diff --git a/test/module/shared_model/backend_proto/proto_block_factory_test.cpp b/test/module/shared_model/backend_proto/proto_block_factory_test.cpp index d63becc915..6a7a604b8d 100644 --- a/test/module/shared_model/backend_proto/proto_block_factory_test.cpp +++ b/test/module/shared_model/backend_proto/proto_block_factory_test.cpp @@ -15,14 +15,14 @@ using namespace shared_model; class ProtoBlockFactoryTest : public ::testing::Test { public: std::unique_ptr factory; - validation::MockValidator *validator; ProtoBlockFactoryTest() { - auto validator_ptr = + auto interface_validator = std::make_unique>(); - validator = validator_ptr.get(); - factory = - std::make_unique(std::move(validator_ptr)); + auto proto_validator = + std::make_unique>(); + factory = std::make_unique( + std::move(interface_validator), std::move(proto_validator)); } }; diff --git a/test/module/shared_model/backend_proto/proto_query_response_factory_test.cpp b/test/module/shared_model/backend_proto/proto_query_response_factory_test.cpp index 1115c3356d..b21a2e3d1a 100644 --- a/test/module/shared_model/backend_proto/proto_query_response_factory_test.cpp +++ b/test/module/shared_model/backend_proto/proto_query_response_factory_test.cpp @@ -7,7 +7,6 @@ #include #include #include "backend/protobuf/common_objects/proto_common_objects_factory.hpp" -#include "cryptography/blob.hpp" #include "cryptography/crypto_provider/crypto_defaults.hpp" #include "interfaces/query_responses/account_asset_response.hpp" #include "interfaces/query_responses/account_detail_response.hpp" @@ -19,6 +18,7 @@ #include "interfaces/query_responses/role_permissions.hpp" #include "interfaces/query_responses/roles_response.hpp" #include "interfaces/query_responses/signatories_response.hpp" +#include "interfaces/query_responses/transactions_page_response.hpp" #include "interfaces/query_responses/transactions_response.hpp" #include "module/shared_model/builders/protobuf/test_block_builder.hpp" #include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" @@ -302,6 +302,89 @@ TEST_F(ProtoQueryResponseFactoryTest, CreateTransactionsResponse) { }); } +/** + * Checks createTransactionsPageResponse method of QueryResponseFactory + * @given collection of transactions, next tx hash and transactions number + * @when creating transactions page response via factory + * @then that response is created @and is well-formed + */ +TEST_F(ProtoQueryResponseFactoryTest, CreateTransactionsPageResponse) { + const HashType kQueryHash{"my_super_hash"}; + const HashType kNextTxHash{"next_tx_hash"}; + + constexpr int kTransactionsNumber = 5; + + std::vector> + transactions, transactions_test_copy; + for (auto i = 0; i < kTransactionsNumber; ++i) { + auto tx = std::make_unique( + TestTransactionBuilder().creatorAccountId(std::to_string(i)).build()); + auto tx_copy = std::make_unique( + TestTransactionBuilder().creatorAccountId(std::to_string(i)).build()); + transactions.push_back(std::move(tx)); + transactions_test_copy.push_back(std::move(tx_copy)); + } + auto query_response = response_factory->createTransactionsPageResponse( + std::move(transactions), kNextTxHash, kTransactionsNumber, kQueryHash); + + ASSERT_TRUE(query_response); + EXPECT_EQ(query_response->queryHash(), kQueryHash); + EXPECT_NO_THROW({ + const auto &response = + boost::get( + query_response->get()); + + EXPECT_EQ(response.allTransactionsSize(), kTransactionsNumber); + for (auto i = 0; i < kTransactionsNumber; ++i) { + EXPECT_EQ(response.transactions()[i].creatorAccountId(), + transactions_test_copy[i]->creatorAccountId()); + } + ASSERT_TRUE(response.nextTxHash()); + EXPECT_EQ(response.nextTxHash().value(), kNextTxHash); + }); +} + +/** + * Checks createTransactionsPageResponse method of QueryResponseFactory + * @given collection of transactions, next tx hash and transactions number + * @when creating transactions page response via factory + * @then that response is created @and is well-formed + */ +TEST_F(ProtoQueryResponseFactoryTest, + CreateTransactionsPageResponseWithoutNextTxHash) { + const HashType kQueryHash{"my_super_hash"}; + + constexpr int kTransactionsNumber = 5; + + std::vector> + transactions, transactions_test_copy; + for (auto i = 0; i < kTransactionsNumber; ++i) { + auto tx = std::make_unique( + TestTransactionBuilder().creatorAccountId(std::to_string(i)).build()); + auto tx_copy = std::make_unique( + TestTransactionBuilder().creatorAccountId(std::to_string(i)).build()); + transactions.push_back(std::move(tx)); + transactions_test_copy.push_back(std::move(tx_copy)); + } + auto query_response = response_factory->createTransactionsPageResponse( + std::move(transactions), kTransactionsNumber, kQueryHash); + + ASSERT_TRUE(query_response); + EXPECT_EQ(query_response->queryHash(), kQueryHash); + EXPECT_NO_THROW({ + const auto &response = + boost::get( + query_response->get()); + + ASSERT_EQ(response.allTransactionsSize(), kTransactionsNumber); + for (auto i = 0; i < kTransactionsNumber; ++i) { + EXPECT_EQ(response.transactions()[i].creatorAccountId(), + transactions_test_copy[i]->creatorAccountId()); + } + EXPECT_FALSE(response.nextTxHash()); + }); +} + /** * Checks createAssetResponse method of QueryResponseFactory * @given asset diff --git a/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp b/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp index e8d4bef84b..55b230ddf2 100644 --- a/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp +++ b/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp @@ -48,7 +48,7 @@ namespace shared_model { template using NextBuilder = TemplateBlockBuilder; - iroha::protocol::Block block_; + iroha::protocol::Block_v1 block_; SV stateless_validator_; template @@ -118,7 +118,7 @@ namespace shared_model { auto tx_number = block_.payload().transactions().size(); block_.mutable_payload()->set_tx_number(tx_number); - auto result = Block(iroha::protocol::Block(block_)); + auto result = Block(iroha::protocol::Block_v1(block_)); auto answer = stateless_validator_.validate(result); if (answer.hasErrors()) { diff --git a/test/module/shared_model/interface_mocks.hpp b/test/module/shared_model/interface_mocks.hpp index 4bb8ffcbd9..ac65792f15 100644 --- a/test/module/shared_model/interface_mocks.hpp +++ b/test/module/shared_model/interface_mocks.hpp @@ -71,6 +71,23 @@ struct MockTransaction : public shared_model::interface::Transaction { boost::optional>()); }; +/** + * Creates mock transaction with provided hash + * @param hash -- const ref to hash to be returned by the transaction + * @return shared_ptr for transaction + */ +auto createMockTransactionWithHash( + const shared_model::interface::types::HashType &hash) { + using ::testing::NiceMock; + using ::testing::ReturnRefOfCopy; + + auto res = std::make_shared>(); + + ON_CALL(*res, hash()).WillByDefault(ReturnRefOfCopy(hash)); + + return res; +} + struct MockTransactionBatch : public shared_model::interface::TransactionBatch { MOCK_CONST_METHOD0( transactions, @@ -95,7 +112,7 @@ struct MockTransactionBatch : public shared_model::interface::TransactionBatch { /** * Creates mock batch with provided hash - * @param hash -- const ref to hash to be returned by the batch + * @param hash -- const ref to reduced hash to be returned by the batch * @return shared_ptr for batch */ auto createMockBatchWithHash( @@ -110,6 +127,28 @@ auto createMockBatchWithHash( return res; } +/** + * Creates mock batch with provided transactions + * @param txs -- list of transactions in the batch + * @param hash -- const ref to hash to be returned by the batch + * @return shared_ptr for batch + */ +auto createMockBatchWithTransactions( + const shared_model::interface::types::SharedTxsCollectionType &txs, + std::string hash) { + using ::testing::NiceMock; + using ::testing::ReturnRefOfCopy; + + auto res = std::make_shared>(); + + ON_CALL(*res, transactions()).WillByDefault(ReturnRefOfCopy(txs)); + + ON_CALL(*res, reducedHash()) + .WillByDefault(ReturnRefOfCopy(shared_model::crypto::Hash{hash})); + + return res; +} + struct MockSignature : public shared_model::interface::Signature { MOCK_CONST_METHOD0(publicKey, const PublicKeyType &()); MOCK_CONST_METHOD0(signedData, const SignedType &()); diff --git a/test/module/shared_model/lazy_test.cpp b/test/module/shared_model/lazy_test.cpp deleted file mode 100644 index d3eae010a2..0000000000 --- a/test/module/shared_model/lazy_test.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "utils/lazy_initializer.hpp" - -struct SourceValue { - int val; -}; - -struct TargetValue { - std::string target; -}; - -/** - * @given Initialized value - * @when Call get once - * @then Assert that transform invoked - */ -TEST(LazyTest, GetterTest) { - SourceValue v{100500}; - auto lazy = shared_model::detail::makeLazyInitializer( - [&v] { return TargetValue{std::to_string(v.val)}; }); - ASSERT_EQ("100500", lazy->target); -} - -/** - * @given Initialized value - * @when Call get twice - * @then Assert that transform invoked once - */ -TEST(LazyTest, CheckLaziness) { - SourceValue v{100500}; - auto call_counter = 0; - auto lazy = shared_model::detail::makeLazyInitializer([&call_counter, &v] { - call_counter++; - return TargetValue{std::to_string(v.val)}; - }); - ASSERT_EQ(0, call_counter); - ASSERT_EQ("100500", lazy->target); - ASSERT_EQ(1, call_counter); - ASSERT_EQ("100500", lazy->target); - ASSERT_EQ(1, call_counter); -} diff --git a/test/module/shared_model/validators/CMakeLists.txt b/test/module/shared_model/validators/CMakeLists.txt index a38b0d8387..005f4dc481 100644 --- a/test/module/shared_model/validators/CMakeLists.txt +++ b/test/module/shared_model/validators/CMakeLists.txt @@ -69,3 +69,11 @@ target_link_libraries(proto_transaction_validator_test shared_model_proto_backend shared_model_stateless_validation ) + +addtest(proto_block_validator_test + protobuf/proto_block_validator_test.cpp + ) +target_link_libraries(proto_block_validator_test + shared_model_proto_backend + shared_model_stateless_validation + ) diff --git a/test/module/shared_model/validators/field_validator_test.cpp b/test/module/shared_model/validators/field_validator_test.cpp index 3df278deeb..3cc8c02bed 100644 --- a/test/module/shared_model/validators/field_validator_test.cpp +++ b/test/module/shared_model/validators/field_validator_test.cpp @@ -19,10 +19,10 @@ #include "backend/protobuf/common_objects/peer.hpp" #include "backend/protobuf/permissions.hpp" #include "backend/protobuf/queries/proto_query_payload_meta.hpp" +#include "backend/protobuf/queries/proto_tx_pagination_meta.hpp" #include "builders/protobuf/queries.hpp" #include "builders/protobuf/transaction.hpp" #include "module/shared_model/validators/validators_fixture.hpp" -#include "utils/lazy_initializer.hpp" #include "validators/field_validator.hpp" #include "validators/permissions.hpp" @@ -584,6 +584,9 @@ class FieldValidatorTest : public ValidatorsTest { // "more than max") }; + // TODO mboldyrev 27.11.2018, IR-25: add the test cases + std::vector tx_pagination_meta_test_cases; + /**************************************************************************/ /// Create no-operation validator @@ -678,7 +681,13 @@ class FieldValidatorTest : public ValidatorsTest { &FieldValidator::validateBatchMeta, &FieldValidatorTest::batch_meta, [](auto &&x) { return shared_model::proto::BatchMeta(x); }, - batch_meta_test_cases)}; + batch_meta_test_cases), + makeTransformValidator( + "pagination_meta", + &FieldValidator::validateTxPaginationMeta, + &FieldValidatorTest::tx_pagination_meta, + [](auto &&x) { return proto::TxPaginationMeta(x); }, + tx_pagination_meta_test_cases)}; }; /** diff --git a/test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp b/test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp new file mode 100644 index 0000000000..a7ed970dc4 --- /dev/null +++ b/test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp @@ -0,0 +1,44 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "validators/protobuf/proto_block_validator.hpp" +#include +#include "block.pb.h" +#include "module/shared_model/validators/validators_fixture.hpp" + +using testing::HasSubstr; + +class ProtoBlockValidatorTest : public ValidatorsTest { + public: + shared_model::validation::ProtoBlockValidator validator; +}; + +/** + * @given protocol block object with unset version field + * @when validating this object + * @then corresponding error is returned + */ +TEST_F(ProtoBlockValidatorTest, UnsetVersion) { + iroha::protocol::Block invalid_block; + + auto answer = validator.validate(invalid_block); + ASSERT_TRUE(answer.hasErrors()); + ASSERT_THAT(answer.reason(), HasSubstr("Block version is not set")); +} + +/** + * @given valid protocol block object + * @when validating this object + * @then validation is successful + */ +TEST_F(ProtoBlockValidatorTest, ValidBlock) { + iroha::protocol::Block valid_block; + + iroha::protocol::Block_v1 versioned_block; + *valid_block.mutable_block_v1() = versioned_block; + + auto answer = validator.validate(valid_block); + ASSERT_FALSE(answer.hasErrors()); +} diff --git a/test/module/shared_model/validators/validators_fixture.hpp b/test/module/shared_model/validators/validators_fixture.hpp index 85634b1a95..0f2115a4e8 100644 --- a/test/module/shared_model/validators/validators_fixture.hpp +++ b/test/module/shared_model/validators/validators_fixture.hpp @@ -75,6 +75,9 @@ class ValidatorsTest : public ::testing::Test { field_setters["peer"] = [&](auto refl, auto msg, auto field) { refl->MutableMessage(msg, field)->CopyFrom(peer); }; + field_setters["pagination_meta"] = [&](auto refl, auto msg, auto field) { + refl->MutableMessage(msg, field)->CopyFrom(tx_pagination_meta); + }; } /** @@ -192,6 +195,7 @@ class ValidatorsTest : public ::testing::Test { quorum = 2; peer.set_address(address_localhost); peer.set_peer_key(public_key); + tx_pagination_meta.set_page_size(10); } size_t public_key_size{0}; @@ -224,6 +228,7 @@ class ValidatorsTest : public ::testing::Test { iroha::protocol::Peer peer; decltype(iroha::time::now()) created_time; iroha::protocol::QueryPayloadMeta meta; + iroha::protocol::TxPaginationMeta tx_pagination_meta; // List all used fields in commands std::unordered_map< diff --git a/test/system/irohad_test.cpp b/test/system/irohad_test.cpp index 7d5b616015..50fbd45e7c 100644 --- a/test/system/irohad_test.cpp +++ b/test/system/irohad_test.cpp @@ -197,10 +197,10 @@ DROP TABLE IF EXISTS domain; DROP TABLE IF EXISTS signatory; DROP TABLE IF EXISTS peer; DROP TABLE IF EXISTS role; -DROP TABLE IF EXISTS height_by_hash; +DROP TABLE IF EXISTS position_by_hash; DROP TABLE IF EXISTS height_by_account_set; DROP TABLE IF EXISTS index_by_creator_height; -DROP TABLE IF EXISTS index_by_id_height_asset; +DROP TABLE IF EXISTS position_by_account_asset; )"; soci::session sql(soci::postgresql, pgopts_); diff --git a/test/system/irohad_test_data/genesis.block b/test/system/irohad_test_data/genesis.block index b738bc69f1..c2b476ad88 100644 --- a/test/system/irohad_test_data/genesis.block +++ b/test/system/irohad_test_data/genesis.block @@ -1,5 +1,6 @@ { - "payload":{ + "block_v1":{ + "payload":{ "transactions":[ { "payload":{ @@ -119,5 +120,6 @@ "txNumber":1, "height":"1", "prevBlockHash":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" - } + } + } } From 85f9a462a081180c4dd9098b32ddd27ddc37f76e Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Thu, 13 Dec 2018 16:30:31 +0300 Subject: [PATCH 11/61] Merge branch 'dev' into trunk/cmd-mock-factory Signed-off-by: Akvinikym # Conflicts: # test/module/irohad/ametsuchi/postgres_executor_test.cpp # test/module/irohad/ametsuchi/postgres_query_executor_test.cpp --- .../ametsuchi/postgres_executor_test.cpp | 181 +----------------- 1 file changed, 3 insertions(+), 178 deletions(-) diff --git a/test/module/irohad/ametsuchi/postgres_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_executor_test.cpp index 8566314c89..310bb35a54 100644 --- a/test/module/irohad/ametsuchi/postgres_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_executor_test.cpp @@ -131,29 +131,6 @@ namespace iroha { true); } - /** - * Add one specific permission for account - * @param perm - role permission to add - * @param account_id - tester account_id, by default "id@domain" - * @param role_id - name of the role for tester, by default "all" - */ - void addOnePerm( - const shared_model::interface::permissions::Role perm, - const shared_model::interface::types::AccountIdType account_id = - "id@domain", - const shared_model::interface::types::RoleIdType role_id = "all") { - shared_model::interface::RolePermissionSet permissions; - permissions.set(perm); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createRole( - role_id, permissions)), - true))); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().appendRole( - account_id, role_id)), - true))); - } - /** * Check that command result contains specific error code and error * message @@ -337,79 +314,10 @@ namespace iroha { } /** - * @given addAccountAsset command - * @when trying to add asset to account with a domain permission - * @then account asset is successfully added + * @given command + * @when trying to add account asset without permission + * @then account asset not added */ - TEST_F(AddAccountAssetTest, DomainPermValid) { - addAsset(); - addOnePerm(shared_model::interface::permissions::Role::kAddDomainAssetQty); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))))); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))))); - account_asset = query->getAccountAsset(account->accountId(), asset_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - } - - /** - * @given addAccountAsset command and invalid domain permission - * @when trying to add asset - * @then account asset is not added - */ - TEST_F(AddAccountAssetTest, DomainPermInvalid) { - std::unique_ptr domain2; - domain2 = clone( - TestDomainBuilder().domainId("domain2").defaultRole(role).build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain2->domainId(), role)), - true))); - addAsset(domain2->domainId()); - addOnePerm(shared_model::interface::permissions::Role::kAddDomainAssetQty); - - auto asset2_id = "coin#"+domain2->domainId(); - - - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset2_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); - - - auto account_asset = - query->getAccountAsset(account->accountId(), asset2_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - - auto cmd_result = execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset2_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))); - - std::vector query_args{ - account->accountId(), asset_amount_one_zero, asset2_id, "1"}; - CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - } - - - /** - * @given command - * @when trying to add account asset without permission - * @then account asset not added - */ TEST_F(AddAccountAssetTest, NoPerms) { addAsset(); @@ -1832,89 +1740,6 @@ namespace iroha { account_asset.get()->balance()); } - - /** - * @given command and domain permission - * @when trying to subtract account asset - * @then account asset is successfully subtracted - */ - TEST_F(SubtractAccountAssetTest, DomainPermValid) { - addAsset(); - addOnePerm(shared_model::interface::permissions::Role::kSubtractDomainAssetQty); - - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); - account_asset = query->getAccountAsset(account->accountId(), asset_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - ASSERT_TRUE(val(execute(buildCommand( - TestTransactionBuilder() - .subtractAssetQuantity(asset_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))))); - account_asset = query->getAccountAsset(account->accountId(), asset_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - } - - /** - * @given command and invalid domain permission/ permission in other domain - * @when trying to subtract asset - * @then no account asset is subtracted - */ - TEST_F(SubtractAccountAssetTest, DomainPermInvalid) { - std::unique_ptr domain2; - domain2 = clone( - TestDomainBuilder().domainId("domain2").defaultRole(role).build()); - ASSERT_TRUE( - val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain2->domainId(), role)), - true))); - addAsset(domain2->domainId()); - addOnePerm(shared_model::interface::permissions::Role::kSubtractDomainAssetQty); - - auto asset2_id = "coin#"+domain2->domainId(); - ASSERT_TRUE(val(execute( - buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset2_id, asset_amount_one_zero) - .creatorAccountId(account->accountId())), - true))); - auto account_asset = - query->getAccountAsset(account->accountId(), asset2_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - - auto cmd_result = execute(buildCommand( - TestTransactionBuilder() - .subtractAssetQuantity(asset2_id, asset_amount_one_zero) - .creatorAccountId(account->accountId()))); - - std::vector query_args{ - account->accountId(), asset2_id, asset_amount_one_zero, "1"}; - CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - - account_asset = query->getAccountAsset(account->accountId(), asset2_id); - ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance().toStringRepr()); - } - - - /** * @given command * @when trying to subtract account asset with non-existing asset From d9d7d5ef957079c79658adca4209a1141e8c9529 Mon Sep 17 00:00:00 2001 From: Rory Date: Fri, 14 Dec 2018 08:36:00 +0200 Subject: [PATCH 12/61] Generate secrets for Iroha peers in k8s and add persisted storage. (#1875) * Modified Ansible task to generate secrets for each peer replicant; Added persisted storage for Postgres and block store. Signed-off-by: bagf * Removed unused enumerate Signed-off-by: bagf * Cleaned up Postgres probe commands; Made Iroha docker image configurable; Removed test tail command from init container Signed-off-by: bagf * Added example k8s-peer-key.yaml with accompanying genesis.block Signed-off-by: bagf * Reverted blockstore path to consistent with repo Signed-off-by: bagf * Omit empty blockstore check in container entrypoint script Signed-off-by: bagf * Changed default Iroha image to use the develop tag Signed-off-by: bagf * Added IROHA_POSTGRES_HOST env and removed entrypoint script so default entrypoint can be used Signed-off-by: bagf * Remove entrypoint.sh command Signed-off-by: bagf * Added hyphen between end of secret name and number Signed-off-by: bagf * Corrected iroha containers ENV values for develop tag Signed-off-by: bagf * Renamed config.sample to config.docker Signed-off-by: bagf * Updated Kubernetes cluster documentation Signed-off-by: bagf * Update genesis block and peer add code for k8s deployment Signed-off-by: bagf --- .../iroha-k8s/scripts/genesis-add-peers.py | 27 +++--- deploy/ansible/roles/iroha-k8s/README.md | 3 +- .../ansible/roles/iroha-k8s/defaults/main.yml | 5 ++ .../conf/{config.sample => config.docker} | 3 +- .../roles/iroha-k8s/files/conf/entrypoint.sh | 5 -- .../roles/iroha-k8s/files/conf/genesis.block | 2 +- .../roles/iroha-k8s/files/conf/node0.priv | 1 - .../roles/iroha-k8s/files/conf/node0.pub | 1 - .../roles/iroha-k8s/files/conf/node1.priv | 1 - .../roles/iroha-k8s/files/conf/node1.pub | 1 - .../roles/iroha-k8s/files/conf/node2.priv | 1 - .../roles/iroha-k8s/files/conf/node2.pub | 1 - .../roles/iroha-k8s/files/conf/node3.priv | 1 - .../roles/iroha-k8s/files/conf/node3.pub | 1 - .../roles/iroha-k8s/files/genesis.block | 2 +- .../roles/iroha-k8s/files/k8s-iroha.yaml | 89 ++++++++++++++++--- .../roles/iroha-k8s/files/k8s-peer-keys.yaml | 36 ++++++++ deploy/ansible/roles/iroha-k8s/tasks/main.yml | 34 ++++--- .../{config.sample.j2 => config.docker.j2} | 1 + .../iroha-k8s/templates/k8s-iroha.yaml.j2 | 80 ++++++++++++++--- .../iroha-k8s/templates/k8s-peer-keys.yaml.j2 | 12 +++ docs/source/guides/k8s-deployment.rst | 8 +- 22 files changed, 240 insertions(+), 75 deletions(-) rename deploy/ansible/roles/iroha-k8s/files/conf/{config.sample => config.docker} (82%) delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/entrypoint.sh delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node0.priv delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node0.pub delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node1.priv delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node1.pub delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node2.priv delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node2.pub delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node3.priv delete mode 100644 deploy/ansible/roles/iroha-k8s/files/conf/node3.pub create mode 100644 deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml rename deploy/ansible/roles/iroha-k8s/templates/{config.sample.j2 => config.docker.j2} (90%) create mode 100644 deploy/ansible/roles/iroha-k8s/templates/k8s-peer-keys.yaml.j2 diff --git a/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py b/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py index ea5a40d673..3cb2fc35e3 100644 --- a/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py +++ b/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py @@ -25,13 +25,13 @@ def genesis_add_peers(peers_list, genesis_block_fp): with open(genesis_block_fp, 'r+') as genesis_json: genesis_dict = json.load(genesis_json) try: - genesis_dict['payload']['transactions'][0]['payload']['reducedPayload']['commands'] = filter(lambda c: not c.get('addPeer'), genesis_dict['payload']['transactions'][0]['payload']['reducedPayload']['commands']) + genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands'] = filter(lambda c: not c.get('addPeer'), genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands']) except KeyError: pass - genesis_dict['payload']['transactions'][0]['payload']['reducedPayload']['commands'] = list(genesis_dict['payload']['transactions'][0]['payload']['reducedPayload']['commands']) + genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands'] = list(genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands']) for p in peers_list: p_add_command = {"addPeer": {"peer": {"address": "%s:%s" % (p.host, '10001'), "peerKey":hex_to_b64(p.pub_key)}}} - genesis_dict['payload']['transactions'][0]['payload']['reducedPayload']['commands'].append(p_add_command) + genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands'].append(p_add_command) genesis_json.seek(0) json.dump(genesis_dict, genesis_json, sort_keys=True) genesis_json.truncate() @@ -59,16 +59,17 @@ def caliper_rename_keys(priv_key_name, pub_key_name, caliper_conf_fp): json.dump(caliper_conf_dict, caliper_conf_json, sort_keys=True) caliper_conf_json.truncate() +def to_b64(bytes_array): + return base64.b64encode(bytes_array).decode('utf-8') + def hex_to_b64(hex_string): - hex_string = base64.b64encode(bytearray.fromhex(hex_string)) - return hex_string.decode('utf-8') + return to_b64(bytearray.fromhex(hex_string)) -def make_keys(peers): - for i, p in enumerate(peers): - with open('node%s.priv' % i, 'w+') as priv_key_file: - priv_key_file.write(p.priv_key) - with open('node%s.pub' % i, 'w+') as pub_key_file: - pub_key_file.write(p.pub_key) +def print_keys_b64(peers): + for peer in peers: + priv_key = peer.priv_key.encode() + pub_key = peer.pub_key.encode() + print(to_b64(priv_key) + ',' + to_b64(pub_key)) if __name__ == "__main__": command = sys.argv[1] @@ -83,7 +84,7 @@ def make_keys(peers): elif command == 'add_caliper_peers': caliper_add_peers(peers, json_conf) caliper_rename_keys('admin-test.priv', 'admin-test.pub', json_conf) - elif command == 'make_key_files': - make_keys(peers) + elif command == 'print_keys_b64': + print_keys_b64(peers) else: print('Invalid command') diff --git a/deploy/ansible/roles/iroha-k8s/README.md b/deploy/ansible/roles/iroha-k8s/README.md index 07bc32e3bc..377d6686ef 100644 --- a/deploy/ansible/roles/iroha-k8s/README.md +++ b/deploy/ansible/roles/iroha-k8s/README.md @@ -23,6 +23,7 @@ kubectl create configmap iroha-config --from-file=files/conf/ We're ready to deploy Iroha cluster: ``` kubectl create -f files/k8s-iroha.yaml +kubectl create -f files/k8s-peer-keys.yaml ``` -You should see all the pods are in `Running` state after Docker images are downloaded and run on every node. Check the status with `kubectl get pods` command. \ No newline at end of file +You should see all the pods are in `Running` state after Docker images are downloaded and run on every node. Check the status with `kubectl get pods` command. diff --git a/deploy/ansible/roles/iroha-k8s/defaults/main.yml b/deploy/ansible/roles/iroha-k8s/defaults/main.yml index 2c05b3c5fb..f31d25155d 100644 --- a/deploy/ansible/roles/iroha-k8s/defaults/main.yml +++ b/deploy/ansible/roles/iroha-k8s/defaults/main.yml @@ -2,3 +2,8 @@ max_proposal_size: 3000 proposal_delay: 300 vote_delay: 5000 +load_delay: 5000 +# k8s-iroha.yaml +iroha_image: hyperledger/iroha:develop +postgres_volume_size: 1Gi +blockstore_volume_size: 1Gi diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/config.sample b/deploy/ansible/roles/iroha-k8s/files/conf/config.docker similarity index 82% rename from deploy/ansible/roles/iroha-k8s/files/conf/config.sample rename to deploy/ansible/roles/iroha-k8s/files/conf/config.docker index b4fd909beb..e8916ac105 100644 --- a/deploy/ansible/roles/iroha-k8s/files/conf/config.sample +++ b/deploy/ansible/roles/iroha-k8s/files/conf/config.docker @@ -3,8 +3,9 @@ "torii_port" : 50051, "internal_port" : 10001, "pg_opt" : "host=localhost port=5432 user=postgres password=mysecretpassword", - "max_proposal_size" : 2000, + "max_proposal_size" : 3000, "proposal_delay" : 300, "vote_delay" : 5000, + "load_delay" : 5000, "mst_enable" : false } diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/entrypoint.sh b/deploy/ansible/roles/iroha-k8s/files/conf/entrypoint.sh deleted file mode 100644 index 42a5ddc241..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -sed -ri "s/host=.*( port=.*)/host=${pg-host}\1/" config.sample -KEY=$(echo $KEY | cut -d'-' -f2) -sleep 10 -irohad --genesis_block genesis.block --config config.sample --keypair_name node$KEY diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block b/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block index 881c43d4c1..79003ff20b 100644 --- a/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block +++ b/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block @@ -1 +1 @@ -{"payload": {"height": "1", "prevBlockHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_append_role", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "moneyad"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "mainPubkey": "MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA="}}, {"createAccount": {"accountName": "test", "domainId": "test", "mainPubkey": "cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w="}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "moneyad"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "m0couBWVizNycYFg4k1ybSlDKD7eRK4DEBdd0kjIXrs="}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "r/UNrkzn4EdMn5/flDdEvr1KHGa7O7dqjMkhi0MWaOk="}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "bM1P2cQWNWyyl3ffyiYZCvBC4NyMY7VqzQBaUUseDuA="}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "FtyJpu8rsRcMRakVPAafIEnaee3Qwq321Gg9mJVFVM4="}}}], "quorum": 1}}}], "txNumber": 1}} \ No newline at end of file +{"blockV1": {"payload": {"height": "1", "prevBlockHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "money_creator"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "publicKey": "MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA="}}, {"createAccount": {"accountName": "test", "domainId": "test", "publicKey": "cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w="}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "money_creator"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "HPidCCmB5MiucqYlKyF5eARsFv/29fjB/gWUDqVwLwA="}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "k6njsmjiWSYjcmFiE0fdH/rhnTobmVw7Ttlok0RHZKQ="}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "rAJFaosvrcwMbJJ67x3nv6bk1YYLhF31zcF8gGciUHg="}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "orj/67AMEoauOtbRpZDXFoIWXa51APHYMQImQ/GrKgs="}}}], "quorum": 1}}}], "txNumber": 1}}} \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node0.priv b/deploy/ansible/roles/iroha-k8s/files/conf/node0.priv deleted file mode 100644 index 176247cc6b..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node0.priv +++ /dev/null @@ -1 +0,0 @@ -600e53f7c6ee77a10ee90b1d43519f75253bf3d5dd48ae1867015d99c3d36f4a \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node0.pub b/deploy/ansible/roles/iroha-k8s/files/conf/node0.pub deleted file mode 100644 index dc3d6f1a01..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node0.pub +++ /dev/null @@ -1 +0,0 @@ -9b4728b815958b3372718160e24d726d2943283ede44ae0310175dd248c85ebb \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node1.priv b/deploy/ansible/roles/iroha-k8s/files/conf/node1.priv deleted file mode 100644 index 7fab314b53..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node1.priv +++ /dev/null @@ -1 +0,0 @@ -af01b3647fc64d27b0c3b085b041a5cd35b8015c6c231a9716d8a8d27823b397 \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node1.pub b/deploy/ansible/roles/iroha-k8s/files/conf/node1.pub deleted file mode 100644 index df6f74f05c..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node1.pub +++ /dev/null @@ -1 +0,0 @@ -aff50dae4ce7e0474c9f9fdf943744bebd4a1c66bb3bb76a8cc9218b431668e9 \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node2.priv b/deploy/ansible/roles/iroha-k8s/files/conf/node2.priv deleted file mode 100644 index ed8a8bdb2f..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node2.priv +++ /dev/null @@ -1 +0,0 @@ -71a1d893f4c7d18cc88d539f771452c38d1288f1d4d01ee5f02f8126a66d52fb \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node2.pub b/deploy/ansible/roles/iroha-k8s/files/conf/node2.pub deleted file mode 100644 index 26be3e10a8..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node2.pub +++ /dev/null @@ -1 +0,0 @@ -6ccd4fd9c416356cb29777dfca26190af042e0dc8c63b56acd005a514b1e0ee0 \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node3.priv b/deploy/ansible/roles/iroha-k8s/files/conf/node3.priv deleted file mode 100644 index 07ff6e4ce2..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node3.priv +++ /dev/null @@ -1 +0,0 @@ -e4b91033d0ba4a542d1a796b67fde8253211134b72d15ac684f377a5b0acffc1 \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/node3.pub b/deploy/ansible/roles/iroha-k8s/files/conf/node3.pub deleted file mode 100644 index 93cc082db8..0000000000 --- a/deploy/ansible/roles/iroha-k8s/files/conf/node3.pub +++ /dev/null @@ -1 +0,0 @@ -16dc89a6ef2bb1170c45a9153c069f2049da79edd0c2adf6d4683d98954554ce \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/genesis.block b/deploy/ansible/roles/iroha-k8s/files/genesis.block index 881c43d4c1..79003ff20b 100644 --- a/deploy/ansible/roles/iroha-k8s/files/genesis.block +++ b/deploy/ansible/roles/iroha-k8s/files/genesis.block @@ -1 +1 @@ -{"payload": {"height": "1", "prevBlockHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_append_role", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "moneyad"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "mainPubkey": "MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA="}}, {"createAccount": {"accountName": "test", "domainId": "test", "mainPubkey": "cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w="}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "moneyad"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "m0couBWVizNycYFg4k1ybSlDKD7eRK4DEBdd0kjIXrs="}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "r/UNrkzn4EdMn5/flDdEvr1KHGa7O7dqjMkhi0MWaOk="}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "bM1P2cQWNWyyl3ffyiYZCvBC4NyMY7VqzQBaUUseDuA="}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "FtyJpu8rsRcMRakVPAafIEnaee3Qwq321Gg9mJVFVM4="}}}], "quorum": 1}}}], "txNumber": 1}} \ No newline at end of file +{"blockV1": {"payload": {"height": "1", "prevBlockHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "money_creator"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "publicKey": "MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA="}}, {"createAccount": {"accountName": "test", "domainId": "test", "publicKey": "cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w="}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "money_creator"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "HPidCCmB5MiucqYlKyF5eARsFv/29fjB/gWUDqVwLwA="}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "k6njsmjiWSYjcmFiE0fdH/rhnTobmVw7Ttlok0RHZKQ="}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "rAJFaosvrcwMbJJ67x3nv6bk1YYLhF31zcF8gGciUHg="}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "orj/67AMEoauOtbRpZDXFoIWXa51APHYMQImQ/GrKgs="}}}], "quorum": 1}}}], "txNumber": 1}}} \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/k8s-iroha.yaml b/deploy/ansible/roles/iroha-k8s/files/k8s-iroha.yaml index 6b58873c82..b5a86a5eb4 100644 --- a/deploy/ansible/roles/iroha-k8s/files/k8s-iroha.yaml +++ b/deploy/ansible/roles/iroha-k8s/files/k8s-iroha.yaml @@ -29,6 +29,28 @@ spec: app: iroha spec: terminationGracePeriodSeconds: 7 + initContainers: + - name: copy-data + image: busybox + command: ['sh', '-c', 'cp -v /opt/secrets/$PODNAME/node* /opt/iroha_data && cp -v /opt/iroha_config/* /opt/iroha_data'] + env: + - name: PODNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + volumeMounts: + - name: iroha-secret-0 + mountPath: /opt/secrets/iroha-0 + - name: iroha-secret-1 + mountPath: /opt/secrets/iroha-1 + - name: iroha-secret-2 + mountPath: /opt/secrets/iroha-2 + - name: iroha-secret-3 + mountPath: /opt/secrets/iroha-3 + - name: iroha-config + mountPath: /opt/iroha_config + - name: iroha-data + mountPath: /opt/iroha_data containers: - name: postgres image: postgres:9.5 @@ -39,8 +61,22 @@ spec: env: - name: POSTGRES_PASSWORD value: mysecretpassword + - name: PGDATA + value: /var/lib/postgresql/data/pgdata + livenessProbe: + exec: + command: ["pg_isready", "-h", "localhost", "-U", "postgres"] + initialDelaySeconds: 30 + timeoutSeconds: 5 + readinessProbe: + exec: + command: ["pg_isready", "-h", "localhost", "-U", "postgres"] + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumeMounts: + - name: pg-data + mountPath: /var/lib/postgresql/data - name: iroha - #image: hyperledger/iroha@sha256:eb059d2a03544e2bde91a0e16b7d03076b09bc31e9b970c1c4269f02084e8e91 image: hyperledger/iroha:develop imagePullPolicy: Always ports: @@ -49,24 +85,53 @@ spec: - containerPort: 50051 name: external env: + - name: IROHA_POSTGRES_HOST + value: localhost - name: KEY - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: pg-host - valueFrom: - fieldRef: - fieldPath: status.podIP - command: ['bash', '/opt/iroha_data/entrypoint.sh'] + value: node volumeMounts: + - name: iroha-data + mountPath: /opt/iroha_data - name: block-store mountPath: /tmp/block_store - - name: iroha-config - mountPath: /opt/iroha_data volumes: - # TODO: secrets + - name: iroha-secret-0 + secret: + secretName: iroha-peer-key-0 + - name: iroha-secret-1 + secret: + secretName: iroha-peer-key-1 + - name: iroha-secret-2 + secret: + secretName: iroha-peer-key-2 + - name: iroha-secret-3 + secret: + secretName: iroha-peer-key-3 - name: iroha-config configMap: name: iroha-config + - name: iroha-data + emptyDir: {} - name: block-store emptyDir: {} + volumeClaimTemplates: + - metadata: + name: pg-data + labels: + app: iroha + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + - metadata: + name: block-store + labels: + app: iroha + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml b/deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml new file mode 100644 index 0000000000..ba1b4a90ee --- /dev/null +++ b/deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: iroha-peer-key-0 +type: Opaque +data: + node.priv: NWE5NTU5YjQ2ZGIwN2UwNzUwNGU5ZTFlOTM0NjFmODM3M2ExNzUyMzEyN2E1NmI4MDhkNjE0OWJmMTk1NDljZg== + node.pub: MWNmODlkMDgyOTgxZTRjOGFlNzJhNjI1MmIyMTc5NzgwNDZjMTZmZmY2ZjVmOGMxZmUwNTk0MGVhNTcwMmYwMA== +--- +apiVersion: v1 +kind: Secret +metadata: + name: iroha-peer-key-1 +type: Opaque +data: + node.priv: OTAzZGMzYWFjMjRmYTQwY2YzNDZmMWQwN2E5NGY0NjhhMWU3ZjE2M2MxZWMyYTRhMDI3MzZiMDVjMjY0NDNlNg== + node.pub: OTNhOWUzYjI2OGUyNTkyNjIzNzI2MTYyMTM0N2RkMWZmYWUxOWQzYTFiOTk1YzNiNGVkOTY4OTM0NDQ3NjRhNA== +--- +apiVersion: v1 +kind: Secret +metadata: + name: iroha-peer-key-2 +type: Opaque +data: + node.priv: OWZhZTA4YmI1NGRiNGI3YWFiZTc0YTI2ZmVlN2ZhMmRiNDc0YjdhNTVmOTAzYmQ4ZjJmMDkyMWYyYWMyZjQzYQ== + node.pub: YWMwMjQ1NmE4YjJmYWRjYzBjNmM5MjdhZWYxZGU3YmZhNmU0ZDU4NjBiODQ1ZGY1Y2RjMTdjODA2NzIyNTA3OA== +--- +apiVersion: v1 +kind: Secret +metadata: + name: iroha-peer-key-3 +type: Opaque +data: + node.priv: MDBlMzEyODlmOTIxZjE0NWRjZjI1MDE3NTRjOWM1ZjIxMTlhNmEzNWFkZjM3N2I0NDU3YmEwNmFiNWE2OWUxNg== + node.pub: YTJiOGZmZWJiMDBjMTI4NmFlM2FkNmQxYTU5MGQ3MTY4MjE2NWRhZTc1MDBmMWQ4MzEwMjI2NDNmMWFiMmEwYg== diff --git a/deploy/ansible/roles/iroha-k8s/tasks/main.yml b/deploy/ansible/roles/iroha-k8s/tasks/main.yml index 4c930b5135..5d2017de59 100644 --- a/deploy/ansible/roles/iroha-k8s/tasks/main.yml +++ b/deploy/ansible/roles/iroha-k8s/tasks/main.yml @@ -17,25 +17,10 @@ chdir: "{{ playbook_dir }}/../../roles/iroha-k8s/files" loop: "{{ range(replicas|int)|list }}" - - name: Remove old keys - shell: "rm -f node*.priv node*.pub" - args: - chdir: "{{ playbook_dir }}/../../roles/iroha-k8s/files/conf" - - - name: Generate node key files - command: "python3 {{ playbook_dir }}/scripts/genesis-add-peers.py make_key_files {{ playbook_dir }}/scripts/peers.csv" - args: - chdir: "{{ playbook_dir }}/../../roles/iroha-k8s/files" - - - name: Move iroha keys - shell: "mv node*.priv node*.pub conf/" - args: - chdir: "{{ playbook_dir }}/../../roles/iroha-k8s/files" - - - name: Generate config.sample + - name: Generate config.docker template: - src: config.sample.j2 - dest: "{{ playbook_dir }}/../../roles/iroha-k8s/files/conf/config.sample" + src: config.docker.j2 + dest: "{{ playbook_dir }}/../../roles/iroha-k8s/files/conf/config.docker" delegate_to: localhost - name: Make genesis block file @@ -49,6 +34,19 @@ args: chdir: "{{ playbook_dir }}/../../roles/iroha-k8s/files" + - name: Get peer keys for secrets + command: > + python3 {{ playbook_dir }}/scripts/genesis-add-peers.py print_keys_b64 {{ playbook_dir }}/scripts/peers.csv genesis.block + args: + chdir: "{{ playbook_dir }}/../../roles/iroha-k8s/files" + register: peer_keys + + - name: Generate k8s secrets + template: + src: k8s-peer-keys.yaml.j2 + dest: "{{ playbook_dir }}/../../roles/iroha-k8s/files/k8s-peer-keys.yaml" + delegate_to: localhost + - name: Generate k8s config template: src: k8s-iroha.yaml.j2 diff --git a/deploy/ansible/roles/iroha-k8s/templates/config.sample.j2 b/deploy/ansible/roles/iroha-k8s/templates/config.docker.j2 similarity index 90% rename from deploy/ansible/roles/iroha-k8s/templates/config.sample.j2 rename to deploy/ansible/roles/iroha-k8s/templates/config.docker.j2 index 4909ac9b45..0c7b44fb7d 100644 --- a/deploy/ansible/roles/iroha-k8s/templates/config.sample.j2 +++ b/deploy/ansible/roles/iroha-k8s/templates/config.docker.j2 @@ -6,5 +6,6 @@ "max_proposal_size" : {{ max_proposal_size }}, "proposal_delay" : {{ proposal_delay }}, "vote_delay" : {{ vote_delay }}, + "load_delay" : {{ load_delay }}, "mst_enable" : false } diff --git a/deploy/ansible/roles/iroha-k8s/templates/k8s-iroha.yaml.j2 b/deploy/ansible/roles/iroha-k8s/templates/k8s-iroha.yaml.j2 index a0eea1fe94..2e18607f13 100644 --- a/deploy/ansible/roles/iroha-k8s/templates/k8s-iroha.yaml.j2 +++ b/deploy/ansible/roles/iroha-k8s/templates/k8s-iroha.yaml.j2 @@ -29,6 +29,24 @@ spec: app: iroha spec: terminationGracePeriodSeconds: 7 + initContainers: + - name: copy-data + image: busybox + command: ['sh', '-c', 'cp -v /opt/secrets/$PODNAME/node* /opt/iroha_data && cp -v /opt/iroha_config/* /opt/iroha_data'] + env: + - name: PODNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + volumeMounts: +{% for key_pair in peer_keys.stdout_lines %} + - name: iroha-secret-{{ loop.index - 1 }} + mountPath: /opt/secrets/iroha-{{ loop.index - 1 }} +{% endfor %} + - name: iroha-config + mountPath: /opt/iroha_config + - name: iroha-data + mountPath: /opt/iroha_data containers: - name: postgres image: postgres:9.5 @@ -39,9 +57,23 @@ spec: env: - name: POSTGRES_PASSWORD value: mysecretpassword + - name: PGDATA + value: /var/lib/postgresql/data/pgdata + livenessProbe: + exec: + command: ["pg_isready", "-h", "localhost", "-U", "postgres"] + initialDelaySeconds: 30 + timeoutSeconds: 5 + readinessProbe: + exec: + command: ["pg_isready", "-h", "localhost", "-U", "postgres"] + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumeMounts: + - name: pg-data + mountPath: /var/lib/postgresql/data - name: iroha - #image: hyperledger/iroha@sha256:eb059d2a03544e2bde91a0e16b7d03076b09bc31e9b970c1c4269f02084e8e91 - image: hyperledger/iroha:develop + image: {{ iroha_image }} imagePullPolicy: Always ports: - containerPort: 10001 @@ -49,24 +81,46 @@ spec: - containerPort: 50051 name: external env: + - name: IROHA_POSTGRES_HOST + value: localhost - name: KEY - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: pg-host - valueFrom: - fieldRef: - fieldPath: status.podIP - command: ['bash', '/opt/iroha_data/entrypoint.sh'] + value: node volumeMounts: + - name: iroha-data + mountPath: /opt/iroha_data - name: block-store mountPath: /tmp/block_store - - name: iroha-config - mountPath: /opt/iroha_data volumes: - # TODO: secrets +{% for key_pair in peer_keys.stdout_lines %} + - name: iroha-secret-{{ loop.index - 1 }} + secret: + secretName: iroha-peer-key-{{ loop.index - 1 }} +{% endfor %} - name: iroha-config configMap: name: iroha-config + - name: iroha-data + emptyDir: {} - name: block-store emptyDir: {} + volumeClaimTemplates: + - metadata: + name: pg-data + labels: + app: iroha + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ postgres_volume_size }} + - metadata: + name: block-store + labels: + app: iroha + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ blockstore_volume_size }} diff --git a/deploy/ansible/roles/iroha-k8s/templates/k8s-peer-keys.yaml.j2 b/deploy/ansible/roles/iroha-k8s/templates/k8s-peer-keys.yaml.j2 new file mode 100644 index 0000000000..af85c77d2b --- /dev/null +++ b/deploy/ansible/roles/iroha-k8s/templates/k8s-peer-keys.yaml.j2 @@ -0,0 +1,12 @@ +{% for key_pair in peer_keys.stdout_lines %} +{% set keys = key_pair.split(',') %} +--- +apiVersion: v1 +kind: Secret +metadata: + name: iroha-peer-key-{{ loop.index - 1 }} +type: Opaque +data: + node.priv: {{ keys[0] }} + node.pub: {{ keys[1] }} +{% endfor %} diff --git a/docs/source/guides/k8s-deployment.rst b/docs/source/guides/k8s-deployment.rst index 4c868b447d..38546e6a2b 100644 --- a/docs/source/guides/k8s-deployment.rst +++ b/docs/source/guides/k8s-deployment.rst @@ -120,13 +120,17 @@ Replace the default *kubectl* configuration: We can now control the remote k8s cluster -*k8s-iroha.yaml* pod specification file requires to create a *config-map* first. This is a special resource that is mounted into each pod, and contains keys and configuration files required to run Iroha. +*k8s-iroha.yaml* pod specification file requires the creation of a *config-map* first. This is a special resource that is mounted in the init container of each pod, and contains the configuration and genesis block files required to run Iroha. .. code-block:: shell kubectl create configmap iroha-config --from-file=deploy/ansible/roles/iroha-k8s/files/conf/ -.. Attention:: We store all the keys in a single *config-map*. This greatly simplifies the deployment, but suits only for proof-of-concept purposes as each node would have an access to private keys of others. +Each peer will have their public and private keys stored in a Kubernetes secret which is mounted in the init container and copied over for Iroha to use. Peers will only be able read their assigned secret when running Iroha. + +.. code-block:: shell + + kubectl create -f deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml Deploy Iroha network pod specification: From f4ff4a0e2a52b8166895fe053eafca62747ac56f Mon Sep 17 00:00:00 2001 From: Victor Drobny Date: Fri, 14 Dec 2018 11:48:35 +0100 Subject: [PATCH 13/61] remove common object builders (#1930) Signed-off-by: Victor Drobny --- .../postgres_query_executor_test.cpp | 446 +++++++----------- 1 file changed, 181 insertions(+), 265 deletions(-) diff --git a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp index 808d7d1fda..1f89a91e5a 100644 --- a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp @@ -33,11 +33,7 @@ #include "module/irohad/ametsuchi/ametsuchi_fixture.hpp" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/pending_txs_storage/pending_txs_storage_mock.hpp" -#include "module/shared_model/builders/protobuf/test_account_builder.hpp" -#include "module/shared_model/builders/protobuf/test_asset_builder.hpp" #include "module/shared_model/builders/protobuf/test_block_builder.hpp" -#include "module/shared_model/builders/protobuf/test_domain_builder.hpp" -#include "module/shared_model/builders/protobuf/test_peer_builder.hpp" #include "module/shared_model/builders/protobuf/test_query_builder.hpp" #include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" @@ -60,22 +56,14 @@ namespace { const std::string zero_string{kHashLength, '0'}; const std::string asset_id = "coin#domain"; const std::string role = "role"; - const std::unique_ptr domain = - clone(TestDomainBuilder().domainId("domain").defaultRole(role).build()); - const std::unique_ptr account = - clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); - const std::unique_ptr account2 = - clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); + const shared_model::interface::types::DomainIdType domain_id = "domain"; + const shared_model::interface::types::DomainIdType another_domain_id = + "andomain"; + const shared_model::interface::types::AccountIdType account_id = + "id@" + domain_id; + const shared_model::interface::types::AccountIdType another_account_id = + "id@" + another_domain_id; + const shared_model::interface::types::AccountIdType account_id2 = "id2@" + domain_id; } // namespace namespace iroha { @@ -132,15 +120,6 @@ namespace iroha { pubkey = std::make_unique( std::string('1', 32)); - another_domain = clone( - TestDomainBuilder().domainId("andomain").defaultRole(role).build()); - another_account = - clone(TestAccountBuilder() - .domainId(another_domain->domainId()) - .accountId("id@" + another_domain->domainId()) - .quorum(1) - .jsonData(R"({"id@andomain": {"key": "value"}})") - .build()); query_response_factory = std::make_shared(); } @@ -164,20 +143,20 @@ namespace iroha { ASSERT_TRUE(val(result)) << err(result)->error.toString(); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createDomain( - domain->domainId(), role)), + domain_id, role)), true))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", domain->domainId(), *pubkey)), + "id", domain_id, *pubkey)), true))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createDomain( - another_domain->domainId(), role)), + another_domain_id, role)), true))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id", another_domain->domainId(), *pubkey)), + "id", another_domain_id, *pubkey)), true))); } @@ -259,8 +238,7 @@ namespace iroha { std::string role = "role"; shared_model::interface::RolePermissionSet role_permissions; shared_model::interface::permissions::Grantable grantable_permission; - std::unique_ptr another_account; - std::unique_ptr another_domain; + std::unique_ptr pubkey; std::unique_ptr sql; @@ -290,9 +268,8 @@ namespace iroha { */ TEST_F(BlocksQueryExecutorTest, BlocksQueryExecutorTestValid) { addAllPerms(); - auto blocks_query = TestBlocksQueryBuilder() - .creatorAccountId(account->accountId()) - .build(); + auto blocks_query = + TestBlocksQueryBuilder().creatorAccountId(account_id).build(); ASSERT_TRUE(query_executor->createQueryExecutor(pending_txs_storage, query_response_factory) | [&blocks_query](const auto &executor) { @@ -306,9 +283,8 @@ namespace iroha { * @then result is error */ TEST_F(BlocksQueryExecutorTest, BlocksQueryExecutorTestInvalid) { - auto blocks_query = TestBlocksQueryBuilder() - .creatorAccountId(account->accountId()) - .build(); + auto blocks_query = + TestBlocksQueryBuilder().creatorAccountId(account_id).build(); ASSERT_FALSE(query_executor->createQueryExecutor(pending_txs_storage, query_response_factory) | [&blocks_query](const auto &executor) { @@ -320,22 +296,14 @@ namespace iroha { public: void SetUp() override { QueryExecutorTest::SetUp(); - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); auto pubkey2 = std::make_unique( std::string('2', 32)); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), + "id2", domain_id, *pubkey2)), true))); } - - std::unique_ptr account2; }; /** @@ -346,13 +314,13 @@ namespace iroha { TEST_F(GetAccountExecutorTest, ValidMyAccount) { addPerms({shared_model::interface::permissions::Role::kGetMyAccount}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccount(account->accountId()) + .creatorAccountId(account_id) + .getAccount(account_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [](const auto &cast_resp) { - ASSERT_EQ(cast_resp.account().accountId(), account->accountId()); + ASSERT_EQ(cast_resp.account().accountId(), account_id); }); } @@ -364,13 +332,13 @@ namespace iroha { TEST_F(GetAccountExecutorTest, ValidAllAccounts) { addPerms({shared_model::interface::permissions::Role::kGetAllAccounts}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccount(account2->accountId()) + .creatorAccountId(account_id) + .getAccount(another_account_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { - ASSERT_EQ(cast_resp.account().accountId(), account2->accountId()); + std::move(result), [](const auto &cast_resp) { + ASSERT_EQ(cast_resp.account().accountId(), another_account_id); }); } @@ -383,13 +351,13 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainAccounts}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccount(account2->accountId()) + .creatorAccountId(account_id) + .getAccount(account_id2) .build(); auto result = executeQuery(query); checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { - ASSERT_EQ(cast_resp.account().accountId(), account2->accountId()); + std::move(result), [](const auto &cast_resp) { + ASSERT_EQ(cast_resp.account().accountId(), account_id2); }); } @@ -402,8 +370,8 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainAccounts}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccount(another_account->accountId()) + .creatorAccountId(account_id) + .getAccount(another_account_id) .build(); auto result = executeQuery(query); checkStatefulError( @@ -418,7 +386,7 @@ namespace iroha { TEST_F(GetAccountExecutorTest, InvalidNoAccount) { addPerms({shared_model::interface::permissions::Role::kGetAllAccounts}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAccount("some@domain") .build(); auto result = executeQuery(query); @@ -430,27 +398,14 @@ namespace iroha { public: void SetUp() override { QueryExecutorTest::SetUp(); - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); auto pubkey2 = std::make_unique( std::string('2', 32)); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), + "id2", domain_id, *pubkey2)), true))); } - - // TODO mboldyrev 05.12.2018 IR-57 unify the common constants. - // Some of them, like account2, are defined multiple times, but seem - // contain the same and never modified. Looks like a global constant. - // Also, there is another_account, which seems forgotten by the creators - // of account2's (probably due to the same reason). - std::unique_ptr account2; }; /** @@ -461,8 +416,8 @@ namespace iroha { TEST_F(GetSignatoriesExecutorTest, ValidMyAccount) { addPerms({shared_model::interface::permissions::Role::kGetMySignatories}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getSignatories(account->accountId()) + .creatorAccountId(account_id) + .getSignatories(account_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -479,8 +434,8 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetAllSignatories}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getSignatories(account2->accountId()) + .creatorAccountId(account_id) + .getSignatories(another_account_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -497,8 +452,8 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainSignatories}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getSignatories(account2->accountId()) + .creatorAccountId(account_id) + .getSignatories(account_id2) .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -515,8 +470,8 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainAccounts}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getSignatories(another_account->accountId()) + .creatorAccountId(account_id) + .getSignatories(another_account_id) .build(); auto result = executeQuery(query); checkStatefulError( @@ -532,7 +487,7 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetAllSignatories}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getSignatories("some@domain") .build(); auto result = executeQuery(query); @@ -545,46 +500,31 @@ namespace iroha { void SetUp() override { QueryExecutorTest::SetUp(); - auto asset = clone(TestAccountAssetBuilder() - .domainId(domain->domainId()) - .assetId(asset_id) - .precision(1) - .build()); - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); auto pubkey2 = std::make_unique( std::string('2', 32)); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), + "id2", domain_id, *pubkey2)), true))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), + "coin", domain_id, 1)), true))); - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, "1.0") - .creatorAccountId(account->accountId())), - true))); - ASSERT_TRUE(val( - execute(buildCommand(TestTransactionBuilder() - .addAssetQuantity(asset_id, "1.0") - .creatorAccountId(account2->accountId())), - true, - account2->accountId()))); + ASSERT_TRUE( + val(execute(buildCommand(TestTransactionBuilder() + .addAssetQuantity(asset_id, "1.0") + .creatorAccountId(account_id)), + true))); + ASSERT_TRUE( + val(execute(buildCommand(TestTransactionBuilder() + .addAssetQuantity(asset_id, "1.0") + .creatorAccountId(account_id2)), + true, + account_id2))); } - - std::unique_ptr account2; - shared_model::interface::types::AssetIdType asset_id = - "coin#" + domain->domainId(); }; /** @@ -595,14 +535,13 @@ namespace iroha { TEST_F(GetAccountAssetExecutorTest, ValidMyAccount) { addPerms({shared_model::interface::permissions::Role::kGetMyAccAst}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssets(account->accountId()) + .creatorAccountId(account_id) + .getAccountAssets(account_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { - ASSERT_EQ(cast_resp.accountAssets()[0].accountId(), - account->accountId()); + std::move(result), [](const auto &cast_resp) { + ASSERT_EQ(cast_resp.accountAssets()[0].accountId(), account_id); ASSERT_EQ(cast_resp.accountAssets()[0].assetId(), asset_id); }); } @@ -615,14 +554,14 @@ namespace iroha { TEST_F(GetAccountAssetExecutorTest, ValidAllAccounts) { addPerms({shared_model::interface::permissions::Role::kGetAllAccAst}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssets(account2->accountId()) + .creatorAccountId(account_id) + .getAccountAssets(account_id2) .build(); auto result = executeQuery(query); checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { + std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.accountAssets()[0].accountId(), - account2->accountId()); + account_id2); ASSERT_EQ(cast_resp.accountAssets()[0].assetId(), asset_id); }); } @@ -635,14 +574,14 @@ namespace iroha { TEST_F(GetAccountAssetExecutorTest, ValidDomainAccount) { addPerms({shared_model::interface::permissions::Role::kGetDomainAccAst}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssets(account2->accountId()) + .creatorAccountId(account_id) + .getAccountAssets(account_id2) .build(); auto result = executeQuery(query); checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { + std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.accountAssets()[0].accountId(), - account2->accountId()); + account_id2); ASSERT_EQ(cast_resp.accountAssets()[0].assetId(), asset_id); }); } @@ -655,8 +594,8 @@ namespace iroha { TEST_F(GetAccountAssetExecutorTest, InvalidDifferentDomain) { addPerms({shared_model::interface::permissions::Role::kGetDomainAccAst}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssets(another_account->accountId()) + .creatorAccountId(account_id) + .getAccountAssets(another_account_id) .build(); auto result = executeQuery(query); checkStatefulError( @@ -671,7 +610,7 @@ namespace iroha { TEST_F(GetAccountAssetExecutorTest, DISABLED_InvalidNoAccount) { addPerms({shared_model::interface::permissions::Role::kGetAllAccAst}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAccountAssets("some@domain") .build(); auto result = executeQuery(query); @@ -683,52 +622,47 @@ namespace iroha { public: void SetUp() override { QueryExecutorTest::SetUp(); - - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData("{\"id@domain\": {\"key\": \"value\", " - "\"key2\": \"value2\"}," - " \"id2@domain\": {\"key\": \"value\", " - "\"key2\": \"value2\"}}") - .build()); + detail = + "{\"id@domain\": {\"key\": \"value\", " + "\"key2\": \"value2\"}," + " \"id2@domain\": {\"key\": \"value\", " + "\"key2\": \"value2\"}}"; auto pubkey2 = std::make_unique( std::string('2', 32)); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), + "id2", domain_id, *pubkey2)), true))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), + "coin", domain_id, 1)), true))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key", "value")), + account_id2, "key", "value")), true, - account->accountId()))); + account_id))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key2", "value2")), + account_id2, "key2", "value2")), true, - account->accountId()))); + account_id))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key", "value")), + account_id2, "key", "value")), true, - account2->accountId()))); + account_id2))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().setAccountDetail( - account2->accountId(), "key2", "value2")), + account_id2, "key2", "value2")), true, - account2->accountId()))); + account_id2))); } - std::unique_ptr account2; + shared_model::interface::types::DetailType detail; }; /** @@ -739,8 +673,8 @@ namespace iroha { TEST_F(GetAccountDetailExecutorTest, ValidMyAccount) { addPerms({shared_model::interface::permissions::Role::kGetMyAccDetail}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountDetail(account->accountId()) + .creatorAccountId(account_id) + .getAccountDetail(account_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -756,13 +690,13 @@ namespace iroha { TEST_F(GetAccountDetailExecutorTest, ValidAllAccounts) { addPerms({shared_model::interface::permissions::Role::kGetAllAccDetail}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountDetail(account2->accountId()) + .creatorAccountId(account_id) + .getAccountDetail(account_id2) .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [this](const auto &cast_resp) { - ASSERT_EQ(cast_resp.detail(), account2->jsonData()); + ASSERT_EQ(cast_resp.detail(), detail); }); } @@ -775,13 +709,13 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainAccDetail}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountDetail(account2->accountId()) + .creatorAccountId(account_id) + .getAccountDetail(account_id2) .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [this](const auto &cast_resp) { - ASSERT_EQ(cast_resp.detail(), account2->jsonData()); + ASSERT_EQ(cast_resp.detail(), detail); }); } @@ -794,8 +728,8 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainAccDetail}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountDetail(another_account->accountId()) + .creatorAccountId(account_id) + .getAccountDetail(another_account_id) .build(); auto result = executeQuery(query); checkStatefulError( @@ -810,7 +744,7 @@ namespace iroha { TEST_F(GetAccountDetailExecutorTest, InvalidNoAccount) { addPerms({shared_model::interface::permissions::Role::kGetAllAccDetail}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAccountDetail("some@domain") .build(); auto result = executeQuery(query); @@ -828,8 +762,8 @@ namespace iroha { TEST_F(GetAccountDetailExecutorTest, ValidKey) { addPerms({shared_model::interface::permissions::Role::kGetAllAccDetail}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountDetail(account2->accountId(), "key") + .creatorAccountId(account_id) + .getAccountDetail(account_id2, "key") .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -848,11 +782,10 @@ namespace iroha { */ TEST_F(GetAccountDetailExecutorTest, ValidWriter) { addPerms({shared_model::interface::permissions::Role::kGetAllAccDetail}); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountDetail(account2->accountId(), "", account->accountId()) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountDetail(account_id2, "", account_id) + .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [](const auto &cast_resp) { @@ -872,9 +805,8 @@ namespace iroha { TEST_F(GetAccountDetailExecutorTest, ValidKeyWriter) { addPerms({shared_model::interface::permissions::Role::kGetAllAccDetail}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountDetail( - account2->accountId(), "key", account->accountId()) + .creatorAccountId(account_id) + .getAccountDetail(account_id2, "key", account_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -898,10 +830,8 @@ namespace iroha { */ TEST_F(GetRolesExecutorTest, Valid) { addPerms({shared_model::interface::permissions::Role::kGetRoles}); - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getRoles() - .build(); + auto query = + TestQueryBuilder().creatorAccountId(account_id).getRoles().build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [](const auto &cast_resp) { @@ -917,10 +847,8 @@ namespace iroha { * @then Return Error */ TEST_F(GetRolesExecutorTest, Invalid) { - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getRoles() - .build(); + auto query = + TestQueryBuilder().creatorAccountId(account_id).getRoles().build(); auto result = executeQuery(query); checkStatefulError( std::move(result), kNoPermissions); @@ -941,7 +869,7 @@ namespace iroha { TEST_F(GetRolePermsExecutorTest, Valid) { addPerms({shared_model::interface::permissions::Role::kGetRoles}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getRolePermissions("perms") .build(); auto result = executeQuery(query); @@ -961,7 +889,7 @@ namespace iroha { TEST_F(GetRolePermsExecutorTest, InvalidNoRole) { addPerms({shared_model::interface::permissions::Role::kGetRoles}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getRolePermissions("some") .build(); auto result = executeQuery(query); @@ -976,7 +904,7 @@ namespace iroha { */ TEST_F(GetRolePermsExecutorTest, Invalid) { auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getRolePermissions("role") .build(); auto result = executeQuery(query); @@ -993,7 +921,7 @@ namespace iroha { void createAsset() { ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), + "coin", domain_id, 1)), true))); } const std::string asset_id = "coin#domain"; @@ -1008,14 +936,14 @@ namespace iroha { addPerms({shared_model::interface::permissions::Role::kReadAssets}); createAsset(); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAssetInfo(asset_id) .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [this](const auto &cast_resp) { ASSERT_EQ(cast_resp.asset().assetId(), asset_id); - ASSERT_EQ(cast_resp.asset().domainId(), domain->domainId()); + ASSERT_EQ(cast_resp.asset().domainId(), domain_id); ASSERT_EQ(cast_resp.asset().precision(), 1); }); } @@ -1028,7 +956,7 @@ namespace iroha { TEST_F(GetAssetInfoExecutorTest, InvalidNoAsset) { addPerms({shared_model::interface::permissions::Role::kReadAssets}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAssetInfo("some#domain") .build(); auto result = executeQuery(query); @@ -1043,7 +971,7 @@ namespace iroha { */ TEST_F(GetAssetInfoExecutorTest, Invalid) { auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAssetInfo(asset_id) .build(); auto result = executeQuery(query); @@ -1064,17 +992,16 @@ namespace iroha { auto block_store = FlatFile::create(block_store_dir); ASSERT_TRUE(block_store); this->block_store = std::move(block_store.get()); - auto pubkey2 = std::make_unique( std::string('2', 32)); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAccount( - "id2", domain->domainId(), *pubkey2)), + "id2", domain_id, *pubkey2)), true))); ASSERT_TRUE( val(execute(buildCommand(TestTransactionBuilder().createAsset( - "coin", domain->domainId(), 1)), + "coin", domain_id, 1)), true))); } @@ -1104,20 +1031,17 @@ namespace iroha { std::vector txs1; txs1.push_back(TestTransactionBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .createRole("user", {}) .build()); + txs1.push_back( + TestTransactionBuilder() + .creatorAccountId(account_id) + .addAssetQuantity(asset_id, "2.0") + .transferAsset(account_id, account_id2, asset_id, "", "1.0") + .build()); txs1.push_back(TestTransactionBuilder() - .creatorAccountId(account->accountId()) - .addAssetQuantity(asset_id, "2.0") - .transferAsset(account->accountId(), - account2->accountId(), - asset_id, - "", - "1.0") - .build()); - txs1.push_back(TestTransactionBuilder() - .creatorAccountId(account2->accountId()) + .creatorAccountId(account_id2) .createRole("user2", {}) .build()); @@ -1130,16 +1054,13 @@ namespace iroha { apply(storage, block1); std::vector txs2; + txs2.push_back( + TestTransactionBuilder() + .creatorAccountId(account_id2) + .transferAsset(account_id, account_id2, asset_id, "", "1.0") + .build()); txs2.push_back(TestTransactionBuilder() - .creatorAccountId(account2->accountId()) - .transferAsset(account->accountId(), - account2->accountId(), - asset_id, - "", - "1.0") - .build()); - txs2.push_back(TestTransactionBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .createRole("user3", {}) .build()); @@ -1156,6 +1077,7 @@ namespace iroha { hash3 = txs2.at(0).hash(); } + const std::string asset_id = "coin#domain"; shared_model::crypto::Hash fake_hash{zero_string}; shared_model::crypto::PublicKey fake_pubkey{zero_string}; shared_model::crypto::Hash hash1; @@ -1276,9 +1198,9 @@ namespace iroha { for (size_t i = 0; i < transactions_amount; ++i) { transactions.emplace_back( TestTransactionBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .createdTime(iroha::time::now(std::chrono::milliseconds(i))) - .setAccountDetail(account->accountId(), + .setAccountDetail(account_id, "key_" + std::to_string(i), "val_" + std::to_string(i)) .build()); @@ -1290,9 +1212,9 @@ namespace iroha { types::TransactionsNumberType page_size, const boost::optional &first_hash = boost::none) { return TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .createdTime(iroha::time::now()) - .getAccountTransactions(account->accountId(), page_size, first_hash) + .getAccountTransactions(account_id, page_size, first_hash) .build(); } }; @@ -1314,7 +1236,7 @@ namespace iroha { makeInitialTransactions(size_t transactions_amount) { return { TestTransactionBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .createdTime(iroha::time::now()) .addAssetQuantity( asset_id, assetAmount(transactions_amount, kAssetPrecision)) @@ -1327,10 +1249,10 @@ namespace iroha { for (size_t i = 0; i < transactions_amount; ++i) { transactions.emplace_back( TestTransactionBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .createdTime(iroha::time::now(std::chrono::milliseconds(i))) - .transferAsset(account->accountId(), - account2->accountId(), + .transferAsset(account_id, + another_account_id, asset_id, "tx #" + std::to_string(i), assetAmount(1, kAssetPrecision)) @@ -1343,10 +1265,10 @@ namespace iroha { types::TransactionsNumberType page_size, const boost::optional &first_hash = boost::none) { return TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .createdTime(iroha::time::now()) .getAccountAssetTransactions( - account->accountId(), asset_id, page_size, first_hash) + account_id, asset_id, page_size, first_hash) .build(); } }; @@ -1364,18 +1286,17 @@ namespace iroha { commitBlocks(); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(account->accountId(), kTxPageSize) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountTransactions(account_id, kTxPageSize) + .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 3); for (const auto &tx : cast_resp.transactions()) { static size_t i = 0; - EXPECT_EQ(account->accountId(), tx.creatorAccountId()) + EXPECT_EQ(account_id, tx.creatorAccountId()) << tx.toString() << " ~~ " << i; ++i; } @@ -1392,17 +1313,16 @@ namespace iroha { commitBlocks(); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(account2->accountId(), kTxPageSize) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountTransactions(account_id2, kTxPageSize) + .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 2); for (const auto &tx : cast_resp.transactions()) { - EXPECT_EQ(account2->accountId(), tx.creatorAccountId()) + EXPECT_EQ(account_id2, tx.creatorAccountId()) << tx.toString(); } }); @@ -1418,17 +1338,16 @@ namespace iroha { commitBlocks(); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(account2->accountId(), kTxPageSize) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountTransactions(account_id2, kTxPageSize) + .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [](const auto &cast_resp) { ASSERT_EQ(cast_resp.transactions().size(), 2); for (const auto &tx : cast_resp.transactions()) { - EXPECT_EQ(account2->accountId(), tx.creatorAccountId()) + EXPECT_EQ(account_id2, tx.creatorAccountId()) << tx.toString(); } }); @@ -1441,11 +1360,10 @@ namespace iroha { */ TEST_F(GetAccountTransactionsExecutorTest, InvalidDifferentDomain) { addPerms({shared_model::interface::permissions::Role::kGetDomainAccTxs}); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(another_account->accountId(), kTxPageSize) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountTransactions(another_account_id, kTxPageSize) + .build(); auto result = executeQuery(query); checkStatefulError( std::move(result), kNoPermissions); @@ -1460,7 +1378,7 @@ namespace iroha { addPerms({shared_model::interface::permissions::Role::kGetAllAccTxs}); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAccountTransactions("some@domain", kTxPageSize) .build(); auto result = executeQuery(query); @@ -1596,7 +1514,7 @@ namespace iroha { hashes.push_back(hash3); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getTransactions(hashes) .build(); auto result = executeQuery(query); @@ -1623,7 +1541,7 @@ namespace iroha { hashes.push_back(hash3); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getTransactions(hashes) .build(); auto result = executeQuery(query); @@ -1648,11 +1566,11 @@ namespace iroha { commitBlocks(); - auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountAssetTransactions( - account->accountId(), asset_id, kTxPageSize) - .build(); + auto query = + TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountAssetTransactions(account_id, asset_id, kTxPageSize) + .build(); auto result = executeQuery(query); checkSuccessfulResult( std::move(result), [this](const auto &cast_resp) { @@ -1673,9 +1591,9 @@ namespace iroha { commitBlocks(); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAccountAssetTransactions( - account2->accountId(), asset_id, kTxPageSize) + account_id2, asset_id, kTxPageSize) .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -1698,9 +1616,9 @@ namespace iroha { commitBlocks(); auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getAccountAssetTransactions( - account2->accountId(), asset_id, kTxPageSize) + account_id2, asset_id, kTxPageSize) .build(); auto result = executeQuery(query); checkSuccessfulResult( @@ -1720,11 +1638,10 @@ namespace iroha { addPerms( {shared_model::interface::permissions::Role::kGetDomainAccAstTxs}); - auto query = - TestQueryBuilder() - .creatorAccountId(account->accountId()) - .getAccountTransactions(another_account->accountId(), kTxPageSize) - .build(); + auto query = TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountTransactions(another_account_id, kTxPageSize) + .build(); auto result = executeQuery(query); checkStatefulError( std::move(result), kNoPermissions); @@ -1737,12 +1654,11 @@ namespace iroha { */ TEST_F(QueryExecutorTest, TransactionsStorageIsAccessed) { auto query = TestQueryBuilder() - .creatorAccountId(account->accountId()) + .creatorAccountId(account_id) .getPendingTransactions() .build(); - EXPECT_CALL(*pending_txs_storage, - getPendingTransactions(account->accountId())) + EXPECT_CALL(*pending_txs_storage, getPendingTransactions(account_id)) .Times(1); executeQuery(query); From 8f6fad13f937b8acbe31cc171f52fb8a93b1e247 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 16 Dec 2018 11:59:56 +0300 Subject: [PATCH 14/61] Updated documentation on commands, removed empty sub-menus (#1938) Signed-off-by: Sara --- docs/source/api/commands.rst | 68 ++++++++++-------------------- docs/source/api/cpp_library.rst | 6 --- docs/source/api/java_library.rst | 6 --- docs/source/api/nodejs_library.rst | 6 --- docs/source/api/objc_library.rst | 6 --- docs/source/api/python_library.rst | 6 --- docs/source/api/swift_library.rst | 6 --- 7 files changed, 22 insertions(+), 82 deletions(-) delete mode 100644 docs/source/api/cpp_library.rst delete mode 100644 docs/source/api/java_library.rst delete mode 100644 docs/source/api/nodejs_library.rst delete mode 100644 docs/source/api/objc_library.rst delete mode 100644 docs/source/api/python_library.rst delete mode 100644 docs/source/api/swift_library.rst diff --git a/docs/source/api/commands.rst b/docs/source/api/commands.rst index 9de14d1ea3..ef0fb82366 100644 --- a/docs/source/api/commands.rst +++ b/docs/source/api/commands.rst @@ -20,19 +20,7 @@ Schema message AddAssetQuantity { string asset_id = 1; - Amount amount = 2; - } - - message uint256 { - uint64 first = 1; - uint64 second = 2; - uint64 third = 3; - uint64 fourth = 4; - } - - message Amount { - uint256 value = 1; - uint32 precision = 2; + string amount = 2; } .. note:: @@ -297,8 +285,8 @@ Schema .. code-block:: proto message CreateRole { - string role_name = 1; - repeated string permissions = 2; + string role_name = 1; + repeated RolePermission permissions = 2; } Structure @@ -309,7 +297,7 @@ Structure :widths: 15, 30, 20, 15 "Role name", "name of role to create", "`[a-z_0-9]{1,32}`", "User" - "Permissions", "array of already existent permissions", "set of passed permissions is fully included into set of existing permissions", "{can_receive, can_transfer}" + "RolePermission", "array of already existent permissions", "set of passed permissions is fully included into set of existing permissions", "{can_receive, can_transfer}" Validation ^^^^^^^^^^ @@ -366,8 +354,8 @@ Schema .. code-block:: proto message GrantPermission { - string account_id = 1; - string permission_name = 2; + string account_id = 1; + GrantablePermission permission = 2; } Structure @@ -377,8 +365,8 @@ Structure :header: "Field", "Description", "Constraint", "Example" :widths: 15, 30, 20, 15 - "Account ID", "id of account whom rights are granted", "already existent", "makoto@soramitsu" - "Permission name", "name of granted permission", "permission is defined", "CanTransferAssets" + "Account ID", "id of the account to which the rights are granted", "already existent", "makoto@soramitsu" + "GrantablePermission name", "name of grantable permission", "permission is defined", "CanTransferAssets" Validation @@ -412,7 +400,7 @@ Structure :header: "Field", "Description", "Constraint", "Example" :widths: 15, 30, 20, 15 - "Account ID", "id of account whom rights are granted", "already existent", "makoto@soramitsu" + "Account ID", "id of the account to which the rights are granted", "already existent", "makoto@soramitsu" "Public key", "Signatory to delete", "ed25519 public key", "407e57f50ca48969b08ba948171bb2435e035d82cec417e18e4a38f5fb113f83" Validation @@ -441,8 +429,8 @@ Schema .. code-block:: proto message RevokePermission { - string account_id = 1; - string permission_name = 2; + string account_id = 1; + GrantablePermission permission = 2; } Structure @@ -452,8 +440,8 @@ Structure :header: "Field", "Description", "Constraint", "Example" :widths: 15, 30, 20, 15 - "Account ID", "id of account whom rights are granted", "already existent", "makoto@soramitsu" - "Permission name", "name of granted permission", "permission was granted", "CanTransferAssets" + "Account ID", "id of the account to which the rights are granted", "already existent", "makoto@soramitsu" + "GrantablePermission name", "name of grantable permission", "permission was granted", "CanTransferAssets" Validation ^^^^^^^^^^ @@ -488,7 +476,7 @@ Structure :header: "Field", "Description", "Constraint", "Example" :widths: 15, 30, 20, 15 - "Account ID", "id of account whom key-value information was set", "already existent", "makoto@soramitsu" + "Account ID", "id of the account to which the key-value information was set", "already existent", "makoto@soramitsu" "Key", "key of information being set", "`[A-Za-z0-9_]{1,64}`", "Name" "Value", "value of corresponding key", "≤ 4096", "Makoto" @@ -528,7 +516,7 @@ Structure :widths: 15, 30, 20, 15 "Account ID", "ID of account to set quorum", "already existent", "makoto@soramitsu" - "Quorum", "number of signatories needed to be included with a transaction from this account", "0 < quorum ≤ public-key set up to account ≤ 128", "5" + "Quorum", "number of signatories needed to be included within a transaction from this account", "0 < quorum ≤ public-key set up to account ≤ 128", "5" Validation ^^^^^^^^^^ @@ -556,19 +544,7 @@ Schema message SubtractAssetQuantity { string asset_id = 1; - Amount amount = 2; - } - - message uint256 { - uint64 first = 1; - uint64 second = 2; - uint64 third = 3; - uint64 fourth = 4; - } - - message Amount { - uint256 value = 1; - uint32 precision = 2; + string amount = 2; } .. note:: @@ -610,7 +586,7 @@ Schema string dest_account_id = 2; string asset_id = 3; string description = 4; - Amount amount = 5; + string amount = 5; } Structure @@ -620,11 +596,11 @@ Structure :header: "Field", "Description", "Constraint", "Example" :widths: 15, 30, 20, 15 - "Source account ID", "ID of account to withdraw asset from", "already existent", "makoto@soramitsu" - "Destination account ID", "ID of account to send asset at", "already existent", "alex@california" - "Asset ID", "ID of asset to transfer", "already existent", "usd#usa" - "Description", "Message to attach to transfer", "Max length is 64", "here's my money take it" - "Amount", "amount of the asset to transfer", "0 < amount < max_uint256", "200.20" + "Source account ID", "ID of the account to withdraw the asset from", "already existent", "makoto@soramitsu" + "Destination account ID", "ID of the account to send the asset to", "already existent", "alex@california" + "Asset ID", "ID of the asset to transfer", "already existent", "usd#usa" + "Description", "Message to attach to the transfer", "Max length is 64", "here's my money take it" + "Amount", "amount of the asset to transfer", "0 <= precision <= 255", "200.20" Validation ^^^^^^^^^^ diff --git a/docs/source/api/cpp_library.rst b/docs/source/api/cpp_library.rst deleted file mode 100644 index ad194fc7ee..0000000000 --- a/docs/source/api/cpp_library.rst +++ /dev/null @@ -1,6 +0,0 @@ -С++ library -=========== - -This section only contains code reference (autogenerated docs are possible with a description of arguments and return values) - -.. Attention:: Contents are missing for now. \ No newline at end of file diff --git a/docs/source/api/java_library.rst b/docs/source/api/java_library.rst deleted file mode 100644 index a93319ef90..0000000000 --- a/docs/source/api/java_library.rst +++ /dev/null @@ -1,6 +0,0 @@ -Java library -============ - -This section only contains code reference (autogenerated docs are possible with a description of arguments and return values) - -.. Attention:: Contents are missing for now. \ No newline at end of file diff --git a/docs/source/api/nodejs_library.rst b/docs/source/api/nodejs_library.rst deleted file mode 100644 index c67107175d..0000000000 --- a/docs/source/api/nodejs_library.rst +++ /dev/null @@ -1,6 +0,0 @@ -NodeJS library -============== - -This section only contains code reference (autogenerated docs are possible with a description of arguments and return values) - -.. Attention:: Contents are missing for now. \ No newline at end of file diff --git a/docs/source/api/objc_library.rst b/docs/source/api/objc_library.rst deleted file mode 100644 index 3166394e81..0000000000 --- a/docs/source/api/objc_library.rst +++ /dev/null @@ -1,6 +0,0 @@ -Objective-C library -=================== - -This section only contains code reference (autogenerated docs are possible with a description of arguments and return values) - -.. Attention:: Contents are missing for now. \ No newline at end of file diff --git a/docs/source/api/python_library.rst b/docs/source/api/python_library.rst deleted file mode 100644 index 4fcda6b2df..0000000000 --- a/docs/source/api/python_library.rst +++ /dev/null @@ -1,6 +0,0 @@ -Python library -============== - -This section only contains code reference (autogenerated docs are possible with a description of arguments and return values) - -.. Attention:: Contents are missing for now. \ No newline at end of file diff --git a/docs/source/api/swift_library.rst b/docs/source/api/swift_library.rst deleted file mode 100644 index fd6a487b60..0000000000 --- a/docs/source/api/swift_library.rst +++ /dev/null @@ -1,6 +0,0 @@ -Swift library -============= - -This section only contains code reference (autogenerated docs are possible with a description of arguments and return values) - -.. Attention:: Contents are missing for now. From f7e8257bc9c9d229fd22a636a0fef262c563c1bb Mon Sep 17 00:00:00 2001 From: BulatSaif Date: Mon, 17 Dec 2018 09:38:24 +0300 Subject: [PATCH 15/61] Add fuzzing build process to nightly Iroha builds (#1950) * add fuzzingEnabled Signed-off-by: Bulat Saifullin * clang COMPILER Signed-off-by: Bulat Saifullin * fix to CMAKE_C_COMPILER Signed-off-by: Bulat Saifullin --- .jenkinsci/debug-build.groovy | 19 +++++++++++++------ Jenkinsfile | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.jenkinsci/debug-build.groovy b/.jenkinsci/debug-build.groovy index d0f290d4b8..89564aea65 100644 --- a/.jenkinsci/debug-build.groovy +++ b/.jenkinsci/debug-build.groovy @@ -6,6 +6,7 @@ def doDebugBuild(coverageEnabled=false) { def pCommit = load ".jenkinsci/previous-commit.groovy" def parallelism = params.PARALLELISM def sanitizeEnabled = params.sanitize + def fuzzingEnabled = params.fuzzing def platform = sh(script: 'uname -m', returnStdout: true).trim() def previousCommit = pCommit.previousCommitOrCurrent() // params are always null unless job is started @@ -66,6 +67,9 @@ def doDebugBuild(coverageEnabled=false) { if ( sanitizeEnabled ){ cmakeOptions += " -DSANITIZE='address;leak' " } + if ( fuzzingEnabled ){ + cmakeOptions += " -DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_CXX_COMPILER=clang++-6.0 -DFUZZING=ON " + } env.IROHA_VERSION = "0x${scmVars.GIT_COMMIT}" env.IROHA_HOME = "/opt/iroha" env.IROHA_BUILD = "${env.IROHA_HOME}/build" @@ -90,12 +94,15 @@ def doDebugBuild(coverageEnabled=false) { if ( coverageEnabled ) { sh "cmake --build build --target coverage.init.info" } - sh "cd build; ctest --output-on-failure --no-compress-output -T Test || true" - sh 'python .jenkinsci/helpers/platform_tag.py "Linux \$(uname -m)" \$(ls build/Testing/*/Test.xml)' - // Mark build as UNSTABLE if there are any failed tests (threshold <100%) - xunit testTimeMargin: '3000', thresholdMode: 2, thresholds: [passed(unstableThreshold: '100')], \ - tools: [CTest(deleteOutputFiles: true, failIfNotNew: false, \ - pattern: 'build/Testing/**/Test.xml', skipNoTestFiles: false, stopProcessingIfError: true)] + //If fuzzing Enabled do not run tests, they never stop + if ( !fuzzingEnabled ){ + sh "cd build; ctest --output-on-failure --no-compress-output -T Test || true" + sh 'python .jenkinsci/helpers/platform_tag.py "Linux \$(uname -m)" \$(ls build/Testing/*/Test.xml)' + // Mark build as UNSTABLE if there are any failed tests (threshold <100%) + xunit testTimeMargin: '3000', thresholdMode: 2, thresholds: [passed(unstableThreshold: '100')], \ + tools: [CTest(deleteOutputFiles: true, failIfNotNew: false, \ + pattern: 'build/Testing/**/Test.xml', skipNoTestFiles: false, stopProcessingIfError: true)] + } if ( coverageEnabled ) { sh "cmake --build build --target cppcheck" // Sonar diff --git a/Jenkinsfile b/Jenkinsfile index 1d4861e506..dae4a219dc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,6 +19,7 @@ properties([parameters([ choice(choices: 'arm64-v8a\narmeabi-v7a\narmeabi\nx86_64\nx86', description: 'Android bindings platform', name: 'ABPlatform'), booleanParam(defaultValue: true, description: 'Build docs', name: 'Doxygen'), booleanParam(defaultValue: true, description: 'Sanitize address;leak', name: 'sanitize'), + booleanParam(defaultValue: false, description: 'Build fuzzing, but do not run tests', name: 'fuzzing'), string(defaultValue: '8', description: 'Expect ~3GB memory consumtion per CPU core', name: 'PARALLELISM')])]) From 86877915db8a15b5bb8807609f3562b64c12f7ef Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Mon, 17 Dec 2018 14:08:08 +0300 Subject: [PATCH 16/61] Review issues Signed-off-by: Akvinikym --- .../ametsuchi/postgres_executor_test.cpp | 963 +++++++++--------- .../mock_command_factory.cpp | 159 ++- 2 files changed, 585 insertions(+), 537 deletions(-) diff --git a/test/module/irohad/ametsuchi/postgres_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_executor_test.cpp index 310bb35a54..9580d59c74 100644 --- a/test/module/irohad/ametsuchi/postgres_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_executor_test.cpp @@ -64,39 +64,49 @@ namespace iroha { AmetsuchiTest::TearDown(); } - /** - * Check that passed result contains value and not an error (without this - * method the one below is not able to perform this check - * @param result to be checked - */ - void checkCommandResult(const CommandResult &result) { - ASSERT_TRUE(val(result)); - } - /** * Execute a given command and optionally check its result - * @tparam check_result - if the result command execution should be - * checked * @tparam CommandType - type of the command - * @param command - the command to execute + * @param command - the command to CHECK_SUCCESSFUL_RESULT(execute * @param do_validation - of the command should be validated * @param creator - creator of the command * @return result of command execution */ - template + template CommandResult execute(CommandType &&command, bool do_validation = false, const shared_model::interface::types::AccountIdType &creator = "id@domain") { executor->doValidation(not do_validation); executor->setCreatorAccountId(creator); - auto result = executor->operator()(std::forward(command)); - if (check_result) { - checkCommandResult(result); - } - return result; + return executor->operator()(std::forward(command)); } + /** + * Check that passed result contains value and not an error + * @param result to be checked + */ +#define CHECK_SUCCESSFUL_RESULT(result) \ + { ASSERT_TRUE(val(result)); } + + /** + * Check that command result contains specific error code and error + * message + * @param cmd_result to be checked + * @param expected_code to be in the result + * @param expected_substrings - collection of strings, which are expected + * to be in command error + */ +#define CHECK_ERROR_CODE_AND_MESSAGE( \ + cmd_result, expected_code, expected_substrings) \ + auto error = err(cmd_result); \ + ASSERT_TRUE(error); \ + EXPECT_EQ(error->error.error_code, expected_code); \ + auto str_error = error->error.error_extra; \ + for (auto substring : expected_substrings) { \ + EXPECT_THAT(str_error, HasSubstr(substring)); \ + } + void addAllPerms( const shared_model::interface::types::AccountIdType &account_id = "id@domain", @@ -104,11 +114,12 @@ namespace iroha { shared_model::interface::RolePermissionSet permissions; permissions.set(); - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role_id, permissions), - true); - execute(*mock_command_factory->constructAppendRole(account_id, role_id), - true); + true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAppendRole(account_id, role_id), + true)); } /** @@ -124,51 +135,36 @@ namespace iroha { const shared_model::interface::types::RoleIdType role_id = "all") { shared_model::interface::RolePermissionSet permissions; permissions.set(perm); - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role_id, permissions), - true); - execute(*mock_command_factory->constructAppendRole(account_id, role_id), - true); + true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAppendRole(account_id, role_id), + true)); } - /** - * Check that command result contains specific error code and error - * message - * @param cmd_result to be checked - * @param expected_code to be in the result - * @param expected_substrings - collection of strings, which are expected - * to be in command error - */ -#define CHECK_ERROR_CODE_AND_MESSAGE( \ - cmd_result, expected_code, expected_substrings) \ - auto error = err(cmd_result); \ - ASSERT_TRUE(error); \ - EXPECT_EQ(error->error.error_code, expected_code); \ - auto str_error = error->error.error_extra; \ - for (auto substring : expected_substrings) { \ - EXPECT_THAT(str_error, HasSubstr(substring)); \ - } - /* * The functions below create common objects with default parameters * without any validation - specifically for SetUp methods */ void createDefaultRole() { - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), - true); + true)); } void createDefaultDomain() { - execute(*mock_command_factory->constructCreateDomain(domain->domainId(), - role), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain->domainId(), role), + true)); } void createDefaultAccount() { - execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true)); } const std::string role = "role"; @@ -214,9 +210,9 @@ namespace iroha { */ void addAsset(const shared_model::interface::types::DomainIdType &domain_id = "domain") { - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateAsset("coin", domain_id, 1), - true); + true)); } shared_model::interface::types::AssetIdType asset_id = @@ -232,16 +228,18 @@ namespace iroha { addAsset(); addAllPerms(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero))); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero))); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); @@ -258,16 +256,18 @@ namespace iroha { addOnePerm( shared_model::interface::permissions::Role::kAddDomainAssetQty); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero))); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero))); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); @@ -283,27 +283,28 @@ namespace iroha { std::unique_ptr domain2; domain2 = clone( TestDomainBuilder().domainId("domain2").defaultRole(role).build()); - execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), - role), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role), + true)); addAsset(domain2->domainId()); addOnePerm( shared_model::interface::permissions::Role::kAddDomainAssetQty); auto asset2_id = "coin#" + domain2->domainId(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset2_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset2_id, asset_amount_one_zero), + true)); auto account_asset = query->getAccountAsset(account->accountId(), asset2_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); auto cmd_result = - execute(*mock_command_factory->constructAddAssetQuantity( + execute(*mock_command_factory->constructAddAssetQuantity( asset2_id, asset_amount_one_zero)); std::vector query_args{account->accountId(), @@ -323,14 +324,14 @@ namespace iroha { auto add_asset = mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero); - execute(*add_asset, true); + CHECK_SUCCESSFUL_RESULT(execute(*add_asset, true)); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - auto cmd_result = execute(*add_asset); + auto cmd_result = execute(*add_asset); std::vector query_args{account->accountId(), asset_amount_one_zero.toStringRepr(), @@ -346,9 +347,9 @@ namespace iroha { */ TEST_F(AddAccountAssetTest, InvalidAsset) { auto cmd_result = - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true); std::vector query_args{account->accountId(), asset_amount_one_zero.toStringRepr(), @@ -367,9 +368,9 @@ namespace iroha { auto add_asset = mock_command_factory->constructAddAssetQuantity( asset_id, uint256_halfmax); - execute(*add_asset, true); + CHECK_SUCCESSFUL_RESULT(execute(*add_asset, true)); - auto cmd_result = execute(*add_asset, true); + auto cmd_result = execute(*add_asset, true); std::vector query_args{ account->accountId(), uint256_halfmax.toStringRepr(), asset_id, "1"}; @@ -395,7 +396,8 @@ namespace iroha { */ TEST_F(AddPeer, Valid) { addAllPerms(); - execute(*mock_command_factory->constructAddPeer(*peer)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddPeer(*peer))); } /** @@ -404,8 +406,7 @@ namespace iroha { * @then peer is not added */ TEST_F(AddPeer, NoPerms) { - auto cmd_result = - execute(*mock_command_factory->constructAddPeer(*peer)); + auto cmd_result = execute(*mock_command_factory->constructAddPeer(*peer)); std::vector query_args{peer->toString()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -417,12 +418,13 @@ namespace iroha { CommandExecutorTest::SetUp(); createDefaultRole(); createDefaultDomain(); - execute(*mock_command_factory->constructCreateAccount( - "id", - domain->domainId(), - shared_model::interface::types::PubkeyType( - std::string('5', 32))), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id", + domain->domainId(), + shared_model::interface::types::PubkeyType( + std::string('5', 32))), + true)); } }; @@ -434,8 +436,9 @@ namespace iroha { TEST_F(AddSignatory, Valid) { addAllPerms(); - execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId())); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId()))); auto signatories = query->getSignatories(account->accountId()); ASSERT_TRUE(signatories); @@ -449,20 +452,21 @@ namespace iroha { * @then signatory is successfully added */ TEST_F(AddSignatory, ValidGrantablePerms) { - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateAccount( "id2", domain->domainId(), shared_model::interface::types::PubkeyType(std::string('2', 32))), - true); + true)); auto perm = shared_model::interface::permissions::Grantable::kAddMySignatory; - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain"); - execute( - *mock_command_factory->constructAddSignatory(*pubkey, "id2@domain")); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain")); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(*pubkey, "id2@domain"))); auto signatories = query->getSignatories("id2@domain"); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) @@ -475,9 +479,8 @@ namespace iroha { * @then signatory is not added */ TEST_F(AddSignatory, NoPerms) { - auto cmd_result = - execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId())); + auto cmd_result = execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId())); std::vector query_args{account->accountId(), pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -496,12 +499,12 @@ namespace iroha { */ TEST_F(AddSignatory, ExistingPubKey) { addAllPerms(); - execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId())); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId()))); - auto cmd_result = - execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId())); + auto cmd_result = execute(*mock_command_factory->constructAddSignatory( + *pubkey, account->accountId())); std::vector query_args{account->accountId(), pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -525,11 +528,13 @@ namespace iroha { */ TEST_F(AppendRole, Valid) { addAllPerms(); - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions), - true); - execute(*mock_command_factory->constructAppendRole(account->accountId(), - another_role)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role))); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -543,10 +548,11 @@ namespace iroha { */ TEST_F(AppendRole, ValidEmptyPerms) { addAllPerms(); - execute(*mock_command_factory->constructCreateRole(another_role, {}), - true); - execute(*mock_command_factory->constructAppendRole(account->accountId(), - another_role)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateRole(another_role, {}), true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role))); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -562,12 +568,14 @@ namespace iroha { TEST_F(AppendRole, AccountDoesNotHavePermsGenesis) { role_permissions2.set( shared_model::interface::permissions::Role::kRemoveMySignatory); - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions2), - true); - execute(*mock_command_factory->constructAppendRole(account->accountId(), - another_role), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions2), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role), + true)); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -580,12 +588,12 @@ namespace iroha { * @then role is not appended */ TEST_F(AppendRole, NoPerms) { - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions), - true); - auto cmd_result = - execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions), + true)); + auto cmd_result = execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -604,12 +612,12 @@ namespace iroha { TEST_F(AppendRole, NoRolePermsInAccount) { role_permissions2.set( shared_model::interface::permissions::Role::kRemoveMySignatory); - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions2), - true); - auto cmd_result = - execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole(another_role, + role_permissions2), + true)); + auto cmd_result = execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -622,11 +630,10 @@ namespace iroha { */ TEST_F(AppendRole, NoAccount) { addAllPerms(); - execute(*mock_command_factory->constructCreateRole(another_role, {}), - true); - auto cmd_result = - execute(*mock_command_factory->constructAppendRole( - "doge@noaccount", another_role)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateRole(another_role, {}), true)); + auto cmd_result = execute(*mock_command_factory->constructAppendRole( + "doge@noaccount", another_role)); std::vector query_args{"doge@noaccount", another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -639,9 +646,8 @@ namespace iroha { */ TEST_F(AppendRole, NoRole) { addAllPerms(); - auto cmd_result = - execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role)); + auto cmd_result = execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -678,8 +684,9 @@ namespace iroha { */ TEST_F(CreateAccount, Valid) { addAllPerms(); - execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey))); auto acc = query->getAccount(account2->accountId()); ASSERT_TRUE(acc); ASSERT_EQ(*account2.get(), *acc.get()); @@ -691,9 +698,8 @@ namespace iroha { * @then account is not created */ TEST_F(CreateAccount, NoPerms) { - auto cmd_result = - execute(*mock_command_factory->constructCreateAccount( - account2->accountId(), domain->domainId(), *pubkey)); + auto cmd_result = execute(*mock_command_factory->constructCreateAccount( + account2->accountId(), domain->domainId(), *pubkey)); auto acc = query->getAccount(account2->accountId()); ASSERT_FALSE(acc); @@ -709,9 +715,8 @@ namespace iroha { */ TEST_F(CreateAccount, NoDomain) { addAllPerms(); - auto cmd_result = - execute(*mock_command_factory->constructCreateAccount( - "doge", "domain6", *pubkey)); + auto cmd_result = execute(*mock_command_factory->constructCreateAccount( + "doge", "domain6", *pubkey)); std::vector query_args{"doge", "domain6", pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -724,9 +729,8 @@ namespace iroha { */ TEST_F(CreateAccount, NameExists) { addAllPerms(); - auto cmd_result = - execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey)); + auto cmd_result = execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey)); std::vector query_args{ "id", domain->domainId(), pubkey->hex()}; @@ -751,22 +755,25 @@ namespace iroha { TEST_F(CreateAsset, Valid) { role_permissions.set( shared_model::interface::permissions::Role::kCreateAsset); - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), - true); - execute(*mock_command_factory->constructCreateDomain(domain->domainId(), - role), - true); + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain->domainId(), role), + true)); auto asset = clone(TestAccountAssetBuilder() .domainId(domain->domainId()) .assetId(asset_id) .precision(1) .build()); - execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), - true); - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1))); auto ass = query->getAsset(asset->assetId()); ASSERT_TRUE(ass); ASSERT_EQ(*asset.get(), *ass.get()); @@ -778,23 +785,24 @@ namespace iroha { * @then asset is not created */ TEST_F(CreateAsset, NoPerms) { - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), - true); - execute(*mock_command_factory->constructCreateDomain(domain->domainId(), - role), - true); + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain->domainId(), role), + true)); auto asset = clone(TestAccountAssetBuilder() .domainId(domain->domainId()) .assetId(asset_id) .precision(1) .build()); - execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), - true); - auto cmd_result = - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true)); + auto cmd_result = execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1)); auto ass = query->getAsset(asset->assetId()); ASSERT_FALSE(ass); @@ -810,18 +818,19 @@ namespace iroha { TEST_F(CreateAsset, NoDomain) { role_permissions.set( shared_model::interface::permissions::Role::kCreateAsset); - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), - true); - execute(*mock_command_factory->constructCreateDomain(domain->domainId(), - role), - true); - execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), - true); - auto cmd_result = - execute(*mock_command_factory->constructCreateAsset( - asset_name, "no_domain", 1)); + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain->domainId(), role), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true)); + auto cmd_result = execute(*mock_command_factory->constructCreateAsset( + asset_name, "no_domain", 1)); std::vector query_args{asset_name, "no_domain", "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -835,20 +844,22 @@ namespace iroha { TEST_F(CreateAsset, NameNotUnique) { role_permissions.set( shared_model::interface::permissions::Role::kCreateAsset); - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), - true); - execute(*mock_command_factory->constructCreateDomain(domain->domainId(), - role), - true); - execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), - true); - execute(*mock_command_factory->constructCreateAsset( + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain->domainId(), role), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id", domain->domainId(), *pubkey), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1))); + auto cmd_result = execute(*mock_command_factory->constructCreateAsset( "coin", domain->domainId(), 1)); - auto cmd_result = - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1)); std::vector query_args{"coin", domain->domainId(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -875,8 +886,9 @@ namespace iroha { */ TEST_F(CreateDomain, Valid) { addAllPerms(); - execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), - role)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role))); auto dom = query->getDomain(domain2->domainId()); ASSERT_TRUE(dom); ASSERT_EQ(*dom.get(), *domain2.get()); @@ -888,9 +900,8 @@ namespace iroha { * @then domain is not created */ TEST_F(CreateDomain, NoPerms) { - auto cmd_result = - execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role)); + auto cmd_result = execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role)); auto dom = query->getDomain(domain2->domainId()); ASSERT_FALSE(dom); @@ -905,11 +916,11 @@ namespace iroha { */ TEST_F(CreateDomain, NameNotUnique) { addAllPerms(); - execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), - role)); - auto cmd_result = - execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role))); + auto cmd_result = execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role)); std::vector query_args{domain2->domainId(), role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -922,9 +933,8 @@ namespace iroha { */ TEST_F(CreateDomain, NoDefaultRole) { addAllPerms(); - auto cmd_result = - execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), another_role)); + auto cmd_result = execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), another_role)); std::vector query_args{domain2->domainId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -948,8 +958,9 @@ namespace iroha { */ TEST_F(CreateRole, Valid) { addAllPerms(); - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions))); auto rl = query->getRolePermissions(role); ASSERT_TRUE(rl); ASSERT_EQ(rl.get(), role_permissions); @@ -963,9 +974,8 @@ namespace iroha { TEST_F(CreateRole, NoPerms) { role_permissions2.set( shared_model::interface::permissions::Role::kRemoveMySignatory); - auto cmd_result = - execute(*mock_command_factory->constructCreateRole( - another_role, role_permissions2)); + auto cmd_result = execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions2)); auto rl = query->getRolePermissions(another_role); ASSERT_TRUE(rl); ASSERT_TRUE(rl->none()); @@ -982,11 +992,11 @@ namespace iroha { */ TEST_F(CreateRole, NameNotUnique) { addAllPerms(); - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions)); - auto cmd_result = - execute(*mock_command_factory->constructCreateRole( - another_role, role_permissions)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions))); + auto cmd_result = execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions)); std::vector query_args{another_role, role_permissions.toBitstring()}; @@ -1001,12 +1011,14 @@ namespace iroha { createDefaultDomain(); createDefaultAccount(); - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions), - true); - execute(*mock_command_factory->constructAppendRole(account->accountId(), - another_role), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAppendRole( + account->accountId(), another_role), + true)); } }; @@ -1017,8 +1029,9 @@ namespace iroha { */ TEST_F(DetachRole, Valid) { addAllPerms(); - execute(*mock_command_factory->constructDetachRole(account->accountId(), - another_role)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructDetachRole( + account->accountId(), another_role))); auto roles = query->getAccountRoles(account->accountId()); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) @@ -1031,9 +1044,8 @@ namespace iroha { * @then role is detached */ TEST_F(DetachRole, NoPerms) { - auto cmd_result = - execute(*mock_command_factory->constructDetachRole( - account->accountId(), another_role)); + auto cmd_result = execute(*mock_command_factory->constructDetachRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -1051,9 +1063,8 @@ namespace iroha { */ TEST_F(DetachRole, NoAccount) { addAllPerms(); - auto cmd_result = - execute(*mock_command_factory->constructDetachRole( - "doge@noaccount", another_role)); + auto cmd_result = execute(*mock_command_factory->constructDetachRole( + "doge@noaccount", another_role)); std::vector query_args{"doge@noaccount", another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -1066,11 +1077,11 @@ namespace iroha { */ TEST_F(DetachRole, NoSuchRoleInAccount) { addAllPerms(); - execute(*mock_command_factory->constructDetachRole(account->accountId(), - another_role)); - auto cmd_result = - execute(*mock_command_factory->constructDetachRole( - account->accountId(), another_role)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructDetachRole( + account->accountId(), another_role))); + auto cmd_result = execute(*mock_command_factory->constructDetachRole( + account->accountId(), another_role)); std::vector query_args{account->accountId(), another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); @@ -1083,9 +1094,8 @@ namespace iroha { */ TEST_F(DetachRole, NoRole) { addAllPerms(); - auto cmd_result = - execute(*mock_command_factory->constructDetachRole( - account->accountId(), "not_existing_role")); + auto cmd_result = execute(*mock_command_factory->constructDetachRole( + account->accountId(), "not_existing_role")); std::vector query_args{account->accountId(), "not_existing_role"}; @@ -1099,9 +1109,10 @@ namespace iroha { createDefaultRole(); createDefaultDomain(); createDefaultAccount(); - execute(*mock_command_factory->constructCreateRole(another_role, - role_permissions), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateRole( + another_role, role_permissions), + true)); } }; @@ -1113,8 +1124,9 @@ namespace iroha { TEST_F(GrantPermission, Valid) { addAllPerms(); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm))); auto has_perm = query->hasAccountGrantablePermission( account->accountId(), account->accountId(), perm); ASSERT_TRUE(has_perm); @@ -1127,9 +1139,8 @@ namespace iroha { */ TEST_F(GrantPermission, NoPerms) { auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - auto cmd_result = - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm)); + auto cmd_result = execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm)); auto has_perm = query->hasAccountGrantablePermission( account->accountId(), account->accountId(), perm); ASSERT_FALSE(has_perm); @@ -1147,9 +1158,8 @@ namespace iroha { TEST_F(GrantPermission, NoAccount) { addAllPerms(); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - auto cmd_result = - execute(*mock_command_factory->constructGrantPermission( - "doge@noaccount", perm)); + auto cmd_result = execute(*mock_command_factory->constructGrantPermission( + "doge@noaccount", perm)); std::vector query_args{"doge@noaccount", perm_converter->toString(perm)}; @@ -1182,11 +1192,13 @@ namespace iroha { TEST_F(RemoveSignatory, Valid) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true); - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *pubkey)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *pubkey))); auto signatories = query->getSignatories(account->accountId()); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) @@ -1201,24 +1213,27 @@ namespace iroha { * @then signatory is successfully removed */ TEST_F(RemoveSignatory, ValidGrantablePerm) { - execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey), + true)); auto perm = shared_model::interface::permissions::Grantable::kRemoveMySignatory; - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain"); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain")); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - execute(*mock_command_factory->constructAddSignatory(pk, "id2@domain"), - true); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(pk, "id2@domain"), + true)); auto signatories = query->getSignatories("id2@domain"); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), pk) != signatories->end()); - execute( - *mock_command_factory->constructRemoveSignatory("id2@domain", pk)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructRemoveSignatory("id2@domain", pk))); signatories = query->getSignatories("id2@domain"); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) @@ -1234,12 +1249,12 @@ namespace iroha { */ TEST_F(RemoveSignatory, NoPerms) { shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true); - auto cmd_result = - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *pubkey)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true)); + auto cmd_result = execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *pubkey)); std::vector query_args{account->accountId(), pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); @@ -1260,11 +1275,12 @@ namespace iroha { TEST_F(RemoveSignatory, NoAccount) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true)); - auto cmd_result = execute( + auto cmd_result = execute( *mock_command_factory->constructRemoveSignatory("hello", *pubkey)); std::vector query_args{"hello", pubkey->hex()}; @@ -1279,19 +1295,21 @@ namespace iroha { TEST_F(RemoveSignatory, NoSuchSignatory) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true); - execute(*mock_command_factory->constructAddSignatory( - *another_pubkey, account->accountId()), - true); - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *another_pubkey), - true); - - auto cmd_result = - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *another_pubkey)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + *another_pubkey, account->accountId()), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *another_pubkey), + true)); + + auto cmd_result = execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *another_pubkey)); std::vector query_args{account->accountId(), another_pubkey->hex()}; @@ -1307,14 +1325,15 @@ namespace iroha { TEST_F(RemoveSignatory, SignatoriesLessThanQuorum) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true); - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *pubkey)); - auto cmd_result = - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), pk)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), *pubkey))); + auto cmd_result = execute(*mock_command_factory->constructRemoveSignatory( + account->accountId(), pk)); std::vector query_args{account->accountId(), pk.hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 5, query_args); @@ -1327,9 +1346,10 @@ namespace iroha { createDefaultRole(); createDefaultDomain(); createDefaultAccount(); - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), grantable_permission), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), grantable_permission), + true)); } }; @@ -1344,16 +1364,18 @@ namespace iroha { ASSERT_TRUE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), grantable_permission)); - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true)); ASSERT_TRUE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), grantable_permission)); ASSERT_TRUE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), perm)); - execute(*mock_command_factory->constructRevokePermission( - account->accountId(), grantable_permission)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructRevokePermission( + account->accountId(), grantable_permission))); ASSERT_FALSE(query->hasAccountGrantablePermission( account->accountId(), account->accountId(), grantable_permission)); ASSERT_TRUE(query->hasAccountGrantablePermission( @@ -1369,7 +1391,7 @@ namespace iroha { auto perm = shared_model::interface::permissions::Grantable::kRemoveMySignatory; auto cmd_result = - execute(*mock_command_factory->constructRevokePermission( + execute(*mock_command_factory->constructRevokePermission( account->accountId(), perm)); std::vector query_args{account->accountId(), @@ -1390,12 +1412,13 @@ namespace iroha { .quorum(1) .jsonData("") .build()); - execute(*mock_command_factory->constructCreateAccount( - "id2", - domain->domainId(), - shared_model::interface::types::PubkeyType( - std::string('2', 32))), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id2", + domain->domainId(), + shared_model::interface::types::PubkeyType( + std::string('2', 32))), + true)); } std::unique_ptr account2; }; @@ -1406,8 +1429,9 @@ namespace iroha { * @then kv is set */ TEST_F(SetAccountDetail, Valid) { - execute(*mock_command_factory->constructSetAccountDetail( - account->accountId(), "key", "value")); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSetAccountDetail( + account->accountId(), "key", "value"))); auto kv = query->getAccountDetail(account->accountId()); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); @@ -1421,14 +1445,16 @@ namespace iroha { TEST_F(SetAccountDetail, ValidGrantablePerm) { auto perm = shared_model::interface::permissions::Grantable::kSetMyAccountDetail; - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain"); - execute(*mock_command_factory->constructSetAccountDetail( - account2->accountId(), "key", "value"), - false, - account->accountId()); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain")); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + false, + account->accountId())); auto kv = query->getAccountDetail(account2->accountId()); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); @@ -1441,10 +1467,11 @@ namespace iroha { */ TEST_F(SetAccountDetail, ValidRolePerm) { addAllPerms(); - execute(*mock_command_factory->constructSetAccountDetail( - account2->accountId(), "key", "value"), - false, - account->accountId()); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + false, + account->accountId())); auto kv = query->getAccountDetail(account2->accountId()); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); @@ -1457,10 +1484,10 @@ namespace iroha { */ TEST_F(SetAccountDetail, NoPerms) { auto cmd_result = - execute(*mock_command_factory->constructSetAccountDetail( - account2->accountId(), "key", "value"), - false, - account->accountId()); + execute(*mock_command_factory->constructSetAccountDetail( + account2->accountId(), "key", "value"), + false, + account->accountId()); std::vector query_args{ account2->accountId(), "key", "value"}; @@ -1479,10 +1506,10 @@ namespace iroha { TEST_F(SetAccountDetail, NoAccount) { addAllPerms(); auto cmd_result = - execute(*mock_command_factory->constructSetAccountDetail( - "doge@noaccount", "key", "value"), - false, - account->accountId()); + execute(*mock_command_factory->constructSetAccountDetail( + "doge@noaccount", "key", "value"), + false, + account->accountId()); std::vector query_args{"doge@noaccount", "key", "value"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -1497,9 +1524,10 @@ namespace iroha { createDefaultRole(); createDefaultDomain(); createDefaultAccount(); - execute(*mock_command_factory->constructAddSignatory( - additional_pubkey_, account->accountId()), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + additional_pubkey_, account->accountId()), + true)); } shared_model::interface::types::PubkeyType additional_pubkey_; }; @@ -1512,8 +1540,8 @@ namespace iroha { TEST_F(SetQuorum, Valid) { addAllPerms(); - execute( - *mock_command_factory->constructSetQuorum(account->accountId(), 2)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructSetQuorum(account->accountId(), 2))); } /** @@ -1522,21 +1550,25 @@ namespace iroha { * @then quorum is set */ TEST_F(SetQuorum, ValidGrantablePerms) { - execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey), + true)); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain"); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account->accountId(), perm), + true, + "id2@domain")); - execute(*mock_command_factory->constructAddSignatory(additional_pubkey_, - "id2@domain"), - true, - "id2@domain"); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + additional_pubkey_, "id2@domain"), + true, + "id2@domain")); - execute(*mock_command_factory->constructSetQuorum("id2@domain", 2)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSetQuorum("id2@domain", 2))); } /** @@ -1545,7 +1577,7 @@ namespace iroha { * @then quorum is not set */ TEST_F(SetQuorum, NoPerms) { - auto cmd_result = execute( + auto cmd_result = execute( *mock_command_factory->constructSetQuorum(account->accountId(), 3)); std::vector query_args{account->accountId(), "3"}; @@ -1560,13 +1592,14 @@ namespace iroha { TEST_F(SetQuorum, LessSignatoriesThanNewQuorum) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true); - execute( - *mock_command_factory->constructSetQuorum(account->accountId(), 3)); - - auto cmd_result = execute( + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddSignatory( + pk, account->accountId()), + true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructSetQuorum(account->accountId(), 3))); + + auto cmd_result = execute( *mock_command_factory->constructSetQuorum(account->accountId(), 5)); std::vector query_args{account->accountId(), "5"}; @@ -1593,9 +1626,9 @@ namespace iroha { .precision(1) .build()); - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateAsset("coin", domain_id, 1), - true); + true)); } shared_model::interface::types::AssetIdType asset_id = @@ -1610,21 +1643,24 @@ namespace iroha { TEST_F(SubtractAccountAssetTest, Valid) { addAllPerms(); addAsset(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - execute(*mock_command_factory->constructSubtractAssetQuantity( - asset_id, asset_amount_one_zero)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, asset_amount_one_zero))); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -1637,16 +1673,17 @@ namespace iroha { */ TEST_F(SubtractAccountAssetTest, NoPerms) { addAsset(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); auto cmd_result = - execute(*mock_command_factory->constructSubtractAssetQuantity( + execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, asset_amount_one_zero)); std::vector query_args{account->accountId(), @@ -1670,32 +1707,33 @@ namespace iroha { addOnePerm( shared_model::interface::permissions::Role::kSubtractDomainAssetQty); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - execute(*mock_command_factory->constructSubtractAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSubtractAssetQuantity( + asset_id, asset_amount_one_zero), + true)); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } /** @@ -1707,25 +1745,26 @@ namespace iroha { std::unique_ptr domain2; domain2 = clone( TestDomainBuilder().domainId("domain2").defaultRole(role).build()); - execute(*mock_command_factory->constructCreateDomain(domain2->domainId(), - role), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateDomain( + domain2->domainId(), role), + true)); addAsset(domain2->domainId()); addOnePerm( shared_model::interface::permissions::Role::kSubtractDomainAssetQty); auto asset2_id = "coin#" + domain2->domainId(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset2_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset2_id, asset_amount_one_zero), + true)); auto account_asset = query->getAccountAsset(account->accountId(), asset2_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); auto cmd_result = - execute(*mock_command_factory->constructSubtractAssetQuantity( + execute(*mock_command_factory->constructSubtractAssetQuantity( asset2_id, asset_amount_one_zero)); std::vector query_args{account->accountId(), @@ -1736,8 +1775,7 @@ namespace iroha { account_asset = query->getAccountAsset(account->accountId(), asset2_id); ASSERT_TRUE(account_asset); - ASSERT_EQ(asset_amount_one_zero, - account_asset.get()->balance()); + ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } /** @@ -1748,7 +1786,7 @@ namespace iroha { TEST_F(SubtractAccountAssetTest, NoAsset) { addAllPerms(); auto cmd_result = - execute(*mock_command_factory->constructSubtractAssetQuantity( + execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, asset_amount_one_zero)); std::vector query_args{account->accountId(), @@ -1767,7 +1805,7 @@ namespace iroha { addAllPerms(); addAsset(); auto cmd_result = - execute(*mock_command_factory->constructSubtractAssetQuantity( + execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, shared_model::interface::Amount{"1.0000"})); std::vector query_args{ @@ -1783,11 +1821,12 @@ namespace iroha { TEST_F(SubtractAccountAssetTest, NotEnoughAsset) { addAllPerms(); addAsset(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); auto cmd_result = - execute(*mock_command_factory->constructSubtractAssetQuantity( + execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, shared_model::interface::Amount{"2.0"})); std::vector query_args{ @@ -1809,9 +1848,10 @@ namespace iroha { createDefaultRole(); createDefaultDomain(); createDefaultAccount(); - execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAccount( + "id2", domain->domainId(), *pubkey), + true)); } public: @@ -1825,9 +1865,10 @@ namespace iroha { .precision(1) .build()); - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructCreateAsset( + "coin", domain->domainId(), 1), + true)); } shared_model::interface::types::AssetIdType asset_id = @@ -1844,25 +1885,28 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - execute( - *mock_command_factory->constructTransferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructTransferAsset( + account->accountId(), + account2->accountId(), + asset_id, + "desc", + asset_amount_one_zero))); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -1881,26 +1925,28 @@ namespace iroha { addAsset(); auto perm = shared_model::interface::permissions::Grantable::kTransferMyAssets; - execute(*mock_command_factory->constructGrantPermission( - account2->accountId(), perm), - true, - account->accountId()); - - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, shared_model::interface::Amount{"2.0"}), - true); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructGrantPermission( + account2->accountId(), perm), + true, + account->accountId())); + + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, shared_model::interface::Amount{"2.0"}), + true)); auto account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); - execute( + CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructTransferAsset(account->accountId(), account2->accountId(), asset_id, "desc", asset_amount_one_zero), false, - account2->accountId()); + account2->accountId())); account_asset = query->getAccountAsset(account->accountId(), asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -1915,7 +1961,7 @@ namespace iroha { * @then account asset fails to be transferred */ TEST_F(TransferAccountAssetTest, NoPerms) { - auto cmd_result = execute( + auto cmd_result = execute( *mock_command_factory->constructTransferAsset(account->accountId(), account2->accountId(), asset_id, @@ -1939,10 +1985,11 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); - auto cmd_result = execute( + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); + auto cmd_result = execute( *mock_command_factory->constructTransferAsset("some@domain", account2->accountId(), asset_id, @@ -1960,7 +2007,7 @@ namespace iroha { CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } - cmd_result = execute( + cmd_result = execute( *mock_command_factory->constructTransferAsset(account->accountId(), "some@domain", asset_id, @@ -1987,7 +2034,7 @@ namespace iroha { TEST_F(TransferAccountAssetTest, NoAsset) { addAllPerms(); addAllPerms(account2->accountId(), "all2"); - auto cmd_result = execute( + auto cmd_result = execute( *mock_command_factory->constructTransferAsset(account->accountId(), account2->accountId(), asset_id, @@ -2011,16 +2058,16 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - execute(*mock_command_factory->constructAddAssetQuantity( - asset_id, asset_amount_one_zero), - true); - auto cmd_result = - execute(*mock_command_factory->constructTransferAsset( - account->accountId(), - account2->accountId(), - asset_id, - "desc", - shared_model::interface::Amount{"2.0"})); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, asset_amount_one_zero), + true)); + auto cmd_result = execute(*mock_command_factory->constructTransferAsset( + account->accountId(), + account2->accountId(), + asset_id, + "desc", + shared_model::interface::Amount{"2.0"})); std::vector query_args{ account->accountId(), account2->accountId(), asset_id, "2.0", "1"}; @@ -2037,14 +2084,16 @@ namespace iroha { addAllPerms(); addAllPerms(account2->accountId(), "all2"); addAsset(); - execute(*mock_command_factory->constructAddAssetQuantity(asset_id, - uint256_halfmax), - true); - execute(*mock_command_factory->constructAddAssetQuantity(asset_id, - uint256_halfmax), - false, - account2->accountId()); - auto cmd_result = execute( + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, uint256_halfmax), + true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructAddAssetQuantity( + asset_id, uint256_halfmax), + false, + account2->accountId())); + auto cmd_result = execute( *mock_command_factory->constructTransferAsset(account->accountId(), account2->accountId(), asset_id, diff --git a/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp b/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp index 63ba3213fe..a6624426ab 100644 --- a/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp +++ b/test/module/shared_model/mock_objects_factories/mock_command_factory.cpp @@ -27,10 +27,10 @@ namespace shared_model { return createFactoryResult( [&asset_id, &asset_amount]( FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, assetId()) - .WillRepeatedly(ReturnRefOfCopy(asset_id)); - EXPECT_CALL(*specific_cmd_mock, amount()) - .WillRepeatedly(ReturnRefOfCopy(asset_amount)); + ON_CALL(*specific_cmd_mock, assetId()) + .WillByDefault(ReturnRefOfCopy(asset_id)); + ON_CALL(*specific_cmd_mock, amount()) + .WillByDefault(ReturnRefOfCopy(asset_amount)); return specific_cmd_mock; }); } @@ -39,8 +39,7 @@ namespace shared_model { MockCommandFactory::constructAddPeer(const Peer &peer) const { return createFactoryResult( [&peer](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, peer()) - .WillRepeatedly(ReturnRef(peer)); + ON_CALL(*specific_cmd_mock, peer()).WillByDefault(ReturnRef(peer)); return specific_cmd_mock; }); } @@ -52,10 +51,10 @@ namespace shared_model { return createFactoryResult( [&pubkey, &account_id](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, pubkey()) - .WillRepeatedly(ReturnRefOfCopy(pubkey)); - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, pubkey()) + .WillByDefault(ReturnRefOfCopy(pubkey)); + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); return specific_cmd_mock; }); } @@ -67,10 +66,10 @@ namespace shared_model { return createFactoryResult( [&account_id, &role_name](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); - EXPECT_CALL(*specific_cmd_mock, roleName()) - .WillRepeatedly(ReturnRefOfCopy(role_name)); + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, roleName()) + .WillByDefault(ReturnRefOfCopy(role_name)); return specific_cmd_mock; }); } @@ -83,12 +82,12 @@ namespace shared_model { return createFactoryResult( [&account_name, &domain_id, &pubkey]( FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountName()) - .WillRepeatedly(ReturnRefOfCopy(account_name)); - EXPECT_CALL(*specific_cmd_mock, domainId()) - .WillRepeatedly(ReturnRefOfCopy(domain_id)); - EXPECT_CALL(*specific_cmd_mock, pubkey()) - .WillRepeatedly(ReturnRefOfCopy(pubkey)); + ON_CALL(*specific_cmd_mock, accountName()) + .WillByDefault(ReturnRefOfCopy(account_name)); + ON_CALL(*specific_cmd_mock, domainId()) + .WillByDefault(ReturnRefOfCopy(domain_id)); + ON_CALL(*specific_cmd_mock, pubkey()) + .WillByDefault(ReturnRefOfCopy(pubkey)); return specific_cmd_mock; }); } @@ -101,12 +100,12 @@ namespace shared_model { return createFactoryResult( [&asset_name, &domain_id, &precision]( FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, assetName()) - .WillRepeatedly(ReturnRefOfCopy(asset_name)); - EXPECT_CALL(*specific_cmd_mock, domainId()) - .WillRepeatedly(ReturnRefOfCopy(domain_id)); - EXPECT_CALL(*specific_cmd_mock, precision()) - .WillRepeatedly(ReturnRefOfCopy(precision)); + ON_CALL(*specific_cmd_mock, assetName()) + .WillByDefault(ReturnRefOfCopy(asset_name)); + ON_CALL(*specific_cmd_mock, domainId()) + .WillByDefault(ReturnRefOfCopy(domain_id)); + ON_CALL(*specific_cmd_mock, precision()) + .WillByDefault(ReturnRefOfCopy(precision)); return specific_cmd_mock; }); } @@ -118,10 +117,10 @@ namespace shared_model { return createFactoryResult( [&domain_id, &role_id](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, domainId()) - .WillRepeatedly(ReturnRefOfCopy(domain_id)); - EXPECT_CALL(*specific_cmd_mock, userDefaultRole()) - .WillRepeatedly(ReturnRefOfCopy(role_id)); + ON_CALL(*specific_cmd_mock, domainId()) + .WillByDefault(ReturnRefOfCopy(domain_id)); + ON_CALL(*specific_cmd_mock, userDefaultRole()) + .WillByDefault(ReturnRefOfCopy(role_id)); return specific_cmd_mock; }); } @@ -133,12 +132,12 @@ namespace shared_model { return createFactoryResult( [&role_id, &role_permissions](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, roleName()) - .WillRepeatedly(ReturnRefOfCopy(role_id)); - EXPECT_CALL(*specific_cmd_mock, rolePermissions()) - .WillRepeatedly(ReturnRefOfCopy(role_permissions)); - EXPECT_CALL(*specific_cmd_mock, toString()) - .WillRepeatedly(Return( + ON_CALL(*specific_cmd_mock, roleName()) + .WillByDefault(ReturnRefOfCopy(role_id)); + ON_CALL(*specific_cmd_mock, rolePermissions()) + .WillByDefault(ReturnRefOfCopy(role_permissions)); + ON_CALL(*specific_cmd_mock, toString()) + .WillByDefault(Return( detail::PrettyStringBuilder() .init("CreateRole") .append("role_name", role_id) @@ -157,10 +156,10 @@ namespace shared_model { return createFactoryResult( [&account_id, &role_id](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); - EXPECT_CALL(*specific_cmd_mock, roleName()) - .WillRepeatedly(ReturnRefOfCopy(role_id)); + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, roleName()) + .WillByDefault(ReturnRefOfCopy(role_id)); return specific_cmd_mock; }); } @@ -172,12 +171,12 @@ namespace shared_model { return createFactoryResult( [&account_id, permission](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); - EXPECT_CALL(*specific_cmd_mock, permissionName()) - .WillRepeatedly(Return(permission)); - EXPECT_CALL(*specific_cmd_mock, toString()) - .WillRepeatedly(Return( + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, permissionName()) + .WillByDefault(Return(permission)); + ON_CALL(*specific_cmd_mock, toString()) + .WillByDefault(Return( detail::PrettyStringBuilder() .init("GrantPermission") .append("account_id", account_id) @@ -196,10 +195,10 @@ namespace shared_model { return createFactoryResult( [&account_id, &pubkey](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); - EXPECT_CALL(*specific_cmd_mock, pubkey()) - .WillRepeatedly(ReturnRefOfCopy(pubkey)); + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, pubkey()) + .WillByDefault(ReturnRefOfCopy(pubkey)); return specific_cmd_mock; }); } @@ -211,12 +210,12 @@ namespace shared_model { return createFactoryResult( [&account_id, permission](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); - EXPECT_CALL(*specific_cmd_mock, permissionName()) - .WillRepeatedly(Return(permission)); - EXPECT_CALL(*specific_cmd_mock, toString()) - .WillRepeatedly(Return( + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, permissionName()) + .WillByDefault(Return(permission)); + ON_CALL(*specific_cmd_mock, toString()) + .WillByDefault(Return( detail::PrettyStringBuilder() .init("RevokePermission") .append("account_id", account_id) @@ -236,12 +235,12 @@ namespace shared_model { return createFactoryResult( [&account_id, &cmd_key, &cmd_value]( FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); - EXPECT_CALL(*specific_cmd_mock, key()) - .WillRepeatedly(ReturnRefOfCopy(cmd_key)); - EXPECT_CALL(*specific_cmd_mock, value()) - .WillRepeatedly(ReturnRefOfCopy(cmd_value)); + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, key()) + .WillByDefault(ReturnRefOfCopy(cmd_key)); + ON_CALL(*specific_cmd_mock, value()) + .WillByDefault(ReturnRefOfCopy(cmd_value)); return specific_cmd_mock; }); } @@ -253,10 +252,10 @@ namespace shared_model { return createFactoryResult( [&account_id, quorum](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, accountId()) - .WillRepeatedly(ReturnRefOfCopy(account_id)); - EXPECT_CALL(*specific_cmd_mock, newQuorum()) - .WillRepeatedly(Return(quorum)); + ON_CALL(*specific_cmd_mock, accountId()) + .WillByDefault(ReturnRefOfCopy(account_id)); + ON_CALL(*specific_cmd_mock, newQuorum()) + .WillByDefault(Return(quorum)); return specific_cmd_mock; }); } @@ -267,10 +266,10 @@ namespace shared_model { return createFactoryResult( [&asset_id, &cmd_amount]( FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, assetId()) - .WillRepeatedly(ReturnRefOfCopy(asset_id)); - EXPECT_CALL(*specific_cmd_mock, amount()) - .WillRepeatedly(ReturnRefOfCopy(cmd_amount)); + ON_CALL(*specific_cmd_mock, assetId()) + .WillByDefault(ReturnRefOfCopy(asset_id)); + ON_CALL(*specific_cmd_mock, amount()) + .WillByDefault(ReturnRefOfCopy(cmd_amount)); return specific_cmd_mock; }); } @@ -288,16 +287,16 @@ namespace shared_model { &asset_id, &cmd_description, &cmd_amount](FactoryResult specific_cmd_mock) { - EXPECT_CALL(*specific_cmd_mock, srcAccountId()) - .WillRepeatedly(ReturnRefOfCopy(src_account_id)); - EXPECT_CALL(*specific_cmd_mock, destAccountId()) - .WillRepeatedly(ReturnRefOfCopy(dest_account_id)); - EXPECT_CALL(*specific_cmd_mock, assetId()) - .WillRepeatedly(ReturnRefOfCopy(asset_id)); - EXPECT_CALL(*specific_cmd_mock, description()) - .WillRepeatedly(ReturnRefOfCopy(cmd_description)); - EXPECT_CALL(*specific_cmd_mock, amount()) - .WillRepeatedly(ReturnRefOfCopy(cmd_amount)); + ON_CALL(*specific_cmd_mock, srcAccountId()) + .WillByDefault(ReturnRefOfCopy(src_account_id)); + ON_CALL(*specific_cmd_mock, destAccountId()) + .WillByDefault(ReturnRefOfCopy(dest_account_id)); + ON_CALL(*specific_cmd_mock, assetId()) + .WillByDefault(ReturnRefOfCopy(asset_id)); + ON_CALL(*specific_cmd_mock, description()) + .WillByDefault(ReturnRefOfCopy(cmd_description)); + ON_CALL(*specific_cmd_mock, amount()) + .WillByDefault(ReturnRefOfCopy(cmd_amount)); return specific_cmd_mock; }); } From 9db4297e3b14b564f8a9e7dba195eab5d5e91504 Mon Sep 17 00:00:00 2001 From: Nikolay Yushkevich Date: Mon, 17 Dec 2018 14:18:43 +0100 Subject: [PATCH 17/61] Split config into yaml files, bump dependencies, update readme, delete stale links (#1954) Signed-off-by: neewy --- docs/README.md | 11 ------ docs/source/api/index.rst | 6 --- docs/source/common.yaml | 8 ++++ docs/source/conf.py | 72 ++++++++++-------------------------- docs/source/locale.yaml | 2 + docs/source/requirements.txt | 4 +- 6 files changed, 31 insertions(+), 72 deletions(-) create mode 100644 docs/source/common.yaml create mode 100644 docs/source/locale.yaml diff --git a/docs/README.md b/docs/README.md index 566a9e0e76..966a61a7b6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -38,14 +38,3 @@ In essence, the flow of docs generation is described on the following page of [S 1. Target project is generated by this command `make -e SPHINXOPTS="-D language='de'" html` (for German) Got troubles with binary of `sphinx-intl` on Mac? Check if you have added it into PATH, usually it should be as following: `$PATH:$HOME/Library/Python/2.7/bin`. - - In the future, .po files should be published into https://weblate.org or similar platform, and the process of docs translation should be incorporated into open source community process. - -## Contributors - -The docs are supported by following contributors ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): - - -| [
Nikolay ](https://github.com/neewy)
[📖](https://github.com/hyperledger/iroha/commits?author=neewy "Documentation") | [
誠](https://github.com/takemiyamakoto)
🔧 -| :---: | :---: | - diff --git a/docs/source/api/index.rst b/docs/source/api/index.rst index 63af593212..addee1fdef 100644 --- a/docs/source/api/index.rst +++ b/docs/source/api/index.rst @@ -11,9 +11,3 @@ We will overview commands and queries that the system has, and the set of client commands.rst queries.rst - cpp_library.rst - java_library.rst - objc_library.rst - swift_library.rst - python_library.rst - nodejs_library.rst \ No newline at end of file diff --git a/docs/source/common.yaml b/docs/source/common.yaml new file mode 100644 index 0000000000..120cdbd537 --- /dev/null +++ b/docs/source/common.yaml @@ -0,0 +1,8 @@ +# General information about the project. +project: "Hyperledger Iroha" +documentation: "Iroha handbook: installation, getting started, API, guides, and troubleshooting" +description: "Distributed ledger technology platform, written in C++" +copyright: "Soramitsu Co., Ltd." +author: "Hyperledger Iroha community" +version: "1.0 release candidate 1" +release: "v1.0 rc1" diff --git a/docs/source/conf.py b/docs/source/conf.py index 741f702a2d..54f0d2d604 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,23 +1,9 @@ -# -*- coding: utf-8 -*- -# -# Iroha documentation build configuration file, created by -# sphinx-quickstart on Wed Jan 17 18:22:31 2018. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# import os import sys import sphinx_rtd_theme -sys.path.insert(0, os.path.abspath('.')) +import yaml +sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ @@ -49,32 +35,6 @@ # The master toctree document. master_doc = 'index' -# General information about the project. -project = u'Iroha' -documentation = u'Iroha Documentation' -description = u'Distributed ledger technology platform, written in C++' -copyright = u'2018 Soramitsu Co., Ltd.' -author = u'Nikolay Yushkevich at Soramitsu Co., Ltd.' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = u'1.0' -# The full version, including alpha/beta/rc tags. -release = u'1.0 beta' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = 'en' - -locale_dirs = ['locale/'] -gettext_compact = False - # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path @@ -86,6 +46,8 @@ # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True +gettext_compact = False + # -- Options for HTML output ---------------------------------------------- @@ -95,17 +57,6 @@ html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - # Custom sidebar templates, must be a dictionary that maps document names # to template names. # @@ -144,6 +95,21 @@ # 'figure_align': 'htbp', } +# Read variables for +# common settings and locale: +with open('common.yaml', 'r') as stream: + common = yaml.load(stream) + project = common.get('project') + documentation = common.get('documentation') + description = common.get('description') + copyright = common.get('copyright') + author = common.get('author') +with open('locale.yaml', 'r') as stream: + locale = yaml.load(stream) + language = locale.get('language') + locale_dirs = locale.get('locale_dirs') + + # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). diff --git a/docs/source/locale.yaml b/docs/source/locale.yaml new file mode 100644 index 0000000000..f7cac564e7 --- /dev/null +++ b/docs/source/locale.yaml @@ -0,0 +1,2 @@ +language: "en" +locale_dirs: "../locale/" diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt index cbe22b13ea..ce32077476 100644 --- a/docs/source/requirements.txt +++ b/docs/source/requirements.txt @@ -17,7 +17,7 @@ port-for==0.3.1 protobuf==3.5.1 Pygments==2.2.0 pytz==2017.3 -PyYAML==3.12 +PyYAML==3.13 requests==2.20.1 restructuredtext-lint==1.1.2 singledispatch==3.4.0.3 @@ -26,7 +26,7 @@ snowballstemmer==1.2.1 Sphinx==1.6.6 sphinx-autobuild==0.7.1 sphinx-intl==0.9.11 -sphinx-rtd-theme==0.2.5b2 +sphinx-rtd-theme==0.4.2 sphinxcontrib-websupport==1.0.1 tornado==4.5.3 typing==3.6.2 From 88c76bbb0103017d3e09d0b60e3fda75652383ca Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Wed, 19 Dec 2018 12:45:48 +0300 Subject: [PATCH 18/61] Fix MST pending storage (#1959) * Replay possibility is removed Signed-off-by: Akvinikym * Review issues Signed-off-by: Akvinikym --- .../impl/mst_processor.cpp | 5 ++++ .../impl/mst_processor_impl.cpp | 9 ++++-- .../multi_sig_transactions/mst_processor.hpp | 12 ++++++++ .../mst_processor_impl.hpp | 2 ++ .../state/impl/mst_state.cpp | 4 +++ .../state/mst_state.hpp | 7 +++++ .../storage/impl/mst_storage.cpp | 4 +++ .../storage/impl/mst_storage_impl.cpp | 4 +++ .../storage/mst_storage.hpp | 10 +++++++ .../storage/mst_storage_impl.hpp | 2 ++ .../impl/transaction_processor_impl.cpp | 3 +- .../pipeline/multisig_tx_pipeline_test.cpp | 5 +--- .../multi_sig_transactions/mst_mocks.hpp | 1 + .../multi_sig_transactions/state_test.cpp | 30 ++++++++++++++++++- .../multi_sig_transactions/storage_test.cpp | 25 ++++++++++++++++ 15 files changed, 114 insertions(+), 9 deletions(-) diff --git a/irohad/multi_sig_transactions/impl/mst_processor.cpp b/irohad/multi_sig_transactions/impl/mst_processor.cpp index 854c002998..1e027eb85a 100644 --- a/irohad/multi_sig_transactions/impl/mst_processor.cpp +++ b/irohad/multi_sig_transactions/impl/mst_processor.cpp @@ -25,4 +25,9 @@ namespace iroha { rxcpp::observable MstProcessor::onExpiredBatches() const { return this->onExpiredBatchesImpl(); } + + bool MstProcessor::batchInStorage(const DataType &batch) const { + return this->batchInStorageImpl(batch); + } + } // namespace iroha diff --git a/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp b/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp index ba5afeb71e..dc6ad7d30d 100644 --- a/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp +++ b/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp @@ -84,11 +84,14 @@ namespace iroha { } } + bool FairMstProcessor::batchInStorageImpl(const DataType &batch) const { + return storage_->batchInStorage(batch); + } + // -------------------| MstTransportNotification override |------------------- - void FairMstProcessor::onNewState( - const shared_model::crypto::PublicKey &from, - ConstRefState new_state) { + void FairMstProcessor::onNewState(const shared_model::crypto::PublicKey &from, + ConstRefState new_state) { log_->info("Applying new state"); auto current_time = time_provider_->getCurrentTime(); diff --git a/irohad/multi_sig_transactions/mst_processor.hpp b/irohad/multi_sig_transactions/mst_processor.hpp index 3ce20291ea..e81e8f9557 100644 --- a/irohad/multi_sig_transactions/mst_processor.hpp +++ b/irohad/multi_sig_transactions/mst_processor.hpp @@ -42,6 +42,13 @@ namespace iroha { */ void propagateBatch(const DataType &batch); + /** + * Check, if passed batch is in pending storage + * @param batch to be checked + * @return true, if batch is already in pending storage, false otherwise + */ + bool batchInStorage(const DataType &batch) const; + /** * Prove updating of state for handling status of signing */ @@ -90,6 +97,11 @@ namespace iroha { */ virtual auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) = 0; + + /** + * @see batchInStorage method + */ + virtual bool batchInStorageImpl(const DataType &batch) const = 0; }; } // namespace iroha diff --git a/irohad/multi_sig_transactions/mst_processor_impl.hpp b/irohad/multi_sig_transactions/mst_processor_impl.hpp index dda664184c..6197949f2a 100644 --- a/irohad/multi_sig_transactions/mst_processor_impl.hpp +++ b/irohad/multi_sig_transactions/mst_processor_impl.hpp @@ -61,6 +61,8 @@ namespace iroha { auto onExpiredBatchesImpl() const -> decltype(onExpiredBatches()) override; + bool batchInStorageImpl(const DataType &batch) const override; + // ------------------| MstTransportNotification override |------------------ void onNewState(const shared_model::crypto::PublicKey &from, diff --git a/irohad/multi_sig_transactions/state/impl/mst_state.cpp b/irohad/multi_sig_transactions/state/impl/mst_state.cpp index 4899bd0247..813e984348 100644 --- a/irohad/multi_sig_transactions/state/impl/mst_state.cpp +++ b/irohad/multi_sig_transactions/state/impl/mst_state.cpp @@ -171,4 +171,8 @@ namespace iroha { index_.push(rhs_batch); } + bool MstState::contains(const DataType &element) const { + return internal_state_.find(element) != internal_state_.end(); + } + } // namespace iroha diff --git a/irohad/multi_sig_transactions/state/mst_state.hpp b/irohad/multi_sig_transactions/state/mst_state.hpp index 69d7244938..3aa6015d14 100644 --- a/irohad/multi_sig_transactions/state/mst_state.hpp +++ b/irohad/multi_sig_transactions/state/mst_state.hpp @@ -128,6 +128,13 @@ namespace iroha { */ MstState eraseByTime(const TimeType &time); + /** + * Check, if this MST state contains that element + * @param element to be checked + * @return true, if state contains the element, false otherwise + */ + bool contains(const DataType &element) const; + private: // --------------------------| private api |------------------------------ diff --git a/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp b/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp index 42c97f10bf..27cf473d05 100644 --- a/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp +++ b/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp @@ -40,4 +40,8 @@ namespace iroha { std::lock_guard lock{this->mutex_}; return whatsNewImpl(new_state); } + + bool MstStorage::batchInStorage(const DataType &batch) const { + return batchInStorageImpl(batch); + } } // namespace iroha diff --git a/irohad/multi_sig_transactions/storage/impl/mst_storage_impl.cpp b/irohad/multi_sig_transactions/storage/impl/mst_storage_impl.cpp index 0e26b840cc..d577622c28 100644 --- a/irohad/multi_sig_transactions/storage/impl/mst_storage_impl.cpp +++ b/irohad/multi_sig_transactions/storage/impl/mst_storage_impl.cpp @@ -59,4 +59,8 @@ namespace iroha { return new_state - own_state_; } + bool MstStorageStateImpl::batchInStorageImpl(const DataType &batch) const { + return own_state_.contains(batch); + } + } // namespace iroha diff --git a/irohad/multi_sig_transactions/storage/mst_storage.hpp b/irohad/multi_sig_transactions/storage/mst_storage.hpp index c3f9d38115..5d0ab747d1 100644 --- a/irohad/multi_sig_transactions/storage/mst_storage.hpp +++ b/irohad/multi_sig_transactions/storage/mst_storage.hpp @@ -19,6 +19,7 @@ #define IROHA_MST_STORAGE_HPP #include + #include "cryptography/public_key.hpp" #include "logger/logger.hpp" #include "multi_sig_transactions/mst_types.hpp" @@ -79,6 +80,13 @@ namespace iroha { */ MstState whatsNew(ConstRefState new_state) const; + /** + * Check, if passed batch is in the storage + * @param batch to be checked + * @return true, if batch is already in the storage, false otherwise + */ + bool batchInStorage(const DataType &batch) const; + virtual ~MstStorage() = default; protected: @@ -109,6 +117,8 @@ namespace iroha { virtual auto whatsNewImpl(ConstRefState new_state) const -> decltype(whatsNew(new_state)) = 0; + virtual bool batchInStorageImpl(const DataType &batch) const = 0; + // -------------------------------| fields |-------------------------------- mutable std::mutex mutex_; diff --git a/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp b/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp index e9277e1100..d37d831c68 100644 --- a/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp +++ b/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp @@ -57,6 +57,8 @@ namespace iroha { auto whatsNewImpl(ConstRefState new_state) const -> decltype(whatsNew(new_state)) override; + bool batchInStorageImpl(const DataType &batch) const override; + private: // ---------------------------| private fields |---------------------------- diff --git a/irohad/torii/processor/impl/transaction_processor_impl.cpp b/irohad/torii/processor/impl/transaction_processor_impl.cpp index 3f43e711cb..a572cd8bec 100644 --- a/irohad/torii/processor/impl/transaction_processor_impl.cpp +++ b/irohad/torii/processor/impl/transaction_processor_impl.cpp @@ -134,7 +134,8 @@ namespace iroha { std::shared_ptr transaction_batch) const { log_->info("handle batch"); - if (transaction_batch->hasAllSignatures()) { + if (transaction_batch->hasAllSignatures() + and not mst_processor_->batchInStorage(transaction_batch)) { log_->info("propagating batch to PCS"); this->publishEnoughSignaturesStatus(transaction_batch->transactions()); pcs_->propagate_batch(transaction_batch); diff --git a/test/integration/pipeline/multisig_tx_pipeline_test.cpp b/test/integration/pipeline/multisig_tx_pipeline_test.cpp index cb0e913e82..ef076d77da 100644 --- a/test/integration/pipeline/multisig_tx_pipeline_test.cpp +++ b/test/integration/pipeline/multisig_tx_pipeline_test.cpp @@ -231,15 +231,12 @@ TEST_F(MstPipelineTest, GetPendingTxsNoSignedTxs) { } /** - * Disabled because fully signed transaction doesn't go through MST and pending - * transaction remains in query response IR-1329 * @given a ledger with mst user (quorum=3) created * @when the user sends a transaction with only one signature, then sends the * transaction with all three signatures * @then there should be no pending transactions */ -TEST_F(MstPipelineTest, DISABLED_ReplayViaFullySignedTransaction) { - // TODO igor-egorov, 2018-09-25, IR-1329, enable the test +TEST_F(MstPipelineTest, ReplayViaFullySignedTransaction) { auto &mst_itf = prepareMstItf(); auto pending_tx = baseTx().setAccountDetail(kUserId, "age", "10").quorum(kSignatories + 1); diff --git a/test/module/irohad/multi_sig_transactions/mst_mocks.hpp b/test/module/irohad/multi_sig_transactions/mst_mocks.hpp index dcebf8e60a..4860f90bb3 100644 --- a/test/module/irohad/multi_sig_transactions/mst_mocks.hpp +++ b/test/module/irohad/multi_sig_transactions/mst_mocks.hpp @@ -57,6 +57,7 @@ namespace iroha { rxcpp::observable>()); MOCK_CONST_METHOD0(onPreparedBatchesImpl, rxcpp::observable()); MOCK_CONST_METHOD0(onExpiredBatchesImpl, rxcpp::observable()); + MOCK_CONST_METHOD1(batchInStorageImpl, bool(const DataType &)); }; } // namespace iroha #endif // IROHA_MST_MOCKS_HPP diff --git a/test/module/irohad/multi_sig_transactions/state_test.cpp b/test/module/irohad/multi_sig_transactions/state_test.cpp index 5f54d57940..f4c1049be7 100644 --- a/test/module/irohad/multi_sig_transactions/state_test.cpp +++ b/test/module/irohad/multi_sig_transactions/state_test.cpp @@ -52,12 +52,40 @@ TEST(StateTest, UpdateExistingState) { ASSERT_EQ(*merged_tx, **state.getBatches().begin()); } +/** + * @given empty state @and a batch + * @when inserting the batch + * @then "contains" method shows presence of the batch + */ +TEST(StateTest, ContainsMethodFindsInsertedBatch) { + auto state = MstState::empty(); + + auto first_signature = makeSignature("1", "pub_key_1"); + auto batch = makeTestBatch(txBuilder(1, iroha::time::now())); + auto tx = addSignatures(batch, 0, first_signature); + state += tx; + + EXPECT_TRUE(state.contains(batch)); +} + +/** + * @given empty state @and a distinct batch + * @when checking that batch's presence in the state + * @then "contains" method shows absence of the batch + */ +TEST(StateTest, ContainsMethodDoesNotFindNonInsertedBatch) { + auto state = MstState::empty(); + auto batch = makeTestBatch(txBuilder(1, iroha::time::now())); + + EXPECT_FALSE(state.contains(batch)); +} + /** * @given empty state * @when insert batch with same signatures two times * @then checks that the state contains only one signature */ -TEST(StateTest, UpdateStateWhenTransacionsSame) { +TEST(StateTest, UpdateStateWhenTransactionsSame) { log_->info("Create empty state => insert two equal transaction"); auto state = MstState::empty(); diff --git a/test/module/irohad/multi_sig_transactions/storage_test.cpp b/test/module/irohad/multi_sig_transactions/storage_test.cpp index 6e7ee99c1b..cdafb2b938 100644 --- a/test/module/irohad/multi_sig_transactions/storage_test.cpp +++ b/test/module/irohad/multi_sig_transactions/storage_test.cpp @@ -98,3 +98,28 @@ TEST_F(StorageTest, StorageWhenCreate) { .getBatches() .size()); } + +/** + * @given storage with three batches + * @when checking, if those batches belong to the storage + * @then storage reports, that those batches are in it + */ +TEST_F(StorageTest, StorageFindsExistingBatch) { + auto batch1 = makeTestBatch(txBuilder(1, creation_time)); + auto batch2 = makeTestBatch(txBuilder(2, creation_time)); + auto batch3 = makeTestBatch(txBuilder(3, creation_time)); + + EXPECT_TRUE(storage->batchInStorage(batch1)); + EXPECT_TRUE(storage->batchInStorage(batch2)); + EXPECT_TRUE(storage->batchInStorage(batch3)); +} + +/** + * @given storage with three batches @and one another batch not in the storage + * @when checking, if the last batch belongs to the storage + * @then storage reports, that this batch is not in it + */ +TEST_F(StorageTest, StorageDoesNotFindNonExistingBatch) { + auto distinct_batch = makeTestBatch(txBuilder(4, creation_time)); + EXPECT_FALSE(storage->batchInStorage(distinct_batch)); +} From 6bd222e3fc610dd05e9d60b319b165b1f69adaa6 Mon Sep 17 00:00:00 2001 From: Nikolay Yushkevich Date: Wed, 19 Dec 2018 20:47:15 +0300 Subject: [PATCH 19/61] Fix script build (#1977) Signed-off-by: neewy --- docs/source/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 54f0d2d604..621e3ddb26 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -107,7 +107,9 @@ with open('locale.yaml', 'r') as stream: locale = yaml.load(stream) language = locale.get('language') - locale_dirs = locale.get('locale_dirs') + if locale.get('locale_dirs'): + print("Setting locale dir to " + locale.get('locale_dirs')) + locale_dirs = [(locale.get('locale_dirs'))] # Grouping the document tree into LaTeX files. List of tuples From 07bc4e93f86c075cc48cb5915c277612293f3b6c Mon Sep 17 00:00:00 2001 From: Andrei Lebedev Date: Thu, 20 Dec 2018 10:47:52 +0200 Subject: [PATCH 20/61] Refactor round logging; replace remaining toString calls (#1967) Signed-off-by: Andrei Lebedev --- irohad/consensus/yac/impl/yac.cpp | 19 ++++------ .../yac/storage/impl/yac_proposal_storage.cpp | 5 ++- irohad/main/impl/on_demand_ordering_init.cpp | 8 +++-- .../state/impl/mst_state.cpp | 2 +- .../transport/impl/mst_transport_grpc.cpp | 3 +- .../impl/on_demand_connection_manager.cpp | 7 ++-- .../ordering/impl/on_demand_ordering_gate.cpp | 8 ++--- .../impl/on_demand_ordering_service_impl.cpp | 36 +++++++------------ irohad/torii/impl/command_service_impl.cpp | 2 +- .../impl/command_service_transport_grpc.cpp | 2 +- .../fake_peer/fake_peer.cpp | 24 ++++++------- 11 files changed, 44 insertions(+), 72 deletions(-) diff --git a/irohad/consensus/yac/impl/yac.cpp b/irohad/consensus/yac/impl/yac.cpp index 07c536d989..d8f09ac03c 100644 --- a/irohad/consensus/yac/impl/yac.cpp +++ b/irohad/consensus/yac/impl/yac.cpp @@ -151,10 +151,8 @@ namespace iroha { == ProposalState::kNotSentNotProcessed) { vote_storage_.nextProcessingState(proposal_round); log_->info( - "Received supermajority of votes for ({}, {}), skip " - "propagation", - proposal_round.block_round, - proposal_round.reject_round); + "Received supermajority of votes for {}, skip propagation", + proposal_round); } } @@ -166,25 +164,20 @@ namespace iroha { switch (processing_state) { case ProposalState::kNotSentNotProcessed: vote_storage_.nextProcessingState(proposal_round); - log_->info("Propagate state ({}, {}) to whole network", - proposal_round.block_round, - proposal_round.reject_round); + log_->info("Propagate state {} to whole network", proposal_round); this->propagateState(visit_in_place(answer, votes)); break; case ProposalState::kSentNotProcessed: vote_storage_.nextProcessingState(proposal_round); - log_->info("Pass outcome for ({}, {}) to pipeline", - proposal_round.block_round, - proposal_round.reject_round); + log_->info("Pass outcome for {} to pipeline", proposal_round); this->closeRound(); notifier_.get_subscriber().on_next(answer); break; case ProposalState::kSentProcessed: if (state.size() == 1) { this->findPeer(state.at(0)) | [&](const auto &from) { - log_->info("Propagate state ({}, {}) directly to {}", - proposal_round.block_round, - proposal_round.reject_round, + log_->info("Propagate state {} directly to {}", + proposal_round, from->address()); this->propagateStateDirectly(*from, visit_in_place(answer, votes)); diff --git a/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp b/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp index 0641091975..dd75708de0 100644 --- a/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp +++ b/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp @@ -64,9 +64,8 @@ namespace iroha { if (shouldInsert(msg)) { // insert to block store - log_->info("Vote with round [{}, {}] and hashes [{}, {}] looks valid", - msg.hash.vote_round.block_round, - msg.hash.vote_round.reject_round, + log_->info("Vote with {} and hashes [{}, {}] looks valid", + msg.hash.vote_round, msg.hash.vote_hashes.proposal_hash, msg.hash.vote_hashes.block_hash); diff --git a/irohad/main/impl/on_demand_ordering_init.cpp b/irohad/main/impl/on_demand_ordering_init.cpp index 0f8c56357d..4161c30091 100644 --- a/irohad/main/impl/on_demand_ordering_init.cpp +++ b/irohad/main/impl/on_demand_ordering_init.cpp @@ -132,9 +132,11 @@ namespace iroha { // with number of peers auto &peer = current_peers_[permutation[reject_round % permutation.size()]]; - log_->debug("For round {}, using OS on peer: {}", - consensus::Round{current_round.block_round, reject_round}, - peer->toString()); + log_->debug( + "For {}, using OS on peer: {}", + consensus::Round{current_round.block_round + block_round_advance, + reject_round}, + *peer); return peer; }; diff --git a/irohad/multi_sig_transactions/state/impl/mst_state.cpp b/irohad/multi_sig_transactions/state/impl/mst_state.cpp index 813e984348..fe58c7b183 100644 --- a/irohad/multi_sig_transactions/state/impl/mst_state.cpp +++ b/irohad/multi_sig_transactions/state/impl/mst_state.cpp @@ -138,7 +138,7 @@ namespace iroha { void MstState::insertOne(StateUpdateResult &state_update, const DataType &rhs_batch) { - log_->info("batch: {}", rhs_batch->toString()); + log_->info("batch: {}", *rhs_batch); auto corresponding = internal_state_.find(rhs_batch); if (corresponding == internal_state_.end()) { // when state does not contain transaction diff --git a/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp b/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp index 0e8a0613a6..193ad7d9c4 100644 --- a/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp +++ b/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp @@ -90,8 +90,7 @@ grpc::Status MstTransportGrpc::SendState( if (not cache_presence) { // TODO andrei 30.11.18 IR-51 Handle database error async_call_->log_->warn( - "Check tx presence database error. Batch: {}", - value.value->toString()); + "Check tx presence database error. Batch: {}", *value.value); return; } auto is_replay = std::any_of( diff --git a/irohad/ordering/impl/on_demand_connection_manager.cpp b/irohad/ordering/impl/on_demand_connection_manager.cpp index a2932b02d1..f59c9ab2eb 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.cpp +++ b/irohad/ordering/impl/on_demand_connection_manager.cpp @@ -50,8 +50,7 @@ void OnDemandConnectionManager::onBatches(consensus::Round round, */ auto propagate = [this, batches](PeerType type, consensus::Round round) { - log_->debug( - "onTransactions, round[{}, {}]", round.block_round, round.reject_round); + log_->debug("onBatches, {}", round); connections_.peers[type]->onBatches(round, batches); }; @@ -69,9 +68,7 @@ boost::optional OnDemandConnectionManager::onRequestProposal(consensus::Round round) { std::shared_lock lock(mutex_); - log_->debug("onRequestProposal, round[{}, {}]", - round.block_round, - round.reject_round); + log_->debug("onRequestProposal, {}", round); return connections_.peers[kIssuer]->onRequestProposal(round); } diff --git a/irohad/ordering/impl/on_demand_ordering_gate.cpp b/irohad/ordering/impl/on_demand_ordering_gate.cpp index 31c17398a4..eb25fb6b87 100644 --- a/irohad/ordering/impl/on_demand_ordering_gate.cpp +++ b/irohad/ordering/impl/on_demand_ordering_gate.cpp @@ -32,9 +32,7 @@ OnDemandOrderingGate::OnDemandOrderingGate( visit_in_place(event, [this](const BlockEvent &block_event) { // block committed, increment block round - log_->debug("BlockEvent. round [{}, {}]", - block_event.round.block_round, - block_event.round.reject_round); + log_->debug("BlockEvent. {}", block_event.round); current_round_ = block_event.round; cache_->remove(block_event.hashes); }, @@ -43,9 +41,7 @@ OnDemandOrderingGate::OnDemandOrderingGate( log_->debug("EmptyEvent"); current_round_ = empty_event.round; }); - log_->debug("Current round: [{}, {}]", - current_round_.block_round, - current_round_.reject_round); + log_->debug("Current: {}", current_round_); auto batches = cache_->pop(); diff --git a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp index 1ba1ba8e55..52866b3e22 100644 --- a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp +++ b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp @@ -41,9 +41,7 @@ OnDemandOrderingServiceImpl::OnDemandOrderingServiceImpl( void OnDemandOrderingServiceImpl::onCollaborationOutcome( consensus::Round round) { - log_->info("onCollaborationOutcome => round[{}, {}]", - round.block_round, - round.reject_round); + log_->info("onCollaborationOutcome => {}", round); // exclusive write lock std::lock_guard guard(lock_); log_->debug("onCollaborationOutcome => write lock is acquired"); @@ -58,10 +56,7 @@ void OnDemandOrderingServiceImpl::onBatches(consensus::Round round, CollectionType batches) { // read lock std::shared_lock guard(lock_); - log_->info("onBatches => collection size = {}, round[{}, {}]", - batches.size(), - round.block_round, - round.reject_round); + log_->info("onBatches => collection size = {}, {}", batches.size(), round); auto unprocessed_batches = boost::adaptors::filter(batches, [this](const auto &batch) { @@ -82,9 +77,7 @@ void OnDemandOrderingServiceImpl::onBatches(consensus::Round round, }); BOOST_ASSERT_MSG(it != current_proposals_.end(), "No place to store the batches!"); - log_->debug("onBatches => collection will be inserted to [{}, {}]", - it->first.block_round, - it->first.reject_round); + log_->debug("onBatches => collection will be inserted to {}", it->first); } std::for_each(unprocessed_batches.begin(), unprocessed_batches.end(), @@ -97,9 +90,10 @@ OnDemandOrderingServiceImpl::onRequestProposal(consensus::Round round) { // read lock std::shared_lock guard(lock_); auto proposal = proposal_map_.find(round); - log_->debug("onRequestProposal, round[{}, {}], {}returning a proposal.", - round.block_round, - round.reject_round, + // space between '{}' and 'returning' is not missing, since either nothing, or + // NOT with space is printed + log_->debug("onRequestProposal, {}, {}returning a proposal.", + round, (proposal == proposal_map_.end()) ? "NOT " : ""); if (proposal != proposal_map_.end()) { return clone(*proposal->second); @@ -113,16 +107,14 @@ OnDemandOrderingServiceImpl::onRequestProposal(consensus::Round round) { void OnDemandOrderingServiceImpl::packNextProposals( const consensus::Round &round) { auto close_round = [this](consensus::Round round) { - log_->debug("close round[{}, {}]", round.block_round, round.reject_round); + log_->debug("close {}", round); auto it = current_proposals_.find(round); if (it != current_proposals_.end()) { log_->debug("proposal found"); if (not it->second.empty()) { proposal_map_.emplace(round, emitProposal(round)); - log_->debug("packNextProposal: data has been fetched for round[{}, {}]", - round.block_round, - round.reject_round); + log_->debug("packNextProposal: data has been fetched for {}", round); round_queue_.push(round); } current_proposals_.erase(it); @@ -130,7 +122,7 @@ void OnDemandOrderingServiceImpl::packNextProposals( }; auto open_round = [this](consensus::Round round) { - log_->debug("open round[{}, {}]", round.block_round, round.reject_round); + log_->debug("open {}", round); current_proposals_[round]; }; @@ -186,9 +178,7 @@ void OnDemandOrderingServiceImpl::packNextProposals( OnDemandOrderingServiceImpl::ProposalType OnDemandOrderingServiceImpl::emitProposal(const consensus::Round &round) { - log_->debug("Mutable proposal generation, round[{}, {}]", - round.block_round, - round.reject_round); + log_->debug("Mutable proposal generation, {}", round); TransactionBatchType batch; std::vector> collection; @@ -219,9 +209,7 @@ void OnDemandOrderingServiceImpl::tryErase() { if (round_queue_.size() >= number_of_proposals_) { auto &round = round_queue_.front(); proposal_map_.erase(round); - log_->info("tryErase: erased round[{}, {}]", - round.block_round, - round.reject_round); + log_->info("tryErase: erased {}", round); round_queue_.pop(); } } diff --git a/irohad/torii/impl/command_service_impl.cpp b/irohad/torii/impl/command_service_impl.cpp index a8da9c46bd..6f03e55030 100644 --- a/irohad/torii/impl/command_service_impl.cpp +++ b/irohad/torii/impl/command_service_impl.cpp @@ -136,7 +136,7 @@ namespace torii { void CommandServiceImpl::pushStatus( const std::string &who, std::shared_ptr response) { - log_->debug("{}: adding item to cache: {}", who, response->toString()); + log_->debug("{}: adding item to cache: {}", who, *response); status_bus_->publish(response); } diff --git a/irohad/torii/impl/command_service_transport_grpc.cpp b/irohad/torii/impl/command_service_transport_grpc.cpp index eac1f6b216..08e99fe934 100644 --- a/irohad/torii/impl/command_service_transport_grpc.cpp +++ b/irohad/torii/impl/command_service_transport_grpc.cpp @@ -193,7 +193,7 @@ namespace torii { ->getStatusStream(hash) // convert to transport objects .map([&](auto response) { - log_->debug("mapped {}, {}", response->toString(), client_id); + log_->debug("mapped {}, {}", *response, client_id); return std::static_pointer_cast< shared_model::proto::TransactionResponse>(response) ->getTransport(); diff --git a/test/framework/integration_framework/fake_peer/fake_peer.cpp b/test/framework/integration_framework/fake_peer/fake_peer.cpp index 03d02d2c21..18cb353c4d 100644 --- a/test/framework/integration_framework/fake_peer/fake_peer.cpp +++ b/test/framework/integration_framework/fake_peer/fake_peer.cpp @@ -190,19 +190,17 @@ namespace integration_framework { } std::vector my_votes; my_votes.reserve(incoming_votes->size()); - std::transform( - incoming_votes->cbegin(), - incoming_votes->cend(), - std::back_inserter(my_votes), - [this](const VoteMessage &incoming_vote) { - log_->debug( - "Sending agreement for proposal (Round ({}, {}), hash ({}, {})).", - incoming_vote.hash.vote_round.block_round, - incoming_vote.hash.vote_round.reject_round, - incoming_vote.hash.vote_hashes.proposal_hash, - incoming_vote.hash.vote_hashes.block_hash); - return makeVote(incoming_vote.hash); - }); + std::transform(incoming_votes->cbegin(), + incoming_votes->cend(), + std::back_inserter(my_votes), + [this](const VoteMessage &incoming_vote) { + log_->debug( + "Sending agreement for proposal ({}, hash ({}, {})).", + incoming_vote.hash.vote_round, + incoming_vote.hash.vote_hashes.proposal_hash, + incoming_vote.hash.vote_hashes.block_hash); + return makeVote(incoming_vote.hash); + }); sendYacState(my_votes); } From 6cd069cb2d46a909107dddd237ea7b75518141b6 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Thu, 20 Dec 2018 12:20:15 +0300 Subject: [PATCH 21/61] K8s hex peer key genesis block (#1969) * Amend genesis-add-peers.py script to insert hex strings instead of base64 for peer keys * Converted prevBlockHash and public keys to hex format Signed-off-by: kamilsa --- .../iroha-k8s/scripts/genesis-add-peers.py | 5 +---- .../roles/iroha-k8s/files/conf/genesis.block | 2 +- .../ansible/roles/iroha-k8s/files/genesis.block | 2 +- .../roles/iroha-k8s/files/k8s-peer-keys.yaml | 16 ++++++++-------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py b/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py index 3cb2fc35e3..adc0eedc39 100644 --- a/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py +++ b/deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py @@ -30,7 +30,7 @@ def genesis_add_peers(peers_list, genesis_block_fp): pass genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands'] = list(genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands']) for p in peers_list: - p_add_command = {"addPeer": {"peer": {"address": "%s:%s" % (p.host, '10001'), "peerKey":hex_to_b64(p.pub_key)}}} + p_add_command = {"addPeer": {"peer": {"address": "%s:%s" % (p.host, '10001'), "peerKey": p.pub_key}}} genesis_dict['blockV1']['payload']['transactions'][0]['payload']['reducedPayload']['commands'].append(p_add_command) genesis_json.seek(0) json.dump(genesis_dict, genesis_json, sort_keys=True) @@ -62,9 +62,6 @@ def caliper_rename_keys(priv_key_name, pub_key_name, caliper_conf_fp): def to_b64(bytes_array): return base64.b64encode(bytes_array).decode('utf-8') -def hex_to_b64(hex_string): - return to_b64(bytearray.fromhex(hex_string)) - def print_keys_b64(peers): for peer in peers: priv_key = peer.priv_key.encode() diff --git a/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block b/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block index 79003ff20b..21b2e48ca4 100644 --- a/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block +++ b/deploy/ansible/roles/iroha-k8s/files/conf/genesis.block @@ -1 +1 @@ -{"blockV1": {"payload": {"height": "1", "prevBlockHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "money_creator"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "publicKey": "MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA="}}, {"createAccount": {"accountName": "test", "domainId": "test", "publicKey": "cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w="}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "money_creator"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "HPidCCmB5MiucqYlKyF5eARsFv/29fjB/gWUDqVwLwA="}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "k6njsmjiWSYjcmFiE0fdH/rhnTobmVw7Ttlok0RHZKQ="}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "rAJFaosvrcwMbJJ67x3nv6bk1YYLhF31zcF8gGciUHg="}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "orj/67AMEoauOtbRpZDXFoIWXa51APHYMQImQ/GrKgs="}}}], "quorum": 1}}}], "txNumber": 1}}} \ No newline at end of file +{"blockV1": {"payload": {"height": "1", "prevBlockHash": "0000000000000000000000000000000000000000000000000000000000000000", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "money_creator"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "publicKey": "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910"}}, {"createAccount": {"accountName": "test", "domainId": "test", "publicKey": "716fe505f69f18511a1b083915aa9ff73ef36e6688199f3959750db38b8f4bfc"}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "money_creator"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "c1328b090617992581ca9bc4b2466f58634b067dd345c783e4a1ab02a691302c"}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "15c09a6019ace7b98c8a5606a8cbca583d6442e84b5faaf57f97245f3d575ef5"}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "f11f7bd883674e7745fb88b8b2ff7e917fac2ebc44f4740bd791a87113169a00"}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "87a97b63b30ef48736c19b5e6a50504e4eb57d582861c25f5c9e0a56a22d8dd3"}}}], "quorum": 1}}}], "txNumber": 1}}} \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/genesis.block b/deploy/ansible/roles/iroha-k8s/files/genesis.block index 79003ff20b..21b2e48ca4 100644 --- a/deploy/ansible/roles/iroha-k8s/files/genesis.block +++ b/deploy/ansible/roles/iroha-k8s/files/genesis.block @@ -1 +1 @@ -{"blockV1": {"payload": {"height": "1", "prevBlockHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "money_creator"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "publicKey": "MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA="}}, {"createAccount": {"accountName": "test", "domainId": "test", "publicKey": "cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w="}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "money_creator"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "HPidCCmB5MiucqYlKyF5eARsFv/29fjB/gWUDqVwLwA="}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "k6njsmjiWSYjcmFiE0fdH/rhnTobmVw7Ttlok0RHZKQ="}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "rAJFaosvrcwMbJJ67x3nv6bk1YYLhF31zcF8gGciUHg="}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "orj/67AMEoauOtbRpZDXFoIWXa51APHYMQImQ/GrKgs="}}}], "quorum": 1}}}], "txNumber": 1}}} \ No newline at end of file +{"blockV1": {"payload": {"height": "1", "prevBlockHash": "0000000000000000000000000000000000000000000000000000000000000000", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "money_creator"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "publicKey": "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910"}}, {"createAccount": {"accountName": "test", "domainId": "test", "publicKey": "716fe505f69f18511a1b083915aa9ff73ef36e6688199f3959750db38b8f4bfc"}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "money_creator"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "c1328b090617992581ca9bc4b2466f58634b067dd345c783e4a1ab02a691302c"}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "15c09a6019ace7b98c8a5606a8cbca583d6442e84b5faaf57f97245f3d575ef5"}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "f11f7bd883674e7745fb88b8b2ff7e917fac2ebc44f4740bd791a87113169a00"}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "87a97b63b30ef48736c19b5e6a50504e4eb57d582861c25f5c9e0a56a22d8dd3"}}}], "quorum": 1}}}], "txNumber": 1}}} \ No newline at end of file diff --git a/deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml b/deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml index ba1b4a90ee..936d95ff5f 100644 --- a/deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml +++ b/deploy/ansible/roles/iroha-k8s/files/k8s-peer-keys.yaml @@ -5,8 +5,8 @@ metadata: name: iroha-peer-key-0 type: Opaque data: - node.priv: NWE5NTU5YjQ2ZGIwN2UwNzUwNGU5ZTFlOTM0NjFmODM3M2ExNzUyMzEyN2E1NmI4MDhkNjE0OWJmMTk1NDljZg== - node.pub: MWNmODlkMDgyOTgxZTRjOGFlNzJhNjI1MmIyMTc5NzgwNDZjMTZmZmY2ZjVmOGMxZmUwNTk0MGVhNTcwMmYwMA== + node.priv: YmI2MGE2ODNiZjQxYTc5ZWRhNzQxODhkYmUxYmM1M2RiOGY0ZmNlYTQwMWY2NDI3MTE1N2QwYWFkNzQxODdjYQ== + node.pub: YzEzMjhiMDkwNjE3OTkyNTgxY2E5YmM0YjI0NjZmNTg2MzRiMDY3ZGQzNDVjNzgzZTRhMWFiMDJhNjkxMzAyYw== --- apiVersion: v1 kind: Secret @@ -14,8 +14,8 @@ metadata: name: iroha-peer-key-1 type: Opaque data: - node.priv: OTAzZGMzYWFjMjRmYTQwY2YzNDZmMWQwN2E5NGY0NjhhMWU3ZjE2M2MxZWMyYTRhMDI3MzZiMDVjMjY0NDNlNg== - node.pub: OTNhOWUzYjI2OGUyNTkyNjIzNzI2MTYyMTM0N2RkMWZmYWUxOWQzYTFiOTk1YzNiNGVkOTY4OTM0NDQ3NjRhNA== + node.priv: NGViOWJhZmIyYTEzZWNiMDRkOTZkN2JmNmQzY2Y3MTNkNTA4NDRjNWYyYTQxMjczNWEwMzU3NDFmYjU0NmU5NQ== + node.pub: MTVjMDlhNjAxOWFjZTdiOThjOGE1NjA2YThjYmNhNTgzZDY0NDJlODRiNWZhYWY1N2Y5NzI0NWYzZDU3NWVmNQ== --- apiVersion: v1 kind: Secret @@ -23,8 +23,8 @@ metadata: name: iroha-peer-key-2 type: Opaque data: - node.priv: OWZhZTA4YmI1NGRiNGI3YWFiZTc0YTI2ZmVlN2ZhMmRiNDc0YjdhNTVmOTAzYmQ4ZjJmMDkyMWYyYWMyZjQzYQ== - node.pub: YWMwMjQ1NmE4YjJmYWRjYzBjNmM5MjdhZWYxZGU3YmZhNmU0ZDU4NjBiODQ1ZGY1Y2RjMTdjODA2NzIyNTA3OA== + node.priv: N2Y3OTI0NWRjMzRiN2FkOGVmNTNjNmI4MzUyZWZlNTdiMzE1N2VlZTgxODQxYzliM2U4NzdjMjQzMzZkNmVmZg== + node.pub: ZjExZjdiZDg4MzY3NGU3NzQ1ZmI4OGI4YjJmZjdlOTE3ZmFjMmViYzQ0ZjQ3NDBiZDc5MWE4NzExMzE2OWEwMA== --- apiVersion: v1 kind: Secret @@ -32,5 +32,5 @@ metadata: name: iroha-peer-key-3 type: Opaque data: - node.priv: MDBlMzEyODlmOTIxZjE0NWRjZjI1MDE3NTRjOWM1ZjIxMTlhNmEzNWFkZjM3N2I0NDU3YmEwNmFiNWE2OWUxNg== - node.pub: YTJiOGZmZWJiMDBjMTI4NmFlM2FkNmQxYTU5MGQ3MTY4MjE2NWRhZTc1MDBmMWQ4MzEwMjI2NDNmMWFiMmEwYg== + node.priv: NGE3Yzc4ODRhNmNhOTFlN2YzOTE2NGQ2Y2UzOGY2NjAwMzFjYzZiYTdjNGFhZjIwNWQ2MjA1MmU0MWE3Nzg0MQ== + node.pub: ODdhOTdiNjNiMzBlZjQ4NzM2YzE5YjVlNmE1MDUwNGU0ZWI1N2Q1ODI4NjFjMjVmNWM5ZTBhNTZhMjJkOGRkMw== From 6457ecc8c859161aca613e5f4250989149024573 Mon Sep 17 00:00:00 2001 From: Konstantin Munichev Date: Thu, 20 Dec 2018 12:53:27 +0300 Subject: [PATCH 22/61] Fix clang build warnings (#1963) Signed-off-by: Konstantin Munichev --- irohad/main/impl/on_demand_ordering_init.cpp | 3 +-- schema/mst.proto | 1 - test/module/irohad/ametsuchi/postgres_query_executor_test.cpp | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/irohad/main/impl/on_demand_ordering_init.cpp b/irohad/main/impl/on_demand_ordering_init.cpp index 4161c30091..6f2b9155c4 100644 --- a/irohad/main/impl/on_demand_ordering_init.cpp +++ b/irohad/main/impl/on_demand_ordering_init.cpp @@ -193,8 +193,7 @@ namespace iroha { // reject_counter and local_counter are local mutable variables of lambda auto delay = [reject_counter = kCounter, local_counter = kCounter, - &time_generator, - kMaxLocalCounter](const auto &commit) mutable { + &time_generator](const auto &commit) mutable { using iroha::synchronizer::SynchronizationOutcomeType; if (commit.sync_outcome == SynchronizationOutcomeType::kReject or commit.sync_outcome == SynchronizationOutcomeType::kNothing) { diff --git a/schema/mst.proto b/schema/mst.proto index bdfeb1029f..4f0f527fbd 100644 --- a/schema/mst.proto +++ b/schema/mst.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package iroha.network.transport; import "transaction.proto"; -import "primitive.proto"; import "google/protobuf/empty.proto"; message MstState { diff --git a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp index 310acee45a..0e7c6281a3 100644 --- a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp @@ -1127,7 +1127,7 @@ namespace iroha { }; struct GetAccountTxPaginationImpl { - static std::initializer_list getUserPermissions() { + static shared_model::interface::RolePermissionSet getUserPermissions() { return {permissions::Role::kSetDetail, permissions::Role::kGetMyAccTxs}; } @@ -1171,7 +1171,7 @@ namespace iroha { } struct GetAccountAssetTxPaginationImpl { - static std::initializer_list getUserPermissions() { + static shared_model::interface::RolePermissionSet getUserPermissions() { return {permissions::Role::kReceive, permissions::Role::kGetMyAccAstTxs}; } From db4a300a22dddcc65a597f3edaa46ba0ecaa7086 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Thu, 20 Dec 2018 17:22:48 +0300 Subject: [PATCH 23/61] Update RequestProposal endpoint fuzzing Signed-off-by: Kitsu --- test/fuzzing/CMakeLists.txt | 2 + test/fuzzing/ordering_service_fixture.hpp | 21 +++++++--- test/fuzzing/request_proposal_fuzz.cpp | 48 ++++++++++++++++------- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/test/fuzzing/CMakeLists.txt b/test/fuzzing/CMakeLists.txt index 46a2163bb7..6d08f68f40 100644 --- a/test/fuzzing/CMakeLists.txt +++ b/test/fuzzing/CMakeLists.txt @@ -55,6 +55,8 @@ target_link_libraries(send_batches_fuzz add_executable(request_proposal_fuzz request_proposal_fuzz.cpp) target_link_libraries(request_proposal_fuzz + ametsuchi + rxcpp gtest::gtest gmock::gmock on_demand_ordering_service diff --git a/test/fuzzing/ordering_service_fixture.hpp b/test/fuzzing/ordering_service_fixture.hpp index 32a98e45c0..fe08bfa535 100644 --- a/test/fuzzing/ordering_service_fixture.hpp +++ b/test/fuzzing/ordering_service_fixture.hpp @@ -21,6 +21,8 @@ #include "module/shared_model/validators/validators.hpp" #include "ordering/impl/on_demand_ordering_service_impl.hpp" #include "ordering/impl/on_demand_os_server_grpc.hpp" +#include "validators/default_validator.hpp" +#include "validators/protobuf/proto_transaction_validator.hpp" using namespace testing; using namespace iroha::ordering; @@ -34,23 +36,30 @@ namespace fuzzing { batch_parser_; std::shared_ptr> transaction_batch_factory_; - NiceMock> *transaction_validator_; + shared_model::validation::AbstractValidator< + shared_model::interface::Transaction> *transaction_validator_; OrderingServiceFixture() { // fuzzing target is intended to run many times (~millions) so any // additional output slows it down significantly spdlog::set_level(spdlog::level::err); - auto transaction_validator = - std::make_unique>>(); + std::unique_ptr> + transaction_validator = + std::make_unique(); transaction_validator_ = transaction_validator.get(); + std::unique_ptr> + proto_transaction_validator = std::make_unique< + shared_model::validation::ProtoTransactionValidator>(); transaction_factory_ = std::make_shared>( - std::move(transaction_validator)); + std::move(transaction_validator), + std::move(proto_transaction_validator)); batch_parser_ = std::make_shared< shared_model::interface::TransactionBatchParserImpl>(); diff --git a/test/fuzzing/request_proposal_fuzz.cpp b/test/fuzzing/request_proposal_fuzz.cpp index c4d9593ac1..88de77896e 100644 --- a/test/fuzzing/request_proposal_fuzz.cpp +++ b/test/fuzzing/request_proposal_fuzz.cpp @@ -3,33 +3,53 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "ordering_service_fixture.hpp" +#include "fuzzing/ordering_service_fixture.hpp" + +#include "ametsuchi/impl/tx_presence_cache_impl.hpp" +#include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" + +struct RequestProposalFixture : public fuzzing::OrderingServiceFixture { + std::shared_ptr proposal_factory_; + std::shared_ptr storage_; + std::shared_ptr persistent_cache_; + std::shared_ptr ordering_service_; + std::shared_ptr server_; + + RequestProposalFixture() : OrderingServiceFixture() { + proposal_factory_ = std::make_unique(); + storage_ = std::make_shared(); + persistent_cache_ = + std::make_shared(storage_); + } + + void init_with(size_t transaction_limit) { + ordering_service_ = std::make_shared( + transaction_limit, + std::move(proposal_factory_), + std::move(persistent_cache_)); + server_ = + std::make_shared(ordering_service_, + transaction_factory_, + batch_parser_, + transaction_batch_factory_); + } +}; extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size) { - static fuzzing::OrderingServiceFixture fixture; + static RequestProposalFixture fixture; if (size < 1) { return 0; } - std::shared_ptr ordering_service_; - std::shared_ptr server_; - - auto proposal_factory = std::make_unique(); - ordering_service_ = std::make_shared( - data[0], std::move(proposal_factory)); - server_ = std::make_shared( - ordering_service_, - fixture.transaction_factory_, - fixture.batch_parser_, - fixture.transaction_batch_factory_); + fixture.init_with(data[0]); proto::ProposalRequest request; if (protobuf_mutator::libfuzzer::LoadProtoInput( true, data + 1, size - 1, &request)) { grpc::ServerContext context; proto::ProposalResponse response; - server_->RequestProposal(&context, &request, &response); + fixture.server_->RequestProposal(&context, &request, &response); } return 0; From d685258b4229ddc19d05405408ef44d46b072971 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Fri, 21 Dec 2018 12:18:19 +0300 Subject: [PATCH 24/61] Add hex to client API (#1940) * Add hex to client API Signed-off-by: kamilsa --- example/genesis.block | 8 ++-- example/python/tx-example.py | 8 +--- .../converters/impl/pb_command_factory.cpp | 34 ++++++++------ irohad/model/converters/impl/pb_common.cpp | 12 +++-- .../impl/pb_query_response_factory.cpp | 8 ++-- .../transport/impl/mst_transport_grpc.cpp | 7 +-- .../impl/command_service_transport_grpc.cpp | 6 +-- schema/loader.proto | 20 ++------ schema/mst.proto | 5 ++ schema/yac.proto | 5 ++ shared_model/backend/protobuf/batch_meta.hpp | 15 +++--- .../commands/impl/proto_add_signatory.cpp | 3 +- .../commands/impl/proto_create_account.cpp | 3 +- .../commands/impl/proto_remove_signatory.cpp | 3 +- .../backend/protobuf/common_objects/peer.hpp | 3 +- .../proto_common_objects_factory.hpp | 6 +-- .../protobuf/common_objects/signature.hpp | 4 +- shared_model/backend/protobuf/impl/block.cpp | 14 +++--- .../protobuf/impl/proto_block_factory.cpp | 4 +- .../impl/proto_query_response_factory.cpp | 3 +- .../protobuf/impl/proto_tx_status_factory.cpp | 2 +- .../backend/protobuf/impl/transaction.cpp | 4 +- .../queries/impl/proto_blocks_query.cpp | 4 +- .../queries/impl/proto_get_transactions.cpp | 12 ++--- .../protobuf/queries/impl/proto_query.cpp | 5 +- .../queries/impl/proto_tx_pagination_meta.cpp | 2 +- .../impl/proto_signatories_response.cpp | 14 +++++- .../impl/proto_tx_response.cpp | 2 +- shared_model/bindings/client_api.cpp | 8 ++-- .../builder_templates/query_template.hpp | 4 +- .../transaction_template.hpp | 10 ++-- .../proto_transaction_status_builder.cpp | 2 +- .../cryptography/model_impl/private_key.cpp | 2 - .../cryptography/model_impl/signed.cpp | 2 + shared_model/cryptography/signed.hpp | 2 + shared_model/schema/block.proto | 4 +- shared_model/schema/commands.proto | 6 +-- shared_model/schema/endpoint.proto | 4 +- shared_model/schema/primitive.proto | 6 +-- shared_model/schema/qry_responses.proto | 2 +- shared_model/schema/queries.proto | 2 +- shared_model/schema/transaction.proto | 2 +- shared_model/validators/field_validator.cpp | 3 +- .../integration_test_framework.cpp | 2 +- test/module/iroha-cli/client_test.cpp | 7 +-- .../irohad/common/raw_block_loader_test.cpp | 2 +- .../irohad/consensus/yac/network_test.cpp | 1 + .../consensus/yac/yac_block_storage_test.cpp | 8 ++-- .../irohad/consensus/yac/yac_common_test.cpp | 16 +++---- .../module/irohad/consensus/yac/yac_mocks.hpp | 2 +- .../yac/yac_proposal_storage_test.cpp | 6 +-- .../consensus/yac/yac_rainy_day_test.cpp | 14 +++--- .../yac/yac_simple_cold_case_test.cpp | 12 ++--- .../consensus/yac/yac_sunny_day_test.cpp | 12 ++--- .../consensus/yac/yac_unknown_peer_test.cpp | 2 +- .../model/converters/pb_commands_test.cpp | 2 +- .../mst_test_helpers.hpp | 3 +- .../irohad/torii/torii_queries_test.cpp | 6 +-- .../irohad/torii/torii_service_test.cpp | 46 +++++++++---------- .../shared_proto_queries_test.cpp | 10 ++-- .../shared_proto_transaction_test.cpp | 5 +- .../shared_proto_tx_response_test.cpp | 2 +- .../builder_templates/block_template.hpp | 5 +- .../common_objects/proto_peer_builder.hpp | 2 +- .../proto_signature_builder.hpp | 6 +-- .../proto_transaction_response_builder.cpp | 12 +++-- .../validators/field_validator_test.cpp | 4 +- .../validators/validators_fixture.hpp | 8 +++- test/system/irohad_test.cpp | 2 +- test/system/irohad_test_data/genesis.block | 8 ++-- 70 files changed, 247 insertions(+), 233 deletions(-) diff --git a/example/genesis.block b/example/genesis.block index ff3f993787..337ae5ace3 100644 --- a/example/genesis.block +++ b/example/genesis.block @@ -10,7 +10,7 @@ "addPeer":{ "peer":{ "address":"0.0.0.0:10001", - "peerKey":"vd1YQE0TFeDrJ5AsXXyOsGAsFiOPAFdz30BrwZEwiSk=" + "peerKey":"bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929" } } }, @@ -89,14 +89,14 @@ "createAccount":{ "accountName":"admin", "domainId":"test", - "publicKey":"MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA=" + "publicKey":"313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910" } }, { "createAccount":{ "accountName":"test", "domainId":"test", - "publicKey":"cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w=" + "publicKey":"716fe505f69f18511a1b083915aa9ff73ef36e6688199f3959750db38b8f4bfc" } }, { @@ -119,7 +119,7 @@ ], "txNumber":1, "height":"1", - "prevBlockHash":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + "prevBlockHash":"0000000000000000000000000000000000000000000000000000000000000000" } } } diff --git a/example/python/tx-example.py b/example/python/tx-example.py index f613ddec2e..3b45962ba4 100644 --- a/example/python/tx-example.py +++ b/example/python/tx-example.py @@ -58,13 +58,7 @@ def print_status_streaming(tx): # Create status request print("Hash of the transaction: ", tx.hash().hex()) - tx_hash = tx.hash().blob() - - # Check python version - if sys.version_info[0] == 2: - tx_hash = ''.join(map(chr, tx_hash)) - else: - tx_hash = bytes(tx_hash) + tx_hash = tx.hash().hex() # Create request request = endpoint_pb2.TxStatusRequest() diff --git a/irohad/model/converters/impl/pb_command_factory.cpp b/irohad/model/converters/impl/pb_command_factory.cpp index 079f2ed6fd..a6aad06ffd 100644 --- a/irohad/model/converters/impl/pb_command_factory.cpp +++ b/irohad/model/converters/impl/pb_command_factory.cpp @@ -7,6 +7,7 @@ #include +#include "common/byteutils.hpp" #include "common/instanceof.hpp" #include "model/converters/pb_common.hpp" @@ -16,6 +17,16 @@ namespace iroha { namespace model { namespace converters { + /** + * convert hex string to pubkey + * @param dest reference to destination public key + * @param src source string + */ + static void trySetHexKey(pubkey_t &dest, const std::string &src) { + iroha::hexstringToArray(src) | + [&dest](const auto &blob) { dest = blob; }; + } + PbCommandFactory::PbCommandFactory() { boost::assign::insert(pb_role_map_) // Can append role @@ -206,17 +217,15 @@ namespace iroha { const model::AddSignatory &add_signatory) { protocol::AddSignatory pb_add_signatory; pb_add_signatory.set_account_id(add_signatory.account_id); - pb_add_signatory.set_public_key(add_signatory.pubkey.data(), - add_signatory.pubkey.size()); + pb_add_signatory.set_public_key(add_signatory.pubkey.to_hexstring()); return pb_add_signatory; } + model::AddSignatory PbCommandFactory::deserializeAddSignatory( const protocol::AddSignatory &pb_add_signatory) { model::AddSignatory add_signatory; add_signatory.account_id = pb_add_signatory.account_id(); - std::copy(pb_add_signatory.public_key().begin(), - pb_add_signatory.public_key().end(), - add_signatory.pubkey.begin()); + trySetHexKey(add_signatory.pubkey, pb_add_signatory.public_key()); return add_signatory; } @@ -246,8 +255,7 @@ namespace iroha { protocol::CreateAccount pb_create_account; pb_create_account.set_account_name(create_account.account_name); pb_create_account.set_domain_id(create_account.domain_id); - pb_create_account.set_public_key(create_account.pubkey.data(), - create_account.pubkey.size()); + pb_create_account.set_public_key(create_account.pubkey.to_hexstring()); return pb_create_account; } model::CreateAccount PbCommandFactory::deserializeCreateAccount( @@ -255,9 +263,7 @@ namespace iroha { model::CreateAccount create_account; create_account.account_name = pb_create_account.account_name(); create_account.domain_id = pb_create_account.domain_id(); - std::copy(pb_create_account.public_key().begin(), - pb_create_account.public_key().end(), - create_account.pubkey.begin()); + trySetHexKey(create_account.pubkey, pb_create_account.public_key()); return create_account; } @@ -283,8 +289,8 @@ namespace iroha { const model::RemoveSignatory &remove_signatory) { protocol::RemoveSignatory pb_remove_signatory; pb_remove_signatory.set_account_id(remove_signatory.account_id); - pb_remove_signatory.set_public_key(remove_signatory.pubkey.data(), - remove_signatory.pubkey.size()); + pb_remove_signatory.set_public_key( + remove_signatory.pubkey.to_hexstring()); return pb_remove_signatory; } @@ -292,9 +298,7 @@ namespace iroha { const protocol::RemoveSignatory &pb_remove_signatory) { model::RemoveSignatory remove_signatory; remove_signatory.account_id = pb_remove_signatory.account_id(); - std::copy(pb_remove_signatory.public_key().begin(), - pb_remove_signatory.public_key().end(), - remove_signatory.pubkey.begin()); + trySetHexKey(remove_signatory.pubkey, pb_remove_signatory.public_key()); return remove_signatory; } // set account quorum diff --git a/irohad/model/converters/impl/pb_common.cpp b/irohad/model/converters/impl/pb_common.cpp index ca61c85720..b6ee6d6d01 100644 --- a/irohad/model/converters/impl/pb_common.cpp +++ b/irohad/model/converters/impl/pb_common.cpp @@ -16,6 +16,8 @@ */ #include "model/converters/pb_common.hpp" + +#include "common/byteutils.hpp" #include "model/command.hpp" #include "model/commands/all.hpp" #include "model/domain.hpp" @@ -28,15 +30,19 @@ namespace iroha { protocol::Peer serializePeer(iroha::model::Peer iroha_peer) { protocol::Peer res; res.set_address(iroha_peer.address); - res.set_peer_key(iroha_peer.pubkey.data(), iroha_peer.pubkey.size()); + res.set_peer_key(iroha_peer.pubkey.to_hexstring()); return res; } iroha::model::Peer deserializePeer(protocol::Peer pb_peer) { iroha::model::Peer res; res.address = pb_peer.address(); - std::copy(pb_peer.peer_key().begin(), - pb_peer.peer_key().end(), + auto blob = iroha::hexstringToBytestring(pb_peer.peer_key()); + if (not blob) { + return res; + } + std::copy(blob->begin(), + blob->end(), res.pubkey.begin()); return res; } diff --git a/irohad/model/converters/impl/pb_query_response_factory.cpp b/irohad/model/converters/impl/pb_query_response_factory.cpp index 6ebbc01936..271f4d5096 100644 --- a/irohad/model/converters/impl/pb_query_response_factory.cpp +++ b/irohad/model/converters/impl/pb_query_response_factory.cpp @@ -16,6 +16,7 @@ */ #include "model/converters/pb_query_response_factory.hpp" +#include "common/byteutils.hpp" #include "common/instanceof.hpp" #include "model/converters/pb_common.hpp" #include "model/converters/pb_transaction_factory.hpp" @@ -238,7 +239,7 @@ namespace iroha { protocol::SignatoriesResponse pb_response; for (auto key : signatoriesResponse.keys) { - pb_response.add_keys(key.data(), key.size()); + pb_response.add_keys(key.to_hexstring()); } return pb_response; } @@ -248,9 +249,8 @@ namespace iroha { const protocol::SignatoriesResponse &signatoriesResponse) const { model::SignatoriesResponse res{}; for (const auto &key : signatoriesResponse.keys()) { - pubkey_t pubkey; - std::copy(key.begin(), key.end(), pubkey.begin()); - res.keys.push_back(pubkey); + iroha::hexstringToArray(key) | + [&](const auto &pubkey) { res.keys.push_back(pubkey); }; } return res; } diff --git a/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp b/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp index 0e8a0613a6..f53caa6b2d 100644 --- a/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp +++ b/irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp @@ -135,9 +135,10 @@ grpc::Status MstTransportGrpc::SendState( return grpc::Status::OK; } - if (auto subscriber = subscriber_.lock()) { - subscriber->onNewState(source_key, std::move(new_state)); - } else { + if (auto subscriber =subscriber_.lock()) { + subscriber->onNewState( + source_key, + std::move(new_state));} else { async_call_->log_->warn("No subscriber for MST SendState event is set"); } diff --git a/irohad/torii/impl/command_service_transport_grpc.cpp b/irohad/torii/impl/command_service_transport_grpc.cpp index eac1f6b216..3cb9c2ad91 100644 --- a/irohad/torii/impl/command_service_transport_grpc.cpp +++ b/irohad/torii/impl/command_service_transport_grpc.cpp @@ -158,7 +158,7 @@ namespace torii { *response = std::static_pointer_cast( command_service_->getStatus( - shared_model::crypto::Hash(request->tx_hash()))) + shared_model::crypto::Hash::fromHexString(request->tx_hash()))) ->getTransport(); return grpc::Status::OK; } @@ -183,7 +183,7 @@ namespace torii { rxcpp::composite_subscription subscription; - auto hash = shared_model::crypto::Hash(request->tx_hash()); + auto hash = shared_model::crypto::Hash::fromHexString(request->tx_hash()); static auto client_id_format = boost::format("Peer: '%s', %s"); std::string client_id = @@ -193,7 +193,7 @@ namespace torii { ->getStatusStream(hash) // convert to transport objects .map([&](auto response) { - log_->debug("mapped {}, {}", response->toString(), client_id); + log_->info("mapped {}, {}", response->toString(), client_id); return std::static_pointer_cast< shared_model::proto::TransactionResponse>(response) ->getTransport(); diff --git a/schema/loader.proto b/schema/loader.proto index 917fa3d40f..1cca5dd16f 100644 --- a/schema/loader.proto +++ b/schema/loader.proto @@ -1,19 +1,7 @@ -// -// Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -// http://soramitsu.co.jp -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ syntax = "proto3"; package iroha.network.proto; diff --git a/schema/mst.proto b/schema/mst.proto index bdfeb1029f..747ddd3421 100644 --- a/schema/mst.proto +++ b/schema/mst.proto @@ -1,3 +1,8 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + syntax = "proto3"; package iroha.network.transport; diff --git a/schema/yac.proto b/schema/yac.proto index 71e0437e66..325e98440f 100644 --- a/schema/yac.proto +++ b/schema/yac.proto @@ -1,3 +1,8 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + syntax = "proto3"; package iroha.consensus.yac.proto; diff --git a/shared_model/backend/protobuf/batch_meta.hpp b/shared_model/backend/protobuf/batch_meta.hpp index 3ca732a9e8..6e7e2547b6 100644 --- a/shared_model/backend/protobuf/batch_meta.hpp +++ b/shared_model/backend/protobuf/batch_meta.hpp @@ -8,6 +8,7 @@ #include #include "backend/protobuf/common_objects/trivial_proto.hpp" +#include "cryptography/hash.hpp" #include "interfaces/common_objects/types.hpp" #include "interfaces/iroha_internal/batch_meta.hpp" #include "transaction.pb.h" @@ -30,13 +31,13 @@ namespace shared_model { ->index(); return static_cast(which); }()}, - reduced_hashes_{ - boost::accumulate(proto_->reduced_hashes(), - ReducedHashesType{}, - [](auto &&acc, const auto &hash) { - acc.emplace_back(hash); - return std::forward(acc); - })} {} + reduced_hashes_{boost::accumulate( + proto_->reduced_hashes(), + ReducedHashesType{}, + [](auto &&acc, const auto &hash) { + acc.emplace_back(crypto::Hash::fromHexString(hash)); + return std::forward(acc); + })} {} BatchMeta(const BatchMeta &o) : BatchMeta(o.proto_) {} diff --git a/shared_model/backend/protobuf/commands/impl/proto_add_signatory.cpp b/shared_model/backend/protobuf/commands/impl/proto_add_signatory.cpp index 3834835aed..1bf6350fdf 100644 --- a/shared_model/backend/protobuf/commands/impl/proto_add_signatory.cpp +++ b/shared_model/backend/protobuf/commands/impl/proto_add_signatory.cpp @@ -4,6 +4,7 @@ */ #include "backend/protobuf/commands/proto_add_signatory.hpp" +#include "cryptography/hash.hpp" namespace shared_model { namespace proto { @@ -12,7 +13,7 @@ namespace shared_model { AddSignatory::AddSignatory(CommandType &&command) : CopyableProto(std::forward(command)), add_signatory_{proto_->add_signatory()}, - pubkey_{add_signatory_.public_key()} {} + pubkey_{crypto::Hash::fromHexString(add_signatory_.public_key())} {} template AddSignatory::AddSignatory(AddSignatory::TransportType &); template AddSignatory::AddSignatory(const AddSignatory::TransportType &); diff --git a/shared_model/backend/protobuf/commands/impl/proto_create_account.cpp b/shared_model/backend/protobuf/commands/impl/proto_create_account.cpp index 297fde460e..e37849e1f1 100644 --- a/shared_model/backend/protobuf/commands/impl/proto_create_account.cpp +++ b/shared_model/backend/protobuf/commands/impl/proto_create_account.cpp @@ -4,6 +4,7 @@ */ #include "backend/protobuf/commands/proto_create_account.hpp" +#include "cryptography/hash.hpp" namespace shared_model { namespace proto { @@ -12,7 +13,7 @@ namespace shared_model { CreateAccount::CreateAccount(CommandType &&command) : CopyableProto(std::forward(command)), create_account_{proto_->create_account()}, - pubkey_{create_account_.public_key()} {} + pubkey_{crypto::Hash::fromHexString(create_account_.public_key())} {} template CreateAccount::CreateAccount(CreateAccount::TransportType &); template CreateAccount::CreateAccount(const CreateAccount::TransportType &); diff --git a/shared_model/backend/protobuf/commands/impl/proto_remove_signatory.cpp b/shared_model/backend/protobuf/commands/impl/proto_remove_signatory.cpp index af4b88ba6d..e59b2f853d 100644 --- a/shared_model/backend/protobuf/commands/impl/proto_remove_signatory.cpp +++ b/shared_model/backend/protobuf/commands/impl/proto_remove_signatory.cpp @@ -4,6 +4,7 @@ */ #include "backend/protobuf/commands/proto_remove_signatory.hpp" +#include "cryptography/hash.hpp" namespace shared_model { namespace proto { @@ -12,7 +13,7 @@ namespace shared_model { RemoveSignatory::RemoveSignatory(CommandType &&command) : CopyableProto(std::forward(command)), remove_signatory_{proto_->remove_signatory()}, - pubkey_{remove_signatory_.public_key()} {} + pubkey_{crypto::Hash::fromHexString(remove_signatory_.public_key())} {} template RemoveSignatory::RemoveSignatory(RemoveSignatory::TransportType &); template RemoveSignatory::RemoveSignatory( diff --git a/shared_model/backend/protobuf/common_objects/peer.hpp b/shared_model/backend/protobuf/common_objects/peer.hpp index 7710c43bb2..62bcf85409 100644 --- a/shared_model/backend/protobuf/common_objects/peer.hpp +++ b/shared_model/backend/protobuf/common_objects/peer.hpp @@ -8,6 +8,7 @@ #include "backend/protobuf/common_objects/trivial_proto.hpp" #include "backend/protobuf/util.hpp" +#include "cryptography/hash.hpp" #include "cryptography/public_key.hpp" #include "interfaces/common_objects/peer.hpp" #include "primitive.pb.h" @@ -34,7 +35,7 @@ namespace shared_model { } private: - const interface::types::PubkeyType public_key_{proto_->peer_key()}; + const interface::types::PubkeyType public_key_{crypto::Hash::fromHexString(proto_->peer_key())}; }; } // namespace proto } // namespace shared_model diff --git a/shared_model/backend/protobuf/common_objects/proto_common_objects_factory.hpp b/shared_model/backend/protobuf/common_objects/proto_common_objects_factory.hpp index b6f848bd2e..7c0be15135 100644 --- a/shared_model/backend/protobuf/common_objects/proto_common_objects_factory.hpp +++ b/shared_model/backend/protobuf/common_objects/proto_common_objects_factory.hpp @@ -34,7 +34,7 @@ namespace shared_model { const interface::types::PubkeyType &public_key) override { iroha::protocol::Peer peer; peer.set_address(address); - peer.set_peer_key(crypto::toBinaryString(public_key)); + peer.set_peer_key(public_key.hex()); auto proto_peer = std::make_unique(std::move(peer)); auto errors = @@ -155,8 +155,8 @@ namespace shared_model { const interface::types::PubkeyType &key, const interface::Signature::SignedType &signed_data) override { iroha::protocol::Signature signature; - signature.set_public_key(crypto::toBinaryString(key)); - signature.set_signature(crypto::toBinaryString(signed_data)); + signature.set_public_key(key.hex()); + signature.set_signature(signed_data.hex()); auto proto_singature = std::make_unique(std::move(signature)); diff --git a/shared_model/backend/protobuf/common_objects/signature.hpp b/shared_model/backend/protobuf/common_objects/signature.hpp index 826f6f709f..266684fbef 100644 --- a/shared_model/backend/protobuf/common_objects/signature.hpp +++ b/shared_model/backend/protobuf/common_objects/signature.hpp @@ -35,9 +35,9 @@ namespace shared_model { } private: - const PublicKeyType public_key_{proto_->public_key()}; + const PublicKeyType public_key_{PublicKeyType::fromHexString(proto_->public_key())}; - const SignedType signed_{proto_->signature()}; + const SignedType signed_{SignedType::fromHexString(proto_->signature())}; }; } // namespace proto } // namespace shared_model diff --git a/shared_model/backend/protobuf/impl/block.cpp b/shared_model/backend/protobuf/impl/block.cpp index 639468075c..6a4f4bb0ab 100644 --- a/shared_model/backend/protobuf/impl/block.cpp +++ b/shared_model/backend/protobuf/impl/block.cpp @@ -6,12 +6,10 @@ #include "backend/protobuf/block.hpp" #include -#include "backend/protobuf/common_objects/noncopyable_proto.hpp" #include "backend/protobuf/common_objects/signature.hpp" #include "backend/protobuf/transaction.hpp" #include "backend/protobuf/util.hpp" -#include "block.pb.h" -#include "interfaces/common_objects/types.hpp" +#include "common/byteutils.hpp" namespace shared_model { namespace proto { @@ -34,7 +32,8 @@ namespace shared_model { interface::types::BlobType blob_{[this] { return makeBlob(proto_); }()}; interface::types::HashType prev_hash_{[this] { - return interface::types::HashType(proto_.payload().prev_block_hash()); + return interface::types::HashType( + crypto::Hash::fromHexString(proto_.payload().prev_block_hash())); }()}; SignatureSetType signatures_{[this] { @@ -51,7 +50,8 @@ namespace shared_model { std::vector hashes; for (const auto &hash : *payload_.mutable_rejected_transactions_hashes()) { - hashes.emplace_back(shared_model::crypto::Hash(hash)); + hashes.emplace_back( + shared_model::crypto::Hash::fromHexString(hash)); } return hashes; }()}; @@ -103,8 +103,8 @@ namespace shared_model { } auto sig = impl_->proto_.add_signatures(); - sig->set_signature(crypto::toBinaryString(signed_blob)); - sig->set_public_key(crypto::toBinaryString(public_key)); + sig->set_signature(signed_blob.hex()); + sig->set_public_key(public_key.hex()); impl_->signatures_ = [this] { auto signatures = impl_->proto_.signatures() diff --git a/shared_model/backend/protobuf/impl/proto_block_factory.cpp b/shared_model/backend/protobuf/impl/proto_block_factory.cpp index 36b1b2cab1..9c8d747cd8 100644 --- a/shared_model/backend/protobuf/impl/proto_block_factory.cpp +++ b/shared_model/backend/protobuf/impl/proto_block_factory.cpp @@ -28,7 +28,7 @@ ProtoBlockFactory::unsafeCreateBlock( iroha::protocol::Block_v1 block; auto *block_payload = block.mutable_payload(); block_payload->set_height(height); - block_payload->set_prev_block_hash(crypto::toBinaryString(prev_hash)); + block_payload->set_prev_block_hash(prev_hash.hex()); block_payload->set_created_time(created_time); // set accepted transactions @@ -44,7 +44,7 @@ ProtoBlockFactory::unsafeCreateBlock( [block_payload](const auto &hash) { auto *next_hash = block_payload->add_rejected_transactions_hashes(); - (*next_hash) = crypto::toBinaryString(hash); + (*next_hash) = hash.hex(); }); return std::make_unique(std::move(block)); diff --git a/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp b/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp index b9ee917731..653c425e08 100644 --- a/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp +++ b/shared_model/backend/protobuf/impl/proto_query_response_factory.cpp @@ -176,8 +176,7 @@ shared_model::proto::ProtoQueryResponseFactory::createSignatoriesResponse( iroha::protocol::SignatoriesResponse *protocol_specific_response = protocol_query_response.mutable_signatories_response(); for (const auto &key : signatories) { - const auto &blob = key.blob(); - protocol_specific_response->add_keys(blob.data(), blob.size()); + protocol_specific_response->add_keys(key.hex()); } }, query_hash); diff --git a/shared_model/backend/protobuf/impl/proto_tx_status_factory.cpp b/shared_model/backend/protobuf/impl/proto_tx_status_factory.cpp index e17bc2dd5a..355bffc102 100644 --- a/shared_model/backend/protobuf/impl/proto_tx_status_factory.cpp +++ b/shared_model/backend/protobuf/impl/proto_tx_status_factory.cpp @@ -21,7 +21,7 @@ namespace { ProtoTxStatusFactory::TransactionError tx_error, iroha::protocol::TxStatus status) { iroha::protocol::ToriiResponse response; - response.set_tx_hash(shared_model::crypto::toBinaryString(hash)); + response.set_tx_hash(hash.hex()); response.set_err_or_cmd_name(tx_error.cmd_name_); response.set_failed_cmd_index(tx_error.cmd_index_); response.set_error_code(tx_error.error_code_); diff --git a/shared_model/backend/protobuf/impl/transaction.cpp b/shared_model/backend/protobuf/impl/transaction.cpp index 329d0691a7..49ac7ebe6e 100644 --- a/shared_model/backend/protobuf/impl/transaction.cpp +++ b/shared_model/backend/protobuf/impl/transaction.cpp @@ -122,8 +122,8 @@ namespace shared_model { } auto sig = impl_->proto_->add_signatures(); - sig->set_signature(crypto::toBinaryString(signed_blob)); - sig->set_public_key(crypto::toBinaryString(public_key)); + sig->set_signature(signed_blob.hex()); + sig->set_public_key(public_key.hex()); impl_->signatures_ = [this] { auto signatures = impl_->proto_->signatures() diff --git a/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp b/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp index b4f1f73fa3..b3ec09f531 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_blocks_query.cpp @@ -59,8 +59,8 @@ namespace shared_model { } auto sig = proto_->mutable_signature(); - sig->set_signature(crypto::toBinaryString(signed_blob)); - sig->set_public_key(crypto::toBinaryString(public_key)); + sig->set_signature(signed_blob.hex()); + sig->set_public_key(public_key.hex()); // TODO: nickaleks IR-120 12.12.2018 remove set signatures_.emplace(proto_->signature()); return true; diff --git a/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp b/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp index 58ffbd0f12..91906dbad1 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_get_transactions.cpp @@ -14,12 +14,12 @@ namespace shared_model { : CopyableProto(std::forward(query)), get_transactions_{proto_->payload().get_transactions()}, transaction_hashes_{ - boost::accumulate(get_transactions_.tx_hashes(), - TransactionHashesType{}, - [](auto &&acc, const auto &hash) { - acc.emplace_back(hash); - return std::forward(acc); - })} {} + boost::accumulate(get_transactions_.tx_hashes(), + TransactionHashesType{}, + [](auto &&acc, const auto &hash) { + acc.push_back(crypto::Hash::fromHexString(hash)); + return std::forward(acc); + })} {} template GetTransactions::GetTransactions(GetTransactions::TransportType &); template GetTransactions::GetTransactions( diff --git a/shared_model/backend/protobuf/queries/impl/proto_query.cpp b/shared_model/backend/protobuf/queries/impl/proto_query.cpp index 791e60b677..c9bd5f5e03 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_query.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_query.cpp @@ -117,12 +117,11 @@ namespace shared_model { } auto sig = impl_->proto_.mutable_signature(); - sig->set_signature(crypto::toBinaryString(signed_blob)); - sig->set_public_key(crypto::toBinaryString(public_key)); + sig->set_signature(signed_blob.hex()); + sig->set_public_key(public_key.hex()); impl_->signatures_ = SignatureSetType{proto::Signature{*sig}}; - return true; } diff --git a/shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp b/shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp index c2673cbd39..a83e704f95 100644 --- a/shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp +++ b/shared_model/backend/protobuf/queries/impl/proto_tx_pagination_meta.cpp @@ -32,5 +32,5 @@ boost::optional TxPaginationMeta::firstTxHash() const { == TransportType::OptFirstTxHashCase::OPT_FIRST_TX_HASH_NOT_SET) { return boost::none; } - return types::HashType(proto_->first_tx_hash()); + return types::HashType::fromHexString(proto_->first_tx_hash()); } diff --git a/shared_model/backend/protobuf/query_responses/impl/proto_signatories_response.cpp b/shared_model/backend/protobuf/query_responses/impl/proto_signatories_response.cpp index e8ade96dbb..1f7edb826e 100644 --- a/shared_model/backend/protobuf/query_responses/impl/proto_signatories_response.cpp +++ b/shared_model/backend/protobuf/query_responses/impl/proto_signatories_response.cpp @@ -5,6 +5,9 @@ #include "backend/protobuf/query_responses/proto_signatories_response.hpp" +#include +#include "cryptography/hash.hpp" + namespace shared_model { namespace proto { @@ -12,8 +15,15 @@ namespace shared_model { SignatoriesResponse::SignatoriesResponse(QueryResponseType &&queryResponse) : CopyableProto(std::forward(queryResponse)), signatories_response_{proto_->signatories_response()}, - keys_{signatories_response_.keys().begin(), - signatories_response_.keys().end()} {} + keys_{[this] { + return boost::accumulate( + signatories_response_.keys(), + interface::types::PublicKeyCollectionType{}, + [](auto acc, auto key) { + acc.emplace_back(crypto::Hash::fromHexString(key)); + return acc; + }); + }()} {} template SignatoriesResponse::SignatoriesResponse( SignatoriesResponse::TransportType &); diff --git a/shared_model/backend/protobuf/transaction_responses/impl/proto_tx_response.cpp b/shared_model/backend/protobuf/transaction_responses/impl/proto_tx_response.cpp index 0c64a247da..42e7798383 100644 --- a/shared_model/backend/protobuf/transaction_responses/impl/proto_tx_response.cpp +++ b/shared_model/backend/protobuf/transaction_responses/impl/proto_tx_response.cpp @@ -60,7 +60,7 @@ namespace shared_model { const ResponseVariantType ivariant_{variant_}; // stub hash - const crypto::Hash hash_{proto_.tx_hash()}; + const crypto::Hash hash_ = crypto::Hash::fromHexString(proto_.tx_hash()); }; TransactionResponse::TransactionResponse(const TransactionResponse &r) diff --git a/shared_model/bindings/client_api.cpp b/shared_model/bindings/client_api.cpp index df44d91ca4..72390b5e8e 100644 --- a/shared_model/bindings/client_api.cpp +++ b/shared_model/bindings/client_api.cpp @@ -70,8 +70,8 @@ namespace shared_model { crypto::CryptoSigner<>::sign(proto::makeBlob(tx.payload()), key); auto sig = tx.add_signatures(); - sig->set_signature(crypto::toBinaryString(signature)); - sig->set_public_key(crypto::toBinaryString(key.publicKey())); + sig->set_signature(signature.hex()); + sig->set_public_key(key.publicKey().hex()); return boost::make_optional(tx); }; if (s) { @@ -87,8 +87,8 @@ namespace shared_model { crypto::CryptoSigner<>::sign(proto::makeBlob(qry.payload()), key); auto sig = qry.mutable_signature(); - sig->set_signature(crypto::toBinaryString(signature)); - sig->set_public_key(crypto::toBinaryString(key.publicKey())); + sig->set_signature(signature.hex()); + sig->set_public_key(key.publicKey().hex()); return boost::make_optional(qry); }; if (s) { diff --git a/shared_model/builders/protobuf/builder_templates/query_template.hpp b/shared_model/builders/protobuf/builder_templates/query_template.hpp index a27d5efd02..f3d61fb72e 100644 --- a/shared_model/builders/protobuf/builder_templates/query_template.hpp +++ b/shared_model/builders/protobuf/builder_templates/query_template.hpp @@ -87,7 +87,7 @@ namespace shared_model { boost::none) { page_meta_payload->set_page_size(page_size); if (first_hash) { - page_meta_payload->set_first_tx_hash(toBinaryString(*first_hash)); + page_meta_payload->set_first_tx_hash(first_hash->hex()); } } @@ -210,7 +210,7 @@ namespace shared_model { return queryField([&](auto proto_query) { auto query = proto_query->mutable_get_transactions(); boost::for_each(hashes, [&query](const auto &hash) { - query->add_tx_hashes(toBinaryString(hash)); + query->add_tx_hashes(hash.hex()); }); }); } diff --git a/shared_model/builders/protobuf/builder_templates/transaction_template.hpp b/shared_model/builders/protobuf/builder_templates/transaction_template.hpp index 58ce7650eb..1fe5018873 100644 --- a/shared_model/builders/protobuf/builder_templates/transaction_template.hpp +++ b/shared_model/builders/protobuf/builder_templates/transaction_template.hpp @@ -108,7 +108,7 @@ namespace shared_model { type)); for (const auto &hash : hashes) { tx.mutable_payload()->mutable_batch()->add_reduced_hashes( - crypto::toBinaryString(hash)); + hash.hex()); } }); } @@ -141,7 +141,7 @@ namespace shared_model { auto command = proto_command->mutable_add_peer(); auto peer = command->mutable_peer(); peer->set_address(address); - peer->set_peer_key(crypto::toBinaryString(peer_key)); + peer->set_peer_key(peer_key.hex()); }); } @@ -150,7 +150,7 @@ namespace shared_model { return addCommand([&](auto proto_command) { auto command = proto_command->mutable_add_signatory(); command->set_account_id(account_id); - command->set_public_key(crypto::toBinaryString(public_key)); + command->set_public_key(public_key.hex()); }); } @@ -160,7 +160,7 @@ namespace shared_model { return addCommand([&](auto proto_command) { auto command = proto_command->mutable_remove_signatory(); command->set_account_id(account_id); - command->set_public_key(crypto::toBinaryString(public_key)); + command->set_public_key(public_key.hex()); }); } @@ -192,7 +192,7 @@ namespace shared_model { auto command = proto_command->mutable_create_account(); command->set_account_name(account_name); command->set_domain_id(domain_id); - command->set_public_key(crypto::toBinaryString(main_pubkey)); + command->set_public_key(main_pubkey.hex()); }); } diff --git a/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp b/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp index 96aea5b7da..0ea5d32d00 100644 --- a/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp +++ b/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp @@ -99,7 +99,7 @@ namespace shared_model { TransactionStatusBuilder TransactionStatusBuilder::txHash( const crypto::Hash &hash) { TransactionStatusBuilder copy(*this); - copy.tx_response_.set_tx_hash(crypto::toBinaryString(hash)); + copy.tx_response_.set_tx_hash(hash.hex()); return copy; } diff --git a/shared_model/cryptography/model_impl/private_key.cpp b/shared_model/cryptography/model_impl/private_key.cpp index 9dd2974d8f..40a6dd6079 100644 --- a/shared_model/cryptography/model_impl/private_key.cpp +++ b/shared_model/cryptography/model_impl/private_key.cpp @@ -17,8 +17,6 @@ #include "cryptography/private_key.hpp" -#include "utils/string_builder.hpp" - namespace shared_model { namespace crypto { diff --git a/shared_model/cryptography/model_impl/signed.cpp b/shared_model/cryptography/model_impl/signed.cpp index f84cf4eebb..91b0c3e09c 100644 --- a/shared_model/cryptography/model_impl/signed.cpp +++ b/shared_model/cryptography/model_impl/signed.cpp @@ -32,5 +32,7 @@ namespace shared_model { Signed::Signed(const std::string &blob) : Blob(blob) {} Signed::Signed(const Bytes &blob) : Blob(blob) {} + + Signed::Signed(const Blob &blob) : Blob(blob) {} } // namespace crypto } // namespace shared_model diff --git a/shared_model/cryptography/signed.hpp b/shared_model/cryptography/signed.hpp index 849248c80c..7974365d2f 100644 --- a/shared_model/cryptography/signed.hpp +++ b/shared_model/cryptography/signed.hpp @@ -32,6 +32,8 @@ namespace shared_model { explicit Signed(const Bytes &blob); + explicit Signed(const Blob &blob); + std::string toString() const override; }; } // namespace crypto diff --git a/shared_model/schema/block.proto b/shared_model/schema/block.proto index d70ef64ecb..6a415ad1aa 100644 --- a/shared_model/schema/block.proto +++ b/shared_model/schema/block.proto @@ -15,13 +15,13 @@ message Block_v1 { uint32 tx_number = 2; ///< The number of accepted transactions inside. ///< Maximum 16384 or 2^14. uint64 height = 3; ///< The current block number in a ledger. - bytes prev_block_hash = 4; ///< Previous block hash. + string prev_block_hash = 4; ///< Previous block hash. uint64 created_time = 5; /// Hashes of the transactions that did not pass stateful validation. /// Needed here to be able to guarantee the client that this transaction /// was not and will never be executed. - repeated bytes rejected_transactions_hashes = 6; + repeated string rejected_transactions_hashes = 6; } Payload payload = 1; diff --git a/shared_model/schema/commands.proto b/shared_model/schema/commands.proto index 02b4b01f11..4c8ab8360c 100644 --- a/shared_model/schema/commands.proto +++ b/shared_model/schema/commands.proto @@ -18,7 +18,7 @@ message AddPeer { message AddSignatory { string account_id = 1; - bytes public_key = 2; + string public_key = 2; // hex string } message CreateAsset { @@ -30,7 +30,7 @@ message CreateAsset { message CreateAccount { string account_name = 1; string domain_id = 2; - bytes public_key = 3; + string public_key = 3; // hex string } message SetAccountDetail{ @@ -46,7 +46,7 @@ message CreateDomain { message RemoveSignatory { string account_id = 1; - bytes public_key = 2; + string public_key = 2; // hex string } message SetAccountQuorum { diff --git a/shared_model/schema/endpoint.proto b/shared_model/schema/endpoint.proto index 5ad858ea58..8169351387 100644 --- a/shared_model/schema/endpoint.proto +++ b/shared_model/schema/endpoint.proto @@ -27,14 +27,14 @@ enum TxStatus { message ToriiResponse { TxStatus tx_status = 1; - bytes tx_hash = 2; + string tx_hash = 2; string err_or_cmd_name = 3; uint64 failed_cmd_index = 4; uint32 error_code = 5; } message TxStatusRequest { - bytes tx_hash = 1; + string tx_hash = 1; } message TxList { diff --git a/shared_model/schema/primitive.proto b/shared_model/schema/primitive.proto index b50c7c0ad8..2e00545df8 100644 --- a/shared_model/schema/primitive.proto +++ b/shared_model/schema/primitive.proto @@ -88,11 +88,11 @@ enum GrantablePermission { } message Signature { - bytes public_key = 1; - bytes signature = 2; + string public_key = 1; + string signature = 2; } message Peer { string address = 1; - bytes peer_key = 2; + string peer_key = 2; // hex string } diff --git a/shared_model/schema/qry_responses.proto b/shared_model/schema/qry_responses.proto index 47c342bd5e..12890a05d6 100644 --- a/shared_model/schema/qry_responses.proto +++ b/shared_model/schema/qry_responses.proto @@ -78,7 +78,7 @@ message ErrorResponse { } message SignatoriesResponse { - repeated bytes keys = 1; + repeated string keys = 1; } message TransactionsResponse { diff --git a/shared_model/schema/queries.proto b/shared_model/schema/queries.proto index 69cb74ce15..cf96e54e7d 100644 --- a/shared_model/schema/queries.proto +++ b/shared_model/schema/queries.proto @@ -35,7 +35,7 @@ message GetAccountAssetTransactions { } message GetTransactions { - repeated bytes tx_hashes = 1; + repeated string tx_hashes = 1; } message GetAccountAssets { diff --git a/shared_model/schema/transaction.proto b/shared_model/schema/transaction.proto index 05742958c9..3ea54dfc02 100644 --- a/shared_model/schema/transaction.proto +++ b/shared_model/schema/transaction.proto @@ -17,7 +17,7 @@ message Transaction { } BatchType type = 1; // array of reduced hashes of all txs from the batch - repeated bytes reduced_hashes = 2; + repeated string reduced_hashes = 2; } message ReducedPayload{ repeated Command commands = 1; diff --git a/shared_model/validators/field_validator.cpp b/shared_model/validators/field_validator.cpp index 3fb352db5b..b055bf7053 100644 --- a/shared_model/validators/field_validator.cpp +++ b/shared_model/validators/field_validator.cpp @@ -237,7 +237,8 @@ namespace shared_model { ReasonsGroupType &reason, const interface::permissions::Grantable &permission) const { if (not isValid(permission)) { - reason.second.emplace_back("Provided grantable permission does not exist"); + reason.second.emplace_back( + "Provided grantable permission does not exist"); } } diff --git a/test/framework/integration_framework/integration_test_framework.cpp b/test/framework/integration_framework/integration_test_framework.cpp index ed7418e49c..0f2bf86e42 100644 --- a/test/framework/integration_framework/integration_test_framework.cpp +++ b/test/framework/integration_framework/integration_test_framework.cpp @@ -364,7 +364,7 @@ namespace integration_framework { std::function validation) { iroha::protocol::TxStatusRequest request; - request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); + request.set_tx_hash(hash.hex()); iroha::protocol::ToriiResponse response; command_client_.Status(request, response); validation(shared_model::proto::TransactionResponse(std::move(response))); diff --git a/test/module/iroha-cli/client_test.cpp b/test/module/iroha-cli/client_test.cpp index 83622de5aa..797044909f 100644 --- a/test/module/iroha-cli/client_test.cpp +++ b/test/module/iroha-cli/client_test.cpp @@ -270,7 +270,7 @@ TEST_F(ClientServerTest, SendTxWhenStatelessInvalid) { iroha_cli::CliClient::OK); auto getAnswer = [&]() { return iroha_cli::CliClient(ip, port) - .getTxStatus(shared_model::crypto::toBinaryString(shm_tx.hash())) + .getTxStatus(shm_tx.hash().hex()) .answer; }; decltype(getAnswer()) answer; @@ -336,10 +336,7 @@ TEST_F(ClientServerTest, SendTxWhenStatefulInvalid) { iroha::simulator::VerifiedProposalCreatorEvent{ verified_proposal_and_errors, round}); - auto getAnswer = [&]() { - return client.getTxStatus(shared_model::crypto::toBinaryString(tx.hash())) - .answer; - }; + auto getAnswer = [&]() { return client.getTxStatus(tx.hash().hex()).answer; }; decltype(getAnswer()) answer; auto read_attempt_counter(status_read_attempts); do { diff --git a/test/module/irohad/common/raw_block_loader_test.cpp b/test/module/irohad/common/raw_block_loader_test.cpp index d7fc96ba0d..f704d8c39d 100644 --- a/test/module/irohad/common/raw_block_loader_test.cpp +++ b/test/module/irohad/common/raw_block_loader_test.cpp @@ -24,7 +24,7 @@ TEST(BlockLoaderTest, BlockLoaderJsonParsing) { "payload": { "transactions": [], "height": 1, - "prev_block_hash": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=", + "prev_block_hash": "0101010101010101010101010101010101010101010101010101010101010101", "created_time": 0 }, "signatures": [] diff --git a/test/module/irohad/consensus/yac/network_test.cpp b/test/module/irohad/consensus/yac/network_test.cpp index bd16b66b09..751928e244 100644 --- a/test/module/irohad/consensus/yac/network_test.cpp +++ b/test/module/irohad/consensus/yac/network_test.cpp @@ -61,6 +61,7 @@ namespace iroha { std::unique_ptr server; std::mutex mtx; std::condition_variable cv; + shared_model::crypto::PublicKey pubkey = shared_model::crypto::PublicKey{""}; }; /** diff --git a/test/module/irohad/consensus/yac/yac_block_storage_test.cpp b/test/module/irohad/consensus/yac/yac_block_storage_test.cpp index 225c3a566e..e555903ab2 100644 --- a/test/module/irohad/consensus/yac/yac_block_storage_test.cpp +++ b/test/module/irohad/consensus/yac/yac_block_storage_test.cpp @@ -28,10 +28,10 @@ class YacBlockStorageTest : public ::testing::Test { hash = YacHash(iroha::consensus::Round{1, 1}, "proposal", "commit"); number_of_peers = 4; storage = YacBlockStorage(hash, number_of_peers); - valid_votes = {create_vote(hash, "one"), - create_vote(hash, "two"), - create_vote(hash, "three"), - create_vote(hash, "four")}; + valid_votes = {createVote(hash, "one"), + createVote(hash, "two"), + createVote(hash, "three"), + createVote(hash, "four")}; } }; diff --git a/test/module/irohad/consensus/yac/yac_common_test.cpp b/test/module/irohad/consensus/yac/yac_common_test.cpp index fbb87c91a1..b2eb98d6ea 100644 --- a/test/module/irohad/consensus/yac/yac_common_test.cpp +++ b/test/module/irohad/consensus/yac/yac_common_test.cpp @@ -19,14 +19,14 @@ TEST(YacCommonTest, SameProposalTest) { log_->info("-----------| Verify ok and fail cases |-----------"); YacHash hash(Round{1, 1}, "proposal", "commit"); - std::vector votes{create_vote(hash, "two"), - create_vote(hash, "three"), - create_vote(hash, "four")}; + std::vector votes{createVote(hash, "two"), + createVote(hash, "three"), + createVote(hash, "four")}; ASSERT_TRUE(sameKeys(votes)); votes.push_back( - create_vote(YacHash(Round{1, 2}, "not-proposal", "commit"), "five")); + createVote(YacHash(Round{1, 2}, "not-proposal", "commit"), "five")); ASSERT_FALSE(sameKeys(votes)); } @@ -34,13 +34,13 @@ TEST(YacCommonTest, getProposalHashTest) { log_->info("-----------| Verify ok and fail cases |-----------"); YacHash hash(Round{1, 1}, "proposal", "commit"); - std::vector votes{create_vote(hash, "two"), - create_vote(hash, "three"), - create_vote(hash, "four")}; + std::vector votes{createVote(hash, "two"), + createVote(hash, "three"), + createVote(hash, "four")}; ASSERT_EQ(hash.vote_round, getKey(votes).value()); votes.push_back( - create_vote(YacHash(Round{1, 2}, "not-proposal", "commit"), "five")); + createVote(YacHash(Round{1, 2}, "not-proposal", "commit"), "five")); ASSERT_FALSE(getKey(votes)); } diff --git a/test/module/irohad/consensus/yac/yac_mocks.hpp b/test/module/irohad/consensus/yac/yac_mocks.hpp index d461e233cd..db0c7c4a22 100644 --- a/test/module/irohad/consensus/yac/yac_mocks.hpp +++ b/test/module/irohad/consensus/yac/yac_mocks.hpp @@ -62,7 +62,7 @@ namespace iroha { return sig; } - VoteMessage create_vote(YacHash hash, std::string pub_key) { + VoteMessage createVote(YacHash hash, std::string pub_key) { VoteMessage vote; vote.hash = hash; vote.signature = createSig(pub_key); diff --git a/test/module/irohad/consensus/yac/yac_proposal_storage_test.cpp b/test/module/irohad/consensus/yac/yac_proposal_storage_test.cpp index f5d93afd54..7af6e0a541 100644 --- a/test/module/irohad/consensus/yac/yac_proposal_storage_test.cpp +++ b/test/module/irohad/consensus/yac/yac_proposal_storage_test.cpp @@ -30,7 +30,7 @@ class YacProposalStorageTest : public ::testing::Test { valid_votes = [this]() { std::vector votes; for (auto i = 0u; i < number_of_peers; ++i) { - votes.push_back(create_vote(hash, std::to_string(i))); + votes.push_back(createVote(hash, std::to_string(i))); } return votes; }(); @@ -83,13 +83,13 @@ TEST_F(YacProposalStorageTest, YacProposalStorageWhenRejectCase) { "other_commit"); for (auto i = 0; i < 2; ++i) { auto answer = storage.insert( - create_vote(other_hash, std::to_string(valid_votes.size() + 1 + i))); + createVote(other_hash, std::to_string(valid_votes.size() + 1 + i))); ASSERT_EQ(boost::none, answer); } // insert more one for other hash auto answer = storage.insert( - create_vote(other_hash, std::to_string(2 * valid_votes.size() + 1))); + createVote(other_hash, std::to_string(2 * valid_votes.size() + 1))); ASSERT_NE(boost::none, answer); ASSERT_EQ(6, boost::get(*answer).votes.size()); } diff --git a/test/module/irohad/consensus/yac/yac_rainy_day_test.cpp b/test/module/irohad/consensus/yac/yac_rainy_day_test.cpp index 9e70decfff..e1b0973b7c 100644 --- a/test/module/irohad/consensus/yac/yac_rainy_day_test.cpp +++ b/test/module/irohad/consensus/yac/yac_rainy_day_test.cpp @@ -42,10 +42,10 @@ TEST_F(YacTest, InvalidCaseWhenNotReceiveSupermajority) { yac->vote(hash1, my_order.value()); for (auto i = 0; i < 2; ++i) { - yac->onState({create_vote(hash1, std::to_string(i))}); + yac->onState({createVote(hash1, std::to_string(i))}); }; for (auto i = 2; i < 4; ++i) { - yac->onState({create_vote(hash2, std::to_string(i))}); + yac->onState({createVote(hash2, std::to_string(i))}); }; } @@ -75,10 +75,10 @@ TEST_F(YacTest, InvalidCaseWhenDoesNotVerify) { YacHash hash2(iroha::consensus::Round{1, 1}, "proposal_hash", "block_hash2"); for (auto i = 0; i < 2; ++i) { - yac->onState({create_vote(hash1, std::to_string(i))}); + yac->onState({createVote(hash1, std::to_string(i))}); }; for (auto i = 2; i < 4; ++i) { - yac->onState({create_vote(hash2, std::to_string(i))}); + yac->onState({createVote(hash2, std::to_string(i))}); }; } @@ -117,12 +117,12 @@ TEST_F(YacTest, ValidCaseWhenReceiveOnVoteAfterReject) { for (size_t i = 0; i < peers_number / 2; ++i) { auto peer = my_order->getPeers().at(i); auto pubkey = shared_model::crypto::toBinaryString(peer->pubkey()); - votes.push_back(create_vote(hash1, pubkey)); + votes.push_back(createVote(hash1, pubkey)); }; for (size_t i = peers_number / 2; i < peers_number - 1; ++i) { auto peer = my_order->getPeers().at(i); auto pubkey = shared_model::crypto::toBinaryString(peer->pubkey()); - votes.push_back(create_vote(hash2, pubkey)); + votes.push_back(createVote(hash2, pubkey)); }; for (const auto &vote : votes) { @@ -132,5 +132,5 @@ TEST_F(YacTest, ValidCaseWhenReceiveOnVoteAfterReject) { yac->onState(votes); auto peer = my_order->getPeers().back(); auto pubkey = shared_model::crypto::toBinaryString(peer->pubkey()); - yac->onState({create_vote(hash1, pubkey)}); + yac->onState({createVote(hash1, pubkey)}); } diff --git a/test/module/irohad/consensus/yac/yac_simple_cold_case_test.cpp b/test/module/irohad/consensus/yac/yac_simple_cold_case_test.cpp index e6e0d2a956..16051d9c4d 100644 --- a/test/module/irohad/consensus/yac/yac_simple_cold_case_test.cpp +++ b/test/module/irohad/consensus/yac/yac_simple_cold_case_test.cpp @@ -119,7 +119,7 @@ TEST_F(YacTest, YacWhenColdStartAndAchieveCommitMessage) { auto committed_peer = default_peers.at(0); auto msg = CommitMessage(std::vector{}); for (size_t i = 0; i < default_peers.size(); ++i) { - msg.votes.push_back(create_vote(propagated_hash, std::to_string(i))); + msg.votes.push_back(createVote(propagated_hash, std::to_string(i))); } network->notification->onState(msg.votes); @@ -148,7 +148,7 @@ TEST_F(YacTest, PropagateCommitBeforeNotifyingSubscribersApplyVote) { }); for (size_t i = 0; i < default_peers.size(); ++i) { - yac->onState({create_vote(YacHash{}, std::to_string(i))}); + yac->onState({createVote(YacHash{}, std::to_string(i))}); } // verify that on_commit subscribers are notified @@ -181,16 +181,16 @@ TEST_F(YacTest, PropagateCommitBeforeNotifyingSubscribersApplyReject) { auto f = (default_peers.size() - 1) / 3; for (size_t i = 0; i < 2 * f; ++i) { - auto vote = create_vote(YacHash{}, std::to_string(i)); + auto vote = createVote(YacHash{}, std::to_string(i)); yac->onState({vote}); commit.push_back(vote); } - auto vote = create_vote(YacHash{}, std::to_string(2 * f + 1)); + auto vote = createVote(YacHash{}, std::to_string(2 * f + 1)); RejectMessage reject( {vote, - create_vote(YacHash(iroha::consensus::Round{1, 1}, "", "my_block"), - std::to_string(2 * f + 2))}); + createVote(YacHash(iroha::consensus::Round{1, 1}, "", "my_block"), + std::to_string(2 * f + 2))}); commit.push_back(vote); yac->onState(reject.votes); diff --git a/test/module/irohad/consensus/yac/yac_sunny_day_test.cpp b/test/module/irohad/consensus/yac/yac_sunny_day_test.cpp index 52d676eed8..b00d3884aa 100644 --- a/test/module/irohad/consensus/yac/yac_sunny_day_test.cpp +++ b/test/module/irohad/consensus/yac/yac_sunny_day_test.cpp @@ -43,7 +43,7 @@ TEST_F(YacTest, ValidCaseWhenReceiveSupermajority) { for (auto i = 0; i < 3; ++i) { auto peer = my_peers.at(i); auto pubkey = shared_model::crypto::toBinaryString(peer->pubkey()); - yac->onState({create_vote(my_hash, pubkey)}); + yac->onState({createVote(my_hash, pubkey)}); }; } @@ -74,7 +74,7 @@ TEST_F(YacTest, ValidCaseWhenReceiveCommit) { auto votes = std::vector(); for (auto i = 0; i < 4; ++i) { - votes.push_back(create_vote(my_hash, std::to_string(i))); + votes.push_back(createVote(my_hash, std::to_string(i))); }; yac->onState(votes); ASSERT_TRUE(wrapper.validate()); @@ -116,13 +116,13 @@ TEST_F(YacTest, ValidCaseWhenReceiveCommitTwice) { // first commit for (auto i = 0; i < 3; ++i) { - votes.push_back(create_vote(my_hash, std::to_string(i))); + votes.push_back(createVote(my_hash, std::to_string(i))); }; yac->onState(votes); // second commit for (auto i = 1; i < 4; ++i) { - votes.push_back(create_vote(my_hash, std::to_string(i))); + votes.push_back(createVote(my_hash, std::to_string(i))); }; yac->onState(votes); @@ -153,7 +153,7 @@ TEST_F(YacTest, ValidCaseWhenSoloConsensus) { yac->vote(my_hash, my_order.value()); - auto vote_message = create_vote(my_hash, std::to_string(0)); + auto vote_message = createVote(my_hash, std::to_string(0)); yac->onState({vote_message}); @@ -185,7 +185,7 @@ TEST_F(YacTest, ValidCaseWhenVoteAfterCommit) { std::vector votes; for (auto i = 0; i < 3; ++i) { - votes.push_back(create_vote(my_hash, std::to_string(i))); + votes.push_back(createVote(my_hash, std::to_string(i))); }; yac->onState(votes); diff --git a/test/module/irohad/consensus/yac/yac_unknown_peer_test.cpp b/test/module/irohad/consensus/yac/yac_unknown_peer_test.cpp index 6ebb2ad4a0..c4e2a2e340 100644 --- a/test/module/irohad/consensus/yac/yac_unknown_peer_test.cpp +++ b/test/module/irohad/consensus/yac/yac_unknown_peer_test.cpp @@ -68,7 +68,7 @@ TEST_F(YacTest, UnknownVoteAfterCommit) { std::vector votes; for (auto i = 0; i < 3; ++i) { - votes.push_back(create_vote(my_hash, std::to_string(i))); + votes.push_back(createVote(my_hash, std::to_string(i))); }; yac->onState(votes); diff --git a/test/module/irohad/model/converters/pb_commands_test.cpp b/test/module/irohad/model/converters/pb_commands_test.cpp index 4ad27dbec4..ec18b69f30 100644 --- a/test/module/irohad/model/converters/pb_commands_test.cpp +++ b/test/module/irohad/model/converters/pb_commands_test.cpp @@ -86,7 +86,7 @@ TEST(CommandTest, add_peer) { auto factory = iroha::model::converters::PbCommandFactory(); auto proto_add_peer = factory.serializeAddPeer(orig_addPeer); - auto serial_addPeer = factory.deserializeAddPeer(proto_add_peer); + const auto& serial_addPeer = factory.deserializeAddPeer(proto_add_peer); ASSERT_EQ(orig_addPeer, serial_addPeer); command_converter_test(orig_addPeer); diff --git a/test/module/irohad/multi_sig_transactions/mst_test_helpers.hpp b/test/module/irohad/multi_sig_transactions/mst_test_helpers.hpp index 75bf36987e..e875aa9ed0 100644 --- a/test/module/irohad/multi_sig_transactions/mst_test_helpers.hpp +++ b/test/module/irohad/multi_sig_transactions/mst_test_helpers.hpp @@ -107,7 +107,8 @@ inline auto makePeer(const std::string &address, const std::string &pub_key) { return std::make_shared( shared_model::proto::PeerBuilder() .address(address) - .pubkey(shared_model::crypto::PublicKey(pub_key)) + .pubkey(shared_model::crypto::PublicKey( + shared_model::crypto::Hash::fromHexString(pub_key))) .build()); } diff --git a/test/module/irohad/torii/torii_queries_test.cpp b/test/module/irohad/torii/torii_queries_test.cpp index e8d205f874..8980f20d3d 100644 --- a/test/module/irohad/torii/torii_queries_test.cpp +++ b/test/module/irohad/torii/torii_queries_test.cpp @@ -464,8 +464,8 @@ TEST_F(ToriiQueriesTest, FindSignatoriesHasRolePermissions) { iroha::pubkey_t pubkey; std::fill(pubkey.begin(), pubkey.end(), 0x1); std::vector keys; - keys.push_back( - shared_model::interface::types::PubkeyType(pubkey.to_string())); + keys.emplace_back(shared_model::interface::types::PubkeyType::fromHexString( + pubkey.to_hexstring())); EXPECT_CALL(*wsv_query, getSignatories(creator)) .WillRepeatedly(Return(signatories)); @@ -503,7 +503,7 @@ TEST_F(ToriiQueriesTest, FindSignatoriesHasRolePermissions) { /// valid ASSERT_FALSE(response.has_error_response()); // check if fields in response are valid - ASSERT_EQ(resp_pubkey, signatories.back()); + ASSERT_EQ(resp_pubkey.toString(), signatories.back().toString()); ASSERT_EQ(model_query.hash(), shared_response.queryHash()); }); } diff --git a/test/module/irohad/torii/torii_service_test.cpp b/test/module/irohad/torii/torii_service_test.cpp index 67dfdfc53a..57792c0e4f 100644 --- a/test/module/irohad/torii/torii_service_test.cpp +++ b/test/module/irohad/torii/torii_service_test.cpp @@ -237,8 +237,7 @@ TEST_F(ToriiServiceTest, StatusWhenTxWasNotReceivedBlocking) { for (size_t i = 0; i < TimesToriiBlocking; ++i) { iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); + tx_request.set_tx_hash(tx_hashes.at(i).hex()); iroha::protocol::ToriiResponse toriiResponse; // this test does not require the fix for thread scheduling issues client.Status(tx_request, toriiResponse); @@ -305,8 +304,7 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { // check if stateless validation passed for (size_t i = 0; i < TimesToriiBlocking; ++i) { iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); + tx_request.set_tx_hash(tx_hashes.at(i).hex()); iroha::protocol::ToriiResponse toriiResponse; client2.Status(tx_request, toriiResponse); @@ -363,8 +361,7 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { // check if all transactions but the last one passed stateful validation for (size_t i = 0; i < TimesToriiBlocking - 1; ++i) { iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); + tx_request.set_tx_hash(tx_hashes.at(i).hex()); iroha::protocol::ToriiResponse toriiResponse; auto resub_counter(resubscribe_attempts); @@ -385,8 +382,7 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { // check if all transactions but the last have committed state for (size_t i = 0; i < TimesToriiBlocking - 1; ++i) { iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); + tx_request.set_tx_hash(tx_hashes.at(i).hex()); iroha::protocol::ToriiResponse toriiResponse; client4.Status(tx_request, toriiResponse); @@ -396,8 +392,7 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) { torii::CommandSyncClient client5(client4); // check if the last transaction from txs has failed stateful validation iroha::protocol::TxStatusRequest last_tx_request; - last_tx_request.set_tx_hash(shared_model::crypto::toBinaryString( - tx_hashes.at(TimesToriiBlocking - 1))); + last_tx_request.set_tx_hash(tx_hashes.at(TimesToriiBlocking - 1).hex()); iroha::protocol::ToriiResponse stful_invalid_response; client5.Status(last_tx_request, stful_invalid_response); ASSERT_EQ(stful_invalid_response.tx_status(), @@ -428,14 +423,14 @@ TEST_F(ToriiServiceTest, CheckHash) { // get statuses of transactions for (auto &hash : tx_hashes) { iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); + tx_request.set_tx_hash(hash.hex()); iroha::protocol::ToriiResponse toriiResponse; - const auto binary_hash = shared_model::crypto::toBinaryString(hash); + const auto hex_hash = hash.hex(); auto resub_counter(resubscribe_attempts); do { client.Status(tx_request, toriiResponse); - } while (toriiResponse.tx_hash() != binary_hash and --resub_counter); - ASSERT_EQ(toriiResponse.tx_hash(), binary_hash); + } while (toriiResponse.tx_hash() != hex_hash and --resub_counter); + ASSERT_EQ(toriiResponse.tx_hash(), hex_hash); } } @@ -459,7 +454,7 @@ TEST_F(ToriiServiceTest, StreamingFullPipelineTest) { .signAndAddSignature(keypair) .finish(); - std::string txhash = crypto::toBinaryString(iroha_tx.hash()); + std::string txhash = iroha_tx.hash().hex(); std::vector torii_response; // StatusStream is a blocking call and returns only when the last status @@ -495,14 +490,15 @@ TEST_F(ToriiServiceTest, StreamingFullPipelineTest) { verified_prop_notifier_.get_subscriber().on_next( iroha::simulator::VerifiedProposalCreatorEvent{validation_result, round}); - auto block = clone(proto::BlockBuilder() - .height(1) - .createdTime(iroha::time::now()) - .transactions(txs) - .prevHash(crypto::Hash(std::string(32, '0'))) - .build() - .signAndAddSignature(keypair) - .finish()); + auto block = + clone(proto::BlockBuilder() + .height(1) + .createdTime(iroha::time::now()) + .transactions(txs) + .prevHash(crypto::Hash::fromHexString(std::string(64, '0'))) + .build() + .signAndAddSignature(keypair) + .finish()); // create commit from block notifier's observable rxcpp::subjects::subject> @@ -585,7 +581,7 @@ TEST_F(ToriiServiceTest, ListOfTxs) { std::for_each( std::begin(tx_hashes), std::end(tx_hashes), [&client](auto &hash) { iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); + tx_request.set_tx_hash(hash.hex()); iroha::protocol::ToriiResponse toriiResponse; auto resub_counter(resubscribe_attempts); @@ -638,7 +634,7 @@ TEST_F(ToriiServiceTest, FailedListOfTxs) { std::for_each( std::begin(tx_hashes), std::end(tx_hashes), [&client](auto &hash) { iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); + tx_request.set_tx_hash(hash.hex()); iroha::protocol::ToriiResponse toriiResponse; auto resub_counter(resubscribe_attempts); do { diff --git a/test/module/shared_model/backend_proto/shared_proto_queries_test.cpp b/test/module/shared_model/backend_proto/shared_proto_queries_test.cpp index ab9911c8c1..ebc9b56c88 100644 --- a/test/module/shared_model/backend_proto/shared_proto_queries_test.cpp +++ b/test/module/shared_model/backend_proto/shared_proto_queries_test.cpp @@ -59,9 +59,8 @@ TEST(ProtoQueryBuilder, Builder) { keypair); auto sig = proto_query.mutable_signature(); - sig->set_public_key( - shared_model::crypto::toBinaryString(keypair.publicKey())); - sig->set_signature(shared_model::crypto::toBinaryString(signedProto)); + sig->set_public_key(keypair.publicKey().hex()); + sig->set_signature(signedProto.hex()); auto query = shared_model::proto::QueryBuilder() .createdTime(created_time) @@ -96,9 +95,8 @@ TEST(ProtoQueryBuilder, BlocksQueryBuilder) { keypair); auto sig = proto_query.mutable_signature(); - sig->set_public_key( - shared_model::crypto::toBinaryString(keypair.publicKey())); - sig->set_signature(shared_model::crypto::toBinaryString(signedProto)); + sig->set_public_key(keypair.publicKey().hex()); + sig->set_signature(signedProto.hex()); auto query = shared_model::proto::BlocksQueryBuilder() .createdTime(created_time) diff --git a/test/module/shared_model/backend_proto/shared_proto_transaction_test.cpp b/test/module/shared_model/backend_proto/shared_proto_transaction_test.cpp index cfe015a6c8..a2d4e4f97c 100644 --- a/test/module/shared_model/backend_proto/shared_proto_transaction_test.cpp +++ b/test/module/shared_model/backend_proto/shared_proto_transaction_test.cpp @@ -67,9 +67,8 @@ TEST(ProtoTransaction, Builder) { keypair); auto sig = proto_tx.add_signatures(); - sig->set_public_key( - shared_model::crypto::toBinaryString(keypair.publicKey())); - sig->set_signature(shared_model::crypto::toBinaryString(signedProto)); + sig->set_public_key(keypair.publicKey().hex()); + sig->set_signature(signedProto.hex()); auto tx = shared_model::proto::TransactionBuilder() .creatorAccountId(creator_account_id) diff --git a/test/module/shared_model/backend_proto/shared_proto_tx_response_test.cpp b/test/module/shared_model/backend_proto/shared_proto_tx_response_test.cpp index 491686b037..4379b983af 100644 --- a/test/module/shared_model/backend_proto/shared_proto_tx_response_test.cpp +++ b/test/module/shared_model/backend_proto/shared_proto_tx_response_test.cpp @@ -34,7 +34,7 @@ TEST(ProtoTxResponse, TxResponseLoad) { auto model_response = shared_model::proto::TransactionResponse(response); ASSERT_EQ(i, model_response.get().which()); ASSERT_EQ(model_response.transactionHash(), - shared_model::crypto::Hash(hash)); + shared_model::crypto::Hash::fromHexString(hash)); }); } diff --git a/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp b/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp index 55b230ddf2..a504e4dee6 100644 --- a/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp +++ b/test/module/shared_model/builders/protobuf/builder_templates/block_template.hpp @@ -88,7 +88,7 @@ namespace shared_model { for (const auto &hash : rejected_transactions_hashes) { auto *next_hash = block.mutable_payload()->add_rejected_transactions_hashes(); - (*next_hash) = shared_model::crypto::toBinaryString(hash); + (*next_hash) = hash.hex(); } }); } @@ -100,8 +100,7 @@ namespace shared_model { auto prevHash(crypto::Hash hash) const { return transform([&](auto &block) { - block.mutable_payload()->set_prev_block_hash( - crypto::toBinaryString(hash)); + block.mutable_payload()->set_prev_block_hash(hash.hex()); }); } diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp b/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp index a6d20de1b3..33a56522c0 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp @@ -42,7 +42,7 @@ namespace shared_model { PeerBuilder pubkey(const interface::types::PubkeyType &key) { PeerBuilder copy(*this); - copy.peer_.set_peer_key(shared_model::crypto::toBinaryString(key)); + copy.peer_.set_peer_key(key.hex()); return copy; } diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder.hpp b/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder.hpp index 8d58a56e77..08d4123525 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder.hpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder.hpp @@ -27,16 +27,14 @@ namespace shared_model { SignatureBuilder publicKey( const shared_model::interface::types::PubkeyType &key) { SignatureBuilder copy(*this); - copy.signature_.set_public_key( - shared_model::crypto::toBinaryString(key)); + copy.signature_.set_public_key(key.hex()); return copy; } SignatureBuilder signedData( const interface::Signature::SignedType &signed_data) { SignatureBuilder copy(*this); - copy.signature_.set_signature( - shared_model::crypto::toBinaryString(signed_data)); + copy.signature_.set_signature(signed_data.hex()); return copy; } diff --git a/test/module/shared_model/builders/protobuf/transaction_responses/proto_transaction_response_builder.cpp b/test/module/shared_model/builders/protobuf/transaction_responses/proto_transaction_response_builder.cpp index 551c17fd9c..54909f47e0 100644 --- a/test/module/shared_model/builders/protobuf/transaction_responses/proto_transaction_response_builder.cpp +++ b/test/module/shared_model/builders/protobuf/transaction_responses/proto_transaction_response_builder.cpp @@ -60,11 +60,13 @@ TYPED_TEST(ProtoTransactionStatusBuilderTest, TestStatusType) { auto expected_status = TypeParam::status; auto expected_hash = std::string(32, '1'); - auto response = (TransactionStatusBuilder().*TypeParam::member)() - .txHash(shared_model::crypto::Hash(expected_hash)) - .build(); + auto response = + (TransactionStatusBuilder().*TypeParam::member)() + .txHash(shared_model::crypto::Hash::fromHexString(expected_hash)) + .build(); - ASSERT_NO_THROW(boost::get(response.get())); + ASSERT_NO_THROW(boost::get( + response.get())); auto proto_status = response.getTransport(); ASSERT_EQ(proto_status.tx_status(), expected_status); @@ -81,7 +83,7 @@ TEST(ProtoTransactionStatusBuilderTest, SeveralObjectsFromOneBuilder) { auto expected_hash = std::string(32, '1'); auto state = TransactionStatusBuilder().notReceived().txHash( - shared_model::crypto::Hash(expected_hash)); + shared_model::crypto::Hash::fromHexString(expected_hash)); auto response1 = state.build(); auto response2 = state.build(); diff --git a/test/module/shared_model/validators/field_validator_test.cpp b/test/module/shared_model/validators/field_validator_test.cpp index 3cc8c02bed..ad36393fa6 100644 --- a/test/module/shared_model/validators/field_validator_test.cpp +++ b/test/module/shared_model/validators/field_validator_test.cpp @@ -294,7 +294,7 @@ class FieldValidatorTest : public ValidatorsTest { return {case_name, [&, address, pubkey] { this->peer.set_address(address); - this->peer.set_peer_key(pubkey); + this->peer.set_peer_key(shared_model::crypto::Hash(pubkey).hex()); }, true, ""}; @@ -385,7 +385,7 @@ class FieldValidatorTest : public ValidatorsTest { // invalid pubkey makeInvalidPeerPubkeyTestCase("invalid_peer_pubkey_length", "182.13.35.1:3040", - std::string(64, '0')), + std::string(123, '0')), makeInvalidPeerPubkeyTestCase( "invalid_peer_pubkey_empty", "182.13.35.1:3040", "") // clang-format on diff --git a/test/module/shared_model/validators/validators_fixture.hpp b/test/module/shared_model/validators/validators_fixture.hpp index 0f2115a4e8..9f7c128d9d 100644 --- a/test/module/shared_model/validators/validators_fixture.hpp +++ b/test/module/shared_model/validators/validators_fixture.hpp @@ -187,8 +187,12 @@ class ValidatorsTest : public ::testing::Test { domain_id = "ru"; detail_key = "key"; writer = "account@domain"; - public_key = std::string(public_key_size, '0'); - hash = std::string(public_key_size, '0'); + + // size of public_key and hash are twice bigger `public_key_size` because it + // is hex representation + public_key = std::string(public_key_size * 2, '0'); + hash = std::string(public_key_size * 2, '0'); + role_permission = iroha::protocol::RolePermission::can_append_role; grantable_permission = iroha::protocol::GrantablePermission::can_add_my_signatory; diff --git a/test/system/irohad_test.cpp b/test/system/irohad_test.cpp index 50fbd45e7c..88d3ea7b48 100644 --- a/test/system/irohad_test.cpp +++ b/test/system/irohad_test.cpp @@ -144,7 +144,7 @@ class IrohadTest : public AcceptanceFixture { auto tx = complete(baseTx(kAdminId).setAccountQuorum(kAdminId, 1), key_pair); - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(tx.hash())); + tx_request.set_tx_hash(tx.hash().hex()); auto client = torii::CommandSyncClient(kAddress, kPort); client.Torii(tx.getTransport()); diff --git a/test/system/irohad_test_data/genesis.block b/test/system/irohad_test_data/genesis.block index c2b476ad88..7f9ac49728 100644 --- a/test/system/irohad_test_data/genesis.block +++ b/test/system/irohad_test_data/genesis.block @@ -10,7 +10,7 @@ "addPeer":{ "peer":{ "address":"0.0.0.0:10001", - "peerKey":"vd1YQE0TFeDrJ5AsXXyOsGAsFiOPAFdz30BrwZEwiSk=" + "peerKey":"bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929" } } }, @@ -89,14 +89,14 @@ "createAccount":{ "accountName":"admin", "domainId":"domain", - "publicKey":"MToH5jhHdu2VRHcQ0V5ZFIRzzPwFKmgTF6cqafKkmRA=" + "publicKey":"313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910" } }, { "createAccount":{ "accountName":"user", "domainId":"domain", - "publicKey":"cW/lBfafGFEaGwg5Faqf9z7zbmaIGZ85WXUNs4uPS/w=" + "publicKey":"716fe505f69f18511a1b083915aa9ff73ef36e6688199f3959750db38b8f4bfc" } }, { @@ -119,7 +119,7 @@ ], "txNumber":1, "height":"1", - "prevBlockHash":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + "prevBlockHash":"0000000000000000000000000000000000000000000000000000000000000000" } } } From b8f67ae61c70996c3443a051b1416d2d1e4e7b39 Mon Sep 17 00:00:00 2001 From: Mikhail Boldyrev Date: Fri, 21 Dec 2018 12:33:24 +0300 Subject: [PATCH 25/61] New Style License Comments (#1944) Corrected and added missing licenses in cpp, hpp and CMakeLists.txt files. Signed-off-by: Mikhail Boldyrev --- iroha-cli/CMakeLists.txt | 16 ++-------------- iroha-cli/client.cpp | 16 ++-------------- iroha-cli/client.hpp | 16 ++-------------- iroha-cli/grpc_response_handler.hpp | 16 ++-------------- iroha-cli/impl/grpc_response_handler.cpp | 16 ++-------------- iroha-cli/impl/query_response_handler.cpp | 16 ++-------------- .../impl/transaction_response_handler.cpp | 16 ++-------------- iroha-cli/interactive/CMakeLists.txt | 16 ++-------------- .../interactive/impl/interactive_cli.cpp | 16 ++-------------- .../impl/interactive_common_cli.cpp | 16 ++-------------- .../impl/interactive_query_cli.cpp | 16 ++-------------- .../impl/interactive_status_cli.cpp | 16 ++-------------- iroha-cli/interactive/interactive_cli.hpp | 16 ++-------------- .../interactive/interactive_common_cli.hpp | 16 ++-------------- .../interactive/interactive_query_cli.hpp | 16 ++-------------- .../interactive/interactive_status_cli.hpp | 16 ++-------------- .../interactive_transaction_cli.hpp | 16 ++-------------- iroha-cli/main.cpp | 16 ++-------------- iroha-cli/query_response_handler.hpp | 16 ++-------------- iroha-cli/transaction_response_handler.hpp | 16 ++-------------- iroha-cli/validators.cpp | 16 ++-------------- iroha-cli/validators.hpp | 16 ++-------------- irohad/CMakeLists.txt | 13 ++----------- irohad/ametsuchi/CMakeLists.txt | 5 +++++ irohad/ametsuchi/impl/block_index.hpp | 16 ++-------------- irohad/ametsuchi/impl/peer_query_wsv.cpp | 16 ++-------------- irohad/ametsuchi/impl/peer_query_wsv.hpp | 16 ++-------------- .../ametsuchi/impl/postgres_block_index.hpp | 16 ++-------------- ...gres_ordering_service_persistent_state.cpp | 16 ++-------------- ...gres_ordering_service_persistent_state.hpp | 16 ++-------------- .../ametsuchi/impl/postgres_wsv_command.hpp | 16 ++-------------- irohad/ametsuchi/impl/postgres_wsv_query.hpp | 16 ++-------------- irohad/ametsuchi/impl/wsv_restorer_impl.cpp | 16 ++-------------- irohad/ametsuchi/impl/wsv_restorer_impl.hpp | 16 ++-------------- irohad/ametsuchi/mutable_factory.hpp | 16 ++-------------- .../ordering_service_persistent_state.hpp | 16 ++-------------- irohad/ametsuchi/temporary_factory.hpp | 16 ++-------------- irohad/ametsuchi/wsv_command.hpp | 16 ++-------------- irohad/ametsuchi/wsv_restorer.hpp | 16 ++-------------- irohad/consensus/yac/cluster_order.hpp | 16 ++-------------- irohad/consensus/yac/impl/cluster_order.cpp | 16 ++-------------- .../consensus/yac/impl/peer_orderer_impl.cpp | 16 ++-------------- .../consensus/yac/impl/peer_orderer_impl.hpp | 16 ++-------------- irohad/consensus/yac/impl/timer_impl.cpp | 16 ++-------------- irohad/consensus/yac/impl/timer_impl.hpp | 16 ++-------------- irohad/consensus/yac/messages.hpp | 16 ++-------------- .../consensus/yac/storage/impl/yac_common.cpp | 16 ++-------------- .../yac/storage/impl/yac_proposal_storage.cpp | 16 ++-------------- .../consensus/yac/storage/storage_result.hpp | 16 ++-------------- irohad/consensus/yac/storage/yac_common.hpp | 16 ++-------------- .../yac/storage/yac_proposal_storage.hpp | 16 ++-------------- irohad/consensus/yac/timer.hpp | 16 ++-------------- .../yac/transport/impl/network_impl.cpp | 16 ++-------------- .../yac/transport/impl/network_impl.hpp | 16 ++-------------- .../yac/transport/yac_network_interface.hpp | 16 ++-------------- irohad/consensus/yac/yac.hpp | 16 ++-------------- irohad/consensus/yac/yac_crypto_provider.hpp | 16 ++-------------- irohad/consensus/yac/yac_gate.hpp | 16 ++-------------- irohad/consensus/yac/yac_peer_orderer.hpp | 16 ++-------------- irohad/main/CMakeLists.txt | 16 ++-------------- irohad/main/assert_config.hpp | 16 ++-------------- irohad/main/impl/ordering_init.hpp | 16 ++-------------- irohad/main/impl/raw_block_loader.cpp | 16 ++-------------- irohad/main/irohad.cpp | 16 ++-------------- irohad/main/raw_block_loader.hpp | 16 ++-------------- irohad/model/CMakeLists.txt | 16 ++-------------- irohad/model/account.hpp | 16 ++-------------- irohad/model/account_asset.hpp | 16 ++-------------- irohad/model/asset.hpp | 16 ++-------------- irohad/model/block.hpp | 16 ++-------------- irohad/model/client.hpp | 16 ++-------------- irohad/model/command.hpp | 16 ++-------------- irohad/model/commands/add_asset_quantity.hpp | 16 ++-------------- irohad/model/commands/add_peer.hpp | 16 ++-------------- irohad/model/commands/add_signatory.hpp | 16 ++-------------- irohad/model/commands/all.hpp | 16 ++-------------- irohad/model/commands/append_role.hpp | 16 ++-------------- irohad/model/commands/create_account.hpp | 16 ++-------------- irohad/model/commands/create_asset.hpp | 16 ++-------------- irohad/model/commands/create_domain.hpp | 16 ++-------------- irohad/model/commands/create_role.hpp | 16 ++-------------- irohad/model/commands/detach_role.hpp | 16 ++-------------- irohad/model/commands/grant_permission.hpp | 16 ++-------------- irohad/model/commands/remove_signatory.hpp | 16 ++-------------- irohad/model/commands/revoke_permission.hpp | 16 ++-------------- irohad/model/commands/set_account_detail.hpp | 16 ++-------------- irohad/model/commands/set_quorum.hpp | 16 ++-------------- .../commands/subtract_asset_quantity.hpp | 16 ++-------------- irohad/model/commands/transfer_asset.hpp | 16 ++-------------- irohad/model/commit.hpp | 16 ++-------------- irohad/model/common.hpp | 16 ++-------------- irohad/model/converters/CMakeLists.txt | 16 ++-------------- .../converters/impl/json_block_factory.cpp | 16 ++-------------- .../converters/impl/json_command_factory.cpp | 16 ++-------------- irohad/model/converters/impl/json_common.cpp | 16 ++-------------- .../converters/impl/json_query_factory.cpp | 16 ++-------------- .../impl/json_transaction_factory.cpp | 16 ++-------------- .../converters/impl/pb_block_factory.cpp | 16 ++-------------- irohad/model/converters/impl/pb_common.cpp | 16 ++-------------- .../impl/pb_query_response_factory.cpp | 16 ++-------------- .../model/converters/json_block_factory.hpp | 16 ++-------------- .../model/converters/json_command_factory.hpp | 16 ++-------------- irohad/model/converters/json_common.hpp | 16 ++-------------- .../model/converters/json_query_factory.hpp | 16 ++-------------- .../converters/json_transaction_factory.hpp | 16 ++-------------- irohad/model/converters/pb_block_factory.hpp | 16 ++-------------- .../model/converters/pb_command_factory.hpp | 16 ++-------------- irohad/model/converters/pb_common.hpp | 16 ++-------------- irohad/model/converters/pb_query_factory.hpp | 16 ++-------------- .../converters/pb_query_response_factory.hpp | 16 ++-------------- .../converters/pb_transaction_factory.hpp | 16 ++-------------- irohad/model/domain.hpp | 16 ++-------------- irohad/model/generators/CMakeLists.txt | 16 ++-------------- irohad/model/generators/block_generator.hpp | 16 ++-------------- irohad/model/generators/command_generator.hpp | 16 ++-------------- .../model/generators/impl/block_generator.cpp | 16 ++-------------- .../generators/impl/command_generator.cpp | 16 ++-------------- .../model/generators/impl/query_generator.cpp | 16 ++-------------- .../generators/impl/transaction_generator.cpp | 16 ++-------------- irohad/model/generators/query_generator.hpp | 16 ++-------------- .../model/generators/signature_generator.hpp | 16 ++-------------- .../generators/transaction_generator.hpp | 16 ++-------------- irohad/model/impl/model_operators.cpp | 16 ++-------------- irohad/model/model_crypto_provider.hpp | 16 ++-------------- irohad/model/model_crypto_provider_impl.cpp | 16 ++-------------- irohad/model/model_crypto_provider_impl.hpp | 16 ++-------------- irohad/model/peer.hpp | 16 ++-------------- irohad/model/proposal.hpp | 16 ++-------------- irohad/model/queries/get_account.hpp | 16 ++-------------- irohad/model/queries/get_account_assets.hpp | 16 ++-------------- irohad/model/queries/get_account_detail.hpp | 16 ++-------------- irohad/model/queries/get_asset_info.hpp | 16 ++-------------- irohad/model/queries/get_roles.hpp | 16 ++-------------- irohad/model/queries/get_signatories.hpp | 16 ++-------------- irohad/model/queries/get_transactions.hpp | 16 ++-------------- .../responses/account_assets_response.hpp | 16 ++-------------- .../responses/account_detail_response.hpp | 16 ++-------------- .../queries/responses/account_response.hpp | 16 ++-------------- .../queries/responses/asset_response.hpp | 16 ++-------------- .../queries/responses/error_response.hpp | 16 ++-------------- .../queries/responses/roles_response.hpp | 16 ++-------------- .../responses/signatories_response.hpp | 16 ++-------------- .../responses/transactions_response.hpp | 16 ++-------------- irohad/model/query.hpp | 16 ++-------------- irohad/model/query_response.hpp | 16 ++-------------- irohad/model/sha3_hash.cpp | 16 ++-------------- irohad/model/sha3_hash.hpp | 16 ++-------------- irohad/model/signature.hpp | 16 ++-------------- irohad/model/transaction.hpp | 16 ++-------------- .../gossip_propagation_strategy.hpp | 16 ++-------------- .../multi_sig_transactions/mst_processor.hpp | 16 ++-------------- .../mst_processor_impl.hpp | 16 ++-------------- .../mst_propagation_strategy.hpp | 16 ++-------------- .../mst_time_provider_impl.hpp | 16 ++-------------- .../storage/mst_storage.hpp | 16 ++-------------- .../storage/mst_storage_impl.hpp | 16 ++-------------- irohad/network/impl/async_grpc_client.hpp | 16 ++-------------- irohad/network/impl/block_loader_service.cpp | 16 ++-------------- irohad/network/impl/block_loader_service.hpp | 16 ++-------------- irohad/network/impl/grpc_channel_builder.hpp | 16 ++-------------- irohad/network/ordering_gate_transport.hpp | 16 ++-------------- irohad/network/ordering_service.hpp | 16 ++-------------- irohad/network/ordering_service_transport.hpp | 16 ++-------------- irohad/ordering/impl/ordering_gate_impl.hpp | 16 ++-------------- .../impl/ordering_gate_transport_grpc.hpp | 16 ++-------------- .../impl/ordering_service_transport_grpc.hpp | 16 ++-------------- irohad/synchronizer/CMakeLists.txt | 5 +++++ irohad/torii/command_client.hpp | 19 ++++--------------- irohad/torii/impl/command_client.cpp | 16 ++++------------ irohad/torii/impl/query_client.cpp | 16 ++++------------ irohad/torii/query_client.hpp | 19 ++++--------------- irohad/validation/CMakeLists.txt | 16 ++-------------- libs/cache/cache.hpp | 16 ++-------------- libs/common/files.cpp | 16 ++-------------- libs/common/files.hpp | 16 ++-------------- libs/common/result.hpp | 16 ++-------------- libs/common/set.hpp | 16 ++-------------- libs/common/visitor.hpp | 16 ++-------------- libs/crypto/CMakeLists.txt | 16 ++-------------- libs/generator/CMakeLists.txt | 5 +++++ libs/generator/generator.cpp | 16 ++-------------- libs/generator/generator.hpp | 16 ++-------------- libs/logger/CMakeLists.txt | 5 +++++ libs/logger/logger.cpp | 19 ++++--------------- libs/parser/CMakeLists.txt | 5 +++++ libs/parser/parser.cpp | 16 ++-------------- libs/parser/parser.hpp | 16 ++-------------- shared_model/backend/CMakeLists.txt | 13 ++----------- shared_model/backend/protobuf/block.hpp | 16 ++-------------- .../protobuf/queries/proto_get_account.hpp | 16 ++-------------- .../proto_get_account_asset_transactions.hpp | 16 ++-------------- .../queries/proto_get_account_assets.hpp | 16 ++-------------- .../queries/proto_get_account_detail.hpp | 16 ++-------------- .../proto_get_account_transactions.hpp | 16 ++-------------- .../protobuf/queries/proto_get_asset_info.hpp | 16 ++-------------- .../queries/proto_get_role_permissions.hpp | 16 ++-------------- .../protobuf/queries/proto_get_roles.hpp | 16 ++-------------- .../queries/proto_get_signatories.hpp | 16 ++-------------- .../queries/proto_get_transactions.hpp | 16 ++-------------- shared_model/backend/protobuf/util.hpp | 16 ++-------------- shared_model/bindings/CMakeLists.txt | 13 ++----------- shared_model/bindings/model_crypto.cpp | 16 ++-------------- shared_model/bindings/model_crypto.hpp | 16 ++-------------- shared_model/bindings/model_proto.hpp | 16 ++-------------- .../bindings/model_transaction_builder.cpp | 16 ++-------------- .../bindings/model_transaction_builder.hpp | 16 ++-------------- shared_model/builders/CMakeLists.txt | 13 ++----------- shared_model/builders/default_builders.hpp | 16 ++-------------- shared_model/builders/protobuf/CMakeLists.txt | 13 ++----------- shared_model/builders/protobuf/queries.hpp | 16 ++-------------- .../builders/protobuf/transaction.hpp | 16 ++-------------- .../proto_transaction_status_builder.cpp | 16 ++-------------- .../proto_transaction_status_builder.hpp | 16 ++-------------- .../builders/protobuf/transport_builder.hpp | 16 ++-------------- .../builders/protobuf/unsigned_proto.hpp | 16 ++-------------- .../transaction_status_builder.hpp | 16 ++-------------- shared_model/converters/CMakeLists.txt | 13 ++----------- .../protobuf/json_proto_converter.hpp | 16 ++-------------- shared_model/cryptography/CMakeLists.txt | 13 ++----------- shared_model/cryptography/blob.hpp | 16 ++-------------- .../crypto_provider/crypto_defaults.hpp | 16 ++-------------- .../crypto_provider/crypto_model_signer.hpp | 16 ++-------------- .../crypto_provider/crypto_signer.hpp | 16 ++-------------- .../crypto_provider/crypto_verifier.hpp | 16 ++-------------- .../cryptography/default_hash_provider.hpp | 16 ++-------------- .../ed25519_sha3_impl/CMakeLists.txt | 13 ++----------- .../ed25519_sha3_impl/crypto_provider.cpp | 16 ++-------------- .../ed25519_sha3_impl/crypto_provider.hpp | 16 ++-------------- .../ed25519_sha3_impl/internal/CMakeLists.txt | 16 ++-------------- .../cryptography/ed25519_sha3_impl/signer.cpp | 16 ++-------------- .../cryptography/ed25519_sha3_impl/signer.hpp | 16 ++-------------- .../ed25519_sha3_impl/verifier.cpp | 16 ++-------------- .../ed25519_sha3_impl/verifier.hpp | 16 ++-------------- shared_model/cryptography/hash.hpp | 16 ++-------------- .../cryptography/hash_providers/sha3_512.hpp | 16 ++-------------- shared_model/cryptography/keypair.hpp | 16 ++-------------- .../cryptography/model_impl/CMakeLists.txt | 5 +++++ shared_model/cryptography/model_impl/blob.cpp | 16 ++-------------- shared_model/cryptography/model_impl/hash.cpp | 16 ++-------------- .../cryptography/model_impl/keypair.cpp | 16 ++-------------- .../cryptography/model_impl/private_key.cpp | 16 ++-------------- .../cryptography/model_impl/public_key.cpp | 16 ++-------------- shared_model/cryptography/model_impl/seed.cpp | 16 ++-------------- .../cryptography/model_impl/signed.cpp | 16 ++-------------- shared_model/cryptography/private_key.hpp | 16 ++-------------- shared_model/cryptography/public_key.hpp | 16 ++-------------- shared_model/cryptography/seed.hpp | 16 ++-------------- shared_model/cryptography/signed.hpp | 16 ++-------------- .../interfaces/base/model_primitive.hpp | 16 ++-------------- .../commands/add_asset_quantity.hpp | 16 ++-------------- shared_model/interfaces/commands/add_peer.hpp | 16 ++-------------- .../interfaces/commands/add_signatory.hpp | 16 ++-------------- .../interfaces/commands/append_role.hpp | 16 ++-------------- .../interfaces/commands/create_account.hpp | 16 ++-------------- .../interfaces/commands/create_asset.hpp | 16 ++-------------- .../interfaces/commands/create_domain.hpp | 16 ++-------------- .../interfaces/commands/create_role.hpp | 16 ++-------------- .../interfaces/commands/detach_role.hpp | 16 ++-------------- .../interfaces/commands/grant_permission.hpp | 16 ++-------------- .../interfaces/commands/remove_signatory.hpp | 16 ++-------------- .../interfaces/commands/revoke_permission.hpp | 16 ++-------------- .../commands/set_account_detail.hpp | 16 ++-------------- .../interfaces/commands/set_quorum.hpp | 16 ++-------------- .../commands/subtract_asset_quantity.hpp | 16 ++-------------- .../interfaces/commands/transfer_asset.hpp | 16 ++-------------- .../interfaces/common_objects/account.hpp | 16 ++-------------- .../common_objects/account_asset.hpp | 16 ++-------------- .../interfaces/common_objects/asset.hpp | 16 ++-------------- .../interfaces/common_objects/domain.hpp | 16 ++-------------- .../interfaces/iroha_internal/proposal.hpp | 16 ++-------------- .../interfaces/queries/get_account.hpp | 16 ++-------------- .../get_account_asset_transactions.hpp | 16 ++-------------- .../interfaces/queries/get_account_assets.hpp | 16 ++-------------- .../interfaces/queries/get_account_detail.hpp | 16 ++-------------- .../queries/get_account_transactions.hpp | 16 ++-------------- .../interfaces/queries/get_asset_info.hpp | 16 ++-------------- .../queries/get_role_permissions.hpp | 16 ++-------------- shared_model/interfaces/queries/get_roles.hpp | 16 ++-------------- .../interfaces/queries/get_signatories.hpp | 16 ++-------------- .../interfaces/queries/get_transactions.hpp | 16 ++-------------- .../account_detail_response.hpp | 16 ++-------------- .../query_responses/account_response.hpp | 16 ++-------------- .../query_responses/asset_response.hpp | 16 ++-------------- .../abstract_error_response.hpp | 17 ++--------------- .../no_account_assets_error_response.hpp | 16 ++-------------- .../no_account_detail_error_response.hpp | 16 ++-------------- .../no_account_error_response.hpp | 16 ++-------------- .../no_asset_error_response.hpp | 16 ++-------------- .../no_roles_error_response.hpp | 16 ++-------------- .../no_signatories_error_response.hpp | 16 ++-------------- .../not_supported_error_response.hpp | 16 ++-------------- .../stateful_failed_error_response.hpp | 16 ++-------------- .../stateless_failed_error_response.hpp | 16 ++-------------- .../query_responses/role_permissions.hpp | 16 ++-------------- .../query_responses/roles_response.hpp | 16 ++-------------- .../query_responses/signatories_response.hpp | 16 ++-------------- .../abstract_tx_response.hpp | 16 ++-------------- .../committed_tx_response.hpp | 16 ++-------------- .../not_received_tx_response.hpp | 16 ++-------------- .../stateful_failed_tx_response.hpp | 16 ++-------------- .../stateful_valid_tx_response.hpp | 16 ++-------------- .../stateless_failed_tx_response.hpp | 16 ++-------------- .../stateless_valid_tx_response.hpp | 16 ++-------------- shared_model/test/CMakeLists.txt | 5 +++++ .../utils/query_error_response_visitor.hpp | 16 ++-------------- shared_model/utils/swig_keyword_hider.hpp | 16 ++-------------- shared_model/utils/visitor_apply_for_all.hpp | 16 ++-------------- .../validators/amount_true_validator.hpp | 16 ++-------------- shared_model/validators/answer.hpp | 16 ++-------------- shared_model/validators/permissions.hpp | 16 ++-------------- test/benchmark/CMakeLists.txt | 5 +++++ test/benchmark/benchmark_example.cpp | 16 ++-------------- test/framework/CMakeLists.txt | 16 ++-------------- test/framework/config_helper.cpp | 16 ++-------------- test/framework/config_helper.hpp | 16 ++-------------- .../integration_framework/iroha_instance.cpp | 16 ++-------------- .../integration_framework/iroha_instance.hpp | 16 ++-------------- .../integration_framework/test_irohad.hpp | 16 ++-------------- test/framework/result_fixture.hpp | 16 ++-------------- test/framework/test_subscriber.hpp | 16 ++-------------- test/framework/test_subscriber_testing.cpp | 16 ++-------------- test/integration/binary/CMakeLists.txt | 5 +++++ test/integration/consensus/CMakeLists.txt | 16 ++-------------- test/integration/pipeline/CMakeLists.txt | 16 ++-------------- test/module/CMakeLists.txt | 16 ++-------------- test/module/iroha-cli/CMakeLists.txt | 16 ++-------------- test/module/irohad/ametsuchi/CMakeLists.txt | 5 +++++ .../ametsuchi/block_query_transfer_test.cpp | 16 ++-------------- .../irohad/ametsuchi/flat_file_test.cpp | 16 ++-------------- .../irohad/ametsuchi/kv_storage_test.cpp | 16 ++-------------- .../ametsuchi/wsv_query_command_test.cpp | 16 ++-------------- test/module/irohad/common/CMakeLists.txt | 5 +++++ .../irohad/common/blob_converter_test.cpp | 16 ++-------------- test/module/irohad/consensus/CMakeLists.txt | 16 ++-------------- test/module/irohad/logger/CMakeLists.txt | 5 +++++ test/module/irohad/logger/logger_test.cpp | 19 ++++--------------- test/module/irohad/main/CMakeLists.txt | 16 ++-------------- .../module/irohad/main/server_runner_test.cpp | 16 ++-------------- test/module/irohad/model/CMakeLists.txt | 16 ++-------------- .../model/converters/json_block_test.cpp | 16 ++-------------- .../model/converters/json_commands_test.cpp | 16 ++-------------- .../converters/json_query_factory_test.cpp | 16 ++-------------- .../converters/json_transaction_test.cpp | 16 ++-------------- .../irohad/model/converters/pb_block_test.cpp | 16 ++-------------- .../model/converters/pb_commands_test.cpp | 16 ++-------------- .../converters/pb_query_factory_test.cpp | 16 ++-------------- .../converters/pb_query_responses_test.cpp | 16 ++-------------- .../model/converters/pb_transaction_test.cpp | 16 ++-------------- .../model/model_crypto_provider_test.cpp | 16 ++-------------- .../model/operators/model_operators_test.cpp | 16 ++-------------- test/module/irohad/network/CMakeLists.txt | 16 ++-------------- ...mock_ordering_service_persistent_state.hpp | 16 ++-------------- test/module/irohad/simulator/CMakeLists.txt | 5 +++++ .../module/irohad/synchronizer/CMakeLists.txt | 5 +++++ test/module/irohad/torii/CMakeLists.txt | 13 ++----------- .../irohad/torii/processor/CMakeLists.txt | 5 +++++ .../irohad/validation/validation_mocks.hpp | 16 ++-------------- test/module/libs/CMakeLists.txt | 5 +++++ test/module/libs/cache/CMakeLists.txt | 13 ++----------- test/module/libs/cache/cache_test.cpp | 16 ++-------------- test/module/libs/common/CMakeLists.txt | 16 ++-------------- test/module/libs/common/result_test.cpp | 16 ++-------------- test/module/libs/converter/CMakeLists.txt | 5 +++++ .../libs/converter/string_converter_test.cpp | 16 ++-------------- test/module/libs/crypto/CMakeLists.txt | 16 ++-------------- test/module/libs/crypto/hash_test.cpp | 19 ++++--------------- test/module/libs/crypto/signature_test.cpp | 19 ++++--------------- test/module/libs/datetime/CMakeLists.txt | 5 +++++ test/module/libs/datetime/time_test.cpp | 16 ++-------------- .../shared_model/backend_proto/CMakeLists.txt | 16 ++-------------- .../shared_proto_commands_test.cpp | 16 ++-------------- .../backend_proto/shared_proto_util_test.cpp | 16 ++-------------- .../shared_model/bindings/CMakeLists.txt | 13 ++----------- .../bindings/model_crypto_test.cpp | 16 ++-------------- .../bindings/model_query_builder_test.cpp | 16 ++-------------- .../shared_model/builders/CMakeLists.txt | 13 ++----------- .../builders/common_objects/CMakeLists.txt | 13 ++----------- .../common_objects/account_asset_builder.hpp | 16 ++-------------- .../account_asset_builder_test.cpp | 16 ++-------------- .../common_objects/account_builder.hpp | 16 ++-------------- .../common_objects/account_builder_test.cpp | 16 ++-------------- .../builders/common_objects/asset_builder.hpp | 16 ++-------------- .../common_objects/asset_builder_test.cpp | 16 ++-------------- .../common_objects/builders_test_fixture.hpp | 16 ++-------------- .../builders/common_objects/common.hpp | 16 ++-------------- .../common_objects/domain_builder.hpp | 16 ++-------------- .../builders/common_objects/peer_builder.hpp | 16 ++-------------- .../common_objects/peer_builder_test.cpp | 16 ++-------------- .../common_objects/signature_builder.hpp | 16 ++-------------- .../common_objects/signature_builder_test.cpp | 16 ++-------------- .../builders/protobuf/CMakeLists.txt | 13 ++----------- .../proto_account_asset_builder.hpp | 16 ++-------------- .../proto_account_asset_builder_test.cpp | 16 ++-------------- .../common_objects/proto_account_builder.hpp | 16 ++-------------- .../proto_account_builder_test.cpp | 16 ++-------------- .../common_objects/proto_asset_builder.hpp | 16 ++-------------- .../proto_asset_builder_test.cpp | 16 ++-------------- .../common_objects/proto_domain_builder.hpp | 16 ++-------------- .../common_objects/proto_peer_builder.hpp | 16 ++-------------- .../proto_peer_builder_test.cpp | 16 ++-------------- .../proto_signature_builder_test.cpp | 16 ++-------------- .../protobuf/test_account_asset_builder.hpp | 16 ++-------------- .../protobuf/test_account_builder.hpp | 16 ++-------------- .../builders/protobuf/test_asset_builder.hpp | 16 ++-------------- .../builders/protobuf/test_domain_builder.hpp | 16 ++-------------- .../builders/protobuf/test_peer_builder.hpp | 16 ++-------------- .../builders/protobuf/test_query_builder.hpp | 16 ++-------------- .../protobuf/test_signature_builder.hpp | 16 ++-------------- .../protobuf/test_transaction_builder.hpp | 16 ++-------------- .../transaction_responses/CMakeLists.txt | 13 ++----------- .../shared_model/converters/CMakeLists.txt | 16 ++-------------- .../converters/json_proto_converter_test.cpp | 16 ++-------------- .../shared_model/cryptography/CMakeLists.txt | 5 +++++ .../shared_model/cryptography/blob_test.cpp | 16 ++-------------- .../cryptography/crypto_model_signer_mock.hpp | 16 ++-------------- .../cryptography/crypto_usage_test.cpp | 16 ++-------------- .../shared_model/reference_holder_test.cpp | 16 ++-------------- .../shared_model/validators/CMakeLists.txt | 16 ++-------------- .../validators/transaction_validator_test.cpp | 16 ++-------------- .../validators/validators_fixture.hpp | 16 ++-------------- test/module/vendor/CMakeLists.txt | 5 +++++ test/module/vendor/rxcpp_subject_usage.cpp | 16 ++-------------- test/module/vendor/tbb_test.cpp | 16 ++-------------- test/regression/CMakeLists.txt | 5 +++++ test/regression/regression_test.cpp | 16 ++-------------- test/system/CMakeLists.txt | 5 +++++ 426 files changed, 934 insertions(+), 5614 deletions(-) diff --git a/iroha-cli/CMakeLists.txt b/iroha-cli/CMakeLists.txt index cebbaa5860..33df3b0112 100644 --- a/iroha-cli/CMakeLists.txt +++ b/iroha-cli/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) diff --git a/iroha-cli/client.cpp b/iroha-cli/client.cpp index a9cb123342..3777228b7d 100644 --- a/iroha-cli/client.cpp +++ b/iroha-cli/client.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "client.hpp" diff --git a/iroha-cli/client.hpp b/iroha-cli/client.hpp index 16c41c4abd..6ab556d1dc 100644 --- a/iroha-cli/client.hpp +++ b/iroha-cli/client.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHACLI_CLIENT_HPP diff --git a/iroha-cli/grpc_response_handler.hpp b/iroha-cli/grpc_response_handler.hpp index dad16b6500..a727f2dccc 100644 --- a/iroha-cli/grpc_response_handler.hpp +++ b/iroha-cli/grpc_response_handler.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_GRPC_RESPONSE_HANDLER_HPP diff --git a/iroha-cli/impl/grpc_response_handler.cpp b/iroha-cli/impl/grpc_response_handler.cpp index 58fd68711a..31baf60c70 100644 --- a/iroha-cli/impl/grpc_response_handler.cpp +++ b/iroha-cli/impl/grpc_response_handler.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "grpc_response_handler.hpp" diff --git a/iroha-cli/impl/query_response_handler.cpp b/iroha-cli/impl/query_response_handler.cpp index 82ed461391..2d814e5289 100644 --- a/iroha-cli/impl/query_response_handler.cpp +++ b/iroha-cli/impl/query_response_handler.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "query_response_handler.hpp" diff --git a/iroha-cli/impl/transaction_response_handler.cpp b/iroha-cli/impl/transaction_response_handler.cpp index bb4edbe727..4dd07c5fa0 100644 --- a/iroha-cli/impl/transaction_response_handler.cpp +++ b/iroha-cli/impl/transaction_response_handler.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "transaction_response_handler.hpp" #include "logger/logger.hpp" diff --git a/iroha-cli/interactive/CMakeLists.txt b/iroha-cli/interactive/CMakeLists.txt index 539875503a..c84d76a265 100644 --- a/iroha-cli/interactive/CMakeLists.txt +++ b/iroha-cli/interactive/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # # Interactive Client diff --git a/iroha-cli/interactive/impl/interactive_cli.cpp b/iroha-cli/interactive/impl/interactive_cli.cpp index 222fa7b8e2..9220e76b4f 100644 --- a/iroha-cli/interactive/impl/interactive_cli.cpp +++ b/iroha-cli/interactive/impl/interactive_cli.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/iroha-cli/interactive/impl/interactive_common_cli.cpp b/iroha-cli/interactive/impl/interactive_common_cli.cpp index 2544440fc1..f57b68e969 100644 --- a/iroha-cli/interactive/impl/interactive_common_cli.cpp +++ b/iroha-cli/interactive/impl/interactive_common_cli.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include #include diff --git a/iroha-cli/interactive/impl/interactive_query_cli.cpp b/iroha-cli/interactive/impl/interactive_query_cli.cpp index dedad966b0..d2f86cd621 100644 --- a/iroha-cli/interactive/impl/interactive_query_cli.cpp +++ b/iroha-cli/interactive/impl/interactive_query_cli.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/iroha-cli/interactive/impl/interactive_status_cli.cpp b/iroha-cli/interactive/impl/interactive_status_cli.cpp index 47a8a63091..9fba678873 100644 --- a/iroha-cli/interactive/impl/interactive_status_cli.cpp +++ b/iroha-cli/interactive/impl/interactive_status_cli.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "interactive/interactive_status_cli.hpp" diff --git a/iroha-cli/interactive/interactive_cli.hpp b/iroha-cli/interactive/interactive_cli.hpp index 0756746042..aa3567ae07 100644 --- a/iroha-cli/interactive/interactive_cli.hpp +++ b/iroha-cli/interactive/interactive_cli.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_INTERACTIVE_CLI_HPP diff --git a/iroha-cli/interactive/interactive_common_cli.hpp b/iroha-cli/interactive/interactive_common_cli.hpp index 958d1fb9fc..e97d9c16cd 100644 --- a/iroha-cli/interactive/interactive_common_cli.hpp +++ b/iroha-cli/interactive/interactive_common_cli.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_INTERACTIVE_COMMON_CLI_HPP diff --git a/iroha-cli/interactive/interactive_query_cli.hpp b/iroha-cli/interactive/interactive_query_cli.hpp index ac1e2963f6..050945ad17 100644 --- a/iroha-cli/interactive/interactive_query_cli.hpp +++ b/iroha-cli/interactive/interactive_query_cli.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_INTERACTIVE_QUERY_CLI_HPP diff --git a/iroha-cli/interactive/interactive_status_cli.hpp b/iroha-cli/interactive/interactive_status_cli.hpp index 6e2ae2103b..894a7548c5 100644 --- a/iroha-cli/interactive/interactive_status_cli.hpp +++ b/iroha-cli/interactive/interactive_status_cli.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_INTERACTIVE_STATUS_CLI_HPP diff --git a/iroha-cli/interactive/interactive_transaction_cli.hpp b/iroha-cli/interactive/interactive_transaction_cli.hpp index ee8a61eb75..c12c4436bb 100644 --- a/iroha-cli/interactive/interactive_transaction_cli.hpp +++ b/iroha-cli/interactive/interactive_transaction_cli.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_INTERACTIVE_TRANSACTION_CLI_HPP diff --git a/iroha-cli/main.cpp b/iroha-cli/main.cpp index 41b158d65e..b5ad790085 100644 --- a/iroha-cli/main.cpp +++ b/iroha-cli/main.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY =KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/iroha-cli/query_response_handler.hpp b/iroha-cli/query_response_handler.hpp index 85f4b11510..7e63994596 100644 --- a/iroha-cli/query_response_handler.hpp +++ b/iroha-cli/query_response_handler.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_QUERY_RESPONSE_HANDLER_HPP diff --git a/iroha-cli/transaction_response_handler.hpp b/iroha-cli/transaction_response_handler.hpp index 19aa03dc16..05cb0e1edf 100644 --- a/iroha-cli/transaction_response_handler.hpp +++ b/iroha-cli/transaction_response_handler.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_TRANSACTION_RESPONSE_HANDLER_HPP diff --git a/iroha-cli/validators.cpp b/iroha-cli/validators.cpp index 1000a458cc..4abe45178e 100644 --- a/iroha-cli/validators.cpp +++ b/iroha-cli/validators.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/iroha-cli/validators.hpp b/iroha-cli/validators.hpp index bde2ce4137..7c0df395ce 100644 --- a/iroha-cli/validators.hpp +++ b/iroha-cli/validators.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/irohad/CMakeLists.txt b/irohad/CMakeLists.txt index a4c36cc395..ac1e840891 100644 --- a/irohad/CMakeLists.txt +++ b/irohad/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_subdirectory(ametsuchi) add_subdirectory(consensus) diff --git a/irohad/ametsuchi/CMakeLists.txt b/irohad/ametsuchi/CMakeLists.txt index 4b0c4cc100..87541fcb3a 100644 --- a/irohad/ametsuchi/CMakeLists.txt +++ b/irohad/ametsuchi/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + add_library(ametsuchi impl/flat_file/flat_file.cpp impl/storage_impl.cpp diff --git a/irohad/ametsuchi/impl/block_index.hpp b/irohad/ametsuchi/impl/block_index.hpp index 0f365eaedd..c38aaee4ce 100644 --- a/irohad/ametsuchi/impl/block_index.hpp +++ b/irohad/ametsuchi/impl/block_index.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_BLOCK_INDEX_HPP diff --git a/irohad/ametsuchi/impl/peer_query_wsv.cpp b/irohad/ametsuchi/impl/peer_query_wsv.cpp index d99d8b1225..a10832edcd 100644 --- a/irohad/ametsuchi/impl/peer_query_wsv.cpp +++ b/irohad/ametsuchi/impl/peer_query_wsv.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "ametsuchi/impl/peer_query_wsv.hpp" diff --git a/irohad/ametsuchi/impl/peer_query_wsv.hpp b/irohad/ametsuchi/impl/peer_query_wsv.hpp index f4e48e748a..ee6e99d78c 100644 --- a/irohad/ametsuchi/impl/peer_query_wsv.hpp +++ b/irohad/ametsuchi/impl/peer_query_wsv.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PEER_QUERY_WSV_HPP diff --git a/irohad/ametsuchi/impl/postgres_block_index.hpp b/irohad/ametsuchi/impl/postgres_block_index.hpp index 6b3204fa72..40f7e2e2bb 100644 --- a/irohad/ametsuchi/impl/postgres_block_index.hpp +++ b/irohad/ametsuchi/impl/postgres_block_index.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_POSTGRES_BLOCK_INDEX_HPP diff --git a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp index 42c403ca41..f382f2ae69 100644 --- a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp +++ b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "ametsuchi/impl/postgres_ordering_service_persistent_state.hpp" diff --git a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp index 2f2092206d..ea2d843a09 100644 --- a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp +++ b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_POSTGRES_ORDERING_SERVICE_PERSISTENT_STATE_HPP diff --git a/irohad/ametsuchi/impl/postgres_wsv_command.hpp b/irohad/ametsuchi/impl/postgres_wsv_command.hpp index 9f1cbe7ae1..b06b61ff6d 100644 --- a/irohad/ametsuchi/impl/postgres_wsv_command.hpp +++ b/irohad/ametsuchi/impl/postgres_wsv_command.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_POSTGRES_WSV_COMMAND_HPP diff --git a/irohad/ametsuchi/impl/postgres_wsv_query.hpp b/irohad/ametsuchi/impl/postgres_wsv_query.hpp index f477443c12..4fad3c164f 100644 --- a/irohad/ametsuchi/impl/postgres_wsv_query.hpp +++ b/irohad/ametsuchi/impl/postgres_wsv_query.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_POSTGRES_WSV_QUERY_HPP diff --git a/irohad/ametsuchi/impl/wsv_restorer_impl.cpp b/irohad/ametsuchi/impl/wsv_restorer_impl.cpp index 3b30d9fac8..f357d8a1f6 100644 --- a/irohad/ametsuchi/impl/wsv_restorer_impl.cpp +++ b/irohad/ametsuchi/impl/wsv_restorer_impl.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "wsv_restorer_impl.hpp" diff --git a/irohad/ametsuchi/impl/wsv_restorer_impl.hpp b/irohad/ametsuchi/impl/wsv_restorer_impl.hpp index 2ab84c50cd..1238ea7cf2 100644 --- a/irohad/ametsuchi/impl/wsv_restorer_impl.hpp +++ b/irohad/ametsuchi/impl/wsv_restorer_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_WSVRESTORERIMPL_HPP diff --git a/irohad/ametsuchi/mutable_factory.hpp b/irohad/ametsuchi/mutable_factory.hpp index eabb974156..c53a27f64a 100644 --- a/irohad/ametsuchi/mutable_factory.hpp +++ b/irohad/ametsuchi/mutable_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MUTABLE_FACTORY_HPP diff --git a/irohad/ametsuchi/ordering_service_persistent_state.hpp b/irohad/ametsuchi/ordering_service_persistent_state.hpp index 28fb4ca4a0..87eb4c21f1 100644 --- a/irohad/ametsuchi/ordering_service_persistent_state.hpp +++ b/irohad/ametsuchi/ordering_service_persistent_state.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERING_SERVICE_PERSISTENT_STATE_HPP diff --git a/irohad/ametsuchi/temporary_factory.hpp b/irohad/ametsuchi/temporary_factory.hpp index d7ede2d491..1b91f3bfd8 100644 --- a/irohad/ametsuchi/temporary_factory.hpp +++ b/irohad/ametsuchi/temporary_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TEMPORARY_FACTORY_HPP diff --git a/irohad/ametsuchi/wsv_command.hpp b/irohad/ametsuchi/wsv_command.hpp index cf9c5de8bc..8422041e9a 100644 --- a/irohad/ametsuchi/wsv_command.hpp +++ b/irohad/ametsuchi/wsv_command.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_WSV_COMMAND_HPP diff --git a/irohad/ametsuchi/wsv_restorer.hpp b/irohad/ametsuchi/wsv_restorer.hpp index 95b29ca7c4..9853d41361 100644 --- a/irohad/ametsuchi/wsv_restorer.hpp +++ b/irohad/ametsuchi/wsv_restorer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_WSVRESTORER_HPP #define IROHA_WSVRESTORER_HPP diff --git a/irohad/consensus/yac/cluster_order.hpp b/irohad/consensus/yac/cluster_order.hpp index d17db44c67..c9bcea35c6 100644 --- a/irohad/consensus/yac/cluster_order.hpp +++ b/irohad/consensus/yac/cluster_order.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLUSTER_ORDER_HPP diff --git a/irohad/consensus/yac/impl/cluster_order.cpp b/irohad/consensus/yac/impl/cluster_order.cpp index f06b3618f6..a4c3e73ecb 100644 --- a/irohad/consensus/yac/impl/cluster_order.cpp +++ b/irohad/consensus/yac/impl/cluster_order.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/cluster_order.hpp" diff --git a/irohad/consensus/yac/impl/peer_orderer_impl.cpp b/irohad/consensus/yac/impl/peer_orderer_impl.cpp index 902cb6b4ae..9c8a98869d 100644 --- a/irohad/consensus/yac/impl/peer_orderer_impl.cpp +++ b/irohad/consensus/yac/impl/peer_orderer_impl.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/impl/peer_orderer_impl.hpp" diff --git a/irohad/consensus/yac/impl/peer_orderer_impl.hpp b/irohad/consensus/yac/impl/peer_orderer_impl.hpp index a2b256bee3..099af38be6 100644 --- a/irohad/consensus/yac/impl/peer_orderer_impl.hpp +++ b/irohad/consensus/yac/impl/peer_orderer_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PEER_ORDERER_IMPL_HPP diff --git a/irohad/consensus/yac/impl/timer_impl.cpp b/irohad/consensus/yac/impl/timer_impl.cpp index cc152018e8..f411ad533f 100644 --- a/irohad/consensus/yac/impl/timer_impl.cpp +++ b/irohad/consensus/yac/impl/timer_impl.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/impl/timer_impl.hpp" diff --git a/irohad/consensus/yac/impl/timer_impl.hpp b/irohad/consensus/yac/impl/timer_impl.hpp index e38081a7bf..49e8ae4be9 100644 --- a/irohad/consensus/yac/impl/timer_impl.hpp +++ b/irohad/consensus/yac/impl/timer_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TIMER_IMPL_HPP diff --git a/irohad/consensus/yac/messages.hpp b/irohad/consensus/yac/messages.hpp index dc88584ca7..5ba74a0b29 100644 --- a/irohad/consensus/yac/messages.hpp +++ b/irohad/consensus/yac/messages.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MESSAGES_HPP diff --git a/irohad/consensus/yac/storage/impl/yac_common.cpp b/irohad/consensus/yac/storage/impl/yac_common.cpp index 6e87b807c1..75e461226e 100644 --- a/irohad/consensus/yac/storage/impl/yac_common.cpp +++ b/irohad/consensus/yac/storage/impl/yac_common.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/storage/yac_common.hpp" diff --git a/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp b/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp index dd75708de0..3dd5f9b15e 100644 --- a/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp +++ b/irohad/consensus/yac/storage/impl/yac_proposal_storage.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/storage/yac_proposal_storage.hpp" diff --git a/irohad/consensus/yac/storage/storage_result.hpp b/irohad/consensus/yac/storage/storage_result.hpp index 1db1d43258..9a22d5aca5 100644 --- a/irohad/consensus/yac/storage/storage_result.hpp +++ b/irohad/consensus/yac/storage/storage_result.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_STORAGE_RESULT_HPP diff --git a/irohad/consensus/yac/storage/yac_common.hpp b/irohad/consensus/yac/storage/yac_common.hpp index 8513fce393..b26d630447 100644 --- a/irohad/consensus/yac/storage/yac_common.hpp +++ b/irohad/consensus/yac/storage/yac_common.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_COMMON_HPP diff --git a/irohad/consensus/yac/storage/yac_proposal_storage.hpp b/irohad/consensus/yac/storage/yac_proposal_storage.hpp index ebff776b7d..29deb56386 100644 --- a/irohad/consensus/yac/storage/yac_proposal_storage.hpp +++ b/irohad/consensus/yac/storage/yac_proposal_storage.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_PROPOSAL_STORAGE_HPP diff --git a/irohad/consensus/yac/timer.hpp b/irohad/consensus/yac/timer.hpp index 8ee95b9312..864d07e87f 100644 --- a/irohad/consensus/yac/timer.hpp +++ b/irohad/consensus/yac/timer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_TIMER_HPP diff --git a/irohad/consensus/yac/transport/impl/network_impl.cpp b/irohad/consensus/yac/transport/impl/network_impl.cpp index f3f9470e6c..4db621d36a 100644 --- a/irohad/consensus/yac/transport/impl/network_impl.cpp +++ b/irohad/consensus/yac/transport/impl/network_impl.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "consensus/yac/transport/impl/network_impl.hpp" diff --git a/irohad/consensus/yac/transport/impl/network_impl.hpp b/irohad/consensus/yac/transport/impl/network_impl.hpp index 44cf20b1d7..e094c841a8 100644 --- a/irohad/consensus/yac/transport/impl/network_impl.hpp +++ b/irohad/consensus/yac/transport/impl/network_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_NETWORK_IMPL_HPP diff --git a/irohad/consensus/yac/transport/yac_network_interface.hpp b/irohad/consensus/yac/transport/yac_network_interface.hpp index f4de679485..573332bce6 100644 --- a/irohad/consensus/yac/transport/yac_network_interface.hpp +++ b/irohad/consensus/yac/transport/yac_network_interface.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_NETWORK_INTERFACE_HPP diff --git a/irohad/consensus/yac/yac.hpp b/irohad/consensus/yac/yac.hpp index e9f1835c31..25d75867aa 100644 --- a/irohad/consensus/yac/yac.hpp +++ b/irohad/consensus/yac/yac.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_HPP diff --git a/irohad/consensus/yac/yac_crypto_provider.hpp b/irohad/consensus/yac/yac_crypto_provider.hpp index 31f56a9363..0e2a97777c 100644 --- a/irohad/consensus/yac/yac_crypto_provider.hpp +++ b/irohad/consensus/yac/yac_crypto_provider.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_CRYPTO_PROVIDER_HPP diff --git a/irohad/consensus/yac/yac_gate.hpp b/irohad/consensus/yac/yac_gate.hpp index 4457ae9be7..c84bff8943 100644 --- a/irohad/consensus/yac/yac_gate.hpp +++ b/irohad/consensus/yac/yac_gate.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_GATE_HPP diff --git a/irohad/consensus/yac/yac_peer_orderer.hpp b/irohad/consensus/yac/yac_peer_orderer.hpp index 8f69c5e885..6eaa19cc4c 100644 --- a/irohad/consensus/yac/yac_peer_orderer.hpp +++ b/irohad/consensus/yac/yac_peer_orderer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_YAC_PEER_ORDERER_HPP diff --git a/irohad/main/CMakeLists.txt b/irohad/main/CMakeLists.txt index 91f0975bf5..6b2efc3d00 100644 --- a/irohad/main/CMakeLists.txt +++ b/irohad/main/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) diff --git a/irohad/main/assert_config.hpp b/irohad/main/assert_config.hpp index 536cb05d97..a94f979baf 100644 --- a/irohad/main/assert_config.hpp +++ b/irohad/main/assert_config.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLI_ASSERT_CONFIG_HPP diff --git a/irohad/main/impl/ordering_init.hpp b/irohad/main/impl/ordering_init.hpp index 6b8731cff8..1c980deeee 100644 --- a/irohad/main/impl/ordering_init.hpp +++ b/irohad/main/impl/ordering_init.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERING_INIT_HPP diff --git a/irohad/main/impl/raw_block_loader.cpp b/irohad/main/impl/raw_block_loader.cpp index 62bd943c9c..01b0113a13 100644 --- a/irohad/main/impl/raw_block_loader.cpp +++ b/irohad/main/impl/raw_block_loader.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "main/raw_block_loader.hpp" diff --git a/irohad/main/irohad.cpp b/irohad/main/irohad.cpp index ddd77ed416..8a687d1385 100644 --- a/irohad/main/irohad.cpp +++ b/irohad/main/irohad.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/irohad/main/raw_block_loader.hpp b/irohad/main/raw_block_loader.hpp index c6fc3b0c66..47be31c1d2 100644 --- a/irohad/main/raw_block_loader.hpp +++ b/irohad/main/raw_block_loader.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_RAW_BLOCK_INSERTION_HPP diff --git a/irohad/model/CMakeLists.txt b/irohad/model/CMakeLists.txt index 8d37bfccb7..aede348a68 100644 --- a/irohad/model/CMakeLists.txt +++ b/irohad/model/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # add_subdirectory(generators) diff --git a/irohad/model/account.hpp b/irohad/model/account.hpp index 7d3c811702..e03e6eafbc 100644 --- a/irohad/model/account.hpp +++ b/irohad/model/account.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ACCOUNT_HPP diff --git a/irohad/model/account_asset.hpp b/irohad/model/account_asset.hpp index cbb7b5396e..d4023ba320 100644 --- a/irohad/model/account_asset.hpp +++ b/irohad/model/account_asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ACCOUNT_ASSET_HPP diff --git a/irohad/model/asset.hpp b/irohad/model/asset.hpp index adafae36be..2210ae0aea 100644 --- a/irohad/model/asset.hpp +++ b/irohad/model/asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ASSET_HPP diff --git a/irohad/model/block.hpp b/irohad/model/block.hpp index 26a3fa6ed8..6e19bc2c6f 100644 --- a/irohad/model/block.hpp +++ b/irohad/model/block.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_BLOCK_HPP diff --git a/irohad/model/client.hpp b/irohad/model/client.hpp index f014dbddf3..88841ab273 100644 --- a/irohad/model/client.hpp +++ b/irohad/model/client.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CLIENT_HPP diff --git a/irohad/model/command.hpp b/irohad/model/command.hpp index a688e21f34..f0efdc7305 100644 --- a/irohad/model/command.hpp +++ b/irohad/model/command.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_COMMAND_HPP diff --git a/irohad/model/commands/add_asset_quantity.hpp b/irohad/model/commands/add_asset_quantity.hpp index 578aeec104..4e502370f5 100644 --- a/irohad/model/commands/add_asset_quantity.hpp +++ b/irohad/model/commands/add_asset_quantity.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ADD_ASSET_QUANTITY_HPP diff --git a/irohad/model/commands/add_peer.hpp b/irohad/model/commands/add_peer.hpp index 8100d7d28f..a127894933 100644 --- a/irohad/model/commands/add_peer.hpp +++ b/irohad/model/commands/add_peer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ADD_PEER_HPP diff --git a/irohad/model/commands/add_signatory.hpp b/irohad/model/commands/add_signatory.hpp index cf1271d6a5..01f71d35d8 100644 --- a/irohad/model/commands/add_signatory.hpp +++ b/irohad/model/commands/add_signatory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ADD_SIGNATURE_HPP diff --git a/irohad/model/commands/all.hpp b/irohad/model/commands/all.hpp index 457d4c0072..e8688e6412 100644 --- a/irohad/model/commands/all.hpp +++ b/irohad/model/commands/all.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ALL_HPP_ diff --git a/irohad/model/commands/append_role.hpp b/irohad/model/commands/append_role.hpp index 435100500f..421147894f 100644 --- a/irohad/model/commands/append_role.hpp +++ b/irohad/model/commands/append_role.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_APPEND_ROLE_HPP #define IROHA_APPEND_ROLE_HPP diff --git a/irohad/model/commands/create_account.hpp b/irohad/model/commands/create_account.hpp index ccee52dd36..06929f5f13 100644 --- a/irohad/model/commands/create_account.hpp +++ b/irohad/model/commands/create_account.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CREATE_ACCOUNT_HPP diff --git a/irohad/model/commands/create_asset.hpp b/irohad/model/commands/create_asset.hpp index 427733f627..3de023abea 100644 --- a/irohad/model/commands/create_asset.hpp +++ b/irohad/model/commands/create_asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CREATE_ASSET_HPP diff --git a/irohad/model/commands/create_domain.hpp b/irohad/model/commands/create_domain.hpp index 648f7d1faa..4761226f99 100644 --- a/irohad/model/commands/create_domain.hpp +++ b/irohad/model/commands/create_domain.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CREATE_DOMAIN_HPP #define IROHA_CREATE_DOMAIN_HPP diff --git a/irohad/model/commands/create_role.hpp b/irohad/model/commands/create_role.hpp index 067a734864..9a25d944c8 100644 --- a/irohad/model/commands/create_role.hpp +++ b/irohad/model/commands/create_role.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CREATE_ROLE_HPP #define IROHA_CREATE_ROLE_HPP diff --git a/irohad/model/commands/detach_role.hpp b/irohad/model/commands/detach_role.hpp index ce82147b83..47099676c2 100644 --- a/irohad/model/commands/detach_role.hpp +++ b/irohad/model/commands/detach_role.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_DETACH_ROLE_HPP diff --git a/irohad/model/commands/grant_permission.hpp b/irohad/model/commands/grant_permission.hpp index 80c27133a0..68a7afa5bb 100644 --- a/irohad/model/commands/grant_permission.hpp +++ b/irohad/model/commands/grant_permission.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GRANT_PERMISSION_HPP diff --git a/irohad/model/commands/remove_signatory.hpp b/irohad/model/commands/remove_signatory.hpp index cecffbe43f..5136c72535 100644 --- a/irohad/model/commands/remove_signatory.hpp +++ b/irohad/model/commands/remove_signatory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_REMOVE_SIGNATORY_HPP #define IROHA_REMOVE_SIGNATORY_HPP diff --git a/irohad/model/commands/revoke_permission.hpp b/irohad/model/commands/revoke_permission.hpp index fa2fe3c6db..16081f449c 100644 --- a/irohad/model/commands/revoke_permission.hpp +++ b/irohad/model/commands/revoke_permission.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_REVOKE_PERMISSION_HPP diff --git a/irohad/model/commands/set_account_detail.hpp b/irohad/model/commands/set_account_detail.hpp index 581d6ae35b..9dd2d0e8e6 100644 --- a/irohad/model/commands/set_account_detail.hpp +++ b/irohad/model/commands/set_account_detail.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ADDACCOUNTDETAIL_HPP diff --git a/irohad/model/commands/set_quorum.hpp b/irohad/model/commands/set_quorum.hpp index e732259313..a6c01d0733 100644 --- a/irohad/model/commands/set_quorum.hpp +++ b/irohad/model/commands/set_quorum.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SET_QUORUM_HPP diff --git a/irohad/model/commands/subtract_asset_quantity.hpp b/irohad/model/commands/subtract_asset_quantity.hpp index 8aec619e00..86d4495126 100644 --- a/irohad/model/commands/subtract_asset_quantity.hpp +++ b/irohad/model/commands/subtract_asset_quantity.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SUBTRACT_ASSET_QUANTITY_HPP #define IROHA_SUBTRACT_ASSET_QUANTITY_HPP diff --git a/irohad/model/commands/transfer_asset.hpp b/irohad/model/commands/transfer_asset.hpp index 4b3e42f285..4b735d80b3 100644 --- a/irohad/model/commands/transfer_asset.hpp +++ b/irohad/model/commands/transfer_asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TRANSFER_ASSET_HPP diff --git a/irohad/model/commit.hpp b/irohad/model/commit.hpp index e03f6b8144..879316410e 100644 --- a/irohad/model/commit.hpp +++ b/irohad/model/commit.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_COMMIT_HPP diff --git a/irohad/model/common.hpp b/irohad/model/common.hpp index 2a3701cdfd..454312b3f1 100644 --- a/irohad/model/common.hpp +++ b/irohad/model/common.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_COMMON_HPP diff --git a/irohad/model/converters/CMakeLists.txt b/irohad/model/converters/CMakeLists.txt index 2dad3d8ef5..b26357df3f 100644 --- a/irohad/model/converters/CMakeLists.txt +++ b/irohad/model/converters/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # add_library(json_model_converters diff --git a/irohad/model/converters/impl/json_block_factory.cpp b/irohad/model/converters/impl/json_block_factory.cpp index b1e3e2f747..b0217a0ad3 100644 --- a/irohad/model/converters/impl/json_block_factory.cpp +++ b/irohad/model/converters/impl/json_block_factory.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/json_block_factory.hpp" diff --git a/irohad/model/converters/impl/json_command_factory.cpp b/irohad/model/converters/impl/json_command_factory.cpp index 74cf2bf62f..f0e8846982 100644 --- a/irohad/model/converters/impl/json_command_factory.cpp +++ b/irohad/model/converters/impl/json_command_factory.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/json_command_factory.hpp" diff --git a/irohad/model/converters/impl/json_common.cpp b/irohad/model/converters/impl/json_common.cpp index c5545088b7..a70351331c 100644 --- a/irohad/model/converters/impl/json_common.cpp +++ b/irohad/model/converters/impl/json_common.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/json_common.hpp" diff --git a/irohad/model/converters/impl/json_query_factory.cpp b/irohad/model/converters/impl/json_query_factory.cpp index 22ef346551..ac5d5331fe 100644 --- a/irohad/model/converters/impl/json_query_factory.cpp +++ b/irohad/model/converters/impl/json_query_factory.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/json_query_factory.hpp" diff --git a/irohad/model/converters/impl/json_transaction_factory.cpp b/irohad/model/converters/impl/json_transaction_factory.cpp index 78734220ca..f0d2cb3544 100644 --- a/irohad/model/converters/impl/json_transaction_factory.cpp +++ b/irohad/model/converters/impl/json_transaction_factory.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/json_transaction_factory.hpp" diff --git a/irohad/model/converters/impl/pb_block_factory.cpp b/irohad/model/converters/impl/pb_block_factory.cpp index 181408346c..8e09958929 100644 --- a/irohad/model/converters/impl/pb_block_factory.cpp +++ b/irohad/model/converters/impl/pb_block_factory.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/pb_block_factory.hpp" diff --git a/irohad/model/converters/impl/pb_common.cpp b/irohad/model/converters/impl/pb_common.cpp index ca61c85720..e55e560197 100644 --- a/irohad/model/converters/impl/pb_common.cpp +++ b/irohad/model/converters/impl/pb_common.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/pb_common.hpp" diff --git a/irohad/model/converters/impl/pb_query_response_factory.cpp b/irohad/model/converters/impl/pb_query_response_factory.cpp index 6ebbc01936..e8ce5e10f6 100644 --- a/irohad/model/converters/impl/pb_query_response_factory.cpp +++ b/irohad/model/converters/impl/pb_query_response_factory.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/pb_query_response_factory.hpp" diff --git a/irohad/model/converters/json_block_factory.hpp b/irohad/model/converters/json_block_factory.hpp index b06b6f3a55..3222df1bae 100644 --- a/irohad/model/converters/json_block_factory.hpp +++ b/irohad/model/converters/json_block_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_JSON_BLOCK_FACTORY_HPP diff --git a/irohad/model/converters/json_command_factory.hpp b/irohad/model/converters/json_command_factory.hpp index 53138fd860..2fbc186ffa 100644 --- a/irohad/model/converters/json_command_factory.hpp +++ b/irohad/model/converters/json_command_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_JSON_COMMAND_FACTORY_HPP diff --git a/irohad/model/converters/json_common.hpp b/irohad/model/converters/json_common.hpp index 920fbbf15e..685189247b 100644 --- a/irohad/model/converters/json_common.hpp +++ b/irohad/model/converters/json_common.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_JSON_COMMON_HPP diff --git a/irohad/model/converters/json_query_factory.hpp b/irohad/model/converters/json_query_factory.hpp index ceae78214d..e4caf041f7 100644 --- a/irohad/model/converters/json_query_factory.hpp +++ b/irohad/model/converters/json_query_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_JSON_QUERY_FACTORY_HPP diff --git a/irohad/model/converters/json_transaction_factory.hpp b/irohad/model/converters/json_transaction_factory.hpp index 52dcce685e..6f310d24a8 100644 --- a/irohad/model/converters/json_transaction_factory.hpp +++ b/irohad/model/converters/json_transaction_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_JSON_TRANSACTION_FACTORY_HPP diff --git a/irohad/model/converters/pb_block_factory.hpp b/irohad/model/converters/pb_block_factory.hpp index 9430b1b568..7fa5962791 100644 --- a/irohad/model/converters/pb_block_factory.hpp +++ b/irohad/model/converters/pb_block_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PBFACTORY_HPP diff --git a/irohad/model/converters/pb_command_factory.hpp b/irohad/model/converters/pb_command_factory.hpp index d3316336ea..c0bb0a33c9 100644 --- a/irohad/model/converters/pb_command_factory.hpp +++ b/irohad/model/converters/pb_command_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PB_COMMAND_FACTORY_HPP diff --git a/irohad/model/converters/pb_common.hpp b/irohad/model/converters/pb_common.hpp index f2dddebf39..5acac44202 100644 --- a/irohad/model/converters/pb_common.hpp +++ b/irohad/model/converters/pb_common.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PB_COMMON_HPP diff --git a/irohad/model/converters/pb_query_factory.hpp b/irohad/model/converters/pb_query_factory.hpp index 2a2296bb77..65329a49b9 100644 --- a/irohad/model/converters/pb_query_factory.hpp +++ b/irohad/model/converters/pb_query_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PB_QUERY_FACTORY_HPP #define IROHA_PB_QUERY_FACTORY_HPP diff --git a/irohad/model/converters/pb_query_response_factory.hpp b/irohad/model/converters/pb_query_response_factory.hpp index 8e92a06823..8ddb8b1296 100644 --- a/irohad/model/converters/pb_query_response_factory.hpp +++ b/irohad/model/converters/pb_query_response_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PB_QUERY_RESPONSE_FACTORY_HPP diff --git a/irohad/model/converters/pb_transaction_factory.hpp b/irohad/model/converters/pb_transaction_factory.hpp index 4d1823f523..ac843be323 100644 --- a/irohad/model/converters/pb_transaction_factory.hpp +++ b/irohad/model/converters/pb_transaction_factory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PB_TRANSACTION_FACTORY_HPP diff --git a/irohad/model/domain.hpp b/irohad/model/domain.hpp index 5d8d8addea..03da80206c 100644 --- a/irohad/model/domain.hpp +++ b/irohad/model/domain.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_DOMAIN_HPP #define IROHA_DOMAIN_HPP diff --git a/irohad/model/generators/CMakeLists.txt b/irohad/model/generators/CMakeLists.txt index 7c05584618..5c7775ff28 100644 --- a/irohad/model/generators/CMakeLists.txt +++ b/irohad/model/generators/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # add_library(model_generators diff --git a/irohad/model/generators/block_generator.hpp b/irohad/model/generators/block_generator.hpp index e1550661de..1c8819f52a 100644 --- a/irohad/model/generators/block_generator.hpp +++ b/irohad/model/generators/block_generator.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/block.hpp" diff --git a/irohad/model/generators/command_generator.hpp b/irohad/model/generators/command_generator.hpp index b8381402e8..0e9421a378 100644 --- a/irohad/model/generators/command_generator.hpp +++ b/irohad/model/generators/command_generator.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_COMMAND_GENERATOR_HPP diff --git a/irohad/model/generators/impl/block_generator.cpp b/irohad/model/generators/impl/block_generator.cpp index b109f2be5c..e0668dda82 100644 --- a/irohad/model/generators/impl/block_generator.cpp +++ b/irohad/model/generators/impl/block_generator.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/generators/block_generator.hpp" diff --git a/irohad/model/generators/impl/command_generator.cpp b/irohad/model/generators/impl/command_generator.cpp index 53669975d5..7c5f90a474 100644 --- a/irohad/model/generators/impl/command_generator.cpp +++ b/irohad/model/generators/impl/command_generator.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/generators/command_generator.hpp" diff --git a/irohad/model/generators/impl/query_generator.cpp b/irohad/model/generators/impl/query_generator.cpp index 60d037f1b3..a12dc0f9a0 100644 --- a/irohad/model/generators/impl/query_generator.cpp +++ b/irohad/model/generators/impl/query_generator.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/irohad/model/generators/impl/transaction_generator.cpp b/irohad/model/generators/impl/transaction_generator.cpp index baf31211f2..d013d0b400 100644 --- a/irohad/model/generators/impl/transaction_generator.cpp +++ b/irohad/model/generators/impl/transaction_generator.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/generators/transaction_generator.hpp" diff --git a/irohad/model/generators/query_generator.hpp b/irohad/model/generators/query_generator.hpp index 2cdd0eb6df..c8a32c9417 100644 --- a/irohad/model/generators/query_generator.hpp +++ b/irohad/model/generators/query_generator.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/irohad/model/generators/signature_generator.hpp b/irohad/model/generators/signature_generator.hpp index ef1757b6b2..4c9da43e28 100644 --- a/irohad/model/generators/signature_generator.hpp +++ b/irohad/model/generators/signature_generator.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SIGNATURE_GENERATOR_HPP diff --git a/irohad/model/generators/transaction_generator.hpp b/irohad/model/generators/transaction_generator.hpp index fe72ed4361..8d48b00736 100644 --- a/irohad/model/generators/transaction_generator.hpp +++ b/irohad/model/generators/transaction_generator.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TRANSACTION_GENERATOR_HPP diff --git a/irohad/model/impl/model_operators.cpp b/irohad/model/impl/model_operators.cpp index 244b269d9a..7eb5c70751 100644 --- a/irohad/model/impl/model_operators.cpp +++ b/irohad/model/impl/model_operators.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "common/instanceof.hpp" #include "model/block.hpp" diff --git a/irohad/model/model_crypto_provider.hpp b/irohad/model/model_crypto_provider.hpp index 9b44fb1cb4..6399f0681a 100644 --- a/irohad/model/model_crypto_provider.hpp +++ b/irohad/model/model_crypto_provider.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MODEL_CRYPTO_PROVIDER_HPP diff --git a/irohad/model/model_crypto_provider_impl.cpp b/irohad/model/model_crypto_provider_impl.cpp index 4def1c5a62..e1a0842561 100644 --- a/irohad/model/model_crypto_provider_impl.cpp +++ b/irohad/model/model_crypto_provider_impl.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/model_crypto_provider_impl.hpp" diff --git a/irohad/model/model_crypto_provider_impl.hpp b/irohad/model/model_crypto_provider_impl.hpp index ddb03d4ccd..0e81e219c4 100644 --- a/irohad/model/model_crypto_provider_impl.hpp +++ b/irohad/model/model_crypto_provider_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MODEL_CRYPTO_PROVIDER_IMPL_HPP diff --git a/irohad/model/peer.hpp b/irohad/model/peer.hpp index 6dd86500f2..f5fa870369 100644 --- a/irohad/model/peer.hpp +++ b/irohad/model/peer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PEER_HPP diff --git a/irohad/model/proposal.hpp b/irohad/model/proposal.hpp index 29a07e8eb8..b3d6488d6b 100644 --- a/irohad/model/proposal.hpp +++ b/irohad/model/proposal.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROPOSAL_HPP diff --git a/irohad/model/queries/get_account.hpp b/irohad/model/queries/get_account.hpp index fce83fe5b9..7e1caa5f14 100644 --- a/irohad/model/queries/get_account.hpp +++ b/irohad/model/queries/get_account.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_ACCOUNT_HPP diff --git a/irohad/model/queries/get_account_assets.hpp b/irohad/model/queries/get_account_assets.hpp index 51e04f992e..f092a42d55 100644 --- a/irohad/model/queries/get_account_assets.hpp +++ b/irohad/model/queries/get_account_assets.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_ACCOUNT_ASSETS_HPP diff --git a/irohad/model/queries/get_account_detail.hpp b/irohad/model/queries/get_account_detail.hpp index 376a3a3664..46ef515e59 100644 --- a/irohad/model/queries/get_account_detail.hpp +++ b/irohad/model/queries/get_account_detail.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_ACCOUNT_DETAIL_HPP diff --git a/irohad/model/queries/get_asset_info.hpp b/irohad/model/queries/get_asset_info.hpp index c2f34951ca..fd2bb799ce 100644 --- a/irohad/model/queries/get_asset_info.hpp +++ b/irohad/model/queries/get_asset_info.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_ASSET_INFO_HPP diff --git a/irohad/model/queries/get_roles.hpp b/irohad/model/queries/get_roles.hpp index 9c06aaf6a5..7d4fe26416 100644 --- a/irohad/model/queries/get_roles.hpp +++ b/irohad/model/queries/get_roles.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_ROLES_HPP diff --git a/irohad/model/queries/get_signatories.hpp b/irohad/model/queries/get_signatories.hpp index 54c7ca20aa..ee7392fe3b 100644 --- a/irohad/model/queries/get_signatories.hpp +++ b/irohad/model/queries/get_signatories.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_SIGNATURES_HPP diff --git a/irohad/model/queries/get_transactions.hpp b/irohad/model/queries/get_transactions.hpp index 4e846094bc..6231772d88 100644 --- a/irohad/model/queries/get_transactions.hpp +++ b/irohad/model/queries/get_transactions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_TRANSACTIONS_HPP diff --git a/irohad/model/queries/responses/account_assets_response.hpp b/irohad/model/queries/responses/account_assets_response.hpp index b7710d1f8e..6030fcb76c 100644 --- a/irohad/model/queries/responses/account_assets_response.hpp +++ b/irohad/model/queries/responses/account_assets_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ACCOUNT_ASSETS_RESPONSE_HPP diff --git a/irohad/model/queries/responses/account_detail_response.hpp b/irohad/model/queries/responses/account_detail_response.hpp index 2c3ed3a243..b0edee585d 100644 --- a/irohad/model/queries/responses/account_detail_response.hpp +++ b/irohad/model/queries/responses/account_detail_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ACCOUNT_DETAIL_RESPONSE_HPP diff --git a/irohad/model/queries/responses/account_response.hpp b/irohad/model/queries/responses/account_response.hpp index 52a1664e9b..ddfd20801b 100644 --- a/irohad/model/queries/responses/account_response.hpp +++ b/irohad/model/queries/responses/account_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ACCOUNT_RESPONSE_HPP diff --git a/irohad/model/queries/responses/asset_response.hpp b/irohad/model/queries/responses/asset_response.hpp index 1d4d4e3b90..b5a02d0e0c 100644 --- a/irohad/model/queries/responses/asset_response.hpp +++ b/irohad/model/queries/responses/asset_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ASSET_RESPONSE_HPP diff --git a/irohad/model/queries/responses/error_response.hpp b/irohad/model/queries/responses/error_response.hpp index 87f48c4995..18c2294a90 100644 --- a/irohad/model/queries/responses/error_response.hpp +++ b/irohad/model/queries/responses/error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ERROR_RESPONSE_HPP diff --git a/irohad/model/queries/responses/roles_response.hpp b/irohad/model/queries/responses/roles_response.hpp index 94c7d8f997..15dde832de 100644 --- a/irohad/model/queries/responses/roles_response.hpp +++ b/irohad/model/queries/responses/roles_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ROLES_RESPONSE_HPP diff --git a/irohad/model/queries/responses/signatories_response.hpp b/irohad/model/queries/responses/signatories_response.hpp index 82886fc516..ced23e73ef 100644 --- a/irohad/model/queries/responses/signatories_response.hpp +++ b/irohad/model/queries/responses/signatories_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SIGNATURES_RESPONSE_HPP diff --git a/irohad/model/queries/responses/transactions_response.hpp b/irohad/model/queries/responses/transactions_response.hpp index 5c26e17737..8470b153ea 100644 --- a/irohad/model/queries/responses/transactions_response.hpp +++ b/irohad/model/queries/responses/transactions_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TRANSACTIONS_RESPONSE_HPP diff --git a/irohad/model/query.hpp b/irohad/model/query.hpp index 840729e30b..931519169d 100644 --- a/irohad/model/query.hpp +++ b/irohad/model/query.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_QUERY_HPP diff --git a/irohad/model/query_response.hpp b/irohad/model/query_response.hpp index e3a15ccf22..02496a9d11 100644 --- a/irohad/model/query_response.hpp +++ b/irohad/model/query_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_QUERY_RESPONSE_HPP diff --git a/irohad/model/sha3_hash.cpp b/irohad/model/sha3_hash.cpp index 2922cf6865..9806a06240 100644 --- a/irohad/model/sha3_hash.cpp +++ b/irohad/model/sha3_hash.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "converters/pb_block_factory.hpp" diff --git a/irohad/model/sha3_hash.hpp b/irohad/model/sha3_hash.hpp index dd4abbf10c..9ef838122a 100644 --- a/irohad/model/sha3_hash.hpp +++ b/irohad/model/sha3_hash.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHA3_HASH_HPP #define IROHA_SHA3_HASH_HPP diff --git a/irohad/model/signature.hpp b/irohad/model/signature.hpp index f31225ebb1..a8d2ef0132 100644 --- a/irohad/model/signature.hpp +++ b/irohad/model/signature.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SIGNATURE_HPP diff --git a/irohad/model/transaction.hpp b/irohad/model/transaction.hpp index fcca467092..829ad70ad7 100644 --- a/irohad/model/transaction.hpp +++ b/irohad/model/transaction.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TRANSACTION_HPP diff --git a/irohad/multi_sig_transactions/gossip_propagation_strategy.hpp b/irohad/multi_sig_transactions/gossip_propagation_strategy.hpp index 78d9a71cc0..4158f80939 100644 --- a/irohad/multi_sig_transactions/gossip_propagation_strategy.hpp +++ b/irohad/multi_sig_transactions/gossip_propagation_strategy.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GOSSIP_PROPAGATION_STRATEGY_HPP diff --git a/irohad/multi_sig_transactions/mst_processor.hpp b/irohad/multi_sig_transactions/mst_processor.hpp index e81e8f9557..22c62726c0 100644 --- a/irohad/multi_sig_transactions/mst_processor.hpp +++ b/irohad/multi_sig_transactions/mst_processor.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MST_PROPAGATOR_HPP diff --git a/irohad/multi_sig_transactions/mst_processor_impl.hpp b/irohad/multi_sig_transactions/mst_processor_impl.hpp index 6197949f2a..aa08889ba6 100644 --- a/irohad/multi_sig_transactions/mst_processor_impl.hpp +++ b/irohad/multi_sig_transactions/mst_processor_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MST_PROCESSOR_IMPL_HPP diff --git a/irohad/multi_sig_transactions/mst_propagation_strategy.hpp b/irohad/multi_sig_transactions/mst_propagation_strategy.hpp index b623fef842..9e1ce09499 100644 --- a/irohad/multi_sig_transactions/mst_propagation_strategy.hpp +++ b/irohad/multi_sig_transactions/mst_propagation_strategy.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MST_PROPAGATION_STRATEGY_HPP diff --git a/irohad/multi_sig_transactions/mst_time_provider_impl.hpp b/irohad/multi_sig_transactions/mst_time_provider_impl.hpp index f02315f6fd..0bd69682f5 100644 --- a/irohad/multi_sig_transactions/mst_time_provider_impl.hpp +++ b/irohad/multi_sig_transactions/mst_time_provider_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MST_TIME_PROVIDER_IMPL_HPP diff --git a/irohad/multi_sig_transactions/storage/mst_storage.hpp b/irohad/multi_sig_transactions/storage/mst_storage.hpp index 5d0ab747d1..12202ceaa4 100644 --- a/irohad/multi_sig_transactions/storage/mst_storage.hpp +++ b/irohad/multi_sig_transactions/storage/mst_storage.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MST_STORAGE_HPP diff --git a/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp b/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp index d37d831c68..45c59f0df5 100644 --- a/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp +++ b/irohad/multi_sig_transactions/storage/mst_storage_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MST_STORAGE_IMPL_HPP diff --git a/irohad/network/impl/async_grpc_client.hpp b/irohad/network/impl/async_grpc_client.hpp index cbf14060f3..37a6445e41 100644 --- a/irohad/network/impl/async_grpc_client.hpp +++ b/irohad/network/impl/async_grpc_client.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ASYNC_GRPC_CLIENT_HPP diff --git a/irohad/network/impl/block_loader_service.cpp b/irohad/network/impl/block_loader_service.cpp index b975665a4a..4f0b48079e 100644 --- a/irohad/network/impl/block_loader_service.cpp +++ b/irohad/network/impl/block_loader_service.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "network/impl/block_loader_service.hpp" diff --git a/irohad/network/impl/block_loader_service.hpp b/irohad/network/impl/block_loader_service.hpp index 2cfe2edb86..6f3fcd639f 100644 --- a/irohad/network/impl/block_loader_service.hpp +++ b/irohad/network/impl/block_loader_service.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_BLOCK_LOADER_SERVICE_HPP diff --git a/irohad/network/impl/grpc_channel_builder.hpp b/irohad/network/impl/grpc_channel_builder.hpp index 7b5f524776..23a2cba415 100644 --- a/irohad/network/impl/grpc_channel_builder.hpp +++ b/irohad/network/impl/grpc_channel_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GRPC_CHANNEL_BUILDER_HPP diff --git a/irohad/network/ordering_gate_transport.hpp b/irohad/network/ordering_gate_transport.hpp index b60ed5326f..bf45571926 100644 --- a/irohad/network/ordering_gate_transport.hpp +++ b/irohad/network/ordering_gate_transport.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERING_GATE_TRANSPORT_H #define IROHA_ORDERING_GATE_TRANSPORT_H diff --git a/irohad/network/ordering_service.hpp b/irohad/network/ordering_service.hpp index 446486783c..9be3edb107 100644 --- a/irohad/network/ordering_service.hpp +++ b/irohad/network/ordering_service.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERINGSERVICE_H diff --git a/irohad/network/ordering_service_transport.hpp b/irohad/network/ordering_service_transport.hpp index 38f40ee9ee..2c50643869 100644 --- a/irohad/network/ordering_service_transport.hpp +++ b/irohad/network/ordering_service_transport.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERING_SERVICE_TRANSPORT_H #define IROHA_ORDERING_SERVICE_TRANSPORT_H diff --git a/irohad/ordering/impl/ordering_gate_impl.hpp b/irohad/ordering/impl/ordering_gate_impl.hpp index 4ffd99f225..d031c207a8 100644 --- a/irohad/ordering/impl/ordering_gate_impl.hpp +++ b/irohad/ordering/impl/ordering_gate_impl.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERING_GATE_IMPL_HPP diff --git a/irohad/ordering/impl/ordering_gate_transport_grpc.hpp b/irohad/ordering/impl/ordering_gate_transport_grpc.hpp index 4ac5690ce5..70d7d9c271 100644 --- a/irohad/ordering/impl/ordering_gate_transport_grpc.hpp +++ b/irohad/ordering/impl/ordering_gate_transport_grpc.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERING_GATE_TRANSPORT_GRPC_H #define IROHA_ORDERING_GATE_TRANSPORT_GRPC_H diff --git a/irohad/ordering/impl/ordering_service_transport_grpc.hpp b/irohad/ordering/impl/ordering_service_transport_grpc.hpp index dbfc96af9c..9692992472 100644 --- a/irohad/ordering/impl/ordering_service_transport_grpc.hpp +++ b/irohad/ordering/impl/ordering_service_transport_grpc.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ORDERING_SERVICE_TRANSPORT_GRPC_HPP #define IROHA_ORDERING_SERVICE_TRANSPORT_GRPC_HPP diff --git a/irohad/synchronizer/CMakeLists.txt b/irohad/synchronizer/CMakeLists.txt index 591e6dd56b..d755e5f4fc 100644 --- a/irohad/synchronizer/CMakeLists.txt +++ b/irohad/synchronizer/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + add_library(synchronizer impl/synchronizer_impl.cpp ) diff --git a/irohad/torii/command_client.hpp b/irohad/torii/command_client.hpp index 1925cbf7d2..f101138c95 100644 --- a/irohad/torii/command_client.hpp +++ b/irohad/torii/command_client.hpp @@ -1,18 +1,7 @@ -/* -Copyright 2017 Soramitsu Co., Ltd. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef TORII_COMMAND_CLIENT_HPP #define TORII_COMMAND_CLIENT_HPP diff --git a/irohad/torii/impl/command_client.cpp b/irohad/torii/impl/command_client.cpp index 8a1664a511..a0d207aa0f 100644 --- a/irohad/torii/impl/command_client.cpp +++ b/irohad/torii/impl/command_client.cpp @@ -1,15 +1,7 @@ -/* -Copyright 2017 Soramitsu Co., Ltd. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include diff --git a/irohad/torii/impl/query_client.cpp b/irohad/torii/impl/query_client.cpp index f1effe4164..48c85a1d0d 100644 --- a/irohad/torii/impl/query_client.cpp +++ b/irohad/torii/impl/query_client.cpp @@ -1,15 +1,7 @@ -/* -Copyright 2017 Soramitsu Co., Ltd. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include "torii/query_client.hpp" diff --git a/irohad/torii/query_client.hpp b/irohad/torii/query_client.hpp index 2a442500ab..3943fa36ca 100644 --- a/irohad/torii/query_client.hpp +++ b/irohad/torii/query_client.hpp @@ -1,18 +1,7 @@ -/* -Copyright 2017 Soramitsu Co., Ltd. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef TORII_UTILS_QUERY_CLIENT_HPP #define TORII_UTILS_QUERY_CLIENT_HPP diff --git a/irohad/validation/CMakeLists.txt b/irohad/validation/CMakeLists.txt index 4db0661671..ad0d76602f 100644 --- a/irohad/validation/CMakeLists.txt +++ b/irohad/validation/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # add_library(stateful_validator diff --git a/libs/cache/cache.hpp b/libs/cache/cache.hpp index fb52bd9dd2..339eb9189b 100644 --- a/libs/cache/cache.hpp +++ b/libs/cache/cache.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CACHE_HPP diff --git a/libs/common/files.cpp b/libs/common/files.cpp index f0b8421fc6..1957901786 100644 --- a/libs/common/files.cpp +++ b/libs/common/files.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "common/files.hpp" diff --git a/libs/common/files.hpp b/libs/common/files.hpp index 69ffbf4a95..9254ed78c4 100644 --- a/libs/common/files.hpp +++ b/libs/common/files.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_FILES_HPP diff --git a/libs/common/result.hpp b/libs/common/result.hpp index 3e3ed3184a..99d3103000 100644 --- a/libs/common/result.hpp +++ b/libs/common/result.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_RESULT_HPP diff --git a/libs/common/set.hpp b/libs/common/set.hpp index a82da667d5..c022d61f16 100644 --- a/libs/common/set.hpp +++ b/libs/common/set.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SET_HPP diff --git a/libs/common/visitor.hpp b/libs/common/visitor.hpp index 63b14d816e..5f904c3437 100644 --- a/libs/common/visitor.hpp +++ b/libs/common/visitor.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_VISITOR_HPP diff --git a/libs/crypto/CMakeLists.txt b/libs/crypto/CMakeLists.txt index 8fc432a478..c232666b91 100644 --- a/libs/crypto/CMakeLists.txt +++ b/libs/crypto/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # diff --git a/libs/generator/CMakeLists.txt b/libs/generator/CMakeLists.txt index 61a638ed3f..5948b40eeb 100644 --- a/libs/generator/CMakeLists.txt +++ b/libs/generator/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + add_library(generator generator.cpp) target_link_libraries(generator boost diff --git a/libs/generator/generator.cpp b/libs/generator/generator.cpp index 7e2ffbcdc1..a9cb77a4c0 100644 --- a/libs/generator/generator.cpp +++ b/libs/generator/generator.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "generator/generator.hpp" diff --git a/libs/generator/generator.hpp b/libs/generator/generator.hpp index be9d14e835..27b5806a5e 100644 --- a/libs/generator/generator.hpp +++ b/libs/generator/generator.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GENERATOR_HPP diff --git a/libs/logger/CMakeLists.txt b/libs/logger/CMakeLists.txt index 32c72412e8..f9fadec2cb 100644 --- a/libs/logger/CMakeLists.txt +++ b/libs/logger/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + add_library(logger STATIC logger.cpp) target_link_libraries(logger spdlog diff --git a/libs/logger/logger.cpp b/libs/logger/logger.cpp index 08553e6fa8..2fd87dcc05 100644 --- a/libs/logger/logger.cpp +++ b/libs/logger/logger.cpp @@ -1,18 +1,7 @@ -/* -Copyright Soramitsu Co., Ltd. 2016 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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include "logger/logger.hpp" diff --git a/libs/parser/CMakeLists.txt b/libs/parser/CMakeLists.txt index d7cc70534f..697c3cb933 100644 --- a/libs/parser/CMakeLists.txt +++ b/libs/parser/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + add_library(parser STATIC parser.cpp) target_link_libraries( parser diff --git a/libs/parser/parser.cpp b/libs/parser/parser.cpp index 7c38242897..5d851ce4f9 100644 --- a/libs/parser/parser.cpp +++ b/libs/parser/parser.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "parser.hpp" diff --git a/libs/parser/parser.hpp b/libs/parser/parser.hpp index f093a4423f..f05c185342 100644 --- a/libs/parser/parser.hpp +++ b/libs/parser/parser.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/shared_model/backend/CMakeLists.txt b/shared_model/backend/CMakeLists.txt index 2f1ca9e0ea..adfbb8b20b 100644 --- a/shared_model/backend/CMakeLists.txt +++ b/shared_model/backend/CMakeLists.txt @@ -1,15 +1,6 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_subdirectory(protobuf) diff --git a/shared_model/backend/protobuf/block.hpp b/shared_model/backend/protobuf/block.hpp index 092c75c572..691cf025c9 100644 --- a/shared_model/backend/protobuf/block.hpp +++ b/shared_model/backend/protobuf/block.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_PROTO_BLOCK_HPP diff --git a/shared_model/backend/protobuf/queries/proto_get_account.hpp b/shared_model/backend/protobuf/queries/proto_get_account.hpp index ed6817958f..07fbe144cb 100644 --- a/shared_model/backend/protobuf/queries/proto_get_account.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_account.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_ACCOUNT_H diff --git a/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp b/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp index fc780aa283..304318eb2e 100644 --- a/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_account_asset_transactions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_ACCOUNT_ASSET_TRANSACTIONS_H diff --git a/shared_model/backend/protobuf/queries/proto_get_account_assets.hpp b/shared_model/backend/protobuf/queries/proto_get_account_assets.hpp index bdd08ccaa7..96c66f4926 100644 --- a/shared_model/backend/protobuf/queries/proto_get_account_assets.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_account_assets.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_ACCOUNT_ASSETS_H diff --git a/shared_model/backend/protobuf/queries/proto_get_account_detail.hpp b/shared_model/backend/protobuf/queries/proto_get_account_detail.hpp index d167f8b48e..43722a1747 100644 --- a/shared_model/backend/protobuf/queries/proto_get_account_detail.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_account_detail.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_ACCOUNT_DETAIL_HPP diff --git a/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp b/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp index 25f78a21f2..5e46f4005e 100644 --- a/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_account_transactions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_GET_ACCOUNT_TRANSACTIONS_H diff --git a/shared_model/backend/protobuf/queries/proto_get_asset_info.hpp b/shared_model/backend/protobuf/queries/proto_get_asset_info.hpp index 5fd273f881..7cc7222830 100644 --- a/shared_model/backend/protobuf/queries/proto_get_asset_info.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_asset_info.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_ASSET_INFO_H diff --git a/shared_model/backend/protobuf/queries/proto_get_role_permissions.hpp b/shared_model/backend/protobuf/queries/proto_get_role_permissions.hpp index ab13b1b533..fb874fcfd1 100644 --- a/shared_model/backend/protobuf/queries/proto_get_role_permissions.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_role_permissions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_ROLE_PERMISSIONS_H diff --git a/shared_model/backend/protobuf/queries/proto_get_roles.hpp b/shared_model/backend/protobuf/queries/proto_get_roles.hpp index 4e5ef3c442..0cc56aa68f 100644 --- a/shared_model/backend/protobuf/queries/proto_get_roles.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_roles.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_ROLES_H diff --git a/shared_model/backend/protobuf/queries/proto_get_signatories.hpp b/shared_model/backend/protobuf/queries/proto_get_signatories.hpp index d2f9434c12..a6d0a3b35c 100644 --- a/shared_model/backend/protobuf/queries/proto_get_signatories.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_signatories.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_SIGNATORIES_H diff --git a/shared_model/backend/protobuf/queries/proto_get_transactions.hpp b/shared_model/backend/protobuf/queries/proto_get_transactions.hpp index 6240217d4e..5dc0fa7fd0 100644 --- a/shared_model/backend/protobuf/queries/proto_get_transactions.hpp +++ b/shared_model/backend/protobuf/queries/proto_get_transactions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_GET_TRANSACTIONS_HPP diff --git a/shared_model/backend/protobuf/util.hpp b/shared_model/backend/protobuf/util.hpp index 9819749070..45cc65e0fc 100644 --- a/shared_model/backend/protobuf/util.hpp +++ b/shared_model/backend/protobuf/util.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_PROTO_UTIL_HPP diff --git a/shared_model/bindings/CMakeLists.txt b/shared_model/bindings/CMakeLists.txt index e6eaa5fd30..0983f2a5ef 100644 --- a/shared_model/bindings/CMakeLists.txt +++ b/shared_model/bindings/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_library(bindings diff --git a/shared_model/bindings/model_crypto.cpp b/shared_model/bindings/model_crypto.cpp index 5a70fc0c6d..d129fd0233 100644 --- a/shared_model/bindings/model_crypto.cpp +++ b/shared_model/bindings/model_crypto.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "bindings/model_crypto.hpp" diff --git a/shared_model/bindings/model_crypto.hpp b/shared_model/bindings/model_crypto.hpp index 1112be12f9..d0fd405075 100644 --- a/shared_model/bindings/model_crypto.hpp +++ b/shared_model/bindings/model_crypto.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_MODEL_CRYPTO_HPP diff --git a/shared_model/bindings/model_proto.hpp b/shared_model/bindings/model_proto.hpp index d4de9e4b9c..656a3ca09a 100644 --- a/shared_model/bindings/model_proto.hpp +++ b/shared_model/bindings/model_proto.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_MODEL_PROTO_HPP diff --git a/shared_model/bindings/model_transaction_builder.cpp b/shared_model/bindings/model_transaction_builder.cpp index 728a9b39a4..11480959ed 100644 --- a/shared_model/bindings/model_transaction_builder.cpp +++ b/shared_model/bindings/model_transaction_builder.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "bindings/model_transaction_builder.hpp" diff --git a/shared_model/bindings/model_transaction_builder.hpp b/shared_model/bindings/model_transaction_builder.hpp index 1b678e1d91..8fbebe20fe 100644 --- a/shared_model/bindings/model_transaction_builder.hpp +++ b/shared_model/bindings/model_transaction_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_MODEL_TRANSACTION_BUILDER_HPP diff --git a/shared_model/builders/CMakeLists.txt b/shared_model/builders/CMakeLists.txt index f9e2bc0efc..b50f4841f8 100644 --- a/shared_model/builders/CMakeLists.txt +++ b/shared_model/builders/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_subdirectory(protobuf) diff --git a/shared_model/builders/default_builders.hpp b/shared_model/builders/default_builders.hpp index 780a41447a..7732960387 100644 --- a/shared_model/builders/default_builders.hpp +++ b/shared_model/builders/default_builders.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_DEFAULT_BUILDERS_HPP diff --git a/shared_model/builders/protobuf/CMakeLists.txt b/shared_model/builders/protobuf/CMakeLists.txt index bdfdce5b05..eeb57517d6 100644 --- a/shared_model/builders/protobuf/CMakeLists.txt +++ b/shared_model/builders/protobuf/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2018 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_library(shared_model_proto_builders transaction_responses/proto_transaction_status_builder.cpp diff --git a/shared_model/builders/protobuf/queries.hpp b/shared_model/builders/protobuf/queries.hpp index 4c2ce88c0b..b0f4985ad8 100644 --- a/shared_model/builders/protobuf/queries.hpp +++ b/shared_model/builders/protobuf/queries.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_QUERY_BUILDER_HPP diff --git a/shared_model/builders/protobuf/transaction.hpp b/shared_model/builders/protobuf/transaction.hpp index 77d2ae7134..c374202f6a 100644 --- a/shared_model/builders/protobuf/transaction.hpp +++ b/shared_model/builders/protobuf/transaction.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_TRANSACTION_BUILDER_HPP diff --git a/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp b/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp index 96aea5b7da..68870a194a 100644 --- a/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp +++ b/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "builders/protobuf/transaction_responses/proto_transaction_status_builder.hpp" diff --git a/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.hpp b/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.hpp index ced8310a29..c347394ff3 100644 --- a/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.hpp +++ b/shared_model/builders/protobuf/transaction_responses/proto_transaction_status_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_TRANSACTION_STATUS_BUILDER_HPP diff --git a/shared_model/builders/protobuf/transport_builder.hpp b/shared_model/builders/protobuf/transport_builder.hpp index 2d912d01b2..703232d854 100644 --- a/shared_model/builders/protobuf/transport_builder.hpp +++ b/shared_model/builders/protobuf/transport_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TRANSPORT_BUILDER_HPP diff --git a/shared_model/builders/protobuf/unsigned_proto.hpp b/shared_model/builders/protobuf/unsigned_proto.hpp index 9643f53529..274ffeabb9 100644 --- a/shared_model/builders/protobuf/unsigned_proto.hpp +++ b/shared_model/builders/protobuf/unsigned_proto.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_UNSIGNED_PROTO_HPP diff --git a/shared_model/builders/transaction_responses/transaction_status_builder.hpp b/shared_model/builders/transaction_responses/transaction_status_builder.hpp index 2add1dad59..9fe8bec704 100644 --- a/shared_model/builders/transaction_responses/transaction_status_builder.hpp +++ b/shared_model/builders/transaction_responses/transaction_status_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TRANSACTION_STATUS_BUILDER_HPP diff --git a/shared_model/converters/CMakeLists.txt b/shared_model/converters/CMakeLists.txt index 4d3b778da1..c49040f15a 100644 --- a/shared_model/converters/CMakeLists.txt +++ b/shared_model/converters/CMakeLists.txt @@ -1,14 +1,5 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/shared_model/converters/protobuf/json_proto_converter.hpp b/shared_model/converters/protobuf/json_proto_converter.hpp index 5854b0728c..42e3f30bd2 100644 --- a/shared_model/converters/protobuf/json_proto_converter.hpp +++ b/shared_model/converters/protobuf/json_proto_converter.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_JSON_PROTO_CONVERTER_HPP diff --git a/shared_model/cryptography/CMakeLists.txt b/shared_model/cryptography/CMakeLists.txt index cb80e950e4..ee4dbaa08d 100644 --- a/shared_model/cryptography/CMakeLists.txt +++ b/shared_model/cryptography/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # shared_model_cryptography is the main target which includes ed25519 and crypto_model diff --git a/shared_model/cryptography/blob.hpp b/shared_model/cryptography/blob.hpp index 5a0203f16f..da32d73d4f 100644 --- a/shared_model/cryptography/blob.hpp +++ b/shared_model/cryptography/blob.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_BLOB_HPP diff --git a/shared_model/cryptography/crypto_provider/crypto_defaults.hpp b/shared_model/cryptography/crypto_provider/crypto_defaults.hpp index 1ca6e0e280..fa870b6d7b 100644 --- a/shared_model/cryptography/crypto_provider/crypto_defaults.hpp +++ b/shared_model/cryptography/crypto_provider/crypto_defaults.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_CRYPTO_DEFAULTS_HPP diff --git a/shared_model/cryptography/crypto_provider/crypto_model_signer.hpp b/shared_model/cryptography/crypto_provider/crypto_model_signer.hpp index cd7bb9b426..58f08aaf7b 100644 --- a/shared_model/cryptography/crypto_provider/crypto_model_signer.hpp +++ b/shared_model/cryptography/crypto_provider/crypto_model_signer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CRYPTO_MODEL_SIGNER_HPP_ diff --git a/shared_model/cryptography/crypto_provider/crypto_signer.hpp b/shared_model/cryptography/crypto_provider/crypto_signer.hpp index 452a40f488..b53b8f602e 100644 --- a/shared_model/cryptography/crypto_provider/crypto_signer.hpp +++ b/shared_model/cryptography/crypto_provider/crypto_signer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CRYPTO_SIGNER_HPP diff --git a/shared_model/cryptography/crypto_provider/crypto_verifier.hpp b/shared_model/cryptography/crypto_provider/crypto_verifier.hpp index 0de94f19fe..aaa4d46f08 100644 --- a/shared_model/cryptography/crypto_provider/crypto_verifier.hpp +++ b/shared_model/cryptography/crypto_provider/crypto_verifier.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CRYPTO_VERIFIER_HPP diff --git a/shared_model/cryptography/default_hash_provider.hpp b/shared_model/cryptography/default_hash_provider.hpp index ce07b4b574..9cea98e8ce 100644 --- a/shared_model/cryptography/default_hash_provider.hpp +++ b/shared_model/cryptography/default_hash_provider.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_DEFAULT_HASH_PROVIDER_HPP diff --git a/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt b/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt index 53722056a8..8ae3ee59f9 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt +++ b/shared_model/cryptography/ed25519_sha3_impl/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_subdirectory(internal) diff --git a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp index 8d488438d8..1a35610726 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp +++ b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/ed25519_sha3_impl/crypto_provider.hpp" diff --git a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp index 2ba900cc71..f742618008 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp +++ b/shared_model/cryptography/ed25519_sha3_impl/crypto_provider.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CRYPTOPROVIDER_HPP diff --git a/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt b/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt index 65f9f345c3..4a5b60849e 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt +++ b/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # add_library(hash diff --git a/shared_model/cryptography/ed25519_sha3_impl/signer.cpp b/shared_model/cryptography/ed25519_sha3_impl/signer.cpp index 9ca530a28a..1a08a6ae7f 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/signer.cpp +++ b/shared_model/cryptography/ed25519_sha3_impl/signer.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/ed25519_sha3_impl/signer.hpp" diff --git a/shared_model/cryptography/ed25519_sha3_impl/signer.hpp b/shared_model/cryptography/ed25519_sha3_impl/signer.hpp index 002c89d7a9..052991d15a 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/signer.hpp +++ b/shared_model/cryptography/ed25519_sha3_impl/signer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_SIGNER_HPP diff --git a/shared_model/cryptography/ed25519_sha3_impl/verifier.cpp b/shared_model/cryptography/ed25519_sha3_impl/verifier.cpp index 6809fa7a47..e798d5d133 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/verifier.cpp +++ b/shared_model/cryptography/ed25519_sha3_impl/verifier.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "verifier.hpp" diff --git a/shared_model/cryptography/ed25519_sha3_impl/verifier.hpp b/shared_model/cryptography/ed25519_sha3_impl/verifier.hpp index 405165c02b..295086056e 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/verifier.hpp +++ b/shared_model/cryptography/ed25519_sha3_impl/verifier.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_VERIFIER_HPP diff --git a/shared_model/cryptography/hash.hpp b/shared_model/cryptography/hash.hpp index b42b783911..e237f29d9e 100644 --- a/shared_model/cryptography/hash.hpp +++ b/shared_model/cryptography/hash.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_HASH_HPP diff --git a/shared_model/cryptography/hash_providers/sha3_512.hpp b/shared_model/cryptography/hash_providers/sha3_512.hpp index 6b255cf211..65260c15f1 100644 --- a/shared_model/cryptography/hash_providers/sha3_512.hpp +++ b/shared_model/cryptography/hash_providers/sha3_512.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_SHA3_512_HPP diff --git a/shared_model/cryptography/keypair.hpp b/shared_model/cryptography/keypair.hpp index 3e4b6fc9d1..72a68bf630 100644 --- a/shared_model/cryptography/keypair.hpp +++ b/shared_model/cryptography/keypair.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_KEYPAIR_HPP diff --git a/shared_model/cryptography/model_impl/CMakeLists.txt b/shared_model/cryptography/model_impl/CMakeLists.txt index 9ba390910d..fad9fe7716 100644 --- a/shared_model/cryptography/model_impl/CMakeLists.txt +++ b/shared_model/cryptography/model_impl/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + add_library(shared_model_cryptography_model blob.cpp hash.cpp diff --git a/shared_model/cryptography/model_impl/blob.cpp b/shared_model/cryptography/model_impl/blob.cpp index 8cf6014cee..cb44d8f966 100644 --- a/shared_model/cryptography/model_impl/blob.cpp +++ b/shared_model/cryptography/model_impl/blob.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/blob.hpp" diff --git a/shared_model/cryptography/model_impl/hash.cpp b/shared_model/cryptography/model_impl/hash.cpp index a9faa4d619..77a0f37724 100644 --- a/shared_model/cryptography/model_impl/hash.cpp +++ b/shared_model/cryptography/model_impl/hash.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/hash.hpp" diff --git a/shared_model/cryptography/model_impl/keypair.cpp b/shared_model/cryptography/model_impl/keypair.cpp index e1224cf073..a083106b60 100644 --- a/shared_model/cryptography/model_impl/keypair.cpp +++ b/shared_model/cryptography/model_impl/keypair.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/keypair.hpp" diff --git a/shared_model/cryptography/model_impl/private_key.cpp b/shared_model/cryptography/model_impl/private_key.cpp index 9dd2974d8f..e8bc13d6b7 100644 --- a/shared_model/cryptography/model_impl/private_key.cpp +++ b/shared_model/cryptography/model_impl/private_key.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/private_key.hpp" diff --git a/shared_model/cryptography/model_impl/public_key.cpp b/shared_model/cryptography/model_impl/public_key.cpp index 45212ab811..7a00fcc7fd 100644 --- a/shared_model/cryptography/model_impl/public_key.cpp +++ b/shared_model/cryptography/model_impl/public_key.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/public_key.hpp" diff --git a/shared_model/cryptography/model_impl/seed.cpp b/shared_model/cryptography/model_impl/seed.cpp index 73b503e9ee..ffae683e80 100644 --- a/shared_model/cryptography/model_impl/seed.cpp +++ b/shared_model/cryptography/model_impl/seed.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/seed.hpp" diff --git a/shared_model/cryptography/model_impl/signed.cpp b/shared_model/cryptography/model_impl/signed.cpp index f84cf4eebb..574e4311bd 100644 --- a/shared_model/cryptography/model_impl/signed.cpp +++ b/shared_model/cryptography/model_impl/signed.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/signed.hpp" diff --git a/shared_model/cryptography/private_key.hpp b/shared_model/cryptography/private_key.hpp index 690ed678a0..6d5ae12268 100644 --- a/shared_model/cryptography/private_key.hpp +++ b/shared_model/cryptography/private_key.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_PRIVATE_KEY_HPP diff --git a/shared_model/cryptography/public_key.hpp b/shared_model/cryptography/public_key.hpp index ca6baf14d0..24df42afb9 100644 --- a/shared_model/cryptography/public_key.hpp +++ b/shared_model/cryptography/public_key.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_PUBLIC_KEY_HPP diff --git a/shared_model/cryptography/seed.hpp b/shared_model/cryptography/seed.hpp index d845585893..41470c8b8a 100644 --- a/shared_model/cryptography/seed.hpp +++ b/shared_model/cryptography/seed.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SEED_HPP diff --git a/shared_model/cryptography/signed.hpp b/shared_model/cryptography/signed.hpp index 849248c80c..3bb3f8d830 100644 --- a/shared_model/cryptography/signed.hpp +++ b/shared_model/cryptography/signed.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_SIGNED_HPP diff --git a/shared_model/interfaces/base/model_primitive.hpp b/shared_model/interfaces/base/model_primitive.hpp index 625d2a12aa..3d4e00b3bf 100644 --- a/shared_model/interfaces/base/model_primitive.hpp +++ b/shared_model/interfaces/base/model_primitive.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MODEL_PRIMITIVE_HPP diff --git a/shared_model/interfaces/commands/add_asset_quantity.hpp b/shared_model/interfaces/commands/add_asset_quantity.hpp index 24e768e8a3..df12ee0e34 100644 --- a/shared_model/interfaces/commands/add_asset_quantity.hpp +++ b/shared_model/interfaces/commands/add_asset_quantity.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ADD_ASSET_QUANTITY_HPP diff --git a/shared_model/interfaces/commands/add_peer.hpp b/shared_model/interfaces/commands/add_peer.hpp index 68ddda3cbb..737d440d24 100644 --- a/shared_model/interfaces/commands/add_peer.hpp +++ b/shared_model/interfaces/commands/add_peer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ADD_PEER_HPP diff --git a/shared_model/interfaces/commands/add_signatory.hpp b/shared_model/interfaces/commands/add_signatory.hpp index 89009b7dbe..2d898b02ea 100644 --- a/shared_model/interfaces/commands/add_signatory.hpp +++ b/shared_model/interfaces/commands/add_signatory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ADD_SIGNATORY_HPP diff --git a/shared_model/interfaces/commands/append_role.hpp b/shared_model/interfaces/commands/append_role.hpp index 40e087ca5c..041125699a 100644 --- a/shared_model/interfaces/commands/append_role.hpp +++ b/shared_model/interfaces/commands/append_role.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_APPEND_ROLE_HPP diff --git a/shared_model/interfaces/commands/create_account.hpp b/shared_model/interfaces/commands/create_account.hpp index a7d137a3e6..6df12214af 100644 --- a/shared_model/interfaces/commands/create_account.hpp +++ b/shared_model/interfaces/commands/create_account.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_CREATE_ACCOUNT_HPP diff --git a/shared_model/interfaces/commands/create_asset.hpp b/shared_model/interfaces/commands/create_asset.hpp index 8139767366..dccbf43bcf 100644 --- a/shared_model/interfaces/commands/create_asset.hpp +++ b/shared_model/interfaces/commands/create_asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_CREATE_ASSET_HPP diff --git a/shared_model/interfaces/commands/create_domain.hpp b/shared_model/interfaces/commands/create_domain.hpp index 470f7e8969..b15b3ca9a5 100644 --- a/shared_model/interfaces/commands/create_domain.hpp +++ b/shared_model/interfaces/commands/create_domain.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_CREATE_DOMAIN_HPP diff --git a/shared_model/interfaces/commands/create_role.hpp b/shared_model/interfaces/commands/create_role.hpp index eb916d4ad7..9cc4d38ef0 100644 --- a/shared_model/interfaces/commands/create_role.hpp +++ b/shared_model/interfaces/commands/create_role.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_CREATE_ROLE_HPP diff --git a/shared_model/interfaces/commands/detach_role.hpp b/shared_model/interfaces/commands/detach_role.hpp index 49005daa25..0498ba30e8 100644 --- a/shared_model/interfaces/commands/detach_role.hpp +++ b/shared_model/interfaces/commands/detach_role.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_DETACH_ROLE_HPP diff --git a/shared_model/interfaces/commands/grant_permission.hpp b/shared_model/interfaces/commands/grant_permission.hpp index ea8c4e2005..6bedec76f4 100644 --- a/shared_model/interfaces/commands/grant_permission.hpp +++ b/shared_model/interfaces/commands/grant_permission.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GRANT_PERMISSION_HPP diff --git a/shared_model/interfaces/commands/remove_signatory.hpp b/shared_model/interfaces/commands/remove_signatory.hpp index 6ab02cfed0..56bf6a6d24 100644 --- a/shared_model/interfaces/commands/remove_signatory.hpp +++ b/shared_model/interfaces/commands/remove_signatory.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_REMOVE_SIGNATORY_HPP diff --git a/shared_model/interfaces/commands/revoke_permission.hpp b/shared_model/interfaces/commands/revoke_permission.hpp index 44744cd718..b913ea98bd 100644 --- a/shared_model/interfaces/commands/revoke_permission.hpp +++ b/shared_model/interfaces/commands/revoke_permission.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_REVOKE_PERMISSION_HPP diff --git a/shared_model/interfaces/commands/set_account_detail.hpp b/shared_model/interfaces/commands/set_account_detail.hpp index 5526177699..6648c925dc 100644 --- a/shared_model/interfaces/commands/set_account_detail.hpp +++ b/shared_model/interfaces/commands/set_account_detail.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_SET_ACCOUNT_DETAIL_HPP diff --git a/shared_model/interfaces/commands/set_quorum.hpp b/shared_model/interfaces/commands/set_quorum.hpp index 0f34e98207..46b94fab08 100644 --- a/shared_model/interfaces/commands/set_quorum.hpp +++ b/shared_model/interfaces/commands/set_quorum.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_SET_QUORUM_HPP diff --git a/shared_model/interfaces/commands/subtract_asset_quantity.hpp b/shared_model/interfaces/commands/subtract_asset_quantity.hpp index 9e181c5440..445c736ed2 100644 --- a/shared_model/interfaces/commands/subtract_asset_quantity.hpp +++ b/shared_model/interfaces/commands/subtract_asset_quantity.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_SUBTRACT_ASSET_QUANTITY_HPP diff --git a/shared_model/interfaces/commands/transfer_asset.hpp b/shared_model/interfaces/commands/transfer_asset.hpp index d8e79ff22b..4eab96831f 100644 --- a/shared_model/interfaces/commands/transfer_asset.hpp +++ b/shared_model/interfaces/commands/transfer_asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_TRANSFER_ASSET_HPP diff --git a/shared_model/interfaces/common_objects/account.hpp b/shared_model/interfaces/common_objects/account.hpp index 2202f216b3..1a56819aa8 100644 --- a/shared_model/interfaces/common_objects/account.hpp +++ b/shared_model/interfaces/common_objects/account.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ACCOUNT_HPP diff --git a/shared_model/interfaces/common_objects/account_asset.hpp b/shared_model/interfaces/common_objects/account_asset.hpp index ca254ddd96..89d0122d2f 100644 --- a/shared_model/interfaces/common_objects/account_asset.hpp +++ b/shared_model/interfaces/common_objects/account_asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ACCOUNT_ASSET_HPP diff --git a/shared_model/interfaces/common_objects/asset.hpp b/shared_model/interfaces/common_objects/asset.hpp index 9d88e1dbea..3b2f624aba 100644 --- a/shared_model/interfaces/common_objects/asset.hpp +++ b/shared_model/interfaces/common_objects/asset.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ASSET_HPP diff --git a/shared_model/interfaces/common_objects/domain.hpp b/shared_model/interfaces/common_objects/domain.hpp index 649963b56f..fea972c24c 100644 --- a/shared_model/interfaces/common_objects/domain.hpp +++ b/shared_model/interfaces/common_objects/domain.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_DOMAIN_HPP diff --git a/shared_model/interfaces/iroha_internal/proposal.hpp b/shared_model/interfaces/iroha_internal/proposal.hpp index 53043872ac..94242d2f58 100644 --- a/shared_model/interfaces/iroha_internal/proposal.hpp +++ b/shared_model/interfaces/iroha_internal/proposal.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_PROPOSAL_HPP diff --git a/shared_model/interfaces/queries/get_account.hpp b/shared_model/interfaces/queries/get_account.hpp index a27348ff78..9d7ee1747d 100644 --- a/shared_model/interfaces/queries/get_account.hpp +++ b/shared_model/interfaces/queries/get_account.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ACCOUNT_HPP diff --git a/shared_model/interfaces/queries/get_account_asset_transactions.hpp b/shared_model/interfaces/queries/get_account_asset_transactions.hpp index aa747f1e0d..3a5701d5f6 100644 --- a/shared_model/interfaces/queries/get_account_asset_transactions.hpp +++ b/shared_model/interfaces/queries/get_account_asset_transactions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ACCOUNT_ASSET_TRANSACTIONS_HPP diff --git a/shared_model/interfaces/queries/get_account_assets.hpp b/shared_model/interfaces/queries/get_account_assets.hpp index b50bca0707..ac6867b0e1 100644 --- a/shared_model/interfaces/queries/get_account_assets.hpp +++ b/shared_model/interfaces/queries/get_account_assets.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ACCOUNT_ASSETS_HPP diff --git a/shared_model/interfaces/queries/get_account_detail.hpp b/shared_model/interfaces/queries/get_account_detail.hpp index e65dc78e58..fb318f48a8 100644 --- a/shared_model/interfaces/queries/get_account_detail.hpp +++ b/shared_model/interfaces/queries/get_account_detail.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ACCOUNT_DETAIL_HPP diff --git a/shared_model/interfaces/queries/get_account_transactions.hpp b/shared_model/interfaces/queries/get_account_transactions.hpp index fc5cd59f3d..e38ad9bb13 100644 --- a/shared_model/interfaces/queries/get_account_transactions.hpp +++ b/shared_model/interfaces/queries/get_account_transactions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ACCOUNT_TRANSACTIONS_HPP diff --git a/shared_model/interfaces/queries/get_asset_info.hpp b/shared_model/interfaces/queries/get_asset_info.hpp index 668753d651..50ae43f16e 100644 --- a/shared_model/interfaces/queries/get_asset_info.hpp +++ b/shared_model/interfaces/queries/get_asset_info.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ASSET_INFO_HPP diff --git a/shared_model/interfaces/queries/get_role_permissions.hpp b/shared_model/interfaces/queries/get_role_permissions.hpp index 45a595909a..bf497556ce 100644 --- a/shared_model/interfaces/queries/get_role_permissions.hpp +++ b/shared_model/interfaces/queries/get_role_permissions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copyof the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ROLE_PERMISSIONS_HPP diff --git a/shared_model/interfaces/queries/get_roles.hpp b/shared_model/interfaces/queries/get_roles.hpp index 76c353f136..f562d9ab2e 100644 --- a/shared_model/interfaces/queries/get_roles.hpp +++ b/shared_model/interfaces/queries/get_roles.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_ROLES_HPP diff --git a/shared_model/interfaces/queries/get_signatories.hpp b/shared_model/interfaces/queries/get_signatories.hpp index 33332e5552..0a2f36220e 100644 --- a/shared_model/interfaces/queries/get_signatories.hpp +++ b/shared_model/interfaces/queries/get_signatories.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_SIGNATORIES_HPP diff --git a/shared_model/interfaces/queries/get_transactions.hpp b/shared_model/interfaces/queries/get_transactions.hpp index 20f8ed7052..ea4540d3b6 100644 --- a/shared_model/interfaces/queries/get_transactions.hpp +++ b/shared_model/interfaces/queries/get_transactions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_GET_TRANSACTIONS_HPP diff --git a/shared_model/interfaces/query_responses/account_detail_response.hpp b/shared_model/interfaces/query_responses/account_detail_response.hpp index 175091afa5..4227bd05af 100644 --- a/shared_model/interfaces/query_responses/account_detail_response.hpp +++ b/shared_model/interfaces/query_responses/account_detail_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ACCOUNT_DETAIL_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/account_response.hpp b/shared_model/interfaces/query_responses/account_response.hpp index 262072ff14..1d96ef8575 100644 --- a/shared_model/interfaces/query_responses/account_response.hpp +++ b/shared_model/interfaces/query_responses/account_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ACCOUNT_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/asset_response.hpp b/shared_model/interfaces/query_responses/asset_response.hpp index 10e4d3c62c..dead899109 100644 --- a/shared_model/interfaces/query_responses/asset_response.hpp +++ b/shared_model/interfaces/query_responses/asset_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ASSET_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/abstract_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/abstract_error_response.hpp index 8fc57bae23..02a2ea3b09 100644 --- a/shared_model/interfaces/query_responses/error_responses/abstract_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/abstract_error_response.hpp @@ -1,19 +1,6 @@ - /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ABSTRACT_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/no_account_assets_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/no_account_assets_error_response.hpp index 2c472d432d..9f80af612c 100644 --- a/shared_model/interfaces/query_responses/error_responses/no_account_assets_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/no_account_assets_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_NO_ACCOUNT_ASSETS_ERROR_REPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/no_account_detail_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/no_account_detail_error_response.hpp index 1298e09cd9..be307266b6 100644 --- a/shared_model/interfaces/query_responses/error_responses/no_account_detail_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/no_account_detail_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_NO_ACCOUNT_DETAIL_ERROR_REPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/no_account_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/no_account_error_response.hpp index a5fa32ced9..643c80a83c 100644 --- a/shared_model/interfaces/query_responses/error_responses/no_account_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/no_account_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_NO_ACCOUNT_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/no_asset_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/no_asset_error_response.hpp index 64cce068b2..a91fe1d5bf 100644 --- a/shared_model/interfaces/query_responses/error_responses/no_asset_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/no_asset_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_NO_ASSET_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/no_roles_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/no_roles_error_response.hpp index 7f5a69c056..9f35200aee 100644 --- a/shared_model/interfaces/query_responses/error_responses/no_roles_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/no_roles_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_NO_ROLES_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/no_signatories_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/no_signatories_error_response.hpp index 6461b0dbd3..df32be2526 100644 --- a/shared_model/interfaces/query_responses/error_responses/no_signatories_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/no_signatories_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_NO_SIGNATORIES_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/not_supported_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/not_supported_error_response.hpp index 2dd5cde3a5..f96524f898 100644 --- a/shared_model/interfaces/query_responses/error_responses/not_supported_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/not_supported_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_NOT_SUPPORTED_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/stateful_failed_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/stateful_failed_error_response.hpp index a9eb27ccda..53d2917db5 100644 --- a/shared_model/interfaces/query_responses/error_responses/stateful_failed_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/stateful_failed_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_STATEFUL_FAILED_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/error_responses/stateless_failed_error_response.hpp b/shared_model/interfaces/query_responses/error_responses/stateless_failed_error_response.hpp index 099702a930..921497a42d 100644 --- a/shared_model/interfaces/query_responses/error_responses/stateless_failed_error_response.hpp +++ b/shared_model/interfaces/query_responses/error_responses/stateless_failed_error_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_STATELESS_FAILED_ERROR_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/role_permissions.hpp b/shared_model/interfaces/query_responses/role_permissions.hpp index 7bcbef72c9..ed2051ecaa 100644 --- a/shared_model/interfaces/query_responses/role_permissions.hpp +++ b/shared_model/interfaces/query_responses/role_permissions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ROLE_PERMISSIONS_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/roles_response.hpp b/shared_model/interfaces/query_responses/roles_response.hpp index ee7bebc27e..6f651804b7 100644 --- a/shared_model/interfaces/query_responses/roles_response.hpp +++ b/shared_model/interfaces/query_responses/roles_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_ROLES_RESPONSE_HPP diff --git a/shared_model/interfaces/query_responses/signatories_response.hpp b/shared_model/interfaces/query_responses/signatories_response.hpp index 555a0c5f38..c863dd7318 100644 --- a/shared_model/interfaces/query_responses/signatories_response.hpp +++ b/shared_model/interfaces/query_responses/signatories_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_SIGNATORIES_RESPONSE_HPP diff --git a/shared_model/interfaces/transaction_responses/abstract_tx_response.hpp b/shared_model/interfaces/transaction_responses/abstract_tx_response.hpp index c878e9a5f1..e3be55640b 100644 --- a/shared_model/interfaces/transaction_responses/abstract_tx_response.hpp +++ b/shared_model/interfaces/transaction_responses/abstract_tx_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ABSTRACT_TX_RESPONSE_HPP diff --git a/shared_model/interfaces/transaction_responses/committed_tx_response.hpp b/shared_model/interfaces/transaction_responses/committed_tx_response.hpp index 390c6d9b06..fe2444d37d 100644 --- a/shared_model/interfaces/transaction_responses/committed_tx_response.hpp +++ b/shared_model/interfaces/transaction_responses/committed_tx_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_COMMITTED_TX_RESPONSE_HPP diff --git a/shared_model/interfaces/transaction_responses/not_received_tx_response.hpp b/shared_model/interfaces/transaction_responses/not_received_tx_response.hpp index 71d8e5f1bd..b8e8b39f50 100644 --- a/shared_model/interfaces/transaction_responses/not_received_tx_response.hpp +++ b/shared_model/interfaces/transaction_responses/not_received_tx_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_UNKNOWN_TX_RESPONSE_HPP diff --git a/shared_model/interfaces/transaction_responses/stateful_failed_tx_response.hpp b/shared_model/interfaces/transaction_responses/stateful_failed_tx_response.hpp index a4ffb03ca6..8fc34a516d 100644 --- a/shared_model/interfaces/transaction_responses/stateful_failed_tx_response.hpp +++ b/shared_model/interfaces/transaction_responses/stateful_failed_tx_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_STATEFUL_FAILED_TX_RESPONSE_HPP diff --git a/shared_model/interfaces/transaction_responses/stateful_valid_tx_response.hpp b/shared_model/interfaces/transaction_responses/stateful_valid_tx_response.hpp index 0286e88db1..ba6103a57f 100644 --- a/shared_model/interfaces/transaction_responses/stateful_valid_tx_response.hpp +++ b/shared_model/interfaces/transaction_responses/stateful_valid_tx_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_STATEFUL_VALID_TX_RESPONSE_HPP diff --git a/shared_model/interfaces/transaction_responses/stateless_failed_tx_response.hpp b/shared_model/interfaces/transaction_responses/stateless_failed_tx_response.hpp index eb16d97047..9e29ab3b1e 100644 --- a/shared_model/interfaces/transaction_responses/stateless_failed_tx_response.hpp +++ b/shared_model/interfaces/transaction_responses/stateless_failed_tx_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_STATELESS_FAILED_TX_RESPONSE_HPP diff --git a/shared_model/interfaces/transaction_responses/stateless_valid_tx_response.hpp b/shared_model/interfaces/transaction_responses/stateless_valid_tx_response.hpp index 497b23ae82..8f4023710b 100644 --- a/shared_model/interfaces/transaction_responses/stateless_valid_tx_response.hpp +++ b/shared_model/interfaces/transaction_responses/stateless_valid_tx_response.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_STATELESS_VALID_TX_RESPONSE_HPP diff --git a/shared_model/test/CMakeLists.txt b/shared_model/test/CMakeLists.txt index 3aeb9bd6b2..e6477b65cd 100644 --- a/shared_model/test/CMakeLists.txt +++ b/shared_model/test/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test_bin) include_directories( diff --git a/shared_model/utils/query_error_response_visitor.hpp b/shared_model/utils/query_error_response_visitor.hpp index aefcd79279..cf7895d0f1 100644 --- a/shared_model/utils/query_error_response_visitor.hpp +++ b/shared_model/utils/query_error_response_visitor.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_QUERY_ERROR_RESPONSE_VISITOR_HPP diff --git a/shared_model/utils/swig_keyword_hider.hpp b/shared_model/utils/swig_keyword_hider.hpp index cd1c0f2b88..40cf5daa84 100644 --- a/shared_model/utils/swig_keyword_hider.hpp +++ b/shared_model/utils/swig_keyword_hider.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SWIG_KEYWORD_HIDER_HPP diff --git a/shared_model/utils/visitor_apply_for_all.hpp b/shared_model/utils/visitor_apply_for_all.hpp index d50c1579c9..ede3d2ccf5 100644 --- a/shared_model/utils/visitor_apply_for_all.hpp +++ b/shared_model/utils/visitor_apply_for_all.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_VISITOR_APPLY_FOR_ALL_HPP diff --git a/shared_model/validators/amount_true_validator.hpp b/shared_model/validators/amount_true_validator.hpp index 30a56d6b29..4bc2286ac0 100644 --- a/shared_model/validators/amount_true_validator.hpp +++ b/shared_model/validators/amount_true_validator.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SHARED_MODEL_AMOUNT_TRUE_VALIDATOR_HPP diff --git a/shared_model/validators/answer.hpp b/shared_model/validators/answer.hpp index 90da037a5e..55f4e0227d 100644 --- a/shared_model/validators/answer.hpp +++ b/shared_model/validators/answer.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ANSWER_HPP diff --git a/shared_model/validators/permissions.hpp b/shared_model/validators/permissions.hpp index 605885e6a1..3ea10919f5 100644 --- a/shared_model/validators/permissions.hpp +++ b/shared_model/validators/permissions.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef SHARED_MODEL_PERMISSIONS_HPP diff --git a/test/benchmark/CMakeLists.txt b/test/benchmark/CMakeLists.txt index 7bb5ecb128..d10daed84b 100644 --- a/test/benchmark/CMakeLists.txt +++ b/test/benchmark/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + # directory contains benchmarks # default benchmark path is build/benchmark_bin diff --git a/test/benchmark/benchmark_example.cpp b/test/benchmark/benchmark_example.cpp index eab4c97ec5..ec2715f2ba 100644 --- a/test/benchmark/benchmark_example.cpp +++ b/test/benchmark/benchmark_example.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ /// diff --git a/test/framework/CMakeLists.txt b/test/framework/CMakeLists.txt index 08dd1c99bb..5de576c4ba 100644 --- a/test/framework/CMakeLists.txt +++ b/test/framework/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(test_subscriber_testing test_subscriber_testing.cpp) diff --git a/test/framework/config_helper.cpp b/test/framework/config_helper.cpp index b05d9f2bf8..4cfa2fe69c 100644 --- a/test/framework/config_helper.cpp +++ b/test/framework/config_helper.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "framework/config_helper.hpp" diff --git a/test/framework/config_helper.hpp b/test/framework/config_helper.hpp index b019f6f699..ed09ed8fd4 100644 --- a/test/framework/config_helper.hpp +++ b/test/framework/config_helper.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CONFIG_HELPER_HPP diff --git a/test/framework/integration_framework/iroha_instance.cpp b/test/framework/integration_framework/iroha_instance.cpp index 3cff519632..da9ff7913e 100644 --- a/test/framework/integration_framework/iroha_instance.cpp +++ b/test/framework/integration_framework/iroha_instance.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "framework/integration_framework/iroha_instance.hpp" diff --git a/test/framework/integration_framework/iroha_instance.hpp b/test/framework/integration_framework/iroha_instance.hpp index af9f7fdd69..93eb0ae33b 100644 --- a/test/framework/integration_framework/iroha_instance.hpp +++ b/test/framework/integration_framework/iroha_instance.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_IROHA_INSTANCE_HPP diff --git a/test/framework/integration_framework/test_irohad.hpp b/test/framework/integration_framework/test_irohad.hpp index e1c28ea4cc..f586c2fc21 100644 --- a/test/framework/integration_framework/test_irohad.hpp +++ b/test/framework/integration_framework/test_irohad.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TESTIROHAD_HPP diff --git a/test/framework/result_fixture.hpp b/test/framework/result_fixture.hpp index 8b9006bab9..852ebfa9ea 100644 --- a/test/framework/result_fixture.hpp +++ b/test/framework/result_fixture.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_RESULT_FIXTURE_HPP diff --git a/test/framework/test_subscriber.hpp b/test/framework/test_subscriber.hpp index 072713f56e..6841892fce 100644 --- a/test/framework/test_subscriber.hpp +++ b/test/framework/test_subscriber.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TEST_SUBSCRIBER_HPP diff --git a/test/framework/test_subscriber_testing.cpp b/test/framework/test_subscriber_testing.cpp index 87a1e428a8..0768ec7b9d 100644 --- a/test/framework/test_subscriber_testing.cpp +++ b/test/framework/test_subscriber_testing.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/integration/binary/CMakeLists.txt b/test/integration/binary/CMakeLists.txt index 96aa78ec4b..0630d91523 100644 --- a/test/integration/binary/CMakeLists.txt +++ b/test/integration/binary/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + if (SWIG_PYTHON OR SWIG_JAVA) get_property(SWIG_BUILD_DIR GLOBAL PROPERTY SWIG_BUILD_DIR) diff --git a/test/integration/consensus/CMakeLists.txt b/test/integration/consensus/CMakeLists.txt index b87e7e7a7b..5c51151add 100644 --- a/test/integration/consensus/CMakeLists.txt +++ b/test/integration/consensus/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(consensus_sunny_day consensus_sunny_day.cpp) diff --git a/test/integration/pipeline/CMakeLists.txt b/test/integration/pipeline/CMakeLists.txt index 882bedcb03..d4f33fee57 100644 --- a/test/integration/pipeline/CMakeLists.txt +++ b/test/integration/pipeline/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(pipeline_test pipeline_test.cpp) diff --git a/test/module/CMakeLists.txt b/test/module/CMakeLists.txt index 82f6011664..78b4a7da64 100644 --- a/test/module/CMakeLists.txt +++ b/test/module/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # # Reusable tests diff --git a/test/module/iroha-cli/CMakeLists.txt b/test/module/iroha-cli/CMakeLists.txt index 8ff164a3a5..1a22b30491 100644 --- a/test/module/iroha-cli/CMakeLists.txt +++ b/test/module/iroha-cli/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(client_test client_test.cpp) diff --git a/test/module/irohad/ametsuchi/CMakeLists.txt b/test/module/irohad/ametsuchi/CMakeLists.txt index 579ac18dfe..90e24b7a12 100644 --- a/test/module/irohad/ametsuchi/CMakeLists.txt +++ b/test/module/irohad/ametsuchi/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(ametsuchi_test ametsuchi_test.cpp) target_link_libraries(ametsuchi_test ametsuchi diff --git a/test/module/irohad/ametsuchi/block_query_transfer_test.cpp b/test/module/irohad/ametsuchi/block_query_transfer_test.cpp index 2addf98055..0fdab534db 100644 --- a/test/module/irohad/ametsuchi/block_query_transfer_test.cpp +++ b/test/module/irohad/ametsuchi/block_query_transfer_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/ametsuchi/flat_file_test.cpp b/test/module/irohad/ametsuchi/flat_file_test.cpp index 53d989c998..02377a43ef 100644 --- a/test/module/irohad/ametsuchi/flat_file_test.cpp +++ b/test/module/irohad/ametsuchi/flat_file_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "ametsuchi/impl/flat_file/flat_file.hpp" diff --git a/test/module/irohad/ametsuchi/kv_storage_test.cpp b/test/module/irohad/ametsuchi/kv_storage_test.cpp index 5b24af5145..db3dd29776 100644 --- a/test/module/irohad/ametsuchi/kv_storage_test.cpp +++ b/test/module/irohad/ametsuchi/kv_storage_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/ametsuchi/wsv_query_command_test.cpp b/test/module/irohad/ametsuchi/wsv_query_command_test.cpp index 0231d990e5..681e84b35c 100644 --- a/test/module/irohad/ametsuchi/wsv_query_command_test.cpp +++ b/test/module/irohad/ametsuchi/wsv_query_command_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "ametsuchi/impl/postgres_wsv_command.hpp" diff --git a/test/module/irohad/common/CMakeLists.txt b/test/module/irohad/common/CMakeLists.txt index 879ed80660..d1c0eb25e6 100644 --- a/test/module/irohad/common/CMakeLists.txt +++ b/test/module/irohad/common/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + AddTest(blob_converter_test blob_converter_test.cpp) target_link_libraries(blob_converter_test common diff --git a/test/module/irohad/common/blob_converter_test.cpp b/test/module/irohad/common/blob_converter_test.cpp index ba78969004..8caedaa658 100644 --- a/test/module/irohad/common/blob_converter_test.cpp +++ b/test/module/irohad/common/blob_converter_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/consensus/CMakeLists.txt b/test/module/irohad/consensus/CMakeLists.txt index 21d38b0ec4..d78e98ddb6 100644 --- a/test/module/irohad/consensus/CMakeLists.txt +++ b/test/module/irohad/consensus/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # add_subdirectory(yac) diff --git a/test/module/irohad/logger/CMakeLists.txt b/test/module/irohad/logger/CMakeLists.txt index 22f800b07f..7c99757cc5 100644 --- a/test/module/irohad/logger/CMakeLists.txt +++ b/test/module/irohad/logger/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + # Base64 Test AddTest(logger_test logger_test.cpp) diff --git a/test/module/irohad/logger/logger_test.cpp b/test/module/irohad/logger/logger_test.cpp index 2ed73681e7..358e1dda57 100644 --- a/test/module/irohad/logger/logger_test.cpp +++ b/test/module/irohad/logger/logger_test.cpp @@ -1,18 +1,7 @@ -/* -Copyright Soramitsu Co., Ltd. 2016 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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include "logger/logger.hpp" #include diff --git a/test/module/irohad/main/CMakeLists.txt b/test/module/irohad/main/CMakeLists.txt index f787e8a2a9..d368e27148 100644 --- a/test/module/irohad/main/CMakeLists.txt +++ b/test/module/irohad/main/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(server_runner_test server_runner_test.cpp) diff --git a/test/module/irohad/main/server_runner_test.cpp b/test/module/irohad/main/server_runner_test.cpp index eb3e3b0282..fbea15325f 100644 --- a/test/module/irohad/main/server_runner_test.cpp +++ b/test/module/irohad/main/server_runner_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/CMakeLists.txt b/test/module/irohad/model/CMakeLists.txt index 736691b1c4..537fdf2083 100644 --- a/test/module/irohad/model/CMakeLists.txt +++ b/test/module/irohad/model/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(model_crypto_provider_test model_crypto_provider_test.cpp) diff --git a/test/module/irohad/model/converters/json_block_test.cpp b/test/module/irohad/model/converters/json_block_test.cpp index 45ae1fbf62..9e1026ac2d 100644 --- a/test/module/irohad/model/converters/json_block_test.cpp +++ b/test/module/irohad/model/converters/json_block_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/converters/json_commands_test.cpp b/test/module/irohad/model/converters/json_commands_test.cpp index 6e086cda39..b8bf6e7361 100644 --- a/test/module/irohad/model/converters/json_commands_test.cpp +++ b/test/module/irohad/model/converters/json_commands_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/converters/json_query_factory_test.cpp b/test/module/irohad/model/converters/json_query_factory_test.cpp index 8e857f48d4..62d36c0e8f 100644 --- a/test/module/irohad/model/converters/json_query_factory_test.cpp +++ b/test/module/irohad/model/converters/json_query_factory_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "model/converters/json_query_factory.hpp" diff --git a/test/module/irohad/model/converters/json_transaction_test.cpp b/test/module/irohad/model/converters/json_transaction_test.cpp index fc8751de7b..473d7bcc4d 100644 --- a/test/module/irohad/model/converters/json_transaction_test.cpp +++ b/test/module/irohad/model/converters/json_transaction_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/converters/pb_block_test.cpp b/test/module/irohad/model/converters/pb_block_test.cpp index 4f6251983a..75fe7d4fcd 100644 --- a/test/module/irohad/model/converters/pb_block_test.cpp +++ b/test/module/irohad/model/converters/pb_block_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/converters/pb_commands_test.cpp b/test/module/irohad/model/converters/pb_commands_test.cpp index 4ad27dbec4..9d83c07a43 100644 --- a/test/module/irohad/model/converters/pb_commands_test.cpp +++ b/test/module/irohad/model/converters/pb_commands_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/converters/pb_query_factory_test.cpp b/test/module/irohad/model/converters/pb_query_factory_test.cpp index 11076d8905..0bef13151e 100644 --- a/test/module/irohad/model/converters/pb_query_factory_test.cpp +++ b/test/module/irohad/model/converters/pb_query_factory_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/converters/pb_query_responses_test.cpp b/test/module/irohad/model/converters/pb_query_responses_test.cpp index d29b2222c1..ab2db9c2bd 100644 --- a/test/module/irohad/model/converters/pb_query_responses_test.cpp +++ b/test/module/irohad/model/converters/pb_query_responses_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/converters/pb_transaction_test.cpp b/test/module/irohad/model/converters/pb_transaction_test.cpp index ff4ad5c2e5..5e62f357d2 100644 --- a/test/module/irohad/model/converters/pb_transaction_test.cpp +++ b/test/module/irohad/model/converters/pb_transaction_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/model_crypto_provider_test.cpp b/test/module/irohad/model/model_crypto_provider_test.cpp index 2cf680e806..5be097a252 100644 --- a/test/module/irohad/model/model_crypto_provider_test.cpp +++ b/test/module/irohad/model/model_crypto_provider_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/model/operators/model_operators_test.cpp b/test/module/irohad/model/operators/model_operators_test.cpp index be4727384f..454936951c 100644 --- a/test/module/irohad/model/operators/model_operators_test.cpp +++ b/test/module/irohad/model/operators/model_operators_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/irohad/network/CMakeLists.txt b/test/module/irohad/network/CMakeLists.txt index f336ac775e..085fcedf37 100644 --- a/test/module/irohad/network/CMakeLists.txt +++ b/test/module/irohad/network/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(block_loader_test block_loader_test.cpp) diff --git a/test/module/irohad/ordering/mock_ordering_service_persistent_state.hpp b/test/module/irohad/ordering/mock_ordering_service_persistent_state.hpp index 4a4d665e07..bb95434b87 100644 --- a/test/module/irohad/ordering/mock_ordering_service_persistent_state.hpp +++ b/test/module/irohad/ordering/mock_ordering_service_persistent_state.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_MOCK_ORDERING_SERVICE_PERSISTENT_STATE_HPP #define IROHA_MOCK_ORDERING_SERVICE_PERSISTENT_STATE_HPP diff --git a/test/module/irohad/simulator/CMakeLists.txt b/test/module/irohad/simulator/CMakeLists.txt index 2411cf5352..c1340617d9 100644 --- a/test/module/irohad/simulator/CMakeLists.txt +++ b/test/module/irohad/simulator/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(simulator_test simulator_test.cpp) target_link_libraries(simulator_test simulator diff --git a/test/module/irohad/synchronizer/CMakeLists.txt b/test/module/irohad/synchronizer/CMakeLists.txt index e7922f88df..a4a5d54fd4 100644 --- a/test/module/irohad/synchronizer/CMakeLists.txt +++ b/test/module/irohad/synchronizer/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(synchronizer_test synchronizer_test.cpp) target_link_libraries(synchronizer_test synchronizer diff --git a/test/module/irohad/torii/CMakeLists.txt b/test/module/irohad/torii/CMakeLists.txt index a1f6aac95d..fe361dfbe0 100644 --- a/test/module/irohad/torii/CMakeLists.txt +++ b/test/module/irohad/torii/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_subdirectory(processor) diff --git a/test/module/irohad/torii/processor/CMakeLists.txt b/test/module/irohad/torii/processor/CMakeLists.txt index 3a909ef1ea..c88f7d76b6 100644 --- a/test/module/irohad/torii/processor/CMakeLists.txt +++ b/test/module/irohad/torii/processor/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + # Testing of transaction processor addtest(transaction_processor_test transaction_processor_test.cpp) target_link_libraries(transaction_processor_test diff --git a/test/module/irohad/validation/validation_mocks.hpp b/test/module/irohad/validation/validation_mocks.hpp index e07e0a5e4f..160b12f0af 100644 --- a/test/module/irohad/validation/validation_mocks.hpp +++ b/test/module/irohad/validation/validation_mocks.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_VALIDATION_MOCKS_HPP diff --git a/test/module/libs/CMakeLists.txt b/test/module/libs/CMakeLists.txt index cac6eb7650..d3b3726512 100644 --- a/test/module/libs/CMakeLists.txt +++ b/test/module/libs/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + set(CMAKE_BUILD_TYPE Debug) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test_bin) diff --git a/test/module/libs/cache/CMakeLists.txt b/test/module/libs/cache/CMakeLists.txt index 70875a3f12..3dbbfdd771 100644 --- a/test/module/libs/cache/CMakeLists.txt +++ b/test/module/libs/cache/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. addtest(cache_test cache_test.cpp diff --git a/test/module/libs/cache/cache_test.cpp b/test/module/libs/cache/cache_test.cpp index 825fc77d0d..38d522f344 100644 --- a/test/module/libs/cache/cache_test.cpp +++ b/test/module/libs/cache/cache_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/libs/common/CMakeLists.txt b/test/module/libs/common/CMakeLists.txt index 0257b7db9e..3a371b2994 100644 --- a/test/module/libs/common/CMakeLists.txt +++ b/test/module/libs/common/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(result_test result_test.cpp) diff --git a/test/module/libs/common/result_test.cpp b/test/module/libs/common/result_test.cpp index 61cf7117b7..e6205b580b 100644 --- a/test/module/libs/common/result_test.cpp +++ b/test/module/libs/common/result_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "common/result.hpp" diff --git a/test/module/libs/converter/CMakeLists.txt b/test/module/libs/converter/CMakeLists.txt index e2c192e281..e0438f526e 100644 --- a/test/module/libs/converter/CMakeLists.txt +++ b/test/module/libs/converter/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(string_converter_test string_converter_test.cpp) target_link_libraries(string_converter_test diff --git a/test/module/libs/converter/string_converter_test.cpp b/test/module/libs/converter/string_converter_test.cpp index 51d19f8db9..18b625a7c7 100644 --- a/test/module/libs/converter/string_converter_test.cpp +++ b/test/module/libs/converter/string_converter_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/libs/crypto/CMakeLists.txt b/test/module/libs/crypto/CMakeLists.txt index b9048e7d72..77e9c749b2 100644 --- a/test/module/libs/crypto/CMakeLists.txt +++ b/test/module/libs/crypto/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # # Hash Test diff --git a/test/module/libs/crypto/hash_test.cpp b/test/module/libs/crypto/hash_test.cpp index 0be632cf05..e8f72447d3 100644 --- a/test/module/libs/crypto/hash_test.cpp +++ b/test/module/libs/crypto/hash_test.cpp @@ -1,18 +1,7 @@ -/* -Copyright Soramitsu Co., Ltd. 2016 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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include #include diff --git a/test/module/libs/crypto/signature_test.cpp b/test/module/libs/crypto/signature_test.cpp index b4a3bda331..010cee82c7 100644 --- a/test/module/libs/crypto/signature_test.cpp +++ b/test/module/libs/crypto/signature_test.cpp @@ -1,18 +1,7 @@ -/* -Copyright Soramitsu Co., Ltd. 2016 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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include "common/byteutils.hpp" #include "cryptography/ed25519_sha3_impl/internal/ed25519_impl.hpp" diff --git a/test/module/libs/datetime/CMakeLists.txt b/test/module/libs/datetime/CMakeLists.txt index bdcb51f6c5..73bf0acb06 100644 --- a/test/module/libs/datetime/CMakeLists.txt +++ b/test/module/libs/datetime/CMakeLists.txt @@ -1,2 +1,7 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + # DateTime Test addtest(time_test time_test.cpp) diff --git a/test/module/libs/datetime/time_test.cpp b/test/module/libs/datetime/time_test.cpp index 9d1503ea68..b4bad23669 100644 --- a/test/module/libs/datetime/time_test.cpp +++ b/test/module/libs/datetime/time_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/backend_proto/CMakeLists.txt b/test/module/shared_model/backend_proto/CMakeLists.txt index 7931250d8a..c7c652320c 100644 --- a/test/module/shared_model/backend_proto/CMakeLists.txt +++ b/test/module/shared_model/backend_proto/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(shared_proto_commands_test diff --git a/test/module/shared_model/backend_proto/shared_proto_commands_test.cpp b/test/module/shared_model/backend_proto/shared_proto_commands_test.cpp index 9fcba6d352..c3f3f8a7bd 100644 --- a/test/module/shared_model/backend_proto/shared_proto_commands_test.cpp +++ b/test/module/shared_model/backend_proto/shared_proto_commands_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "backend/protobuf/commands/proto_command.hpp" diff --git a/test/module/shared_model/backend_proto/shared_proto_util_test.cpp b/test/module/shared_model/backend_proto/shared_proto_util_test.cpp index 00f8d60cd8..266e06e643 100644 --- a/test/module/shared_model/backend_proto/shared_proto_util_test.cpp +++ b/test/module/shared_model/backend_proto/shared_proto_util_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "backend/protobuf/util.hpp" diff --git a/test/module/shared_model/bindings/CMakeLists.txt b/test/module/shared_model/bindings/CMakeLists.txt index dbafdac111..d247e7d73d 100644 --- a/test/module/shared_model/bindings/CMakeLists.txt +++ b/test/module/shared_model/bindings/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2017 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. addtest(model_query_builder_test model_query_builder_test.cpp diff --git a/test/module/shared_model/bindings/model_crypto_test.cpp b/test/module/shared_model/bindings/model_crypto_test.cpp index acce7fb844..f8d9b43424 100644 --- a/test/module/shared_model/bindings/model_crypto_test.cpp +++ b/test/module/shared_model/bindings/model_crypto_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "bindings/model_crypto.hpp" diff --git a/test/module/shared_model/bindings/model_query_builder_test.cpp b/test/module/shared_model/bindings/model_query_builder_test.cpp index 69678f0c07..ded5082e18 100644 --- a/test/module/shared_model/bindings/model_query_builder_test.cpp +++ b/test/module/shared_model/bindings/model_query_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "bindings/model_query_builder.hpp" diff --git a/test/module/shared_model/builders/CMakeLists.txt b/test/module/shared_model/builders/CMakeLists.txt index e20aed046c..ac3e366944 100644 --- a/test/module/shared_model/builders/CMakeLists.txt +++ b/test/module/shared_model/builders/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2018 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. add_subdirectory(protobuf) add_subdirectory(common_objects) diff --git a/test/module/shared_model/builders/common_objects/CMakeLists.txt b/test/module/shared_model/builders/common_objects/CMakeLists.txt index 443075e621..dea49f4e72 100644 --- a/test/module/shared_model/builders/common_objects/CMakeLists.txt +++ b/test/module/shared_model/builders/common_objects/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2018 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. addtest(peer_builder_test peer_builder_test.cpp diff --git a/test/module/shared_model/builders/common_objects/account_asset_builder.hpp b/test/module/shared_model/builders/common_objects/account_asset_builder.hpp index 382f093d6a..16b882b57e 100644 --- a/test/module/shared_model/builders/common_objects/account_asset_builder.hpp +++ b/test/module/shared_model/builders/common_objects/account_asset_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ACCOUNT_ASSET_BUILDER_HPP diff --git a/test/module/shared_model/builders/common_objects/account_asset_builder_test.cpp b/test/module/shared_model/builders/common_objects/account_asset_builder_test.cpp index 3f68e17ddb..f00ecfa7b6 100644 --- a/test/module/shared_model/builders/common_objects/account_asset_builder_test.cpp +++ b/test/module/shared_model/builders/common_objects/account_asset_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/common_objects/account_builder.hpp b/test/module/shared_model/builders/common_objects/account_builder.hpp index 655fb33fda..f6501374dd 100644 --- a/test/module/shared_model/builders/common_objects/account_builder.hpp +++ b/test/module/shared_model/builders/common_objects/account_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ACCOUNT_BUILDER_HPP diff --git a/test/module/shared_model/builders/common_objects/account_builder_test.cpp b/test/module/shared_model/builders/common_objects/account_builder_test.cpp index ac6b85f928..69e49df3e8 100644 --- a/test/module/shared_model/builders/common_objects/account_builder_test.cpp +++ b/test/module/shared_model/builders/common_objects/account_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/common_objects/asset_builder.hpp b/test/module/shared_model/builders/common_objects/asset_builder.hpp index 542f28500d..e73c862921 100644 --- a/test/module/shared_model/builders/common_objects/asset_builder.hpp +++ b/test/module/shared_model/builders/common_objects/asset_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_ASSET_BUILDER_HPP diff --git a/test/module/shared_model/builders/common_objects/asset_builder_test.cpp b/test/module/shared_model/builders/common_objects/asset_builder_test.cpp index cb52605219..b2fb132791 100644 --- a/test/module/shared_model/builders/common_objects/asset_builder_test.cpp +++ b/test/module/shared_model/builders/common_objects/asset_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/common_objects/builders_test_fixture.hpp b/test/module/shared_model/builders/common_objects/builders_test_fixture.hpp index 493ce72ae9..cef4010738 100644 --- a/test/module/shared_model/builders/common_objects/builders_test_fixture.hpp +++ b/test/module/shared_model/builders/common_objects/builders_test_fixture.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_BUILDERS_TEST_FIXTURE_HPP diff --git a/test/module/shared_model/builders/common_objects/common.hpp b/test/module/shared_model/builders/common_objects/common.hpp index ec0f771f47..c9c5f00435 100644 --- a/test/module/shared_model/builders/common_objects/common.hpp +++ b/test/module/shared_model/builders/common_objects/common.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_BUILDERS_COMMON_HPP diff --git a/test/module/shared_model/builders/common_objects/domain_builder.hpp b/test/module/shared_model/builders/common_objects/domain_builder.hpp index 3b823b97ef..fa18839e03 100644 --- a/test/module/shared_model/builders/common_objects/domain_builder.hpp +++ b/test/module/shared_model/builders/common_objects/domain_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_DOMAIN_BUILDER_HPP diff --git a/test/module/shared_model/builders/common_objects/peer_builder.hpp b/test/module/shared_model/builders/common_objects/peer_builder.hpp index fba848085c..907f8b3a91 100644 --- a/test/module/shared_model/builders/common_objects/peer_builder.hpp +++ b/test/module/shared_model/builders/common_objects/peer_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PEER_BUILDER_HPP diff --git a/test/module/shared_model/builders/common_objects/peer_builder_test.cpp b/test/module/shared_model/builders/common_objects/peer_builder_test.cpp index fe8fb738d4..9ba4d8db9a 100644 --- a/test/module/shared_model/builders/common_objects/peer_builder_test.cpp +++ b/test/module/shared_model/builders/common_objects/peer_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/common_objects/signature_builder.hpp b/test/module/shared_model/builders/common_objects/signature_builder.hpp index e1af57a680..fac639054f 100644 --- a/test/module/shared_model/builders/common_objects/signature_builder.hpp +++ b/test/module/shared_model/builders/common_objects/signature_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_SIGNATURE_BUILDER_HPP diff --git a/test/module/shared_model/builders/common_objects/signature_builder_test.cpp b/test/module/shared_model/builders/common_objects/signature_builder_test.cpp index e6e6e861d6..6dba07acae 100644 --- a/test/module/shared_model/builders/common_objects/signature_builder_test.cpp +++ b/test/module/shared_model/builders/common_objects/signature_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/protobuf/CMakeLists.txt b/test/module/shared_model/builders/protobuf/CMakeLists.txt index 60a5279d48..0e7491b68a 100644 --- a/test/module/shared_model/builders/protobuf/CMakeLists.txt +++ b/test/module/shared_model/builders/protobuf/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2018 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. if (IROHA_ROOT_PROJECT) addtest(transport_builder_test diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder.hpp b/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder.hpp index 9e2a07a482..f7cf76474a 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder.hpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_ACCOUNT_ASSET_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder_test.cpp b/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder_test.cpp index 6dfb1d658b..4939e5a405 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder_test.cpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder.hpp b/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder.hpp index 487dfbad4d..b07d66d19d 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder.hpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_ACCOUNT_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder_test.cpp b/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder_test.cpp index 2af50ae9db..c876d02015 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder_test.cpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_account_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder.hpp b/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder.hpp index a412725e46..c5ef02924a 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder.hpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_ASSET_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder_test.cpp b/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder_test.cpp index a39826d836..f5824afd31 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder_test.cpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_asset_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_domain_builder.hpp b/test/module/shared_model/builders/protobuf/common_objects/proto_domain_builder.hpp index 3dad699e59..f199bc22de 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_domain_builder.hpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_domain_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_DOMAIN_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp b/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp index a6d20de1b3..7b06fa8069 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_PROTO_PEER_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder_test.cpp b/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder_test.cpp index ac4d294990..3ab1d87236 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder_test.cpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_peer_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder_test.cpp b/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder_test.cpp index 98af07b785..1730b38340 100644 --- a/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder_test.cpp +++ b/test/module/shared_model/builders/protobuf/common_objects/proto_signature_builder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/builders/protobuf/test_account_asset_builder.hpp b/test/module/shared_model/builders/protobuf/test_account_asset_builder.hpp index 4204f3b554..16e0dcc318 100644 --- a/test/module/shared_model/builders/protobuf/test_account_asset_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_account_asset_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "module/shared_model/builders/protobuf/common_objects/proto_account_asset_builder.hpp" diff --git a/test/module/shared_model/builders/protobuf/test_account_builder.hpp b/test/module/shared_model/builders/protobuf/test_account_builder.hpp index 05023494ed..1bef117fab 100644 --- a/test/module/shared_model/builders/protobuf/test_account_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_account_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "module/shared_model/builders/protobuf/common_objects/proto_account_builder.hpp" diff --git a/test/module/shared_model/builders/protobuf/test_asset_builder.hpp b/test/module/shared_model/builders/protobuf/test_asset_builder.hpp index e070bad5db..f6e10c5e1b 100644 --- a/test/module/shared_model/builders/protobuf/test_asset_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_asset_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TEST_ASSET_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/test_domain_builder.hpp b/test/module/shared_model/builders/protobuf/test_domain_builder.hpp index 28d46f30ed..c5d116fff3 100644 --- a/test/module/shared_model/builders/protobuf/test_domain_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_domain_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "module/shared_model/builders/protobuf/common_objects/proto_domain_builder.hpp" diff --git a/test/module/shared_model/builders/protobuf/test_peer_builder.hpp b/test/module/shared_model/builders/protobuf/test_peer_builder.hpp index ea06b18cea..69502a048a 100644 --- a/test/module/shared_model/builders/protobuf/test_peer_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_peer_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "module/shared_model/builders/protobuf/common_objects/proto_peer_builder.hpp" diff --git a/test/module/shared_model/builders/protobuf/test_query_builder.hpp b/test/module/shared_model/builders/protobuf/test_query_builder.hpp index 7349dcfdb9..f61c2bb249 100644 --- a/test/module/shared_model/builders/protobuf/test_query_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_query_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TEST_QUERY_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/test_signature_builder.hpp b/test/module/shared_model/builders/protobuf/test_signature_builder.hpp index 2500101b21..ad801f90ca 100644 --- a/test/module/shared_model/builders/protobuf/test_signature_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_signature_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TEST_SIGNATURE_BUILDER_HPP diff --git a/test/module/shared_model/builders/protobuf/test_transaction_builder.hpp b/test/module/shared_model/builders/protobuf/test_transaction_builder.hpp index cb3602ef04..3698712d9f 100644 --- a/test/module/shared_model/builders/protobuf/test_transaction_builder.hpp +++ b/test/module/shared_model/builders/protobuf/test_transaction_builder.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_TEST_TRANSACTION_BUILDER_HPP diff --git a/test/module/shared_model/builders/transaction_responses/CMakeLists.txt b/test/module/shared_model/builders/transaction_responses/CMakeLists.txt index c48ed70c8c..60ed03a5e3 100644 --- a/test/module/shared_model/builders/transaction_responses/CMakeLists.txt +++ b/test/module/shared_model/builders/transaction_responses/CMakeLists.txt @@ -1,16 +1,7 @@ -# Copyright 2018 Soramitsu Co., Ltd. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. addtest(transaction_response_builder_test transaction_response_builder_test.cpp diff --git a/test/module/shared_model/converters/CMakeLists.txt b/test/module/shared_model/converters/CMakeLists.txt index 7d3a4d0e9e..f8338524c5 100644 --- a/test/module/shared_model/converters/CMakeLists.txt +++ b/test/module/shared_model/converters/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # AddTest(json_proto_converter_test diff --git a/test/module/shared_model/converters/json_proto_converter_test.cpp b/test/module/shared_model/converters/json_proto_converter_test.cpp index d52540650b..2cfcfa5cf2 100644 --- a/test/module/shared_model/converters/json_proto_converter_test.cpp +++ b/test/module/shared_model/converters/json_proto_converter_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/cryptography/CMakeLists.txt b/test/module/shared_model/cryptography/CMakeLists.txt index c2c2ea832a..91faf0d5db 100644 --- a/test/module/shared_model/cryptography/CMakeLists.txt +++ b/test/module/shared_model/cryptography/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(blob_test blob_test.cpp) target_link_libraries(blob_test shared_model_cryptography_model diff --git a/test/module/shared_model/cryptography/blob_test.cpp b/test/module/shared_model/cryptography/blob_test.cpp index 3871e8f1d4..4032e85435 100644 --- a/test/module/shared_model/cryptography/blob_test.cpp +++ b/test/module/shared_model/cryptography/blob_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "cryptography/blob.hpp" diff --git a/test/module/shared_model/cryptography/crypto_model_signer_mock.hpp b/test/module/shared_model/cryptography/crypto_model_signer_mock.hpp index 83fb0183e7..45f989c6c0 100644 --- a/test/module/shared_model/cryptography/crypto_model_signer_mock.hpp +++ b/test/module/shared_model/cryptography/crypto_model_signer_mock.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_CRYPTO_MODEL_SIGNER_MOCK_HPP diff --git a/test/module/shared_model/cryptography/crypto_usage_test.cpp b/test/module/shared_model/cryptography/crypto_usage_test.cpp index e426eec7ec..8d1003cf54 100644 --- a/test/module/shared_model/cryptography/crypto_usage_test.cpp +++ b/test/module/shared_model/cryptography/crypto_usage_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/module/shared_model/reference_holder_test.cpp b/test/module/shared_model/reference_holder_test.cpp index 6b894b21d3..27daa451bc 100644 --- a/test/module/shared_model/reference_holder_test.cpp +++ b/test/module/shared_model/reference_holder_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "utils/reference_holder.hpp" diff --git a/test/module/shared_model/validators/CMakeLists.txt b/test/module/shared_model/validators/CMakeLists.txt index 005f4dc481..ca105daf30 100644 --- a/test/module/shared_model/validators/CMakeLists.txt +++ b/test/module/shared_model/validators/CMakeLists.txt @@ -1,18 +1,6 @@ # -# Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. -# http://soramitsu.co.jp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 # addtest(transaction_validator_test diff --git a/test/module/shared_model/validators/transaction_validator_test.cpp b/test/module/shared_model/validators/transaction_validator_test.cpp index 40d6c7f6b0..3a77fd7d13 100644 --- a/test/module/shared_model/validators/transaction_validator_test.cpp +++ b/test/module/shared_model/validators/transaction_validator_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include "module/shared_model/validators/validators_fixture.hpp" diff --git a/test/module/shared_model/validators/validators_fixture.hpp b/test/module/shared_model/validators/validators_fixture.hpp index 0f2115a4e8..93f3c5bf8f 100644 --- a/test/module/shared_model/validators/validators_fixture.hpp +++ b/test/module/shared_model/validators/validators_fixture.hpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_VALIDATORS_FIXTURE_HPP diff --git a/test/module/vendor/CMakeLists.txt b/test/module/vendor/CMakeLists.txt index fa660f5a56..3743ac3e95 100644 --- a/test/module/vendor/CMakeLists.txt +++ b/test/module/vendor/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(rxcpp_subject_usage rxcpp_subject_usage.cpp) target_link_libraries(rxcpp_subject_usage rxcpp diff --git a/test/module/vendor/rxcpp_subject_usage.cpp b/test/module/vendor/rxcpp_subject_usage.cpp index b4a643893e..95e83fa004 100644 --- a/test/module/vendor/rxcpp_subject_usage.cpp +++ b/test/module/vendor/rxcpp_subject_usage.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef IROHA_RXCPP_SUBJECT_USAGE_HPP diff --git a/test/module/vendor/tbb_test.cpp b/test/module/vendor/tbb_test.cpp index 9e049a3d07..c58ed01aae 100644 --- a/test/module/vendor/tbb_test.cpp +++ b/test/module/vendor/tbb_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/regression/CMakeLists.txt b/test/regression/CMakeLists.txt index 9705065eb1..03b7016e13 100644 --- a/test/regression/CMakeLists.txt +++ b/test/regression/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(regression_test regression_test.cpp) target_link_libraries(regression_test diff --git a/test/regression/regression_test.cpp b/test/regression/regression_test.cpp index e8b6f97356..dcc763be1d 100644 --- a/test/regression/regression_test.cpp +++ b/test/regression/regression_test.cpp @@ -1,18 +1,6 @@ /** - * Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved. - * http://soramitsu.co.jp - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/test/system/CMakeLists.txt b/test/system/CMakeLists.txt index ca48833e29..a316911189 100644 --- a/test/system/CMakeLists.txt +++ b/test/system/CMakeLists.txt @@ -1,3 +1,8 @@ +# +# Copyright Soramitsu Co., Ltd. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + addtest(irohad_test irohad_test.cpp) target_link_libraries(irohad_test boost From f263e12b4af7b0585d23828f55a6e5825280d2cd Mon Sep 17 00:00:00 2001 From: Konstantin Munichev Date: Fri, 21 Dec 2018 12:48:06 +0300 Subject: [PATCH 26/61] Use unsubscribe to prevent memory leaks in rxcpp (#1968) Signed-off-by: Konstantin Munichev --- irohad/main/impl/on_demand_ordering_init.cpp | 4 ++++ irohad/main/impl/on_demand_ordering_init.hpp | 2 ++ irohad/ordering/impl/on_demand_connection_manager.cpp | 4 ++++ irohad/ordering/impl/on_demand_connection_manager.hpp | 2 ++ irohad/ordering/impl/on_demand_ordering_gate.cpp | 4 ++++ irohad/ordering/impl/on_demand_ordering_gate.hpp | 2 ++ 6 files changed, 18 insertions(+) diff --git a/irohad/main/impl/on_demand_ordering_init.cpp b/irohad/main/impl/on_demand_ordering_init.cpp index 6f2b9155c4..4bf0dd18a6 100644 --- a/irohad/main/impl/on_demand_ordering_init.cpp +++ b/irohad/main/impl/on_demand_ordering_init.cpp @@ -266,6 +266,10 @@ namespace iroha { max_size, std::move(proposal_factory), std::move(tx_cache)); } + OnDemandOrderingInit::~OnDemandOrderingInit() { + notifier.get_subscriber().unsubscribe(); + } + std::shared_ptr OnDemandOrderingInit::initOrderingGate( size_t max_size, diff --git a/irohad/main/impl/on_demand_ordering_init.hpp b/irohad/main/impl/on_demand_ordering_init.hpp index 5309c59222..e7a199fb62 100644 --- a/irohad/main/impl/on_demand_ordering_init.hpp +++ b/irohad/main/impl/on_demand_ordering_init.hpp @@ -74,6 +74,8 @@ namespace iroha { std::shared_ptr tx_cache); public: + ~OnDemandOrderingInit(); + /** * Initializes on-demand ordering gate and ordering sevice components * diff --git a/irohad/ordering/impl/on_demand_connection_manager.cpp b/irohad/ordering/impl/on_demand_connection_manager.cpp index f59c9ab2eb..5217231334 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.cpp +++ b/irohad/ordering/impl/on_demand_connection_manager.cpp @@ -32,6 +32,10 @@ OnDemandConnectionManager::OnDemandConnectionManager( initializeConnections(initial_peers); } +OnDemandConnectionManager::~OnDemandConnectionManager() { + subscription_.unsubscribe(); +} + void OnDemandConnectionManager::onBatches(consensus::Round round, CollectionType batches) { std::shared_lock lock(mutex_); diff --git a/irohad/ordering/impl/on_demand_connection_manager.hpp b/irohad/ordering/impl/on_demand_connection_manager.hpp index fabe97ab1a..670cc1f690 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.hpp +++ b/irohad/ordering/impl/on_demand_connection_manager.hpp @@ -58,6 +58,8 @@ namespace iroha { rxcpp::observable peers, CurrentPeers initial_peers); + ~OnDemandConnectionManager() override; + void onBatches(consensus::Round round, CollectionType batches) override; boost::optional onRequestProposal( diff --git a/irohad/ordering/impl/on_demand_ordering_gate.cpp b/irohad/ordering/impl/on_demand_ordering_gate.cpp index eb25fb6b87..7473aa2522 100644 --- a/irohad/ordering/impl/on_demand_ordering_gate.cpp +++ b/irohad/ordering/impl/on_demand_ordering_gate.cpp @@ -68,6 +68,10 @@ OnDemandOrderingGate::OnDemandOrderingGate( tx_cache_(std::move(tx_cache)), current_round_(initial_round) {} +OnDemandOrderingGate::~OnDemandOrderingGate() { + events_subscription_.unsubscribe(); +} + void OnDemandOrderingGate::propagateBatch( std::shared_ptr batch) { std::shared_lock lock(mutex_); diff --git a/irohad/ordering/impl/on_demand_ordering_gate.hpp b/irohad/ordering/impl/on_demand_ordering_gate.hpp index e2c1c8b533..6945725c01 100644 --- a/irohad/ordering/impl/on_demand_ordering_gate.hpp +++ b/irohad/ordering/impl/on_demand_ordering_gate.hpp @@ -64,6 +64,8 @@ namespace iroha { std::shared_ptr tx_cache, consensus::Round initial_round); + ~OnDemandOrderingGate() override; + void propagateBatch( std::shared_ptr batch) override; From 7291d1b6f77ab6da151fa42b5b7dd60fd90dbda4 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Fri, 21 Dec 2018 23:19:59 +0300 Subject: [PATCH 27/61] Remove OrderingGate (internal) fuzzing (#1981) Signed-off-by: Kitsu --- test/fuzzing/CMakeLists.txt | 9 ---- test/fuzzing/ordering_gate_fuzz.cpp | 70 ----------------------------- 2 files changed, 79 deletions(-) delete mode 100644 test/fuzzing/ordering_gate_fuzz.cpp diff --git a/test/fuzzing/CMakeLists.txt b/test/fuzzing/CMakeLists.txt index 46a2163bb7..38231263b0 100644 --- a/test/fuzzing/CMakeLists.txt +++ b/test/fuzzing/CMakeLists.txt @@ -35,15 +35,6 @@ target_link_libraries(find_fuzzing protobuf-mutator ) -add_executable(ordering_gate_fuzz ordering_gate_fuzz.cpp) -target_link_libraries(ordering_gate_fuzz - gtest::gtest - gmock::gmock - on_demand_ordering_gate - shared_model_default_builders - protobuf-mutator - ) - add_executable(send_batches_fuzz send_batches_fuzz.cpp) target_link_libraries(send_batches_fuzz gtest::gtest diff --git a/test/fuzzing/ordering_gate_fuzz.cpp b/test/fuzzing/ordering_gate_fuzz.cpp deleted file mode 100644 index 1335c8bb23..0000000000 --- a/test/fuzzing/ordering_gate_fuzz.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright Soramitsu Co., Ltd. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "backend/protobuf/proto_block_factory.hpp" -#include "module/irohad/ordering/ordering_mocks.hpp" -#include "module/shared_model/interface_mocks.hpp" -#include "ordering/impl/on_demand_ordering_gate.hpp" -#include "validators/default_validator.hpp" - -using namespace iroha::ordering; -using namespace testing; - -namespace fuzzing { - struct OrderingGateFixture { - std::shared_ptr block_factory_; - std::shared_ptr> ordering_service_; - std::shared_ptr> network_client_; - - rxcpp::subjects::subject rounds_; - NiceMock *proposal_factory_; - std::shared_ptr ordering_gate_; - iroha::consensus::Round initial_round_ = {2, 1}; - - OrderingGateFixture() - : block_factory_(std::make_shared< - shared_model::proto::ProtoBlockFactory>( - std::make_unique< - shared_model::validation::DefaultUnsignedBlockValidator>())), - ordering_service_( - std::make_shared> - - ()), - network_client_( - std::make_shared>()) { - auto proposal_factory = - std::make_unique>(); - proposal_factory_ = proposal_factory.get(); - ordering_gate_ = - std::make_shared(ordering_service_, - network_client_, - rounds_.get_observable(), - std::move(proposal_factory), - initial_round_); - } - }; -} // namespace fuzzing - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size) { - static fuzzing::OrderingGateFixture ordering_gate_fixture; - if (size < 1) { - return 0; - } - - iroha::protocol::Block block; - if (protobuf_mutator::libfuzzer::LoadProtoInput(true, data, size, &block)) { - auto iroha_block = - ordering_gate_fixture.block_factory_->createBlock(std::move(block)); - if (auto result = boost::get>>(&iroha_block)) { - ordering_gate_fixture.rounds_.get_subscriber().on_next( - std::move(result->value)); - } - } - - return 0; -} From 7ff16dd3debaecfc13ae4411ef8b1dd7e36a9598 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 22 Dec 2018 00:04:22 +0300 Subject: [PATCH 28/61] Update query Find endpoint fuzzing (#1982) Signed-off-by: Kitsu --- test/fuzzing/find_fuzz.cpp | 52 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/test/fuzzing/find_fuzz.cpp b/test/fuzzing/find_fuzz.cpp index f430f3329f..2cdc4a78e1 100644 --- a/test/fuzzing/find_fuzz.cpp +++ b/test/fuzzing/find_fuzz.cpp @@ -3,13 +3,19 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "torii/query_service.hpp" + #include #include +#include "backend/protobuf/proto_query_response_factory.hpp" +#include "backend/protobuf/proto_transport_factory.hpp" #include "libfuzzer/libfuzzer_macro.h" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/network/network_mocks.hpp" +#include "module/irohad/pending_txs_storage/pending_txs_storage_mock.hpp" #include "torii/processor/query_processor_impl.hpp" -#include "torii/query_service.hpp" +#include "validators/default_validator.hpp" +#include "validators/protobuf/proto_query_validator.hpp" using namespace std::chrono_literals; using testing::_; @@ -18,8 +24,8 @@ using testing::Return; struct QueryFixture { std::shared_ptr service_; std::shared_ptr qry_processor_; - std::shared_ptr qry_exec_; std::shared_ptr storage_; + std::shared_ptr pending_transactions_; std::shared_ptr bq_; std::shared_ptr wq_; @@ -29,25 +35,33 @@ struct QueryFixture { wq_ = std::make_shared(); EXPECT_CALL(*storage_, getBlockQuery()).WillRepeatedly(Return(bq_)); EXPECT_CALL(*storage_, getWsvQuery()).WillRepeatedly(Return(wq_)); - qry_exec_ = std::make_shared(); - qry_processor_ = - std::make_shared(storage_, qry_exec_); - service_ = std::make_shared(qry_processor_); + pending_transactions_ = + std::make_shared(); + auto query_response_factory_ = + std::make_shared(); + qry_processor_ = std::make_shared( + storage_, storage_, pending_transactions_, query_response_factory_); + + std::unique_ptr> + query_validator = std::make_unique< + shared_model::validation::DefaultSignedQueryValidator>(); + std::unique_ptr< + shared_model::validation::AbstractValidator> + proto_query_validator = + std::make_unique(); + auto query_factory = + std::make_shared>(std::move(query_validator), + std::move(proto_query_validator)); + service_ = + std::make_shared(qry_processor_, query_factory); } }; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size) { +DEFINE_BINARY_PROTO_FUZZER(const iroha::protocol::Query &qry) { static QueryFixture handler; - if (size < 1) { - return 0; - } - - EXPECT_CALL(*handler.qry_exec_, validateAndExecute(_)) - .WillRepeatedly(testing::Invoke([](auto &) { return nullptr; })); - iroha::protocol::Query qry; - if (protobuf_mutator::libfuzzer::LoadProtoInput(true, data, size, &qry)) { - iroha::protocol::QueryResponse resp; - handler.service_->Find(qry, resp); - } - return 0; + iroha::protocol::QueryResponse resp; + handler.service_->Find(nullptr, &qry, &resp); } From 8a9d53337438db3c16c3e1e3ad74ba0000a97a18 Mon Sep 17 00:00:00 2001 From: BulatSaif Date: Tue, 25 Dec 2018 09:27:17 +0300 Subject: [PATCH 29/61] Add libc++(clang-7) to docker build image (#1970) Signed-off-by: Bulat Saifullin --- docker/develop/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker/develop/Dockerfile b/docker/develop/Dockerfile index 3bd466d553..e9f84225ce 100644 --- a/docker/develop/Dockerfile +++ b/docker/develop/Dockerfile @@ -18,6 +18,7 @@ RUN set -e; \ add-apt-repository -y ppa:ubuntu-toolchain-r/test; \ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -; \ echo 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main' >> /etc/apt/sources.list; \ + echo 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main' >> /etc/apt/sources.list; \ apt-get update RUN set -e; \ @@ -38,6 +39,14 @@ RUN set -e; \ gcovr cppcheck doxygen rsync graphviz graphviz-dev unzip vim zip; \ apt-get -y clean +# compiler clang-7 and libc++ only on x86_64, for debug purpose +RUN set -e; \ + if [ `uname -m` = "x86_64" ]; then \ + apt-get -y --no-install-recommends install \ + clang-7 lldb-7 lld-7 libc++-7-dev libc++abi-7-dev; \ + apt-get -y clean; \ + fi + # install cmake 3.11.4 RUN set -e; \ git clone https://gitlab.kitware.com/cmake/cmake.git /tmp/cmake; \ From 311f8974f9fa5ec221b89195b677cb77561fc883 Mon Sep 17 00:00:00 2001 From: Konstantin Munichev Date: Tue, 25 Dec 2018 13:28:45 +0300 Subject: [PATCH 30/61] More fuzzing fixes (#1984) Signed-off-by: Konstantin Munichev --- test/fuzzing/CMakeLists.txt | 2 ++ test/fuzzing/mst_fuzz.cpp | 26 ++++++++++++++++++----- test/fuzzing/ordering_service_fixture.hpp | 16 ++++++-------- test/fuzzing/send_batches_fuzz.cpp | 6 +++++- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/test/fuzzing/CMakeLists.txt b/test/fuzzing/CMakeLists.txt index f2e2fd265f..1d0bcfd760 100644 --- a/test/fuzzing/CMakeLists.txt +++ b/test/fuzzing/CMakeLists.txt @@ -39,6 +39,7 @@ add_executable(send_batches_fuzz send_batches_fuzz.cpp) target_link_libraries(send_batches_fuzz gtest::gtest gmock::gmock + ametsuchi on_demand_ordering_service on_demand_ordering_service_transport_grpc protobuf-mutator @@ -86,5 +87,6 @@ target_link_libraries(mst_fuzz gtest::gtest gmock::gmock mst_transport + ametsuchi protobuf-mutator ) diff --git a/test/fuzzing/mst_fuzz.cpp b/test/fuzzing/mst_fuzz.cpp index c50079471d..8c3c25b13d 100644 --- a/test/fuzzing/mst_fuzz.cpp +++ b/test/fuzzing/mst_fuzz.cpp @@ -8,11 +8,14 @@ #include #include +#include "ametsuchi/impl/tx_presence_cache_impl.hpp" #include "backend/protobuf/proto_transport_factory.hpp" #include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp" #include "interfaces/iroha_internal/transaction_batch_parser_impl.hpp" +#include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/multi_sig_transactions/mst_test_helpers.hpp" #include "multi_sig_transactions/transport/mst_transport_grpc.hpp" +#include "validators/protobuf/proto_transaction_validator.hpp" using namespace testing; using namespace iroha::network; @@ -22,27 +25,40 @@ namespace fuzzing { std::shared_ptr mst_transport_grpc_; MstFixture() { + spdlog::set_level(spdlog::level::err); + auto async_call_ = std::make_shared< iroha::network::AsyncGrpcClient>(); + // TODO luckychess 25.12.2018 Component initialisation reuse + // IR-1886, IR-142 std::unique_ptr> - // TODO luckychess 20.11.2018 Reuse validator from application.cpp IR-1886 - tx_validator = - std::make_unique(); + interface_validator = std::make_unique< + shared_model::validation::DefaultUnsignedTransactionValidator>(); + std::unique_ptr> + tx_validator = std::make_unique< + shared_model::validation::ProtoTransactionValidator>(); + auto tx_factory = std::make_shared>(std::move(tx_validator)); + shared_model::proto::Transaction>>(std::move(interface_validator), + std::move(tx_validator)); auto parser = std::make_shared< shared_model::interface::TransactionBatchParserImpl>(); auto batch_factory = std::make_shared< shared_model::interface::TransactionBatchFactoryImpl>(); + auto storage = + std::make_shared>(); + auto cache = + std::make_shared(storage); mst_transport_grpc_ = std::make_shared( async_call_, std::move(tx_factory), std::move(parser), std::move(batch_factory), + std::move(cache), shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair() .publicKey()); } diff --git a/test/fuzzing/ordering_service_fixture.hpp b/test/fuzzing/ordering_service_fixture.hpp index fe08bfa535..d1a24eb459 100644 --- a/test/fuzzing/ordering_service_fixture.hpp +++ b/test/fuzzing/ordering_service_fixture.hpp @@ -36,8 +36,6 @@ namespace fuzzing { batch_parser_; std::shared_ptr> transaction_batch_factory_; - shared_model::validation::AbstractValidator< - shared_model::interface::Transaction> *transaction_validator_; OrderingServiceFixture() { // fuzzing target is intended to run many times (~millions) so any @@ -46,19 +44,19 @@ namespace fuzzing { std::unique_ptr> - transaction_validator = - std::make_unique(); - transaction_validator_ = transaction_validator.get(); + interface_transaction_validator = + std::make_unique>>(); std::unique_ptr> - proto_transaction_validator = std::make_unique< - shared_model::validation::ProtoTransactionValidator>(); + proto_transaction_validator = + std::make_unique>>(); transaction_factory_ = std::make_shared>( - std::move(transaction_validator), + std::move(interface_transaction_validator), std::move(proto_transaction_validator)); batch_parser_ = std::make_shared< diff --git a/test/fuzzing/send_batches_fuzz.cpp b/test/fuzzing/send_batches_fuzz.cpp index 94a3aa81d8..c36d08d292 100644 --- a/test/fuzzing/send_batches_fuzz.cpp +++ b/test/fuzzing/send_batches_fuzz.cpp @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "ametsuchi/impl/tx_presence_cache_impl.hpp" +#include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "ordering_service_fixture.hpp" extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size) { @@ -16,8 +18,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size) { std::shared_ptr server_; auto proposal_factory = std::make_unique(); + auto storage = std::make_shared>(); + auto cache = std::make_shared(storage); ordering_service_ = std::make_shared( - data[0], std::move(proposal_factory)); + data[0], std::move(proposal_factory), std::move(cache)); server_ = std::make_shared( ordering_service_, fixture.transaction_factory_, From 6de2dbbd25bc1b145609f5b71b997b8a7cce7b4d Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Tue, 25 Dec 2018 15:48:28 +0300 Subject: [PATCH 31/61] Fix GetTransactions query behaviour (#1973) * Fixed query's behaviour Signed-off-by: Akvinikym * Fix build Signed-off-by: Akvinikym * Review issues and fixed test Signed-off-by: Akvinikym * Final review issues Signed-off-by: Akvinikym --- docs/source/api/queries.rst | 1 + .../impl/postgres_query_executor.cpp | 19 ++++++++++++---- .../impl/postgres_query_executor.hpp | 16 ++++++++------ .../acceptance/get_transactions_test.cpp | 10 ++++++--- .../postgres_query_executor_test.cpp | 22 +++++++++---------- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/docs/source/api/queries.rst b/docs/source/api/queries.rst index 470f6d9d8f..8af0c649b5 100644 --- a/docs/source/api/queries.rst +++ b/docs/source/api/queries.rst @@ -122,6 +122,7 @@ Purpose ------- GetTransactions is used for retrieving information about transactions, based on their hashes. +.. note:: This query is valid if and only if all the requested hashes are correct: corresponding transactions exist, and the user has a permission to retrieve them Request Schema -------------- diff --git a/irohad/ametsuchi/impl/postgres_query_executor.cpp b/irohad/ametsuchi/impl/postgres_query_executor.cpp index 094c010513..6cc03bdec1 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.cpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.cpp @@ -191,11 +191,11 @@ namespace iroha { typename PermissionTuple, typename QueryExecutor, typename ResponseCreator, - typename ErrResponse> + typename PermissionsErrResponse> QueryExecutorResult PostgresQueryExecutorVisitor::executeQuery( QueryExecutor &&query_executor, ResponseCreator &&response_creator, - ErrResponse &&err_response) { + PermissionsErrResponse &&perms_err_response) { using T = concat; try { soci::rowset st = std::forward(query_executor)(); @@ -203,7 +203,8 @@ namespace iroha { return apply( viewPermissions(range.front()), - [this, range, &response_creator, &err_response](auto... perms) { + [this, range, &response_creator, &perms_err_response]( + auto... perms) { bool temp[] = {not perms...}; if (std::all_of(std::begin(temp), std::end(temp), [](auto b) { return b; @@ -212,7 +213,7 @@ namespace iroha { // with a named constant return this->logAndReturnErrorResponse( QueryErrorType::kStatefulFailed, - std::forward(err_response)(), + std::forward(perms_err_response)(), 2); } auto query_range = range @@ -619,6 +620,16 @@ namespace iroha { return (sql_.prepare << cmd, soci::use(creator_id_, "account_id")); }, [&](auto range, auto &my_perm, auto &all_perm) { + if (boost::size(range) != q.transactionHashes().size()) { + // TODO [IR-1816] Akvinikym 03.12.18: replace magic number 4 + // with a named constant + // at least one of the hashes in the query was invalid - + // nonexistent or permissions were missed + return this->logAndReturnErrorResponse( + QueryErrorType::kStatefulFailed, + "At least one of the supplied hashes is incorrect", + 4); + } std::map> index; boost::for_each(range, [&index](auto t) { apply(t, [&index](auto &height, auto &hash) { diff --git a/irohad/ametsuchi/impl/postgres_query_executor.hpp b/irohad/ametsuchi/impl/postgres_query_executor.hpp index 523a2ceac7..caebf7a35f 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.hpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.hpp @@ -114,21 +114,23 @@ namespace iroha { * @tparam PermissionTuple - permissions, needed for the query * @tparam QueryExecutor - type of function, which executes the query * @tparam ResponseCreator - type of function, which creates response of - * the query - * @tparam ErrResponse - type of function, which creates error response + * the query, successful or error one + * @tparam PermissionsErrResponse - type of function, which creates error + * response in case something wrong with permissions * @param query_executor - function, executing query * @param response_creator - function, creating query response - * @param err_response - function, creating error response + * @param perms_err_response - function, creating error response * @return query response created as a result of query execution */ template - QueryExecutorResult executeQuery(QueryExecutor &&query_executor, - ResponseCreator &&response_creator, - ErrResponse &&err_response); + typename PermissionsErrResponse> + QueryExecutorResult executeQuery( + QueryExecutor &&query_executor, + ResponseCreator &&response_creator, + PermissionsErrResponse &&perms_err_response); /** * Create a query error response and log it diff --git a/test/integration/acceptance/get_transactions_test.cpp b/test/integration/acceptance/get_transactions_test.cpp index 619ae6d432..6893e5c2d0 100644 --- a/test/integration/acceptance/get_transactions_test.cpp +++ b/test/integration/acceptance/get_transactions_test.cpp @@ -172,15 +172,19 @@ TEST_F(GetTransactions, InvalidSignatures) { /** * @given some user with only can_get_my_txs permission * @when query GetTransactions with nonexistent hash - * @then TransactionsResponse with no transactions + * @then Stateful invalid query response */ TEST_F(GetTransactions, NonexistentHash) { auto check = [](auto &status) { ASSERT_NO_THROW({ const auto &resp = - boost::get( + boost::get( status.get()); - ASSERT_EQ(resp.transactions().size(), 0); + // TODO [IR-1816] Akvinikym 03.12.18: replace magic number 4 + // with a named constant + ASSERT_EQ(resp.errorCode(), 4); + boost::get( + resp.get()); }); }; diff --git a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp index 0e7c6281a3..3abfae097e 100644 --- a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp @@ -1468,31 +1468,29 @@ namespace iroha { } /** - * @given initialized storage, permission to his/her account - * @when get transactions - * @then Return transactions of user + * @given initialized storage @and global permission + * @when get transactions with two valid @and one invalid hashes in query + * @then error is returned */ - TEST_F(GetTransactionsHashExecutorTest, ValidMyAccount) { - addPerms({shared_model::interface::permissions::Role::kGetMyTxs}); + TEST_F(GetTransactionsHashExecutorTest, BadHash) { + addPerms({shared_model::interface::permissions::Role::kGetAllTxs}); commitBlocks(); std::vector hashes; hashes.push_back(hash1); + hashes.emplace_back("AbsolutelyInvalidHash"); hashes.push_back(hash2); - hashes.push_back(hash3); auto query = TestQueryBuilder() .creatorAccountId(account_id) .getTransactions(hashes) .build(); auto result = executeQuery(query); - checkSuccessfulResult( - std::move(result), [this](const auto &cast_resp) { - ASSERT_EQ(cast_resp.transactions().size(), 2); - ASSERT_EQ(cast_resp.transactions()[0].hash(), hash1); - ASSERT_EQ(cast_resp.transactions()[1].hash(), hash2); - }); + // TODO [IR-1816] Akvinikym 03.12.18: replace magic number 4 + // with a named constant + checkStatefulError( + std::move(result), 4); } using GetAccountAssetTransactionsExecutorTest = From e7e67b3c9f35c636169ca9aa26c32c4f6ee14462 Mon Sep 17 00:00:00 2001 From: Artyom Bakhtin Date: Tue, 25 Dec 2018 17:08:45 +0300 Subject: [PATCH 32/61] move external dependencies dir (#1992) Signed-off-by: Artyom Bakhtin --- cmake/dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 04df6ad089..854b22b768 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -2,7 +2,7 @@ find_package(PackageHandleStandardArgs) include(ExternalProject) -set(EP_PREFIX "${PROJECT_SOURCE_DIR}/external") +set(EP_PREFIX "${PROJECT_BINARY_DIR}/external") set_directory_properties(PROPERTIES EP_PREFIX ${EP_PREFIX} ) From 97e809c4090f83577f6578b76845d6659a0467a1 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Tue, 25 Dec 2018 17:09:50 +0300 Subject: [PATCH 33/61] No in-place logger creation I (#1953) Signed-off-by: Akvinikym --- irohad/ametsuchi/impl/mutable_storage_impl.cpp | 5 +++-- irohad/ametsuchi/impl/mutable_storage_impl.hpp | 3 ++- irohad/ametsuchi/impl/postgres_block_index.cpp | 5 +++-- irohad/ametsuchi/impl/postgres_block_index.hpp | 4 +++- irohad/ametsuchi/impl/postgres_block_query.cpp | 10 ++++++---- irohad/ametsuchi/impl/postgres_block_query.hpp | 6 ++++-- .../postgres_ordering_service_persistent_state.cpp | 5 ++--- .../postgres_ordering_service_persistent_state.hpp | 11 ++++++----- irohad/ametsuchi/impl/postgres_wsv_query.cpp | 10 ++++++---- irohad/ametsuchi/impl/postgres_wsv_query.hpp | 6 ++++-- irohad/ametsuchi/impl/storage_impl.cpp | 5 +++-- irohad/ametsuchi/impl/storage_impl.hpp | 3 ++- irohad/ametsuchi/impl/temporary_wsv_impl.cpp | 5 +++-- irohad/ametsuchi/impl/temporary_wsv_impl.hpp | 3 ++- irohad/main/impl/raw_block_loader.cpp | 5 +++-- irohad/main/raw_block_loader.hpp | 4 ++-- irohad/main/server_runner.cpp | 8 ++++---- irohad/main/server_runner.hpp | 5 ++++- irohad/model/converters/impl/json_block_factory.cpp | 5 ++--- irohad/model/converters/impl/json_query_factory.cpp | 4 ++-- irohad/model/converters/impl/pb_query_factory.cpp | 5 +++-- irohad/model/converters/json_block_factory.hpp | 6 +++--- irohad/model/converters/json_query_factory.hpp | 3 ++- irohad/model/converters/pb_query_factory.hpp | 3 ++- irohad/model/sha3_hash.cpp | 2 +- irohad/network/impl/async_grpc_client.hpp | 5 +++-- irohad/network/impl/block_loader_impl.cpp | 5 +++-- irohad/network/impl/block_loader_impl.hpp | 3 ++- irohad/network/impl/block_loader_service.cpp | 5 +++-- irohad/network/impl/block_loader_service.hpp | 5 +++-- .../network/impl/peer_communication_service_impl.cpp | 8 ++++---- .../network/impl/peer_communication_service_impl.hpp | 3 ++- .../ordering/impl/on_demand_connection_manager.cpp | 10 ++++++---- .../ordering/impl/on_demand_connection_manager.hpp | 6 ++++-- irohad/ordering/impl/on_demand_ordering_gate.cpp | 5 +++-- irohad/ordering/impl/on_demand_ordering_gate.hpp | 3 ++- .../impl/on_demand_ordering_service_impl.cpp | 5 +++-- .../impl/on_demand_ordering_service_impl.hpp | 5 ++++- irohad/ordering/impl/on_demand_os_client_grpc.cpp | 8 +++++--- irohad/ordering/impl/on_demand_os_client_grpc.hpp | 3 ++- irohad/ordering/impl/on_demand_os_server_grpc.cpp | 5 +++-- irohad/ordering/impl/on_demand_os_server_grpc.hpp | 3 ++- irohad/ordering/impl/ordering_gate_impl.cpp | 5 +++-- irohad/ordering/impl/ordering_gate_impl.hpp | 4 +++- .../ordering/impl/single_peer_ordering_service.cpp | 5 +++-- .../ordering/impl/single_peer_ordering_service.hpp | 4 +++- irohad/torii/command_client.hpp | 4 +++- irohad/torii/impl/command_client.cpp | 9 ++++++--- irohad/torii/impl/command_service_transport_grpc.cpp | 5 +++-- irohad/torii/impl/command_service_transport_grpc.hpp | 8 +++++++- irohad/torii/processor/impl/query_processor_impl.cpp | 5 +++-- .../processor/impl/transaction_processor_impl.cpp | 5 +++-- irohad/torii/processor/query_processor_impl.hpp | 3 ++- .../torii/processor/transaction_processor_impl.hpp | 4 +++- irohad/validation/impl/stateful_validator_impl.cpp | 5 +++-- irohad/validation/impl/stateful_validator_impl.hpp | 5 +++-- libs/crypto/keys_manager_impl.cpp | 10 ++++++---- libs/crypto/keys_manager_impl.hpp | 10 +++++++--- test/module/irohad/ametsuchi/block_query_test.cpp | 4 ++-- test/module/irohad/main/server_runner_test.cpp | 12 ++++++++---- .../torii/processor/transaction_processor_test.cpp | 7 ++++--- 61 files changed, 206 insertions(+), 126 deletions(-) diff --git a/irohad/ametsuchi/impl/mutable_storage_impl.cpp b/irohad/ametsuchi/impl/mutable_storage_impl.cpp index bab2d40ddb..0d8a6a1bb7 100644 --- a/irohad/ametsuchi/impl/mutable_storage_impl.cpp +++ b/irohad/ametsuchi/impl/mutable_storage_impl.cpp @@ -20,7 +20,8 @@ namespace iroha { shared_model::interface::types::HashType top_hash, std::shared_ptr cmd_executor, std::unique_ptr sql, - std::shared_ptr factory) + std::shared_ptr factory, + logger::Logger log) : top_hash_(top_hash), sql_(std::move(sql)), peer_query_(std::make_unique( @@ -28,7 +29,7 @@ namespace iroha { block_index_(std::make_unique(*sql_)), command_executor_(std::move(cmd_executor)), committed(false), - log_(logger::log("MutableStorage")) { + log_(std::move(log)) { *sql_ << "BEGIN"; } diff --git a/irohad/ametsuchi/impl/mutable_storage_impl.hpp b/irohad/ametsuchi/impl/mutable_storage_impl.hpp index 65b82211aa..736aa81f3e 100644 --- a/irohad/ametsuchi/impl/mutable_storage_impl.hpp +++ b/irohad/ametsuchi/impl/mutable_storage_impl.hpp @@ -29,7 +29,8 @@ namespace iroha { std::shared_ptr cmd_executor, std::unique_ptr sql, std::shared_ptr - factory); + factory, + logger::Logger log = logger::log("MutableStorage")); bool apply(const shared_model::interface::Block &block) override; diff --git a/irohad/ametsuchi/impl/postgres_block_index.cpp b/irohad/ametsuchi/impl/postgres_block_index.cpp index f5b8f1f7d0..ab403f7789 100644 --- a/irohad/ametsuchi/impl/postgres_block_index.cpp +++ b/irohad/ametsuchi/impl/postgres_block_index.cpp @@ -118,8 +118,9 @@ namespace { namespace iroha { namespace ametsuchi { - PostgresBlockIndex::PostgresBlockIndex(soci::session &sql) - : sql_(sql), log_(logger::log("PostgresBlockIndex")) {} + PostgresBlockIndex::PostgresBlockIndex(soci::session &sql, + logger::Logger log) + : sql_(sql), log_(std::move(log)) {} void PostgresBlockIndex::index( const shared_model::interface::Block &block) { diff --git a/irohad/ametsuchi/impl/postgres_block_index.hpp b/irohad/ametsuchi/impl/postgres_block_index.hpp index 40f7e2e2bb..740a5496da 100644 --- a/irohad/ametsuchi/impl/postgres_block_index.hpp +++ b/irohad/ametsuchi/impl/postgres_block_index.hpp @@ -17,7 +17,9 @@ namespace iroha { namespace ametsuchi { class PostgresBlockIndex : public BlockIndex { public: - explicit PostgresBlockIndex(soci::session &sql); + PostgresBlockIndex( + soci::session &sql, + logger::Logger log = logger::log("PostgresBlockIndex")); /** * Create several indices for block. Namely: diff --git a/irohad/ametsuchi/impl/postgres_block_query.cpp b/irohad/ametsuchi/impl/postgres_block_query.cpp index 55043713ea..807a304259 100644 --- a/irohad/ametsuchi/impl/postgres_block_query.cpp +++ b/irohad/ametsuchi/impl/postgres_block_query.cpp @@ -18,22 +18,24 @@ namespace iroha { soci::session &sql, KeyValueStorage &file_store, std::shared_ptr - converter) + converter, + logger::Logger log) : sql_(sql), block_store_(file_store), converter_(std::move(converter)), - log_(logger::log("PostgresBlockQuery")) {} + log_(std::move(log)) {} PostgresBlockQuery::PostgresBlockQuery( std::unique_ptr sql, KeyValueStorage &file_store, std::shared_ptr - converter) + converter, + logger::Logger log) : psql_(std::move(sql)), sql_(*psql_), block_store_(file_store), converter_(std::move(converter)), - log_(logger::log("PostgresBlockQuery")) {} + log_(std::move(log)) {} std::vector PostgresBlockQuery::getBlocks( shared_model::interface::types::HeightType height, uint32_t count) { diff --git a/irohad/ametsuchi/impl/postgres_block_query.hpp b/irohad/ametsuchi/impl/postgres_block_query.hpp index a24dc49ec5..4dfef6c51f 100644 --- a/irohad/ametsuchi/impl/postgres_block_query.hpp +++ b/irohad/ametsuchi/impl/postgres_block_query.hpp @@ -28,13 +28,15 @@ namespace iroha { soci::session &sql, KeyValueStorage &file_store, std::shared_ptr - converter); + converter, + logger::Logger log = logger::log("PostgresBlockQuery")); PostgresBlockQuery( std::unique_ptr sql, KeyValueStorage &file_store, std::shared_ptr - converter); + converter, + logger::Logger log = logger::log("PostgresBlockQuery")); std::vector getAccountTransactions( const shared_model::interface::types::AccountIdType &account_id) diff --git a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp index f382f2ae69..636cb64a4f 100644 --- a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp +++ b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp @@ -48,9 +48,8 @@ namespace iroha { PostgresOrderingServicePersistentState:: PostgresOrderingServicePersistentState( - std::unique_ptr sql) - : sql_(std::move(sql)), - log_(logger::log("PostgresOrderingServicePersistentState")) {} + std::unique_ptr sql, logger::Logger log) + : sql_(std::move(sql)), log_(std::move(log)) {} bool PostgresOrderingServicePersistentState::initStorage() { return execute_( diff --git a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp index ea2d843a09..3231f90778 100644 --- a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp +++ b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.hpp @@ -33,12 +33,13 @@ namespace iroha { create(const std::string &postgres_options); /** - * Constructor - * @param postgres_connection postgres connection object - * @param postgres_transaction postgres transaction object + * @param sql - pointer to soci session + * @param log to print progress */ - explicit PostgresOrderingServicePersistentState( - std::unique_ptr sql); + PostgresOrderingServicePersistentState( + std::unique_ptr sql, + logger::Logger log = + logger::log("PostgresOrderingServicePersistentState")); /** * Initialize storage. diff --git a/irohad/ametsuchi/impl/postgres_wsv_query.cpp b/irohad/ametsuchi/impl/postgres_wsv_query.cpp index 1d61231d63..89da2a87bc 100644 --- a/irohad/ametsuchi/impl/postgres_wsv_query.cpp +++ b/irohad/ametsuchi/impl/postgres_wsv_query.cpp @@ -28,16 +28,18 @@ namespace iroha { PostgresWsvQuery::PostgresWsvQuery( soci::session &sql, - std::shared_ptr factory) - : sql_(sql), factory_(factory), log_(logger::log("PostgresWsvQuery")) {} + std::shared_ptr factory, + logger::Logger log) + : sql_(sql), factory_(factory), log_(std::move(log)) {} PostgresWsvQuery::PostgresWsvQuery( std::unique_ptr sql, - std::shared_ptr factory) + std::shared_ptr factory, + logger::Logger log) : psql_(std::move(sql)), sql_(*psql_), factory_(factory), - log_(logger::log("PostgresWsvQuery")) {} + log_(std::move(log)) {} template boost::optional> PostgresWsvQuery::fromResult( diff --git a/irohad/ametsuchi/impl/postgres_wsv_query.hpp b/irohad/ametsuchi/impl/postgres_wsv_query.hpp index 4fad3c164f..fc6b4bd724 100644 --- a/irohad/ametsuchi/impl/postgres_wsv_query.hpp +++ b/irohad/ametsuchi/impl/postgres_wsv_query.hpp @@ -20,12 +20,14 @@ namespace iroha { PostgresWsvQuery( soci::session &sql, std::shared_ptr - factory); + factory, + logger::Logger log = logger::log("PostgresWsvQuery")); PostgresWsvQuery( std::unique_ptr sql, std::shared_ptr - factory); + factory, + logger::Logger log = logger::log("PostgresWsvQuery")); boost::optional> getAccountRoles(const shared_model::interface::types::AccountIdType diff --git a/irohad/ametsuchi/impl/storage_impl.cpp b/irohad/ametsuchi/impl/storage_impl.cpp index bdc38f2ca8..3b0e953893 100644 --- a/irohad/ametsuchi/impl/storage_impl.cpp +++ b/irohad/ametsuchi/impl/storage_impl.cpp @@ -62,7 +62,8 @@ namespace iroha { std::shared_ptr perm_converter, size_t pool_size, - bool enable_prepared_blocks) + bool enable_prepared_blocks, + logger::Logger log) : block_store_dir_(std::move(block_store_dir)), postgres_options_(std::move(postgres_options)), block_store_(std::move(block_store)), @@ -70,7 +71,7 @@ namespace iroha { factory_(std::move(factory)), converter_(std::move(converter)), perm_converter_(std::move(perm_converter)), - log_(logger::log("StorageImpl")), + log_(std::move(log)), pool_size_(pool_size), prepared_blocks_enabled_(enable_prepared_blocks), block_is_prepared(false) { diff --git a/irohad/ametsuchi/impl/storage_impl.hpp b/irohad/ametsuchi/impl/storage_impl.hpp index 2273842977..0ddef6e888 100644 --- a/irohad/ametsuchi/impl/storage_impl.hpp +++ b/irohad/ametsuchi/impl/storage_impl.hpp @@ -127,7 +127,8 @@ namespace iroha { std::shared_ptr perm_converter, size_t pool_size, - bool enable_prepared_blocks); + bool enable_prepared_blocks, + logger::Logger log = logger::log("StorageImpl")); /** * Folder with raw blocks diff --git a/irohad/ametsuchi/impl/temporary_wsv_impl.cpp b/irohad/ametsuchi/impl/temporary_wsv_impl.cpp index be998a2398..9745e47402 100644 --- a/irohad/ametsuchi/impl/temporary_wsv_impl.cpp +++ b/irohad/ametsuchi/impl/temporary_wsv_impl.cpp @@ -18,11 +18,12 @@ namespace iroha { std::unique_ptr sql, std::shared_ptr factory, std::shared_ptr - perm_converter) + perm_converter, + logger::Logger log) : sql_(std::move(sql)), command_executor_(std::make_unique( *sql_, std::move(perm_converter))), - log_(logger::log("TemporaryWSV")) { + log_(std::move(log)) { *sql_ << "BEGIN"; } diff --git a/irohad/ametsuchi/impl/temporary_wsv_impl.hpp b/irohad/ametsuchi/impl/temporary_wsv_impl.hpp index 4b931ea35c..709cbfa9df 100644 --- a/irohad/ametsuchi/impl/temporary_wsv_impl.hpp +++ b/irohad/ametsuchi/impl/temporary_wsv_impl.hpp @@ -45,7 +45,8 @@ namespace iroha { std::shared_ptr factory, std::shared_ptr - perm_converter); + perm_converter, + logger::Logger log = logger::log("TemporaryWSV")); expected::Result apply( const shared_model::interface::Transaction &transaction) override; diff --git a/irohad/main/impl/raw_block_loader.cpp b/irohad/main/impl/raw_block_loader.cpp index 01b0113a13..4d03f23e2d 100644 --- a/irohad/main/impl/raw_block_loader.cpp +++ b/irohad/main/impl/raw_block_loader.cpp @@ -17,13 +17,14 @@ namespace iroha { using shared_model::converters::protobuf::jsonToProto; using shared_model::interface::Block; - BlockLoader::BlockLoader() : log_(logger::log("BlockLoader")) {} + BlockLoader::BlockLoader(logger::Logger log) : log_(std::move(log)) {} boost::optional> BlockLoader::parseBlock( const std::string &data) { return jsonToProto(data) | [](auto &&block) { return boost::optional>( - std::make_shared(std::move(block.block_v1()))); + std::make_shared( + std::move(block.block_v1()))); }; } diff --git a/irohad/main/raw_block_loader.hpp b/irohad/main/raw_block_loader.hpp index 47be31c1d2..92d555999c 100644 --- a/irohad/main/raw_block_loader.hpp +++ b/irohad/main/raw_block_loader.hpp @@ -17,7 +17,7 @@ namespace shared_model { namespace interface { class Block; } -} +} // namespace shared_model namespace iroha { namespace main { @@ -29,7 +29,7 @@ namespace iroha { */ class BlockLoader { public: - BlockLoader(); + explicit BlockLoader(logger::Logger log = logger::log("BlockLoader")); /** * Parse block from file diff --git a/irohad/main/server_runner.cpp b/irohad/main/server_runner.cpp index 5b0eedbaef..75297af8e3 100644 --- a/irohad/main/server_runner.cpp +++ b/irohad/main/server_runner.cpp @@ -9,10 +9,10 @@ const auto kPortBindError = "Cannot bind server to address %s"; -ServerRunner::ServerRunner(const std::string &address, bool reuse) - : log_(logger::log("ServerRunner")), - serverAddress_(address), - reuse_(reuse) {} +ServerRunner::ServerRunner(const std::string &address, + bool reuse, + logger::Logger log) + : log_(std::move(log)), serverAddress_(address), reuse_(reuse) {} ServerRunner &ServerRunner::append(std::shared_ptr service) { services_.push_back(service); diff --git a/irohad/main/server_runner.hpp b/irohad/main/server_runner.hpp index e4d3890e5f..495a8a2393 100644 --- a/irohad/main/server_runner.hpp +++ b/irohad/main/server_runner.hpp @@ -20,8 +20,11 @@ class ServerRunner { * Constructor. Initialize a new instance of ServerRunner class. * @param address - the address the server will be bind to in URI form * @param reuse - allow multiple sockets to bind to the same port + * @param log to print progress to */ - explicit ServerRunner(const std::string &address, bool reuse = true); + explicit ServerRunner(const std::string &address, + bool reuse = true, + logger::Logger log = logger::log("ServerRunner")); /** * Adds a new grpc service to be run. diff --git a/irohad/model/converters/impl/json_block_factory.cpp b/irohad/model/converters/impl/json_block_factory.cpp index b0217a0ad3..36e6cb46e7 100644 --- a/irohad/model/converters/impl/json_block_factory.cpp +++ b/irohad/model/converters/impl/json_block_factory.cpp @@ -11,9 +11,8 @@ namespace iroha { namespace model { namespace converters { - JsonBlockFactory::JsonBlockFactory() { - log_ = logger::log("JsonBlockFactory"); - } + JsonBlockFactory::JsonBlockFactory(logger::Logger log) + : log_{std::move(log)} {} Document JsonBlockFactory::serialize(const Block &block) { Document document; diff --git a/irohad/model/converters/impl/json_query_factory.cpp b/irohad/model/converters/impl/json_query_factory.cpp index ac5d5331fe..b853129647 100644 --- a/irohad/model/converters/impl/json_query_factory.cpp +++ b/irohad/model/converters/impl/json_query_factory.cpp @@ -18,8 +18,8 @@ using namespace rapidjson; namespace iroha { namespace model { namespace converters { - JsonQueryFactory::JsonQueryFactory() - : log_(logger::log("JsonQueryFactory")) { + JsonQueryFactory::JsonQueryFactory(logger::Logger log) + : log_{std::move(log)} { deserializers_ = { {"GetAccount", &JsonQueryFactory::deserializeGetAccount}, {"GetAccountAssets", diff --git a/irohad/model/converters/impl/pb_query_factory.cpp b/irohad/model/converters/impl/pb_query_factory.cpp index f6246ecb9e..fbf95663ac 100644 --- a/irohad/model/converters/impl/pb_query_factory.cpp +++ b/irohad/model/converters/impl/pb_query_factory.cpp @@ -4,6 +4,7 @@ */ #include "model/converters/pb_query_factory.hpp" + #include "model/common.hpp" #include "model/queries/get_account.hpp" #include "model/queries/get_account_assets.hpp" @@ -18,8 +19,8 @@ namespace iroha { namespace model { namespace converters { - PbQueryFactory::PbQueryFactory() { - log_ = logger::log("PbQueryFactory"); + PbQueryFactory::PbQueryFactory(logger::Logger log) + : log_{std::move(log)} { serializers_[typeid(GetAccount)] = &PbQueryFactory::serializeGetAccount; serializers_[typeid(GetAccountAssets)] = &PbQueryFactory::serializeGetAccountAssets; diff --git a/irohad/model/converters/json_block_factory.hpp b/irohad/model/converters/json_block_factory.hpp index 3222df1bae..eb3acbe5b5 100644 --- a/irohad/model/converters/json_block_factory.hpp +++ b/irohad/model/converters/json_block_factory.hpp @@ -16,11 +16,11 @@ namespace iroha { class JsonBlockFactory { public: - JsonBlockFactory(); + explicit JsonBlockFactory( + logger::Logger log = logger::log("JsonBlockFactory")); rapidjson::Document serialize(const Block &block); - boost::optional deserialize( - const rapidjson::Document &document); + boost::optional deserialize(const rapidjson::Document &document); private: JsonTransactionFactory factory_; diff --git a/irohad/model/converters/json_query_factory.hpp b/irohad/model/converters/json_query_factory.hpp index e4caf041f7..290ab40b2e 100644 --- a/irohad/model/converters/json_query_factory.hpp +++ b/irohad/model/converters/json_query_factory.hpp @@ -19,7 +19,8 @@ namespace iroha { namespace converters { class JsonQueryFactory { public: - JsonQueryFactory(); + explicit JsonQueryFactory( + logger::Logger log = logger::log("JsonQueryFactory")); /** * get query from string json diff --git a/irohad/model/converters/pb_query_factory.hpp b/irohad/model/converters/pb_query_factory.hpp index 65329a49b9..5faa372798 100644 --- a/irohad/model/converters/pb_query_factory.hpp +++ b/irohad/model/converters/pb_query_factory.hpp @@ -37,7 +37,8 @@ namespace iroha { boost::optional serialize( std::shared_ptr query) const; - PbQueryFactory(); + explicit PbQueryFactory( + logger::Logger log = logger::log("PbQueryFactory")); private: // Query serializer: diff --git a/irohad/model/sha3_hash.cpp b/irohad/model/sha3_hash.cpp index 9806a06240..7965a3ed6e 100644 --- a/irohad/model/sha3_hash.cpp +++ b/irohad/model/sha3_hash.cpp @@ -29,4 +29,4 @@ namespace iroha { auto &&pb_dat = query_factory.serialize(qptr); return hash(*pb_dat); } -} +} // namespace iroha diff --git a/irohad/network/impl/async_grpc_client.hpp b/irohad/network/impl/async_grpc_client.hpp index 37a6445e41..477100b4a9 100644 --- a/irohad/network/impl/async_grpc_client.hpp +++ b/irohad/network/impl/async_grpc_client.hpp @@ -23,9 +23,10 @@ namespace iroha { template class AsyncGrpcClient { public: - AsyncGrpcClient() + explicit AsyncGrpcClient( + logger::Logger log = logger::log("AsyncGrpcClient")) : thread_(&AsyncGrpcClient::asyncCompleteRpc, this), - log_(logger::log("AsyncGrpcClient")) {} + log_(std::move(log)) {} /** * Listen to gRPC server responses diff --git a/irohad/network/impl/block_loader_impl.cpp b/irohad/network/impl/block_loader_impl.cpp index a83ab3185a..085c3c9e73 100644 --- a/irohad/network/impl/block_loader_impl.cpp +++ b/irohad/network/impl/block_loader_impl.cpp @@ -26,10 +26,11 @@ namespace { BlockLoaderImpl::BlockLoaderImpl( std::shared_ptr peer_query_factory, - shared_model::proto::ProtoBlockFactory factory) + shared_model::proto::ProtoBlockFactory factory, + logger::Logger log) : peer_query_factory_(std::move(peer_query_factory)), block_factory_(std::move(factory)), - log_(logger::log("BlockLoaderImpl")) {} + log_(std::move(log)) {} rxcpp::observable> BlockLoaderImpl::retrieveBlocks( const shared_model::interface::types::HeightType height, diff --git a/irohad/network/impl/block_loader_impl.hpp b/irohad/network/impl/block_loader_impl.hpp index d556f2db9d..0ee8a41aed 100644 --- a/irohad/network/impl/block_loader_impl.hpp +++ b/irohad/network/impl/block_loader_impl.hpp @@ -21,7 +21,8 @@ namespace iroha { public: BlockLoaderImpl( std::shared_ptr peer_query_factory, - shared_model::proto::ProtoBlockFactory factory); + shared_model::proto::ProtoBlockFactory factory, + logger::Logger log = logger::log("BlockLoaderImpl")); rxcpp::observable> retrieveBlocks( diff --git a/irohad/network/impl/block_loader_service.cpp b/irohad/network/impl/block_loader_service.cpp index 4f0b48079e..90a1745a3f 100644 --- a/irohad/network/impl/block_loader_service.cpp +++ b/irohad/network/impl/block_loader_service.cpp @@ -14,10 +14,11 @@ using namespace iroha::network; BlockLoaderService::BlockLoaderService( std::shared_ptr block_query_factory, std::shared_ptr - consensus_result_cache) + consensus_result_cache, + logger::Logger log) : block_query_factory_(std::move(block_query_factory)), consensus_result_cache_(std::move(consensus_result_cache)), - log_(logger::log("BlockLoaderService")) {} + log_(std::move(log)) {} grpc::Status BlockLoaderService::retrieveBlocks( ::grpc::ServerContext *context, diff --git a/irohad/network/impl/block_loader_service.hpp b/irohad/network/impl/block_loader_service.hpp index 6f3fcd639f..71b0c57dbb 100644 --- a/irohad/network/impl/block_loader_service.hpp +++ b/irohad/network/impl/block_loader_service.hpp @@ -15,10 +15,11 @@ namespace iroha { namespace network { class BlockLoaderService : public proto::Loader::Service { public: - explicit BlockLoaderService( + BlockLoaderService( std::shared_ptr block_query_factory, std::shared_ptr - consensus_result_cache); + consensus_result_cache, + logger::Logger log = logger::log("BlockLoaderService")); grpc::Status retrieveBlocks( ::grpc::ServerContext *context, diff --git a/irohad/network/impl/peer_communication_service_impl.cpp b/irohad/network/impl/peer_communication_service_impl.cpp index dc2534391a..b90053f01e 100644 --- a/irohad/network/impl/peer_communication_service_impl.cpp +++ b/irohad/network/impl/peer_communication_service_impl.cpp @@ -16,12 +16,12 @@ namespace iroha { std::shared_ptr ordering_gate, std::shared_ptr synchronizer, std::shared_ptr - proposal_creator) + proposal_creator, + logger::Logger log) : ordering_gate_(std::move(ordering_gate)), synchronizer_(std::move(synchronizer)), - proposal_creator_(std::move(proposal_creator)) { - log_ = logger::log("PCS"); - } + proposal_creator_(std::move(proposal_creator)), + log_{std::move(log)} {} void PeerCommunicationServiceImpl::propagate_batch( std::shared_ptr batch) diff --git a/irohad/network/impl/peer_communication_service_impl.hpp b/irohad/network/impl/peer_communication_service_impl.hpp index fd8a9f02ac..bbe4bac05c 100644 --- a/irohad/network/impl/peer_communication_service_impl.hpp +++ b/irohad/network/impl/peer_communication_service_impl.hpp @@ -27,7 +27,8 @@ namespace iroha { PeerCommunicationServiceImpl( std::shared_ptr ordering_gate, std::shared_ptr synchronizer, - std::shared_ptr proposal_creator); + std::shared_ptr proposal_creator, + logger::Logger log = logger::log("PCS")); void propagate_batch( std::shared_ptr batch) diff --git a/irohad/ordering/impl/on_demand_connection_manager.cpp b/irohad/ordering/impl/on_demand_connection_manager.cpp index 5217231334..127a611e89 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.cpp +++ b/irohad/ordering/impl/on_demand_connection_manager.cpp @@ -13,8 +13,9 @@ using namespace iroha::ordering; OnDemandConnectionManager::OnDemandConnectionManager( std::shared_ptr factory, - rxcpp::observable peers) - : log_(logger::log("OnDemandConnectionManager")), + rxcpp::observable peers, + logger::Logger log) + : log_(std::move(log)), factory_(std::move(factory)), subscription_(peers.subscribe([this](const auto &peers) { // exclusive lock @@ -26,8 +27,9 @@ OnDemandConnectionManager::OnDemandConnectionManager( OnDemandConnectionManager::OnDemandConnectionManager( std::shared_ptr factory, rxcpp::observable peers, - CurrentPeers initial_peers) - : OnDemandConnectionManager(std::move(factory), peers) { + CurrentPeers initial_peers, + logger::Logger log) + : OnDemandConnectionManager(std::move(factory), peers, std::move(log)) { // using start_with(initial_peers) results in deadlock initializeConnections(initial_peers); } diff --git a/irohad/ordering/impl/on_demand_connection_manager.hpp b/irohad/ordering/impl/on_demand_connection_manager.hpp index 670cc1f690..d568edbc41 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.hpp +++ b/irohad/ordering/impl/on_demand_connection_manager.hpp @@ -51,12 +51,14 @@ namespace iroha { OnDemandConnectionManager( std::shared_ptr factory, - rxcpp::observable peers); + rxcpp::observable peers, + logger::Logger log = logger::log("OnDemandConnectionManager")); OnDemandConnectionManager( std::shared_ptr factory, rxcpp::observable peers, - CurrentPeers initial_peers); + CurrentPeers initial_peers, + logger::Logger log = logger::log("OnDemandConnectionManager")); ~OnDemandConnectionManager() override; diff --git a/irohad/ordering/impl/on_demand_ordering_gate.cpp b/irohad/ordering/impl/on_demand_ordering_gate.cpp index 7473aa2522..6e2aaeafcf 100644 --- a/irohad/ordering/impl/on_demand_ordering_gate.cpp +++ b/irohad/ordering/impl/on_demand_ordering_gate.cpp @@ -21,8 +21,9 @@ OnDemandOrderingGate::OnDemandOrderingGate( std::shared_ptr cache, std::shared_ptr factory, std::shared_ptr tx_cache, - consensus::Round initial_round) - : log_(logger::log("OnDemandOrderingGate")), + consensus::Round initial_round, + logger::Logger log) + : log_(std::move(log)), ordering_service_(std::move(ordering_service)), network_client_(std::move(network_client)), events_subscription_(events.subscribe([this](auto event) { diff --git a/irohad/ordering/impl/on_demand_ordering_gate.hpp b/irohad/ordering/impl/on_demand_ordering_gate.hpp index 6945725c01..21ab94cdc9 100644 --- a/irohad/ordering/impl/on_demand_ordering_gate.hpp +++ b/irohad/ordering/impl/on_demand_ordering_gate.hpp @@ -62,7 +62,8 @@ namespace iroha { std::shared_ptr factory, std::shared_ptr tx_cache, - consensus::Round initial_round); + consensus::Round initial_round, + logger::Logger log = logger::log("OnDemandOrderingGate")); ~OnDemandOrderingGate() override; diff --git a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp index 52866b3e22..5679620966 100644 --- a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp +++ b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp @@ -28,12 +28,13 @@ OnDemandOrderingServiceImpl::OnDemandOrderingServiceImpl( proposal_factory, std::shared_ptr tx_cache, size_t number_of_proposals, - const consensus::Round &initial_round) + const consensus::Round &initial_round, + logger::Logger log) : transaction_limit_(transaction_limit), number_of_proposals_(number_of_proposals), proposal_factory_(std::move(proposal_factory)), tx_cache_(std::move(tx_cache)), - log_(logger::log("OnDemandOrderingServiceImpl")) { + log_(std::move(log)) { onCollaborationOutcome(initial_round); } diff --git a/irohad/ordering/impl/on_demand_ordering_service_impl.hpp b/irohad/ordering/impl/on_demand_ordering_service_impl.hpp index 35f503784a..a29c781610 100644 --- a/irohad/ordering/impl/on_demand_ordering_service_impl.hpp +++ b/irohad/ordering/impl/on_demand_ordering_service_impl.hpp @@ -29,10 +29,12 @@ namespace iroha { * @param transaction_limit - number of maximum transactions in one * proposal * @param proposal_factory - used to generate proposals + * @param tx_cache - cache of transactions * @param number_of_proposals - number of stored proposals, older will be * removed. Default value is 3 * @param initial_round - first round of agreement. * Default value is {2, kFirstRejectRound} since genesis block height is 1 + * @param log to print progress */ OnDemandOrderingServiceImpl( size_t transaction_limit, @@ -40,7 +42,8 @@ namespace iroha { proposal_factory, std::shared_ptr tx_cache, size_t number_of_proposals = 3, - const consensus::Round &initial_round = {2, kFirstRejectRound}); + const consensus::Round &initial_round = {2, kFirstRejectRound}, + logger::Logger log = logger::log("OnDemandOrderingServiceImpl")); // --------------------- | OnDemandOrderingService |_--------------------- diff --git a/irohad/ordering/impl/on_demand_os_client_grpc.cpp b/irohad/ordering/impl/on_demand_os_client_grpc.cpp index 5a1a578834..262c2781c2 100644 --- a/irohad/ordering/impl/on_demand_os_client_grpc.cpp +++ b/irohad/ordering/impl/on_demand_os_client_grpc.cpp @@ -18,8 +18,9 @@ OnDemandOsClientGrpc::OnDemandOsClientGrpc( std::shared_ptr> async_call, std::function time_provider, - std::chrono::milliseconds proposal_request_timeout) - : log_(logger::log("OnDemandOsClientGrpc")), + std::chrono::milliseconds proposal_request_timeout, + logger::Logger log) + : log_(std::move(log)), stub_(std::move(stub)), async_call_(std::move(async_call)), time_provider_(std::move(time_provider)), @@ -80,5 +81,6 @@ std::unique_ptr OnDemandOsClientGrpcFactory::create( network::createClient(to.address()), async_call_, time_provider_, - proposal_request_timeout_); + proposal_request_timeout_, + logger::log("OnDemandOsClientGrpc")); } diff --git a/irohad/ordering/impl/on_demand_os_client_grpc.hpp b/irohad/ordering/impl/on_demand_os_client_grpc.hpp index 1128adeb37..1edee3b1b0 100644 --- a/irohad/ordering/impl/on_demand_os_client_grpc.hpp +++ b/irohad/ordering/impl/on_demand_os_client_grpc.hpp @@ -32,7 +32,8 @@ namespace iroha { std::shared_ptr> async_call, std::function time_provider, - std::chrono::milliseconds proposal_request_timeout); + std::chrono::milliseconds proposal_request_timeout, + logger::Logger log = logger::log("OnDemandOsClientGrpc")); void onBatches(consensus::Round round, CollectionType batches) override; diff --git a/irohad/ordering/impl/on_demand_os_server_grpc.cpp b/irohad/ordering/impl/on_demand_os_server_grpc.cpp index 1dc8676a26..1d8225f5aa 100644 --- a/irohad/ordering/impl/on_demand_os_server_grpc.cpp +++ b/irohad/ordering/impl/on_demand_os_server_grpc.cpp @@ -22,12 +22,13 @@ OnDemandOsServerGrpc::OnDemandOsServerGrpc( std::shared_ptr batch_parser, std::shared_ptr - transaction_batch_factory) + transaction_batch_factory, + logger::Logger log) : ordering_service_(ordering_service), transaction_factory_(std::move(transaction_factory)), batch_parser_(std::move(batch_parser)), batch_factory_(std::move(transaction_batch_factory)), - log_(logger::log("OnDemandOsServerGrpc")) {} + log_(std::move(log)) {} shared_model::interface::types::SharedTxsCollectionType OnDemandOsServerGrpc::deserializeTransactions( diff --git a/irohad/ordering/impl/on_demand_os_server_grpc.hpp b/irohad/ordering/impl/on_demand_os_server_grpc.hpp index cee51ae125..b9cc974a1c 100644 --- a/irohad/ordering/impl/on_demand_os_server_grpc.hpp +++ b/irohad/ordering/impl/on_demand_os_server_grpc.hpp @@ -34,7 +34,8 @@ namespace iroha { std::shared_ptr batch_parser, std::shared_ptr - transaction_batch_factory); + transaction_batch_factory, + logger::Logger log = logger::log("OnDemandOsServerGrpc")); grpc::Status SendBatches(::grpc::ServerContext *context, const proto::BatchesRequest *request, diff --git a/irohad/ordering/impl/ordering_gate_impl.cpp b/irohad/ordering/impl/ordering_gate_impl.cpp index 3abbe4b6b0..cccd7e67b8 100644 --- a/irohad/ordering/impl/ordering_gate_impl.cpp +++ b/irohad/ordering/impl/ordering_gate_impl.cpp @@ -25,10 +25,11 @@ namespace iroha { OrderingGateImpl::OrderingGateImpl( std::shared_ptr transport, shared_model::interface::types::HeightType initial_height, - bool run_async) + bool run_async, + logger::Logger log) : transport_(std::move(transport)), last_block_height_(initial_height), - log_(logger::log("OrderingGate")), + log_(std::move(log)), run_async_(run_async) {} void OrderingGateImpl::propagateBatch( diff --git a/irohad/ordering/impl/ordering_gate_impl.hpp b/irohad/ordering/impl/ordering_gate_impl.hpp index d031c207a8..08b3a57e71 100644 --- a/irohad/ordering/impl/ordering_gate_impl.hpp +++ b/irohad/ordering/impl/ordering_gate_impl.hpp @@ -49,11 +49,13 @@ namespace iroha { * @param initial_height - height of the last block stored on this peer * @param run_async - whether proposals should be handled * asynchronously (on separate thread). Default is true. + * @param log to print progress */ OrderingGateImpl( std::shared_ptr transport, shared_model::interface::types::HeightType initial_height, - bool run_async = true); + bool run_async = true, + logger::Logger log = logger::log("OrderingGate")); void propagateBatch( std::shared_ptr batch) diff --git a/irohad/ordering/impl/single_peer_ordering_service.cpp b/irohad/ordering/impl/single_peer_ordering_service.cpp index 0e30fd9ea9..0ba99dad80 100644 --- a/irohad/ordering/impl/single_peer_ordering_service.cpp +++ b/irohad/ordering/impl/single_peer_ordering_service.cpp @@ -26,7 +26,8 @@ namespace iroha { std::shared_ptr transport, std::shared_ptr persistent_state, std::unique_ptr factory, - bool is_async) + bool is_async, + logger::Logger log) : peer_query_factory_(peer_query_factory), max_size_(max_size), current_size_(0), @@ -37,7 +38,7 @@ namespace iroha { [](const auto &state) { return state->loadProposalHeight().value(); }), - log_(logger::log("OrderingServiceImpl")) { + log_(std::move(log)) { // restore state of ordering service from persistent storage rxcpp::observable timer = proposal_timeout.map([](auto) { return ProposalEvent::kTimerEvent; }); diff --git a/irohad/ordering/impl/single_peer_ordering_service.hpp b/irohad/ordering/impl/single_peer_ordering_service.hpp index bcacf70e4e..eb0736c2ed 100644 --- a/irohad/ordering/impl/single_peer_ordering_service.hpp +++ b/irohad/ordering/impl/single_peer_ordering_service.hpp @@ -47,6 +47,7 @@ namespace iroha { * @param persistent_state factory to storage for auxiliary information * @param factory is used to generate proposals * @param is_async whether proposals are generated in a separate thread + * @param log to print progress */ SinglePeerOrderingService( std::shared_ptr peer_query_factory, @@ -55,7 +56,8 @@ namespace iroha { std::shared_ptr transport, std::shared_ptr persistent_state, std::unique_ptr factory, - bool is_async = true); + bool is_async = true, + logger::Logger log = logger::log("OrderingServiceImpl")); /** * Process transaction(s) received from network diff --git a/irohad/torii/command_client.hpp b/irohad/torii/command_client.hpp index f101138c95..7f3b4cdb31 100644 --- a/irohad/torii/command_client.hpp +++ b/irohad/torii/command_client.hpp @@ -20,7 +20,9 @@ namespace torii { */ class CommandSyncClient { public: - CommandSyncClient(const std::string &ip, size_t port); + CommandSyncClient(const std::string &ip, + size_t port, + logger::Logger log = logger::log("CommandSyncClient")); CommandSyncClient(const CommandSyncClient &); CommandSyncClient &operator=(CommandSyncClient); diff --git a/irohad/torii/impl/command_client.cpp b/irohad/torii/impl/command_client.cpp index a0d207aa0f..f3b8f4241a 100644 --- a/irohad/torii/impl/command_client.cpp +++ b/irohad/torii/impl/command_client.cpp @@ -17,15 +17,17 @@ namespace torii { using iroha::protocol::ToriiResponse; using iroha::protocol::Transaction; - CommandSyncClient::CommandSyncClient(const std::string &ip, size_t port) + CommandSyncClient::CommandSyncClient(const std::string &ip, + size_t port, + logger::Logger log) : ip_(ip), port_(port), stub_(iroha::network::createClient( ip + ":" + std::to_string(port))), - log_(logger::log("CommandSyncClient")) {} + log_(std::move(log)) {} CommandSyncClient::CommandSyncClient(const CommandSyncClient &rhs) - : CommandSyncClient(rhs.ip_, rhs.port_) {} + : CommandSyncClient(rhs.ip_, rhs.port_, rhs.log_) {} CommandSyncClient &CommandSyncClient::operator=(CommandSyncClient rhs) { swap(*this, rhs); @@ -83,6 +85,7 @@ namespace torii { swap(lhs.ip_, rhs.ip_); swap(lhs.port_, rhs.port_); swap(lhs.stub_, rhs.stub_); + swap(lhs.log_, rhs.log_); } } // namespace torii diff --git a/irohad/torii/impl/command_service_transport_grpc.cpp b/irohad/torii/impl/command_service_transport_grpc.cpp index 08e99fe934..b8a0cb4392 100644 --- a/irohad/torii/impl/command_service_transport_grpc.cpp +++ b/irohad/torii/impl/command_service_transport_grpc.cpp @@ -29,7 +29,8 @@ namespace torii { std::shared_ptr batch_parser, std::shared_ptr - transaction_batch_factory) + transaction_batch_factory, + logger::Logger log) : command_service_(std::move(command_service)), status_bus_(std::move(status_bus)), initial_timeout_(initial_timeout), @@ -38,7 +39,7 @@ namespace torii { transaction_factory_(std::move(transaction_factory)), batch_parser_(std::move(batch_parser)), batch_factory_(std::move(transaction_batch_factory)), - log_(logger::log("CommandServiceTransportGrpc")) {} + log_(std::move(log)) {} grpc::Status CommandServiceTransportGrpc::Torii( grpc::ServerContext *context, diff --git a/irohad/torii/impl/command_service_transport_grpc.hpp b/irohad/torii/impl/command_service_transport_grpc.hpp index 7856c0c4dc..b094bca15c 100644 --- a/irohad/torii/impl/command_service_transport_grpc.hpp +++ b/irohad/torii/impl/command_service_transport_grpc.hpp @@ -34,6 +34,11 @@ namespace torii { * @param status_bus is a common notifier for tx statuses * @param initial_timeout - streaming timeout when tx is not received * @param nonfinal_timeout - streaming timeout when tx is being processed + * @param status_factory - factory of statuses + * @param transaction_factory - factory of transactions + * @param batch_parser - parses of batches + * @param transaction_batch_factory - factory of batches + * @param log to print progress */ CommandServiceTransportGrpc( std::shared_ptr command_service, @@ -46,7 +51,8 @@ namespace torii { std::shared_ptr batch_parser, std::shared_ptr - transaction_batch_factory); + transaction_batch_factory, + logger::Logger log = logger::log("CommandServiceTransportGrpc")); /** * Torii call via grpc diff --git a/irohad/torii/processor/impl/query_processor_impl.cpp b/irohad/torii/processor/impl/query_processor_impl.cpp index 8a0157b1d6..da67d6a7a9 100644 --- a/irohad/torii/processor/impl/query_processor_impl.cpp +++ b/irohad/torii/processor/impl/query_processor_impl.cpp @@ -23,12 +23,13 @@ namespace iroha { std::shared_ptr qry_exec, std::shared_ptr pending_transactions, std::shared_ptr - response_factory) + response_factory, + logger::Logger log) : storage_{std::move(storage)}, qry_exec_{std::move(qry_exec)}, pending_transactions_{std::move(pending_transactions)}, response_factory_{std::move(response_factory)}, - log_{logger::log("QueryProcessorImpl")} { + log_{std::move(log)} { storage_->on_commit().subscribe( [this](std::shared_ptr block) { auto block_response = diff --git a/irohad/torii/processor/impl/transaction_processor_impl.cpp b/irohad/torii/processor/impl/transaction_processor_impl.cpp index a572cd8bec..0786328638 100644 --- a/irohad/torii/processor/impl/transaction_processor_impl.cpp +++ b/irohad/torii/processor/impl/transaction_processor_impl.cpp @@ -47,12 +47,13 @@ namespace iroha { std::shared_ptr mst_processor, std::shared_ptr status_bus, std::shared_ptr - status_factory) + status_factory, + logger::Logger log) : pcs_(std::move(pcs)), mst_processor_(std::move(mst_processor)), status_bus_(std::move(status_bus)), status_factory_(std::move(status_factory)), - log_(logger::log("TxProcessor")) { + log_(std::move(log)) { // process stateful validation results pcs_->onVerifiedProposal().subscribe( [this](const simulator::VerifiedProposalCreatorEvent &event) { diff --git a/irohad/torii/processor/query_processor_impl.hpp b/irohad/torii/processor/query_processor_impl.hpp index 726e2eaac9..84c714a8a5 100644 --- a/irohad/torii/processor/query_processor_impl.hpp +++ b/irohad/torii/processor/query_processor_impl.hpp @@ -25,7 +25,8 @@ namespace iroha { std::shared_ptr pending_transactions, std::shared_ptr - response_factory); + response_factory, + logger::Logger log = logger::log("QueryProcessorImpl")); /** * Checks if query has needed signatures diff --git a/irohad/torii/processor/transaction_processor_impl.hpp b/irohad/torii/processor/transaction_processor_impl.hpp index f9331e487d..5a5fbef488 100644 --- a/irohad/torii/processor/transaction_processor_impl.hpp +++ b/irohad/torii/processor/transaction_processor_impl.hpp @@ -28,13 +28,15 @@ namespace iroha { * @param mst_processor is a handler for multisignature transactions * @param status_bus is a common notifier for tx statuses * @param status_factory creates transaction statuses + * @param log to print the progress */ TransactionProcessorImpl( std::shared_ptr pcs, std::shared_ptr mst_processor, std::shared_ptr status_bus, std::shared_ptr - status_factory); + status_factory, + logger::Logger log = logger::log("TxProcessor")); void batchHandle( std::shared_ptr diff --git a/irohad/validation/impl/stateful_validator_impl.cpp b/irohad/validation/impl/stateful_validator_impl.cpp index 0d36d37ed4..77a7a0753f 100644 --- a/irohad/validation/impl/stateful_validator_impl.cpp +++ b/irohad/validation/impl/stateful_validator_impl.cpp @@ -99,10 +99,11 @@ namespace iroha { StatefulValidatorImpl::StatefulValidatorImpl( std::unique_ptr factory, std::shared_ptr - batch_parser) + batch_parser, + logger::Logger log) : factory_(std::move(factory)), batch_parser_(std::move(batch_parser)), - log_(logger::log("SFV")) {} + log_(std::move(log)) {} std::unique_ptr StatefulValidatorImpl::validate( diff --git a/irohad/validation/impl/stateful_validator_impl.hpp b/irohad/validation/impl/stateful_validator_impl.hpp index b69b400366..54f5e332e9 100644 --- a/irohad/validation/impl/stateful_validator_impl.hpp +++ b/irohad/validation/impl/stateful_validator_impl.hpp @@ -20,11 +20,12 @@ namespace iroha { */ class StatefulValidatorImpl : public StatefulValidator { public: - explicit StatefulValidatorImpl( + StatefulValidatorImpl( std::unique_ptr factory, std::shared_ptr - batch_parser); + batch_parser, + logger::Logger log = logger::log("SFV")); std::unique_ptr validate( const shared_model::interface::Proposal &proposal, diff --git a/libs/crypto/keys_manager_impl.cpp b/libs/crypto/keys_manager_impl.cpp index 3fc46b7576..3b9081c981 100644 --- a/libs/crypto/keys_manager_impl.cpp +++ b/libs/crypto/keys_manager_impl.cpp @@ -43,18 +43,20 @@ namespace iroha { KeysManagerImpl::KeysManagerImpl( const std::string &account_id, - const boost::filesystem::path &path_to_keypair) + const boost::filesystem::path &path_to_keypair, + logger::Logger log) : path_to_keypair_(path_to_keypair), account_id_(account_id), - log_(logger::log("KeysManagerImpl")) {} + log_(std::move(log)) {} /** * Here we use an empty string as a default value of path to file, * since there are usages of KeysManagerImpl with path passed as a part of * account_id. */ - KeysManagerImpl::KeysManagerImpl(const std::string account_id) - : KeysManagerImpl(account_id, "") {} + KeysManagerImpl::KeysManagerImpl(const std::string account_id, + logger::Logger log) + : KeysManagerImpl(account_id, "", std::move(log)) {} bool KeysManagerImpl::validate(const Keypair &keypair) const { try { diff --git a/libs/crypto/keys_manager_impl.hpp b/libs/crypto/keys_manager_impl.hpp index c8c8cc8bce..d376485653 100644 --- a/libs/crypto/keys_manager_impl.hpp +++ b/libs/crypto/keys_manager_impl.hpp @@ -22,15 +22,19 @@ namespace iroha { * @param account_id - fully qualified account id, e.g. admin@test * @param path_to_keypair - path to directory that contains priv and pub key * of an account + * @param log to print progress */ - explicit KeysManagerImpl(const std::string &account_id, - const boost::filesystem::path &path_to_keypair); + KeysManagerImpl(const std::string &account_id, + const boost::filesystem::path &path_to_keypair, + logger::Logger log = logger::log("KeysManagerImpl")); /** * Initialize key manager for a specific account * @param account_id - fully qualified account id, e.g. admin@test + * @param log to print progress */ - explicit KeysManagerImpl(const std::string account_id); + KeysManagerImpl(const std::string account_id, + logger::Logger log = logger::log("KeysManagerImpl")); bool createKeys() override; diff --git a/test/module/irohad/ametsuchi/block_query_test.cpp b/test/module/irohad/ametsuchi/block_query_test.cpp index b9feb2c08c..8e64b7ebe6 100644 --- a/test/module/irohad/ametsuchi/block_query_test.cpp +++ b/test/module/irohad/ametsuchi/block_query_test.cpp @@ -36,8 +36,8 @@ class BlockQueryTest : public AmetsuchiTest { auto converter = std::make_shared(); blocks = std::make_shared(*sql, *file, converter); - empty_blocks = - std::make_shared(*sql, *mock_file, converter); + empty_blocks = std::make_shared( + *sql, *mock_file, converter, logger::log("PostgresBlockQueryEmpty")); *sql << init_; diff --git a/test/module/irohad/main/server_runner_test.cpp b/test/module/irohad/main/server_runner_test.cpp index fbea15325f..bed577243d 100644 --- a/test/module/irohad/main/server_runner_test.cpp +++ b/test/module/irohad/main/server_runner_test.cpp @@ -20,14 +20,16 @@ auto port_visitor = iroha::make_visitor( * @then Result with error is returned */ TEST(ServerRunnerTest, SamePortNoReuse) { - ServerRunner first_runner((address % 0).str()); + ServerRunner first_runner( + (address % 0).str(), true, logger::log("ServerRunner1")); auto first_query_service = std::make_shared(); auto result = first_runner.append(first_query_service).run(); auto port = boost::apply_visitor(port_visitor, result); ASSERT_NE(0, port); - ServerRunner second_runner((address % port).str(), false); + ServerRunner second_runner( + (address % port).str(), false, logger::log("ServerRunner2")); auto second_query_service = std::make_shared(); result = second_runner.append(second_query_service).run(); @@ -41,14 +43,16 @@ TEST(ServerRunnerTest, SamePortNoReuse) { * @then Result with port number is returned */ TEST(ServerRunnerTest, SamePortWithReuse) { - ServerRunner first_runner((address % 0).str()); + ServerRunner first_runner( + (address % 0).str(), true, logger::log("ServerRunner1")); auto first_query_service = std::make_shared(); auto result = first_runner.append(first_query_service).run(); auto port = boost::apply_visitor(port_visitor, result); ASSERT_NE(0, port); - ServerRunner second_runner((address % port).str(), true); + ServerRunner second_runner( + (address % port).str(), true, logger::log("ServerRunner2")); auto second_query_service = std::make_shared(); result = second_runner.append(second_query_service).run(); diff --git a/test/module/irohad/torii/processor/transaction_processor_test.cpp b/test/module/irohad/torii/processor/transaction_processor_test.cpp index 20844e52a5..9e6a982e90 100644 --- a/test/module/irohad/torii/processor/transaction_processor_test.cpp +++ b/test/module/irohad/torii/processor/transaction_processor_test.cpp @@ -394,9 +394,10 @@ TEST_F(TransactionProcessorTest, TransactionProcessorInvalidTxsTest) { std::make_unique( TestProposalBuilder().transactions(block_txs).build()); for (size_t i = 0; i < invalid_txs.size(); ++i) { - validation_result->rejected_transactions.emplace_back(validation::TransactionError{ - invalid_txs[i].hash(), - iroha::validation::CommandError{"SomeCommandName", 1, "", true, i}}); + validation_result->rejected_transactions.emplace_back( + validation::TransactionError{invalid_txs[i].hash(), + iroha::validation::CommandError{ + "SomeCommandName", 1, "", true, i}}); } verified_prop_notifier.get_subscriber().on_next( simulator::VerifiedProposalCreatorEvent{validation_result, round}); From 158f3f60f01cc1b0b680a5f024214d68afa68cd9 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Tue, 25 Dec 2018 19:00:16 +0300 Subject: [PATCH 34/61] Remove redundant methods from block query, add try catch to sql (#1958) * Remove redundant methods and tests Signed-off-by: kamilsa --- irohad/ametsuchi/block_query.hpp | 33 --- .../ametsuchi/impl/mutable_storage_impl.cpp | 30 ++- .../ametsuchi/impl/postgres_block_query.cpp | 173 ------------- .../ametsuchi/impl/postgres_block_query.hpp | 39 --- ...gres_ordering_service_persistent_state.cpp | 13 +- irohad/ametsuchi/impl/storage_impl.cpp | 42 +++- irohad/ametsuchi/impl/temporary_wsv_impl.cpp | 23 +- irohad/ametsuchi/impl/temporary_wsv_impl.hpp | 1 + .../synchronizer/impl/synchronizer_impl.cpp | 7 +- test/module/irohad/ametsuchi/CMakeLists.txt | 7 - .../irohad/ametsuchi/ametsuchi_mocks.hpp | 16 -- .../irohad/ametsuchi/ametsuchi_test.cpp | 231 ------------------ .../irohad/ametsuchi/block_query_test.cpp | 108 -------- .../ametsuchi/block_query_transfer_test.cpp | 194 --------------- .../irohad/synchronizer/synchronizer_test.cpp | 12 +- .../irohad/torii/torii_service_test.cpp | 4 - 16 files changed, 90 insertions(+), 843 deletions(-) delete mode 100644 test/module/irohad/ametsuchi/block_query_transfer_test.cpp diff --git a/irohad/ametsuchi/block_query.hpp b/irohad/ametsuchi/block_query.hpp index 9609a15fcd..6a257edf76 100644 --- a/irohad/ametsuchi/block_query.hpp +++ b/irohad/ametsuchi/block_query.hpp @@ -27,31 +27,6 @@ namespace iroha { public: virtual ~BlockQuery() = default; - /** - * Get all transactions of an account. - * @param account_id - account_id (accountName@domainName) - * @return observable of Model Transaction - */ - virtual std::vector getAccountTransactions( - const shared_model::interface::types::AccountIdType &account_id) = 0; - - /** - * Get asset transactions of an account. - * @param account_id - account_id (accountName@domainName) - * @param asset_id - asset_id (assetName#domainName) - * @return observable of Model Transaction - */ - virtual std::vector getAccountAssetTransactions( - const shared_model::interface::types::AccountIdType &account_id, - const shared_model::interface::types::AssetIdType &asset_id) = 0; - - /** - * Get transactions from transactions' hashes - * @param tx_hashes - transactions' hashes to retrieve - * @return observable of Model Transaction - */ - virtual std::vector> getTransactions( - const std::vector &tx_hashes) = 0; /** * Get given number of blocks starting with given height. @@ -84,14 +59,6 @@ namespace iroha { */ virtual uint32_t getTopBlockHeight() = 0; - /** - * Synchronously gets transaction by its hash - * @param hash - hash to search - * @return transaction or boost::none - */ - virtual boost::optional getTxByHashSync( - const shared_model::crypto::Hash &hash) = 0; - /** * Synchronously checks whether transaction with given hash is present in * any block diff --git a/irohad/ametsuchi/impl/mutable_storage_impl.cpp b/irohad/ametsuchi/impl/mutable_storage_impl.cpp index 0d8a6a1bb7..921c356400 100644 --- a/irohad/ametsuchi/impl/mutable_storage_impl.cpp +++ b/irohad/ametsuchi/impl/mutable_storage_impl.cpp @@ -76,17 +76,21 @@ namespace iroha { template bool MutableStorageImpl::withSavepoint(Function &&function) { - *sql_ << "SAVEPOINT savepoint_"; - - auto function_executed = std::forward(function)(); - - if (function_executed) { - *sql_ << "RELEASE SAVEPOINT savepoint_"; - } else { - *sql_ << "ROLLBACK TO SAVEPOINT savepoint_"; + try { + *sql_ << "SAVEPOINT savepoint_"; + + auto function_executed = std::forward(function)(); + + if (function_executed) { + *sql_ << "RELEASE SAVEPOINT savepoint_"; + } else { + *sql_ << "ROLLBACK TO SAVEPOINT savepoint_"; + } + return function_executed; + } catch (std::exception &e) { + log_->warn("Apply has failed. Reason: {}", e.what()); + return false; } - - return function_executed; } bool MutableStorageImpl::apply( @@ -111,7 +115,11 @@ namespace iroha { MutableStorageImpl::~MutableStorageImpl() { if (not committed) { - *sql_ << "ROLLBACK"; + try { + *sql_ << "ROLLBACK"; + } catch (std::exception &e) { + log_->warn("Apply has been failed. Reason: {}", e.what()); + } } } } // namespace ametsuchi diff --git a/irohad/ametsuchi/impl/postgres_block_query.cpp b/irohad/ametsuchi/impl/postgres_block_query.cpp index 807a304259..e061355968 100644 --- a/irohad/ametsuchi/impl/postgres_block_query.cpp +++ b/irohad/ametsuchi/impl/postgres_block_query.cpp @@ -71,179 +71,6 @@ namespace iroha { return getBlocks(last_id - count + 1, count); } - std::vector - PostgresBlockQuery::getBlockIds( - const shared_model::interface::types::AccountIdType &account_id) { - std::vector result; - soci::indicator ind; - std::string row; - soci::statement st = - (sql_.prepare << "SELECT DISTINCT height FROM height_by_account_set " - "WHERE account_id = :id", - soci::into(row, ind), - soci::use(account_id)); - st.execute(); - - processSoci(st, ind, row, [&result](std::string &r) { - result.push_back(std::stoull(r)); - }); - return result; - } - - boost::optional - PostgresBlockQuery::getBlockId(const shared_model::crypto::Hash &hash) { - boost::optional blockId = boost::none; - boost::optional block_str; - auto hash_str = hash.hex(); - - sql_ << "SELECT height FROM position_by_hash WHERE hash = :hash", - soci::into(block_str), soci::use(hash_str); - if (block_str) { - blockId = std::stoull(block_str.get()); - } else { - log_->info("No block with transaction {}", hash); - } - return blockId; - } - - std::function &result)> - PostgresBlockQuery::callback(std::vector &blocks, - uint64_t block_id) { - return [this, &blocks, block_id](std::vector &result) { - auto block = getBlock(block_id); - block.match( - [&result, &blocks]( - expected::Value> - &v) { - boost::for_each( - result | boost::adaptors::transformed([](const auto &x) { - std::istringstream iss(x); - size_t size; - iss >> size; - return size; - }), - [&](const auto &x) { - blocks.emplace_back(clone(v.value->transactions()[x])); - }); - }, - [this](const expected::Error &e) { - log_->error(e.error); - }); - }; - } - - std::vector - PostgresBlockQuery::getAccountTransactions( - const shared_model::interface::types::AccountIdType &account_id) { - std::vector result; - auto block_ids = this->getBlockIds(account_id); - if (block_ids.empty()) { - return result; - } - for (const auto &block_id : block_ids) { - std::vector index; - soci::indicator ind; - std::string row; - soci::statement st = - (sql_.prepare - << "SELECT DISTINCT index FROM index_by_creator_height " - "WHERE creator_id = :id AND height = :height", - soci::into(row, ind), - soci::use(account_id), - soci::use(block_id)); - st.execute(); - - processSoci( - st, ind, row, [&index](std::string &r) { index.push_back(r); }); - this->callback(result, block_id)(index); - } - return result; - } - - std::vector - PostgresBlockQuery::getAccountAssetTransactions( - const shared_model::interface::types::AccountIdType &account_id, - const shared_model::interface::types::AssetIdType &asset_id) { - std::vector result; - auto block_ids = this->getBlockIds(account_id); - if (block_ids.empty()) { - return result; - } - - for (const auto &block_id : block_ids) { - std::vector index; - soci::indicator ind; - std::string row; - soci::statement st = - (sql_.prepare - << "SELECT DISTINCT index FROM position_by_account_asset " - "WHERE account_id = :id AND height = :height " - "AND asset_id = :asset_id", - soci::into(row, ind), - soci::use(account_id), - soci::use(block_id), - soci::use(asset_id)); - st.execute(); - - processSoci( - st, ind, row, [&index](std::string &r) { index.push_back(r); }); - this->callback(result, block_id)(index); - } - return result; - } - - std::vector> - PostgresBlockQuery::getTransactions( - const std::vector &tx_hashes) { - std::vector> result; - std::for_each(tx_hashes.begin(), - tx_hashes.end(), - [this, &result](const auto &tx_hash) { - result.push_back(this->getTxByHashSync(tx_hash)); - }); - return result; - } - - boost::optional - PostgresBlockQuery::getTxByHashSync( - const shared_model::crypto::Hash &hash) { - return getBlockId(hash) | - [this](const auto &block_id) { - auto result = this->getBlock(block_id); - return result.match( - [](expected::Value< - std::unique_ptr> &v) - -> boost::optional< - std::unique_ptr> { - return std::move(v.value); - }, - [this](const expected::Error &e) - -> boost::optional< - std::unique_ptr> { - log_->error(e.error); - return boost::none; - }); - } - | [&hash, this](const auto &block) { - auto it = std::find_if( - block->transactions().begin(), - block->transactions().end(), - [&hash](const auto &tx) { return tx.hash() == hash; }); - if (it != block->transactions().end()) { - return boost::make_optional( - clone(*it)); - } else { - log_->error("Failed to find transaction {} in block {}", - hash.hex(), - block->height()); - // return type specification for lambda breaks formatting. - // That is why optional is constructed explicitly - return boost::optional( - boost::none); - } - }; - } - boost::optional PostgresBlockQuery::checkTxPresence( const shared_model::crypto::Hash &hash) { int res = -1; diff --git a/irohad/ametsuchi/impl/postgres_block_query.hpp b/irohad/ametsuchi/impl/postgres_block_query.hpp index 4dfef6c51f..aae6ed8360 100644 --- a/irohad/ametsuchi/impl/postgres_block_query.hpp +++ b/irohad/ametsuchi/impl/postgres_block_query.hpp @@ -38,20 +38,6 @@ namespace iroha { converter, logger::Logger log = logger::log("PostgresBlockQuery")); - std::vector getAccountTransactions( - const shared_model::interface::types::AccountIdType &account_id) - override; - - std::vector getAccountAssetTransactions( - const shared_model::interface::types::AccountIdType &account_id, - const shared_model::interface::types::AssetIdType &asset_id) override; - - std::vector> getTransactions( - const std::vector &tx_hashes) override; - - boost::optional getTxByHashSync( - const shared_model::crypto::Hash &hash) override; - std::vector getBlocks( shared_model::interface::types::HeightType height, uint32_t count) override; @@ -69,31 +55,6 @@ namespace iroha { expected::Result getTopBlock() override; private: - /** - * Returns all blocks' ids containing given account id - * @param account_id - * @return vector of block ids - */ - std::vector getBlockIds( - const shared_model::interface::types::AccountIdType &account_id); - /** - * Returns block id which contains transaction with a given hash - * @param hash - hash of transaction - * @return block id or boost::none - */ - boost::optional getBlockId( - const shared_model::crypto::Hash &hash); - - /** - * creates callback to lrange query to Postgres to supply result to - * subscriber s - * @param s - * @param block_id - * @return - */ - std::function &result)> callback( - std::vector &s, uint64_t block_id); - /** * Retrieve block with given id block storage * @param id - height of a block to retrieve diff --git a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp index 636cb64a4f..f045488d83 100644 --- a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp +++ b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp @@ -16,8 +16,7 @@ namespace iroha { try { *sql_ << query; } catch (std::exception &e) { - log_->error("Failed to execute query: " + query - + ". Reason: " + e.what()); + log_->error("Failed to execute query: {}. Reason: {}", query, e.what()); return false; } return true; @@ -75,8 +74,14 @@ namespace iroha { boost::optional PostgresOrderingServicePersistentState::loadProposalHeight() const { boost::optional height; - *sql_ << "SELECT * FROM ordering_service_state LIMIT 1", - soci::into(height); + std::string query = "SELECT * FROM ordering_service_state LIMIT 1"; + try { + *sql_ << query, soci::into(height); + } catch (std::exception &e) { + log_->error("Failed to execute query: " + query + + ". Reason: " + e.what()); + return boost::none; + } if (not height) { log_->error( diff --git a/irohad/ametsuchi/impl/storage_impl.cpp b/irohad/ametsuchi/impl/storage_impl.cpp index 3b0e953893..801be5b554 100644 --- a/irohad/ametsuchi/impl/storage_impl.cpp +++ b/irohad/ametsuchi/impl/storage_impl.cpp @@ -36,8 +36,12 @@ namespace { */ bool preparedTransactionsAvailable(soci::session &sql) { int prepared_txs_count = 0; - sql << "SHOW max_prepared_transactions;", soci::into(prepared_txs_count); - return prepared_txs_count != 0; + try { + sql << "SHOW max_prepared_transactions;", soci::into(prepared_txs_count); + return prepared_txs_count != 0; + } catch (std::exception &e) { + return false; + } } } // namespace @@ -83,8 +87,12 @@ namespace iroha { if (prepared_blocks_enabled_) { rollbackPrepared(sql); } - sql << init_; - prepareStatements(*connection_, pool_size_); + try { + sql << init_; + prepareStatements(*connection_, pool_size_); + } catch (std::exception &e) { + log_->error("Storage was not initialized. Reason: {}", e.what()); + } } expected::Result, std::string> @@ -229,10 +237,13 @@ namespace iroha { void StorageImpl::reset() { log_->info("drop wsv records from db tables"); soci::session sql(*connection_); - sql << reset_; - - log_->info("drop blocks from disk"); - block_store_->dropAll(); + try { + sql << reset_; + log_->info("drop blocks from disk"); + block_store_->dropAll(); + } catch (std::exception &e) { + log_->warn("Drop wsv was failed. Reason: {}", e.what()); + } } void StorageImpl::dropStorage() { @@ -250,7 +261,11 @@ namespace iroha { soci::session sql(soci::postgresql, postgres_options_.optionsStringWithoutDbName()); // perform dropping - sql << "DROP DATABASE " + db; + try { + sql << "DROP DATABASE " + db; + } catch (std::exception &e) { + log_->warn("Drop database was failed. Reason: {}", e.what()); + } } else { soci::session(*connection_) << drop_; } @@ -394,8 +409,13 @@ namespace iroha { for (const auto &block : storage->block_store_) { storeBlock(*block.second); } - *(storage->sql_) << "COMMIT"; - storage->committed = true; + try { + *(storage->sql_) << "COMMIT"; + storage->committed = true; + } catch (std::exception &e) { + storage->committed = false; + log_->warn("Mutable storage is not committed. Reason: {}", e.what()); + } } bool StorageImpl::commitPrepared( diff --git a/irohad/ametsuchi/impl/temporary_wsv_impl.cpp b/irohad/ametsuchi/impl/temporary_wsv_impl.cpp index 9745e47402..1974f53c08 100644 --- a/irohad/ametsuchi/impl/temporary_wsv_impl.cpp +++ b/irohad/ametsuchi/impl/temporary_wsv_impl.cpp @@ -130,7 +130,11 @@ namespace iroha { } TemporaryWsvImpl::~TemporaryWsvImpl() { - *sql_ << "ROLLBACK"; + try { + *sql_ << "ROLLBACK"; + } catch (std::exception &e) { + log_->error("Rollback did not happen: {}", e.what()); + } } TemporaryWsvImpl::SavepointWrapperImpl::SavepointWrapperImpl( @@ -138,19 +142,24 @@ namespace iroha { std::string savepoint_name) : sql_{*wsv.sql_}, savepoint_name_{std::move(savepoint_name)}, - is_released_{false} { + is_released_{false}, + log_(logger::log("Temporary wsv's savepoint wrapper")) { sql_ << "SAVEPOINT " + savepoint_name_ + ";"; - }; + } void TemporaryWsvImpl::SavepointWrapperImpl::release() { is_released_ = true; } TemporaryWsvImpl::SavepointWrapperImpl::~SavepointWrapperImpl() { - if (not is_released_) { - sql_ << "ROLLBACK TO SAVEPOINT " + savepoint_name_ + ";"; - } else { - sql_ << "RELEASE SAVEPOINT " + savepoint_name_ + ";"; + try { + if (not is_released_) { + sql_ << "ROLLBACK TO SAVEPOINT " + savepoint_name_ + ";"; + } else { + sql_ << "RELEASE SAVEPOINT " + savepoint_name_ + ";"; + } + } catch (std::exception &e) { + log_->error("SQL error. Reason: {}", e.what()); } } diff --git a/irohad/ametsuchi/impl/temporary_wsv_impl.hpp b/irohad/ametsuchi/impl/temporary_wsv_impl.hpp index 709cbfa9df..48df66cf94 100644 --- a/irohad/ametsuchi/impl/temporary_wsv_impl.hpp +++ b/irohad/ametsuchi/impl/temporary_wsv_impl.hpp @@ -38,6 +38,7 @@ namespace iroha { soci::session &sql_; std::string savepoint_name_; bool is_released_; + logger::Logger log_; }; TemporaryWsvImpl( diff --git a/irohad/synchronizer/impl/synchronizer_impl.cpp b/irohad/synchronizer/impl/synchronizer_impl.cpp index 17896e2650..28f491fd06 100644 --- a/irohad/synchronizer/impl/synchronizer_impl.cpp +++ b/irohad/synchronizer/impl/synchronizer_impl.cpp @@ -123,8 +123,11 @@ namespace iroha { } std::unique_ptr storage = std::move(opt_storage.value()); - storage->apply(*msg.block); - mutable_factory_->commit(std::move(storage)); + if (storage->apply(*msg.block)) { + mutable_factory_->commit(std::move(storage)); + } else { + log_->warn("Block was not committed due to fail in mutable storage"); + } } notifier_.get_subscriber().on_next( SynchronizationEvent{rxcpp::observable<>::just(msg.block), diff --git a/test/module/irohad/ametsuchi/CMakeLists.txt b/test/module/irohad/ametsuchi/CMakeLists.txt index 90e24b7a12..d5ccaaea39 100644 --- a/test/module/irohad/ametsuchi/CMakeLists.txt +++ b/test/module/irohad/ametsuchi/CMakeLists.txt @@ -28,13 +28,6 @@ target_link_libraries(block_query_test shared_model_stateless_validation ) -addtest(block_query_transfer_test block_query_transfer_test.cpp) -target_link_libraries(block_query_transfer_test - ametsuchi - ametsuchi_fixture - shared_model_stateless_validation - ) - addtest(kv_storage_test kv_storage_test.cpp) target_link_libraries(kv_storage_test ametsuchi diff --git a/test/module/irohad/ametsuchi/ametsuchi_mocks.hpp b/test/module/irohad/ametsuchi/ametsuchi_mocks.hpp index 072d0e2ff9..5602394386 100644 --- a/test/module/irohad/ametsuchi/ametsuchi_mocks.hpp +++ b/test/module/irohad/ametsuchi/ametsuchi_mocks.hpp @@ -147,22 +147,6 @@ namespace iroha { class MockBlockQuery : public BlockQuery { public: - MOCK_METHOD1( - getAccountTransactions, - std::vector( - const shared_model::interface::types::AccountIdType &account_id)); - MOCK_METHOD1(getTxByHashSync, - boost::optional( - const shared_model::crypto::Hash &hash)); - MOCK_METHOD2( - getAccountAssetTransactions, - std::vector( - const shared_model::interface::types::AccountIdType &account_id, - const shared_model::interface::types::AssetIdType &asset_id)); - MOCK_METHOD1( - getTransactions, - std::vector>( - const std::vector &tx_hashes)); MOCK_METHOD2(getBlocks, std::vector( shared_model::interface::types::HeightType, uint32_t)); diff --git a/test/module/irohad/ametsuchi/ametsuchi_test.cpp b/test/module/irohad/ametsuchi/ametsuchi_test.cpp index 91fa376c55..6d97c1974a 100644 --- a/test/module/irohad/ametsuchi/ametsuchi_test.cpp +++ b/test/module/irohad/ametsuchi/ametsuchi_test.cpp @@ -36,48 +36,6 @@ namespace shared_model { } // namespace interface } // namespace shared_model -/** - * Validate getAccountTransaction with given parameters - * @tparam B block query type - * @param blocks block query object - * @param account id to query - * @param call_count number of observable calls - * @param command_count number of commands in transaction - */ -template -void validateAccountTransactions(B &&blocks, - const std::string &account, - int call_count, - int command_count) { - auto txs = blocks->getAccountTransactions(account); - ASSERT_EQ(txs.size(), call_count); - std::for_each(txs.begin(), txs.end(), [&](const auto &tx) { - EXPECT_EQ(tx->commands().size(), command_count); - }); -} - -/** - * Validate getAccountAssetTransactions with given parameters - * @tparam B block query type - * @param blocks block query object - * @param account id to query - * @param asset id to query - * @param call_count number of observable calls - * @param command_count number of commands in transaction - */ -template -void validateAccountAssetTransactions(B &&blocks, - const std::string &account, - const std::string &asset, - int call_count, - int command_count) { - auto txs = blocks->getAccountAssetTransactions(account, asset); - ASSERT_EQ(txs.size(), call_count); - std::for_each(txs.begin(), txs.end(), [&](const auto &tx) { - EXPECT_EQ(tx->commands().size(), command_count); - }); -} - /** * Validate getAccountAsset with given parameters * @tparam W WSV query type @@ -207,15 +165,6 @@ TEST_F(AmetsuchiTest, SampleTest) { for (size_t i = 0; i < stored_blocks.size(); i++) { EXPECT_EQ(*(hashes.begin() + i), stored_blocks[i]->hash()); } - - validateAccountTransactions(blocks, "admin1", 1, 3); - validateAccountTransactions(blocks, user1id, 1, 4); - validateAccountTransactions(blocks, "non_existing_user", 0, 0); - - validateAccountAssetTransactions(blocks, user1id, assetid, 1, 4); - validateAccountAssetTransactions(blocks, user2id, assetid, 1, 4); - validateAccountAssetTransactions( - blocks, "non_existing_user", "non_existing_asset", 0, 0); } TEST_F(AmetsuchiTest, PeerTest) { @@ -238,130 +187,6 @@ TEST_F(AmetsuchiTest, PeerTest) { ASSERT_EQ(peers->at(0)->pubkey(), fake_pubkey); } -TEST_F(AmetsuchiTest, queryGetAccountAssetTransactionsTest) { - ASSERT_TRUE(storage); - auto wsv = storage->getWsvQuery(); - auto blocks = storage->getBlockQuery(); - - const auto admin = "admin", domain = "domain", user1name = "userone", - user2name = "usertwo", user3name = "userthree", - user1id = "userone@domain", user2id = "usertwo@domain", - user3id = "userthree@domain", asset1name = "assetone", - asset2name = "assettwo", asset1id = "assetone#domain", - asset2id = "assettwo#domain"; - - // 1st tx - std::vector txs; - txs.push_back( - TestTransactionBuilder() - .creatorAccountId(admin) - .createRole("user", - {Role::kAddPeer, Role::kCreateAsset, Role::kGetMyAccount}) - .createDomain(domain, "user") - .createAccount(user1name, domain, fake_pubkey) - .createAccount(user2name, domain, fake_pubkey) - .createAccount(user3name, domain, fake_pubkey) - .createAsset(asset1name, domain, 1) - .createAsset(asset2name, domain, 1) - .build()); - txs.push_back(TestTransactionBuilder() - .creatorAccountId(user1id) - .addAssetQuantity(asset1id, "300.0") - .build()); - txs.push_back(TestTransactionBuilder() - .creatorAccountId(user2id) - .addAssetQuantity(asset2id, "250.0") - .build()); - - auto block1 = TestBlockBuilder() - .height(1) - .transactions(txs) - .prevHash(fake_hash) - .build(); - - apply(storage, block1); - - // Check querying accounts - for (const auto &id : {user1id, user2id, user3id}) { - validateAccount(wsv, id, domain); - } - - // Check querying assets for users - validateAccountAsset( - wsv, user1id, asset1id, shared_model::interface::Amount("300.0")); - validateAccountAsset( - wsv, user2id, asset2id, shared_model::interface::Amount("250.0")); - - // 2th tx (user1 -> user2 # asset1) - txs.clear(); - txs.push_back( - TestTransactionBuilder() - .creatorAccountId(user1id) - .transferAsset(user1id, user2id, asset1id, "Transfer asset", "120.0") - .build()); - auto block2 = TestBlockBuilder() - .transactions(txs) - .height(2) - .prevHash(block1.hash()) - .build(); - - apply(storage, block2); - - // Check account asset after transfer assets - validateAccountAsset( - wsv, user1id, asset1id, shared_model::interface::Amount("180.0")); - validateAccountAsset( - wsv, user2id, asset1id, shared_model::interface::Amount("120.0")); - - // 3rd tx - // (user2 -> user3 # asset2) - // (user2 -> user1 # asset2) - txs.clear(); - txs.push_back( - TestTransactionBuilder() - .creatorAccountId(user2id) - .transferAsset(user2id, user3id, asset2id, "Transfer asset", "150.0") - .transferAsset(user2id, user1id, asset2id, "Transfer asset", "10.0") - .build()); - - auto block3 = TestBlockBuilder() - .transactions(txs) - .height(3) - .prevHash(block2.hash()) - .build(); - - apply(storage, block3); - - validateAccountAsset( - wsv, user2id, asset2id, shared_model::interface::Amount("90.0")); - validateAccountAsset( - wsv, user3id, asset2id, shared_model::interface::Amount("150.0")); - validateAccountAsset( - wsv, user1id, asset2id, shared_model::interface::Amount("10.0")); - - // Block store test - auto hashes = {block1.hash(), block2.hash(), block3.hash()}; - - auto stored_blocks = blocks->getBlocks(1, 3); - ASSERT_EQ(3, stored_blocks.size()); - for (size_t i = 0; i < stored_blocks.size(); i++) { - EXPECT_EQ(*(hashes.begin() + i), stored_blocks[i]->hash()); - } - - validateAccountTransactions(blocks, admin, 1, 7); - validateAccountTransactions(blocks, user3id, 0, 0); - - // (user1 -> user2 # asset1) - // (user2 -> user3 # asset2) - // (user2 -> user1 # asset2) - validateAccountAssetTransactions(blocks, user1id, asset1id, 1, 1); - validateAccountAssetTransactions(blocks, user2id, asset1id, 1, 1); - validateAccountAssetTransactions(blocks, user3id, asset1id, 0, 0); - validateAccountAssetTransactions(blocks, user1id, asset2id, 1, 2); - validateAccountAssetTransactions(blocks, user2id, asset2id, 1, 2); - validateAccountAssetTransactions(blocks, user3id, asset2id, 1, 2); -} - TEST_F(AmetsuchiTest, AddSignatoryTest) { ASSERT_TRUE(storage); auto wsv = storage->getWsvQuery(); @@ -620,62 +445,6 @@ TEST_F(AmetsuchiTest, TestingStorageWhenCommitBlock) { ASSERT_TRUE(wrapper.validate()); } -/** - * @given initialized storage - * @when insert block with 2 transactions in - * @then both of them are found with getTxByHashSync call by hash. Transaction - * with some other hash is not found. - */ -TEST_F(AmetsuchiTest, FindTxByHashTest) { - ASSERT_TRUE(storage); - auto blocks = storage->getBlockQuery(); - - shared_model::crypto::PublicKey pubkey1(std::string(32, '1')); - shared_model::crypto::PublicKey pubkey2(std::string(32, '2')); - - std::vector txs; - txs.push_back( - TestTransactionBuilder() - .creatorAccountId("admin1") - .createRole("user", - {Role::kAddPeer, Role::kCreateAsset, Role::kGetMyAccount}) - .createDomain("domain", "user") - .createAccount("userone", "domain", pubkey1) - .build()); - - txs.push_back( - TestTransactionBuilder() - .creatorAccountId("admin1") - .createRole("usertwo", - {Role::kAddPeer, Role::kCreateAsset, Role::kGetMyAccount}) - .createDomain("domaintwo", "user") - .build()); - - auto block = TestBlockBuilder() - .transactions(txs) - .height(1) - .prevHash(fake_hash) - .build(); - - apply(storage, block); - - // TODO: 31.10.2017 luckychess move tx3hash case into a separate test after - // ametsuchi_test redesign - auto tx1hash = txs.at(0).hash(); - auto tx2hash = txs.at(1).hash(); - auto tx3hash = shared_model::crypto::Hash("some garbage"); - - auto tx1 = blocks->getTxByHashSync(tx1hash); - ASSERT_TRUE(tx1); - - auto tx2 = blocks->getTxByHashSync(tx2hash); - ASSERT_TRUE(tx2); - - ASSERT_EQ(**tx1, txs[0]); - ASSERT_EQ(**tx2, txs[1]); - ASSERT_EQ(blocks->getTxByHashSync(tx3hash), boost::none); -} - /** * @given initialized storage for ordering service * @when save proposal height diff --git a/test/module/irohad/ametsuchi/block_query_test.cpp b/test/module/irohad/ametsuchi/block_query_test.cpp index 8e64b7ebe6..89709d29b9 100644 --- a/test/module/irohad/ametsuchi/block_query_test.cpp +++ b/test/module/irohad/ametsuchi/block_query_test.cpp @@ -110,114 +110,6 @@ class BlockQueryTest : public AmetsuchiTest { shared_model::crypto::Hash rejected_hash{"rejected_tx_hash"}; }; -/** - * @given block store with 2 blocks totally containing 3 txs created by - * user1@test - * AND 1 tx created by user2@test - * @when query to get transactions created by user1@test is invoked - * @then query over user1@test returns 3 txs - */ -TEST_F(BlockQueryTest, GetAccountTransactionsFromSeveralBlocks) { - // Check that creator1 has created 3 transactions - auto txs = blocks->getAccountTransactions(creator1); - ASSERT_EQ(txs.size(), 3); - std::for_each(txs.begin(), txs.end(), [&](const auto &tx) { - EXPECT_EQ(tx->creatorAccountId(), creator1); - }); -} - -/** - * @given block store with 2 blocks totally containing 3 txs created by - * user1@test - * AND 1 tx created by user2@test - * @when query to get transactions created by user2@test is invoked - * @then query over user2@test returns 1 tx - */ -TEST_F(BlockQueryTest, GetAccountTransactionsFromSingleBlock) { - // Check that creator1 has created 1 transaction - auto txs = blocks->getAccountTransactions(creator2); - ASSERT_EQ(txs.size(), 1); - std::for_each(txs.begin(), txs.end(), [&](const auto &tx) { - EXPECT_EQ(tx->creatorAccountId(), creator2); - }); -} - -/** - * @given block store - * @when query to get transactions created by user with id not registered in the - * system is invoked - * @then query returns empty result - */ -TEST_F(BlockQueryTest, GetAccountTransactionsNonExistingUser) { - // Check that "nonexisting" user has no transaction - auto txs = blocks->getAccountTransactions("nonexisting user"); - ASSERT_EQ(txs.size(), 0); -} - -/** - * @given block store with 2 blocks totally containing 3 txs created by - * user1@test - * AND 1 tx created by user2@test - * @when query to get transactions with existing transaction hashes - * @then queried transactions - */ -TEST_F(BlockQueryTest, GetTransactionsExistingTxHashes) { - auto txs = blocks->getTransactions({tx_hashes[1], tx_hashes[3]}); - ASSERT_EQ(txs.size(), 2); - ASSERT_TRUE(txs[0]); - ASSERT_TRUE(txs[1]); - ASSERT_EQ(txs[0].get()->hash(), tx_hashes[1]); - ASSERT_EQ(txs[1].get()->hash(), tx_hashes[3]); -} - -/** - * @given block store with 2 blocks totally containing 3 txs created by - * user1@test - * AND 1 tx created by user2@test - * @when query to get transactions with non-existing transaction hashes - * @then nullopt values are retrieved - */ -TEST_F(BlockQueryTest, GetTransactionsIncludesNonExistingTxHashes) { - shared_model::crypto::Hash invalid_tx_hash_1(zero_string), - invalid_tx_hash_2(std::string( - shared_model::crypto::DefaultCryptoAlgorithmType::kHashLength, '9')); - - auto txs = blocks->getTransactions({invalid_tx_hash_1, invalid_tx_hash_2}); - ASSERT_EQ(txs.size(), 2); - ASSERT_FALSE(txs[0]); - ASSERT_FALSE(txs[1]); -} - -/** - * @given block store with 2 blocks totally containing 3 txs created by - * user1@test - * AND 1 tx created by user2@test - * @when query to get transactions with empty vector - * @then no transactions are retrieved - */ -TEST_F(BlockQueryTest, GetTransactionsWithEmpty) { - // transactions' hashes are empty. - auto txs = blocks->getTransactions({}); - ASSERT_EQ(txs.size(), 0); -} - -/** - * @given block store with 2 blocks totally containing 3 txs created by - * user1@test - * AND 1 tx created by user2@test - * @when query to get transactions with non-existing txhash and existing txhash - * @then queried transactions and empty transaction - */ -TEST_F(BlockQueryTest, GetTransactionsWithInvalidTxAndValidTx) { - // TODO 15/11/17 motxx - Use EqualList VerificationStrategy - shared_model::crypto::Hash invalid_tx_hash_1(zero_string); - auto txs = blocks->getTransactions({invalid_tx_hash_1, tx_hashes[0]}); - ASSERT_EQ(txs.size(), 2); - ASSERT_FALSE(txs[0]); - ASSERT_TRUE(txs[1]); - ASSERT_EQ(txs[1].get()->hash(), tx_hashes[0]); -} - /** * @given block store with 2 blocks totally containing 3 txs created by * user1@test AND 1 tx created by user2@test diff --git a/test/module/irohad/ametsuchi/block_query_transfer_test.cpp b/test/module/irohad/ametsuchi/block_query_transfer_test.cpp deleted file mode 100644 index 0fdab534db..0000000000 --- a/test/module/irohad/ametsuchi/block_query_transfer_test.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Copyright Soramitsu Co., Ltd. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include "ametsuchi/impl/postgres_block_index.hpp" -#include "ametsuchi/impl/postgres_block_query.hpp" -#include "backend/protobuf/proto_block_json_converter.hpp" -#include "common/byteutils.hpp" -#include "converters/protobuf/json_proto_converter.hpp" -#include "framework/test_subscriber.hpp" -#include "module/irohad/ametsuchi/ametsuchi_fixture.hpp" -#include "module/shared_model/builders/protobuf/test_block_builder.hpp" -#include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" - -using namespace framework::test_subscriber; - -namespace iroha { - namespace ametsuchi { - class BlockQueryTransferTest : public AmetsuchiTest { - protected: - void SetUp() override { - AmetsuchiTest::SetUp(); - - auto tmp = FlatFile::create(block_store_path); - ASSERT_TRUE(tmp); - file = std::move(*tmp); - - sql = std::make_unique(soci::postgresql, pgopt_); - - index = std::make_shared(*sql); - converter = - std::make_shared(); - blocks = std::make_shared(*sql, *file, converter); - - *sql << init_; - } - - void insert(const shared_model::proto::Block &block) { - converter->serialize(block).match( - [this, &block](const iroha::expected::Value &json) { - file->add(block.height(), iroha::stringToBytes(json.value)); - index->index(block); - }, - [](const auto &error) { FAIL() << error.error; }); - } - - void TearDown() override { - sql->close(); - AmetsuchiTest::TearDown(); - } - - std::unique_ptr sql; - std::vector tx_hashes; - std::shared_ptr blocks; - std::shared_ptr index; - std::unique_ptr file; - std::string creator1 = "user1@test"; - std::string creator2 = "user2@test"; - std::string creator3 = "user3@test"; - std::string asset = "coin#test"; - std::shared_ptr converter; - }; - - auto zero_string = std::string(32, '0'); - auto fake_hash = shared_model::crypto::Hash(zero_string); - - /** - * Make block with one transaction(transfer 0 asset) with specified sender, - * receiver, asset and creator of transaction - * @param creator1 - source account for transfer - * @param creator2 - dest account for transfer - * @param asset - asset for transfer - * @param tx_creator - creator of the transaction - * @return block with one transaction - */ - shared_model::proto::Block makeBlockWithCreator(std::string creator1, - std::string creator2, - std::string asset, - std::string tx_creator) { - std::vector txs; - txs.push_back( - TestTransactionBuilder() - .creatorAccountId(tx_creator) - .transferAsset(creator1, creator2, asset, "Transfer asset", "0.0") - .build()); - return TestBlockBuilder() - .transactions(txs) - .height(1) - .prevHash(fake_hash) - .build(); - } - - /** - * Make block with one transaction(transfer 0 asset) with specified sender, - * receiver and asset - * @param creator1 - source account for transfer - * @param creator2 - dest account for transfer - * @param asset - asset for transfer - * @return block with one transaction - */ - shared_model::proto::Block makeBlock( - std::string creator1, - std::string creator2, - std::string asset, - int height = 1, - shared_model::crypto::Hash hash = fake_hash) { - std::vector txs; - txs.push_back( - TestTransactionBuilder() - .transferAsset(creator1, creator2, asset, "Transfer asset", "0.0") - .build()); - return TestBlockBuilder() - .transactions(txs) - .height(height) - .prevHash(hash) - .build(); - } - - /** - * @given block store and index with block containing 1 transaction - * with transfer from creator 1 to creator 2 sending asset - * @when query to get asset transactions of sender - * @then query returns the transaction - */ - TEST_F(BlockQueryTransferTest, SenderAssetName) { - auto block = makeBlockWithCreator(creator1, creator2, asset, creator1); - tx_hashes.push_back(block.transactions().back().hash()); - insert(block); - - auto txs = blocks->getAccountAssetTransactions(creator1, asset); - ASSERT_EQ(txs.size(), 1); - ASSERT_EQ(txs[0]->hash(), tx_hashes[0]); - } - - /** - * @given block store and index with block containing 1 transaction - * with transfer from creator 1 to creator 2 sending asset - * @when query to get asset transactions of receiver - * @then query returns the transaction - */ - TEST_F(BlockQueryTransferTest, ReceiverAssetName) { - auto block = makeBlockWithCreator(creator1, creator2, asset, creator1); - tx_hashes.push_back(block.transactions().back().hash()); - insert(block); - - auto txs = blocks->getAccountAssetTransactions(creator2, asset); - ASSERT_EQ(txs.size(), 1); - ASSERT_EQ(txs[0]->hash(), tx_hashes[0]); - } - - /** - * @given block store and index with block containing 1 transaction - * from creator 3 with transfer from creator 1 to creator 2 sending asset - * @when query to get asset transactions of transaction creator - * @then query returns the transaction - */ - TEST_F(BlockQueryTransferTest, GrantedTransfer) { - auto block = makeBlockWithCreator(creator1, creator2, asset, creator3); - tx_hashes.push_back(block.transactions().back().hash()); - insert(block); - - auto txs = blocks->getAccountAssetTransactions(creator3, asset); - ASSERT_EQ(txs.size(), 1); - ASSERT_EQ(txs[0]->hash(), tx_hashes[0]); - } - - /** - * @given block store and index with 2 blocks containing 1 transaction - * with transfer from creator 1 to creator 2 sending asset - * @when query to get asset transactions of sender - * @then query returns the transactions - */ - TEST_F(BlockQueryTransferTest, TwoBlocks) { - auto block = makeBlock(creator1, creator2, asset); - - tx_hashes.push_back(block.transactions().back().hash()); - insert(block); - - auto block2 = makeBlock(creator1, creator2, asset, 2, block.hash()); - - tx_hashes.push_back(block.transactions().back().hash()); - insert(block2); - - auto txs = blocks->getAccountAssetTransactions(creator1, asset); - ASSERT_EQ(txs.size(), 2); - for (size_t i = 0; i < txs.size(); i++) { - ASSERT_EQ(txs[i]->hash(), tx_hashes[i]); - } - } - } // namespace ametsuchi -} // namespace iroha diff --git a/test/module/irohad/synchronizer/synchronizer_test.cpp b/test/module/irohad/synchronizer/synchronizer_test.cpp index 976a130ed1..c7df066424 100644 --- a/test/module/irohad/synchronizer/synchronizer_test.cpp +++ b/test/module/irohad/synchronizer/synchronizer_test.cpp @@ -100,9 +100,15 @@ class SynchronizerTest : public ::testing::Test { * @then Successful commit */ TEST_F(SynchronizerTest, ValidWhenSingleCommitSynchronized) { - DefaultValue, std::string>>:: - SetFactory(&createMockMutableStorage); - EXPECT_CALL(*mutable_factory, createMutableStorage()).Times(1); + EXPECT_CALL(*mutable_factory, createMutableStorage()) + .WillOnce(::testing::Invoke( + []() -> expected::Result, + std::string> { + auto mutable_storage = std::make_unique(); + EXPECT_CALL(*mutable_storage, apply(_)).WillOnce(Return(true)); + return expected::Value>{ + std::move(mutable_storage)}; + })); EXPECT_CALL(*mutable_factory, commit_(_)).Times(1); EXPECT_CALL(*chain_validator, validateAndApply(_, _)).Times(0); EXPECT_CALL(*block_loader, retrieveBlocks(_, _)).Times(0); diff --git a/test/module/irohad/torii/torii_service_test.cpp b/test/module/irohad/torii/torii_service_test.cpp index 67dfdfc53a..eb666f4fa7 100644 --- a/test/module/irohad/torii/torii_service_test.cpp +++ b/test/module/irohad/torii/torii_service_test.cpp @@ -98,7 +98,6 @@ class ToriiServiceTest : public testing::Test { pcsMock = std::make_shared( prop_notifier_, commit_notifier_, verified_prop_notifier_); mst = std::make_shared(); - wsv_query = std::make_shared(); block_query = std::make_shared(); storage = std::make_shared(); @@ -117,8 +116,6 @@ class ToriiServiceTest : public testing::Test { status_bus, std::make_shared()); - EXPECT_CALL(*block_query, getTxByHashSync(_)) - .WillRepeatedly(Return(boost::none)); EXPECT_CALL(*storage, getBlockQuery()).WillRepeatedly(Return(block_query)); //----------- Server run ---------------- @@ -167,7 +164,6 @@ class ToriiServiceTest : public testing::Test { std::unique_ptr runner; - std::shared_ptr wsv_query; std::shared_ptr block_query; std::shared_ptr storage; From 5c7e69f1a6a62a45c258d264e846f5ada579df2a Mon Sep 17 00:00:00 2001 From: BulatSaif Date: Wed, 26 Dec 2018 09:28:32 +0300 Subject: [PATCH 35/61] Fix error (92) HTTP/2 (#1989) Signed-off-by: Bulat Saifullin --- .jenkinsci/artifacts.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jenkinsci/artifacts.groovy b/.jenkinsci/artifacts.groovy index ed18fbc65e..d4188ea866 100644 --- a/.jenkinsci/artifacts.groovy +++ b/.jenkinsci/artifacts.groovy @@ -37,7 +37,7 @@ def uploadArtifacts(filePaths, uploadPath, artifactServers=['nexus.iroha.tech']) withCredentials([usernamePassword(credentialsId: 'ci_nexus', passwordVariable: 'NEXUS_PASS', usernameVariable: 'NEXUS_USER')]) { artifactServers.each { - sh(script: "while read line; do curl -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file \$line https://${it}/repository/artifacts/${uploadPath}/ ; done < \$(pwd)/batch.txt") + sh(script: "while read line; do curl --http1.1 -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file \$line https://${it}/repository/artifacts/${uploadPath}/ ; done < \$(pwd)/batch.txt") } } } From 94fceee193899fdf4bdab13afa262413aff8fdbd Mon Sep 17 00:00:00 2001 From: BulatSaif Date: Wed, 26 Dec 2018 09:31:40 +0300 Subject: [PATCH 36/61] Change docker build logic (#1987) * debug Signed-off-by: Bulat Saifullin * test Signed-off-by: Bulat Saifullin * pull, if dev have the image Build with cache if current differ from dev and not differ from previous Build no cache if current differ from dev and differ from previous rest pull Signed-off-by: Bulat Saifullin --- .jenkinsci/docker-pull-or-build.groovy | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.jenkinsci/docker-pull-or-build.groovy b/.jenkinsci/docker-pull-or-build.groovy index 9448feb458..ba4a0ee7b8 100644 --- a/.jenkinsci/docker-pull-or-build.groovy +++ b/.jenkinsci/docker-pull-or-build.groovy @@ -25,7 +25,13 @@ def dockerPullOrUpdate(imageName, currentDockerfileURL, previousDockerfileURL, r // Worst case scenario. We cannot count on the local cache // because Dockerfile may contain apt-get entries that would try to update // from invalid (stale) addresses - iC = docker.build("${DOCKER_REGISTRY_BASENAME}:${commit}-${BUILD_NUMBER}", "${buildOptions} --no-cache -f /tmp/${env.GIT_COMMIT}/f1 /tmp/${env.GIT_COMMIT}") + if(remoteFilesDiffer(currentDockerfileURL, referenceDockerfileURL)){ + // Dockerfile has been changed compared to the develop + iC = docker.build("${DOCKER_REGISTRY_BASENAME}:${commit}-${BUILD_NUMBER}", "${buildOptions} --no-cache -f /tmp/${env.GIT_COMMIT}/f1 /tmp/${env.GIT_COMMIT}") + } else { + // Dockerfile is same as develop, we can just pull it + iC = docker.image("${DOCKER_REGISTRY_BASENAME}:${imageName}") + } } else { // first commit in this branch or Dockerfile modified From be43cdd37f91778faf7def98450258241b6c810d Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Wed, 26 Dec 2018 10:37:51 +0300 Subject: [PATCH 37/61] No in-place logger creation II (#1957) Finished with logger Signed-off-by: Akvinikym --- iroha-cli/grpc_response_handler.hpp | 3 ++- iroha-cli/impl/grpc_response_handler.cpp | 4 ++-- iroha-cli/impl/query_response_handler.cpp | 5 +++-- iroha-cli/impl/transaction_response_handler.cpp | 5 +++-- iroha-cli/query_response_handler.hpp | 8 +++----- iroha-cli/transaction_response_handler.hpp | 4 +++- irohad/ametsuchi/impl/flat_file/flat_file.cpp | 6 +++--- irohad/ametsuchi/impl/flat_file/flat_file.hpp | 4 +++- irohad/ametsuchi/impl/postgres_query_executor.cpp | 10 ++++++---- irohad/ametsuchi/impl/postgres_query_executor.hpp | 6 ++++-- irohad/consensus/yac/impl/yac.cpp | 13 +++++++------ irohad/consensus/yac/impl/yac_gate_impl.cpp | 5 +++-- irohad/consensus/yac/impl/yac_gate_impl.hpp | 3 ++- irohad/consensus/yac/yac.hpp | 6 ++++-- irohad/main/application.cpp | 4 +++- .../multi_sig_transactions/impl/mst_processor.cpp | 2 +- .../impl/mst_processor_impl.cpp | 6 ++---- irohad/multi_sig_transactions/mst_processor.hpp | 2 +- .../multi_sig_transactions/state/impl/mst_state.cpp | 12 ++++++------ irohad/multi_sig_transactions/state/mst_state.hpp | 6 ++++-- .../storage/impl/mst_storage.cpp | 4 +--- .../multi_sig_transactions/storage/mst_storage.hpp | 2 +- irohad/simulator/impl/simulator.cpp | 5 +++-- irohad/simulator/impl/simulator.hpp | 3 ++- irohad/synchronizer/impl/synchronizer_impl.cpp | 5 +++-- irohad/synchronizer/impl/synchronizer_impl.hpp | 3 ++- irohad/torii/impl/command_service_impl.cpp | 5 +++-- irohad/torii/impl/command_service_impl.hpp | 4 +++- irohad/torii/impl/query_service.cpp | 5 +++-- irohad/torii/query_service.hpp | 10 +++++----- irohad/validation/impl/chain_validator_impl.cpp | 6 +++--- irohad/validation/impl/chain_validator_impl.hpp | 6 ++++-- libs/crypto/keys_manager_impl.cpp | 1 + .../validation/chain_validator_storage_test.cpp | 3 ++- test/module/irohad/network/block_loader_test.cpp | 4 ++-- 35 files changed, 103 insertions(+), 77 deletions(-) diff --git a/iroha-cli/grpc_response_handler.hpp b/iroha-cli/grpc_response_handler.hpp index a727f2dccc..d00d16e0a5 100644 --- a/iroha-cli/grpc_response_handler.hpp +++ b/iroha-cli/grpc_response_handler.hpp @@ -16,7 +16,8 @@ namespace spdlog { namespace iroha_cli { class GrpcResponseHandler { public: - GrpcResponseHandler(); + explicit GrpcResponseHandler( + logger::Logger log = logger::log("GrpcResponseHandler")); /** * Handle iroha GRPC TxResponse * @param response diff --git a/iroha-cli/impl/grpc_response_handler.cpp b/iroha-cli/impl/grpc_response_handler.cpp index 31baf60c70..1d69f6d6b0 100644 --- a/iroha-cli/impl/grpc_response_handler.cpp +++ b/iroha-cli/impl/grpc_response_handler.cpp @@ -9,8 +9,8 @@ using namespace grpc; namespace iroha_cli { - GrpcResponseHandler::GrpcResponseHandler() - : log_(logger::log("GrpcResponseHandler")) { + GrpcResponseHandler::GrpcResponseHandler(logger::Logger log) + : log_(std::move(log)) { handler_map_[CANCELLED] = "Operation canceled"; handler_map_[UNKNOWN] = "Unknown error"; handler_map_[INVALID_ARGUMENT] = "INVALID_ARGUMENT"; diff --git a/iroha-cli/impl/query_response_handler.cpp b/iroha-cli/impl/query_response_handler.cpp index 2d814e5289..ba0840ce61 100644 --- a/iroha-cli/impl/query_response_handler.cpp +++ b/iroha-cli/impl/query_response_handler.cpp @@ -15,8 +15,9 @@ using namespace iroha::protocol; namespace iroha_cli { - QueryResponseHandler::QueryResponseHandler() - : log_(logger::log("QueryResponseHandler")) { + QueryResponseHandler::QueryResponseHandler( + std::shared_ptr log) + : log_(std::move(log)) { handler_map_[QueryResponse::ResponseCase::kErrorResponse] = &QueryResponseHandler::handleErrorResponse; handler_map_[QueryResponse::ResponseCase::kAccountResponse] = diff --git a/iroha-cli/impl/transaction_response_handler.cpp b/iroha-cli/impl/transaction_response_handler.cpp index 4dd07c5fa0..4b9bb378f2 100644 --- a/iroha-cli/impl/transaction_response_handler.cpp +++ b/iroha-cli/impl/transaction_response_handler.cpp @@ -20,7 +20,8 @@ namespace iroha_cli { */ } } - TransactionResponseHandler::TransactionResponseHandler() - : log_(logger::log("TransactionResponseHandler")) {} + TransactionResponseHandler::TransactionResponseHandler( + std::shared_ptr log) + : log_(std::move(log)) {} } // namespace iroha_cli diff --git a/iroha-cli/query_response_handler.hpp b/iroha-cli/query_response_handler.hpp index 7e63994596..5b317fa67c 100644 --- a/iroha-cli/query_response_handler.hpp +++ b/iroha-cli/query_response_handler.hpp @@ -11,12 +11,9 @@ #include #include +#include "logger/logger.hpp" #include "qry_responses.pb.h" -namespace spdlog { - class logger; -} - namespace iroha_cli { /* workaround for circle-ci compilation issue; see @@ -33,7 +30,8 @@ namespace iroha_cli { class QueryResponseHandler { public: - QueryResponseHandler(); + explicit QueryResponseHandler(std::shared_ptr log = + logger::log("QueryResponseHandler")); /** * Handle query response diff --git a/iroha-cli/transaction_response_handler.hpp b/iroha-cli/transaction_response_handler.hpp index 05cb0e1edf..5dc413d202 100644 --- a/iroha-cli/transaction_response_handler.hpp +++ b/iroha-cli/transaction_response_handler.hpp @@ -16,7 +16,9 @@ namespace iroha_cli { class TransactionResponseHandler { public: - TransactionResponseHandler(); + explicit TransactionResponseHandler( + std::shared_ptr log = + logger::log("TransactionResponseHandler")); /** * Handle response from Iroha * @param status of transaction diff --git a/irohad/ametsuchi/impl/flat_file/flat_file.cpp b/irohad/ametsuchi/impl/flat_file/flat_file.cpp index ab6fa66fe3..b9833db508 100644 --- a/irohad/ametsuchi/impl/flat_file/flat_file.cpp +++ b/irohad/ametsuchi/impl/flat_file/flat_file.cpp @@ -111,9 +111,9 @@ void FlatFile::dropAll() { FlatFile::FlatFile(Identifier current_id, const std::string &path, - FlatFile::private_tag) - : dump_dir_(path) { - log_ = logger::log("FlatFile"); + FlatFile::private_tag, + logger::Logger log) + : dump_dir_(path), log_{std::move(log)} { current_id_.store(current_id); } diff --git a/irohad/ametsuchi/impl/flat_file/flat_file.hpp b/irohad/ametsuchi/impl/flat_file/flat_file.hpp index 2474ac8125..62f1cf51bf 100644 --- a/irohad/ametsuchi/impl/flat_file/flat_file.hpp +++ b/irohad/ametsuchi/impl/flat_file/flat_file.hpp @@ -89,10 +89,12 @@ namespace iroha { * Create storage in path with respect to last key * @param last_id - maximal key written in storage * @param path - folder of storage + * @param log to print progress */ FlatFile(Identifier last_id, const std::string &path, - FlatFile::private_tag); + FlatFile::private_tag, + logger::Logger log = logger::log("FlatFile")); private: // ----------| private fields |---------- diff --git a/irohad/ametsuchi/impl/postgres_query_executor.cpp b/irohad/ametsuchi/impl/postgres_query_executor.cpp index 6cc03bdec1..5b780ac63e 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.cpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.cpp @@ -241,7 +241,8 @@ namespace iroha { std::shared_ptr response_factory, std::shared_ptr - perm_converter) + perm_converter, + logger::Logger log) : sql_(std::move(sql)), block_store_(block_store), pending_txs_storage_(std::move(pending_txs_storage)), @@ -252,7 +253,7 @@ namespace iroha { response_factory, perm_converter), query_response_factory_{std::move(response_factory)}, - log_(logger::log("PostgresQueryExecutor")) {} + log_(std::move(log)) {} QueryExecutorResult PostgresQueryExecutor::validateAndExecute( const shared_model::interface::Query &query) { @@ -286,14 +287,15 @@ namespace iroha { std::shared_ptr response_factory, std::shared_ptr - perm_converter) + perm_converter, + logger::Logger log) : sql_(sql), block_store_(block_store), pending_txs_storage_(std::move(pending_txs_storage)), converter_(std::move(converter)), query_response_factory_{std::move(response_factory)}, perm_converter_(std::move(perm_converter)), - log_(logger::log("PostgresQueryExecutorVisitor")) {} + log_(std::move(log)) {} void PostgresQueryExecutorVisitor::setCreatorId( const shared_model::interface::types::AccountIdType &creator_id) { diff --git a/irohad/ametsuchi/impl/postgres_query_executor.hpp b/irohad/ametsuchi/impl/postgres_query_executor.hpp index caebf7a35f..b7600adca9 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.hpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.hpp @@ -57,7 +57,8 @@ namespace iroha { std::shared_ptr response_factory, std::shared_ptr - perm_converter); + perm_converter, + logger::Logger log = logger::log("PostgresQueryExecutorVisitor")); void setCreatorId( const shared_model::interface::types::AccountIdType &creator_id); @@ -186,7 +187,8 @@ namespace iroha { std::shared_ptr response_factory, std::shared_ptr - perm_converter); + perm_converter, + logger::Logger log = logger::log("PostgresQueryExecutor")); QueryExecutorResult validateAndExecute( const shared_model::interface::Query &query) override; diff --git a/irohad/consensus/yac/impl/yac.cpp b/irohad/consensus/yac/impl/yac.cpp index d8f09ac03c..cd7756234c 100644 --- a/irohad/consensus/yac/impl/yac.cpp +++ b/irohad/consensus/yac/impl/yac.cpp @@ -41,23 +41,24 @@ namespace iroha { std::shared_ptr network, std::shared_ptr crypto, std::shared_ptr timer, - ClusterOrdering order) { + ClusterOrdering order, + logger::Logger log) { return std::make_shared( - vote_storage, network, crypto, timer, order); + vote_storage, network, crypto, timer, order, std::move(log)); } Yac::Yac(YacVoteStorage vote_storage, std::shared_ptr network, std::shared_ptr crypto, std::shared_ptr timer, - ClusterOrdering order) + ClusterOrdering order, + logger::Logger log) : vote_storage_(std::move(vote_storage)), network_(std::move(network)), crypto_(std::move(crypto)), timer_(std::move(timer)), - cluster_order_(order) { - log_ = logger::log("YAC"); - } + cluster_order_(order), + log_(std::move(log)) {} // ------|Hash gate|------ diff --git a/irohad/consensus/yac/impl/yac_gate_impl.cpp b/irohad/consensus/yac/impl/yac_gate_impl.cpp index fbea1623bb..7ba3977b19 100644 --- a/irohad/consensus/yac/impl/yac_gate_impl.cpp +++ b/irohad/consensus/yac/impl/yac_gate_impl.cpp @@ -27,13 +27,14 @@ namespace iroha { std::shared_ptr hash_provider, std::shared_ptr block_creator, std::shared_ptr - consensus_result_cache) + consensus_result_cache, + logger::Logger log) : hash_gate_(std::move(hash_gate)), orderer_(std::move(orderer)), hash_provider_(std::move(hash_provider)), block_creator_(std::move(block_creator)), consensus_result_cache_(std::move(consensus_result_cache)), - log_(logger::log("YacGate")), + log_(std::move(log)), current_hash_() { block_creator_->onBlock().subscribe( [this](const auto &event) { this->vote(event); }); diff --git a/irohad/consensus/yac/impl/yac_gate_impl.hpp b/irohad/consensus/yac/impl/yac_gate_impl.hpp index 8ec09c6f4f..92a147bb4c 100644 --- a/irohad/consensus/yac/impl/yac_gate_impl.hpp +++ b/irohad/consensus/yac/impl/yac_gate_impl.hpp @@ -37,7 +37,8 @@ namespace iroha { std::shared_ptr hash_provider, std::shared_ptr block_creator, std::shared_ptr - consensus_result_cache); + consensus_result_cache, + logger::Logger log = logger::log("YacGate")); void vote(const simulator::BlockCreatorEvent &event) override; rxcpp::observable onOutcome() override; diff --git a/irohad/consensus/yac/yac.hpp b/irohad/consensus/yac/yac.hpp index 25d75867aa..542f14d891 100644 --- a/irohad/consensus/yac/yac.hpp +++ b/irohad/consensus/yac/yac.hpp @@ -36,13 +36,15 @@ namespace iroha { std::shared_ptr network, std::shared_ptr crypto, std::shared_ptr timer, - ClusterOrdering order); + ClusterOrdering order, + logger::Logger log = logger::log("YAC")); Yac(YacVoteStorage vote_storage, std::shared_ptr network, std::shared_ptr crypto, std::shared_ptr timer, - ClusterOrdering order); + ClusterOrdering order, + logger::Logger log = logger::log("YAC")); // ------|Hash gate|------ diff --git a/irohad/main/application.cpp b/irohad/main/application.cpp index 1408763eca..68104b7c12 100644 --- a/irohad/main/application.cpp +++ b/irohad/main/application.cpp @@ -461,7 +461,9 @@ Irohad::RunResult Irohad::run() { // Initializing internal server internal_server = std::make_unique( - listen_ip_ + ":" + std::to_string(internal_port_), false); + listen_ip_ + ":" + std::to_string(internal_port_), + false, + logger::log("InternalServerRunner")); // Run torii server return (torii_server->append(command_service_transport) diff --git a/irohad/multi_sig_transactions/impl/mst_processor.cpp b/irohad/multi_sig_transactions/impl/mst_processor.cpp index 1e027eb85a..4edd2a61ce 100644 --- a/irohad/multi_sig_transactions/impl/mst_processor.cpp +++ b/irohad/multi_sig_transactions/impl/mst_processor.cpp @@ -7,7 +7,7 @@ namespace iroha { - MstProcessor::MstProcessor() : log_(logger::log("MstProcessor")) {} + MstProcessor::MstProcessor(logger::Logger log) : log_(std::move(log)) {} void MstProcessor::propagateBatch(const DataType &batch) { this->propagateBatchImpl(batch); diff --git a/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp b/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp index dc6ad7d30d..ad76bcfa1c 100644 --- a/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp +++ b/irohad/multi_sig_transactions/impl/mst_processor_impl.cpp @@ -14,15 +14,13 @@ namespace iroha { std::shared_ptr storage, std::shared_ptr strategy, std::shared_ptr time_provider) - : MstProcessor(), + : MstProcessor(logger::log("FairMstProcessor")), transport_(std::move(transport)), storage_(std::move(storage)), strategy_(std::move(strategy)), time_provider_(std::move(time_provider)), propagation_subscriber_(strategy_->emitter().subscribe( - [this](auto data) { this->onPropagate(data); })) { - log_ = logger::log("FairMstProcessor"); - } + [this](auto data) { this->onPropagate(data); })) {} FairMstProcessor::~FairMstProcessor() { propagation_subscriber_.unsubscribe(); diff --git a/irohad/multi_sig_transactions/mst_processor.hpp b/irohad/multi_sig_transactions/mst_processor.hpp index 22c62726c0..0e7a85a5b4 100644 --- a/irohad/multi_sig_transactions/mst_processor.hpp +++ b/irohad/multi_sig_transactions/mst_processor.hpp @@ -56,7 +56,7 @@ namespace iroha { virtual ~MstProcessor() = default; protected: - MstProcessor(); + explicit MstProcessor(logger::Logger log = logger::log("MstProcessor")); logger::Logger log_; diff --git a/irohad/multi_sig_transactions/state/impl/mst_state.cpp b/irohad/multi_sig_transactions/state/impl/mst_state.cpp index fe58c7b183..e2d751f36b 100644 --- a/irohad/multi_sig_transactions/state/impl/mst_state.cpp +++ b/irohad/multi_sig_transactions/state/impl/mst_state.cpp @@ -125,16 +125,16 @@ namespace iroha { return inserted_new_signatures; } - MstState::MstState(const CompleterType &completer) - : MstState(completer, InternalStateType{}) {} + MstState::MstState(const CompleterType &completer, logger::Logger log) + : MstState(completer, InternalStateType{}, std::move(log)) {} MstState::MstState(const CompleterType &completer, - const InternalStateType &transactions) + const InternalStateType &transactions, + logger::Logger log) : completer_(completer), internal_state_(transactions.begin(), transactions.end()), - index_(transactions.begin(), transactions.end()) { - log_ = logger::log("MstState"); - } + index_(transactions.begin(), transactions.end()), + log_(std::move(log)) {} void MstState::insertOne(StateUpdateResult &state_update, const DataType &rhs_batch) { diff --git a/irohad/multi_sig_transactions/state/mst_state.hpp b/irohad/multi_sig_transactions/state/mst_state.hpp index 3aa6015d14..ab1a00f3d4 100644 --- a/irohad/multi_sig_transactions/state/mst_state.hpp +++ b/irohad/multi_sig_transactions/state/mst_state.hpp @@ -154,10 +154,12 @@ namespace iroha { using IndexType = std::priority_queue, Less>; - MstState(const CompleterType &completer); + explicit MstState(const CompleterType &completer, + logger::Logger log = logger::log("MstState")); MstState(const CompleterType &completer, - const InternalStateType &transactions); + const InternalStateType &transactions, + logger::Logger log = logger::log("MstState")); /** * Insert batch in own state and push it in out_completed_state or diff --git a/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp b/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp index 27cf473d05..5b6b15c86b 100644 --- a/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp +++ b/irohad/multi_sig_transactions/storage/impl/mst_storage.cpp @@ -8,9 +8,7 @@ #include "multi_sig_transactions/storage/mst_storage.hpp" namespace iroha { - MstStorage::MstStorage() { - log_ = logger::log("MstStorage"); - } + MstStorage::MstStorage(logger::Logger log) : log_{std::move(log)} {} StateUpdateResult MstStorage::apply( const shared_model::crypto::PublicKey &target_peer_key, diff --git a/irohad/multi_sig_transactions/storage/mst_storage.hpp b/irohad/multi_sig_transactions/storage/mst_storage.hpp index 12202ceaa4..d07a07a15b 100644 --- a/irohad/multi_sig_transactions/storage/mst_storage.hpp +++ b/irohad/multi_sig_transactions/storage/mst_storage.hpp @@ -83,7 +83,7 @@ namespace iroha { /** * Constructor provide initialization of protected fields, such as logger. */ - MstStorage(); + explicit MstStorage(logger::Logger log = logger::log("MstStorage")); private: virtual auto applyImpl( diff --git a/irohad/simulator/impl/simulator.cpp b/irohad/simulator/impl/simulator.cpp index 08995c2981..58a185e837 100644 --- a/irohad/simulator/impl/simulator.cpp +++ b/irohad/simulator/impl/simulator.cpp @@ -21,13 +21,14 @@ namespace iroha { std::shared_ptr> crypto_signer, std::unique_ptr - block_factory) + block_factory, + logger::Logger log) : validator_(std::move(statefulValidator)), ametsuchi_factory_(std::move(factory)), block_query_factory_(block_query_factory), crypto_signer_(std::move(crypto_signer)), block_factory_(std::move(block_factory)), - log_(logger::log("Simulator")) { + log_(std::move(log)) { ordering_gate->onProposal().subscribe( proposal_subscription_, [this](const network::OrderingEvent &event) { if (event.proposal) { diff --git a/irohad/simulator/impl/simulator.hpp b/irohad/simulator/impl/simulator.hpp index c5da5fcc32..cbc3d82538 100644 --- a/irohad/simulator/impl/simulator.hpp +++ b/irohad/simulator/impl/simulator.hpp @@ -31,7 +31,8 @@ namespace iroha { std::shared_ptr> crypto_signer, std::unique_ptr - block_factory); + block_factory, + logger::Logger log = logger::log("Simulator")); ~Simulator() override; diff --git a/irohad/synchronizer/impl/synchronizer_impl.cpp b/irohad/synchronizer/impl/synchronizer_impl.cpp index 28f491fd06..3e095cf1bc 100644 --- a/irohad/synchronizer/impl/synchronizer_impl.cpp +++ b/irohad/synchronizer/impl/synchronizer_impl.cpp @@ -20,12 +20,13 @@ namespace iroha { std::shared_ptr validator, std::shared_ptr mutable_factory, std::shared_ptr block_query_factory, - std::shared_ptr block_loader) + std::shared_ptr block_loader, + logger::Logger log) : validator_(std::move(validator)), mutable_factory_(std::move(mutable_factory)), block_query_factory_(std::move(block_query_factory)), block_loader_(std::move(block_loader)), - log_(logger::log("synchronizer")) { + log_(std::move(log)) { consensus_gate->onOutcome().subscribe( subscription_, [this](consensus::GateObject object) { this->processOutcome(object); diff --git a/irohad/synchronizer/impl/synchronizer_impl.hpp b/irohad/synchronizer/impl/synchronizer_impl.hpp index bd0d4458ba..a34bc8efb0 100644 --- a/irohad/synchronizer/impl/synchronizer_impl.hpp +++ b/irohad/synchronizer/impl/synchronizer_impl.hpp @@ -29,7 +29,8 @@ namespace iroha { std::shared_ptr validator, std::shared_ptr mutable_factory, std::shared_ptr block_query_factory, - std::shared_ptr block_loader); + std::shared_ptr block_loader, + logger::Logger log = logger::log("Synchronizer")); ~SynchronizerImpl() override; diff --git a/irohad/torii/impl/command_service_impl.cpp b/irohad/torii/impl/command_service_impl.cpp index 6f03e55030..ca8293e949 100644 --- a/irohad/torii/impl/command_service_impl.cpp +++ b/irohad/torii/impl/command_service_impl.cpp @@ -19,13 +19,14 @@ namespace torii { std::shared_ptr tx_processor, std::shared_ptr storage, std::shared_ptr status_bus, - std::shared_ptr status_factory) + std::shared_ptr status_factory, + logger::Logger log) : tx_processor_(std::move(tx_processor)), storage_(std::move(storage)), status_bus_(std::move(status_bus)), cache_(std::make_shared()), status_factory_(std::move(status_factory)), - log_(logger::log("CommandServiceImpl")) { + log_(std::move(log)) { // Notifier for all clients status_bus_->statuses().subscribe([this](auto response) { // find response for this tx in cache; if status of received response diff --git a/irohad/torii/impl/command_service_impl.hpp b/irohad/torii/impl/command_service_impl.hpp index 6dd9c723f0..505331d07b 100644 --- a/irohad/torii/impl/command_service_impl.hpp +++ b/irohad/torii/impl/command_service_impl.hpp @@ -27,13 +27,15 @@ namespace torii { * @param tx_processor - processor of received transactions * @param storage - to query transactions outside the cache * @param status_bus is a common notifier for tx statuses + * @param log to print progress */ CommandServiceImpl( std::shared_ptr tx_processor, std::shared_ptr storage, std::shared_ptr status_bus, std::shared_ptr - status_factory); + status_factory, + logger::Logger log = logger::log("CommandServiceImpl")); /** * Disable copying in any way to prevent potential issues with common diff --git a/irohad/torii/impl/query_service.cpp b/irohad/torii/impl/query_service.cpp index 1e6bfa7268..5a145745b9 100644 --- a/irohad/torii/impl/query_service.cpp +++ b/irohad/torii/impl/query_service.cpp @@ -15,10 +15,11 @@ namespace torii { QueryService::QueryService( std::shared_ptr query_processor, - std::shared_ptr query_factory) + std::shared_ptr query_factory, + logger::Logger log) : query_processor_{std::move(query_processor)}, query_factory_{std::move(query_factory)}, - log_{logger::log("Query Service")} {} + log_{std::move(log)} {} void QueryService::Find(iroha::protocol::Query const &request, iroha::protocol::QueryResponse &response) { diff --git a/irohad/torii/query_service.hpp b/irohad/torii/query_service.hpp index e79a7a3deb..c8388a800a 100644 --- a/irohad/torii/query_service.hpp +++ b/irohad/torii/query_service.hpp @@ -34,13 +34,13 @@ namespace torii { */ class QueryService : public iroha::protocol::QueryService_v1::Service { public: - using QueryFactoryType = - shared_model::interface::AbstractTransportFactory< - shared_model::interface::Query, - iroha::protocol::Query>; + using QueryFactoryType = shared_model::interface::AbstractTransportFactory< + shared_model::interface::Query, + iroha::protocol::Query>; QueryService(std::shared_ptr query_processor, - std::shared_ptr query_factory); + std::shared_ptr query_factory, + logger::Logger log = logger::log("Query Service")); QueryService(const QueryService &) = delete; QueryService &operator=(const QueryService &) = delete; diff --git a/irohad/validation/impl/chain_validator_impl.cpp b/irohad/validation/impl/chain_validator_impl.cpp index d77a60c703..2dce053c0b 100644 --- a/irohad/validation/impl/chain_validator_impl.cpp +++ b/irohad/validation/impl/chain_validator_impl.cpp @@ -16,9 +16,9 @@ namespace iroha { namespace validation { ChainValidatorImpl::ChainValidatorImpl( std::shared_ptr - supermajority_checker) - : supermajority_checker_(supermajority_checker), - log_(logger::log("ChainValidator")) {} + supermajority_checker, + logger::Logger log) + : supermajority_checker_(supermajority_checker), log_(std::move(log)) {} bool ChainValidatorImpl::validateAndApply( rxcpp::observable> diff --git a/irohad/validation/impl/chain_validator_impl.hpp b/irohad/validation/impl/chain_validator_impl.hpp index d20cdec799..7287f78a40 100644 --- a/irohad/validation/impl/chain_validator_impl.hpp +++ b/irohad/validation/impl/chain_validator_impl.hpp @@ -34,8 +34,10 @@ namespace iroha { namespace validation { class ChainValidatorImpl : public ChainValidator { public: - ChainValidatorImpl(std::shared_ptr - supermajority_checker); + explicit ChainValidatorImpl( + std::shared_ptr + supermajority_checker, + logger::Logger log = logger::log("ChainValidator")); bool validateAndApply( rxcpp::observable> diff --git a/libs/crypto/keys_manager_impl.cpp b/libs/crypto/keys_manager_impl.cpp index 3b9081c981..ccdaf027db 100644 --- a/libs/crypto/keys_manager_impl.cpp +++ b/libs/crypto/keys_manager_impl.cpp @@ -9,6 +9,7 @@ #include "common/byteutils.hpp" #include "cryptography/crypto_provider/crypto_defaults.hpp" +#include "logger/logger.hpp" using namespace shared_model::crypto; diff --git a/test/integration/validation/chain_validator_storage_test.cpp b/test/integration/validation/chain_validator_storage_test.cpp index cbc0c6b0d6..88e5649c98 100644 --- a/test/integration/validation/chain_validator_storage_test.cpp +++ b/test/integration/validation/chain_validator_storage_test.cpp @@ -102,7 +102,8 @@ namespace iroha { auto createAndValidateChain( std::vector> chain) { auto ms = createMutableStorage(); - return validator->validateAndApply(rxcpp::observable<>::iterate(chain), *ms); + return validator->validateAndApply(rxcpp::observable<>::iterate(chain), + *ms); } std::shared_ptr validator; diff --git a/test/module/irohad/network/block_loader_test.cpp b/test/module/irohad/network/block_loader_test.cpp index 368e0c229c..b07ae3be41 100644 --- a/test/module/irohad/network/block_loader_test.cpp +++ b/test/module/irohad/network/block_loader_test.cpp @@ -58,8 +58,8 @@ class BlockLoaderTest : public testing::Test { shared_model::proto::ProtoBlockFactory( std::move(validator_ptr), std::make_unique>())); - service = - std::make_shared(block_query_factory, block_cache); + service = std::make_shared( + block_query_factory, block_cache, logger::log("BlockLoaderService")); grpc::ServerBuilder builder; int port = 0; From 428ab642791700956b246a5ee68b9a9e106d875b Mon Sep 17 00:00:00 2001 From: Konstantin Munichev Date: Wed, 26 Dec 2018 12:58:53 +0300 Subject: [PATCH 38/61] Fix thread safe issue in status streaming (#1991) Signed-off-by: Konstantin Munichev --- irohad/torii/impl/command_service_transport_grpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irohad/torii/impl/command_service_transport_grpc.cpp b/irohad/torii/impl/command_service_transport_grpc.cpp index b8a0cb4392..098500acc6 100644 --- a/irohad/torii/impl/command_service_transport_grpc.cpp +++ b/irohad/torii/impl/command_service_transport_grpc.cpp @@ -186,7 +186,7 @@ namespace torii { auto hash = shared_model::crypto::Hash(request->tx_hash()); - static auto client_id_format = boost::format("Peer: '%s', %s"); + auto client_id_format = boost::format("Peer: '%s', %s"); std::string client_id = (client_id_format % context->peer() % hash.toString()).str(); From 4a446c33fcb7166ceddea36743caba97a3089954 Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Wed, 26 Dec 2018 16:38:11 +0300 Subject: [PATCH 39/61] Fix GetAccountTransactions and GetAccountAssetTransactions behaviour (#1990) * QueryExecutorTest is built Signed-off-by: Akvinikym * Finished the implementation Signed-off-by: Akvinikym * Fix Linux build Signed-off-by: Akvinikym * Review issues Signed-off-by: Akvinikym --- .../impl/postgres_query_executor.cpp | 81 ++++++++++++++++--- .../impl/postgres_query_executor.hpp | 50 +++++++++++- .../postgres_query_executor_test.cpp | 53 ++++++++++-- 3 files changed, 166 insertions(+), 18 deletions(-) diff --git a/irohad/ametsuchi/impl/postgres_query_executor.cpp b/irohad/ametsuchi/impl/postgres_query_executor.cpp index 5b780ac63e..26f401de4c 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.cpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.cpp @@ -228,7 +228,7 @@ namespace iroha { query_range, perms...); }); } catch (const std::exception &e) { - return logAndReturnErrorResponse( + return this->logAndReturnErrorResponse( QueryErrorType::kStatefulFailed, e.what(), 1); } } @@ -343,9 +343,13 @@ namespace iroha { error_type, error, error_code, query_hash_); } - template + template QueryExecutorResult PostgresQueryExecutorVisitor::executeTransactionsQuery( const Query &q, + QueryChecker &&qry_checker, const std::string &related_txs, QueryApplier applier, Permissions... perms) { @@ -422,15 +426,29 @@ namespace iroha { std::move( txs.begin(), txs.end(), std::back_inserter(response_txs)); } - // If 0 transactions are returned, we assume that hash is invalid. - // Since query with valid hash is guaranteed to return at least one - // transaction - if (first_hash and response_txs.empty()) { - auto error = (boost::format("invalid pagination hash: %s") - % first_hash->hex()) - .str(); - return this->logAndReturnErrorResponse( - QueryErrorType::kStatefulFailed, error, 4); + + if (response_txs.empty()) { + if (first_hash) { + // if 0 transactions are returned, and there is a specified + // paging hash, we assume it's invalid, since query with valid + // hash is guaranteed to return at least one transaction + auto error = (boost::format("invalid pagination hash: %s") + % first_hash->hex()) + .str(); + return this->logAndReturnErrorResponse( + QueryErrorType::kStatefulFailed, error, 4); + } + // if paging hash is not specified, we should check, why 0 + // transactions are returned - it can be because there are + // actually no transactions for this query or some of the + // parameters were wrong + if (auto query_incorrect = + std::forward(qry_checker)(q)) { + return this->logAndReturnErrorResponse( + QueryErrorType::kStatefulFailed, + query_incorrect.error_message, + query_incorrect.error_code); + } } // if the number of returned transactions is equal to the @@ -583,7 +601,16 @@ namespace iroha { }; }; + auto check_query = [this](const auto &q) { + if (this->existsInDb("account", "account_id", "quorum", q.accountId())) { + return QueryFallbackCheckResult{}; + } + return QueryFallbackCheckResult{ + 5, "no account with such id found: " + q.accountId()}; + }; + return executeTransactionsQuery(q, + std::move(check_query), related_txs, apply_query, Role::kGetMyAccTxs, @@ -694,7 +721,23 @@ namespace iroha { }; }; + auto check_query = [this](const auto &q) { + if (not this->existsInDb( + "account", "account_id", "quorum", q.accountId())) { + return QueryFallbackCheckResult{ + 5, "no account with such id found: " + q.accountId()}; + } + if (not this->existsInDb( + "asset", "asset_id", "precision", q.assetId())) { + return QueryFallbackCheckResult{ + 6, "no asset with such id found: " + q.assetId()}; + } + + return QueryFallbackCheckResult{}; + }; + return executeTransactionsQuery(q, + std::move(check_query), related_txs, apply_query, Role::kGetMyAccAstTxs, @@ -942,5 +985,21 @@ namespace iroha { std::move(response_txs), query_hash_); } + template + bool PostgresQueryExecutorVisitor::existsInDb( + const std::string &table_name, + const std::string &key_name, + const std::string &value_name, + const std::string &value) const { + auto cmd = (boost::format(R"(SELECT %s + FROM %s + WHERE %s = '%s' + LIMIT 1)") + % value_name % table_name % key_name % value) + .str(); + soci::rowset result = this->sql_.prepare << cmd; + return result.begin() != result.end(); + } + } // namespace ametsuchi } // namespace iroha diff --git a/irohad/ametsuchi/impl/postgres_query_executor.hpp b/irohad/ametsuchi/impl/postgres_query_executor.hpp index b7600adca9..0937561cd1 100644 --- a/irohad/ametsuchi/impl/postgres_query_executor.hpp +++ b/irohad/ametsuchi/impl/postgres_query_executor.hpp @@ -149,6 +149,8 @@ namespace iroha { * Execute query which returns list of transactions * uses pagination * @param query - query object + * @param qry_checker - fallback checker of the query, needed if paging + * hash is not specified and 0 transaction are returned as a query result * @param related_txs - SQL query which returns transaction relevant * to this query * @param applier - function which accepts SQL @@ -156,13 +158,59 @@ namespace iroha { * @param perms - permissions, necessary to execute the query * @return Result of a query execution */ - template + template QueryExecutorResult executeTransactionsQuery( const Query &query, + QueryChecker &&qry_checker, const std::string &related_txs, QueryApplier applier, Permissions... perms); + /** + * Check if entry with such key exists in the database + * @tparam ReturnValueType - type of the value to be returned in the + * underlying query + * @param table_name - name of the table to be checked + * @param key_name - name of the table attribute, against which the search + * is performed + * @param value_name - name of the value, which is to be returned + * from the search (attribute with such name is to exist) + * @param value - actual value of the key attribute + * @return true, if entry with such value of the key attribute exists, + * false otherwise + * + * @throws if check query finishes with an exception + */ + template + bool existsInDb(const std::string &table_name, + const std::string &key_name, + const std::string &value_name, + const std::string &value) const; + + struct QueryFallbackCheckResult { + QueryFallbackCheckResult() = default; + QueryFallbackCheckResult( + shared_model::interface::ErrorQueryResponse::ErrorCodeType + error_code, + shared_model::interface::ErrorQueryResponse::ErrorMessageType + &&error_message) + : contains_error{true}, + error_code{error_code}, + error_message{std::move(error_message)} {} + + explicit operator bool() const { + return contains_error; + } + bool contains_error = false; + shared_model::interface::ErrorQueryResponse::ErrorCodeType error_code = + 0; + shared_model::interface::ErrorQueryResponse::ErrorMessageType + error_message = ""; + }; + soci::session &sql_; KeyValueStorage &block_store_; shared_model::interface::types::AccountIdType creator_id_; diff --git a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp index 3abfae097e..cb30ee020e 100644 --- a/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_query_executor_test.cpp @@ -213,6 +213,10 @@ namespace iroha { ErrorCodeType kNoPermissions = 2; static constexpr shared_model::interface::ErrorQueryResponse:: ErrorCodeType kInvalidPagination = 4; + static constexpr shared_model::interface::ErrorQueryResponse:: + ErrorCodeType kInvalidAccountId = 5; + static constexpr shared_model::interface::ErrorQueryResponse:: + ErrorCodeType kInvalidAssetId = 6; void createDefaultAccount() { execute(*mock_command_factory->constructCreateAccount( @@ -1312,12 +1316,12 @@ namespace iroha { } /** - * @given initialized storage, permission + * @given initialized storage, all permissions * @when get account transactions of non existing account - * @then Return empty account transactions + * @then return error */ - TEST_F(GetAccountTransactionsExecutorTest, DISABLED_InvalidNoAccount) { - addPerms({shared_model::interface::permissions::Role::kGetAllAccTxs}); + TEST_F(GetAccountTransactionsExecutorTest, InvalidNoAccount) { + addAllPerms(); auto query = TestQueryBuilder() .creatorAccountId(account_id) @@ -1325,7 +1329,7 @@ namespace iroha { .build(); auto result = executeQuery(query); checkStatefulError( - std::move(result), kNoStatefulError); + std::move(result), kInvalidAccountId); } // ------------------------/ tx pagination tests \----------------------- // @@ -1580,13 +1584,50 @@ namespace iroha { auto query = TestQueryBuilder() .creatorAccountId(account_id) - .getAccountTransactions(another_account_id, kTxPageSize) + .getAccountAssetTransactions( + another_account_id, asset_id, kTxPageSize) .build(); auto result = executeQuery(query); checkStatefulError( std::move(result), kNoPermissions); } + /** + * @given initialized storage, all permissions + * @when get account asset transactions of non-existing user + * @then corresponding error is returned + */ + TEST_F(GetAccountAssetTransactionsExecutorTest, InvalidAccountId) { + addAllPerms(); + + auto query = TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountAssetTransactions( + "doge@noaccount", asset_id, kTxPageSize) + .build(); + auto result = executeQuery(query); + checkStatefulError( + std::move(result), kInvalidAccountId); + } + + /** + * @given initialized storage, all permissions + * @when get account asset transactions of non-existing asset + * @then corresponding error is returned + */ + TEST_F(GetAccountAssetTransactionsExecutorTest, InvalidAssetId) { + addAllPerms(); + + auto query = + TestQueryBuilder() + .creatorAccountId(account_id) + .getAccountAssetTransactions(account_id, "doge#coin", kTxPageSize) + .build(); + auto result = executeQuery(query); + checkStatefulError( + std::move(result), kInvalidAssetId); + } + /** * @given initialized storage * @when get pending transactions From 6af4727b1a81afdda1e1c7a325b17c51baad9542 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Wed, 26 Dec 2018 23:58:19 +0300 Subject: [PATCH 40/61] Fix/fuzzing status (#1979) Signed-off-by: Kitsu --- test/fuzzing/status_fuzz.cpp | 98 ++++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 14 deletions(-) diff --git a/test/fuzzing/status_fuzz.cpp b/test/fuzzing/status_fuzz.cpp index 413fe7b29f..2d34f0bf81 100644 --- a/test/fuzzing/status_fuzz.cpp +++ b/test/fuzzing/status_fuzz.cpp @@ -3,15 +3,26 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "torii/impl/command_service_transport_grpc.hpp" + #include #include +#include "ametsuchi/tx_cache_response.hpp" +#include "backend/protobuf/proto_transport_factory.hpp" +#include "backend/protobuf/proto_tx_status_factory.hpp" +#include "backend/protobuf/transaction.hpp" +#include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp" +#include "interfaces/iroha_internal/transaction_batch_parser_impl.hpp" #include "libfuzzer/libfuzzer_macro.h" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/multi_sig_transactions/mst_mocks.hpp" #include "module/irohad/network/network_mocks.hpp" #include "synchronizer/synchronizer_common.hpp" -#include "torii/command_service.hpp" +#include "torii/impl/command_service_impl.hpp" +#include "torii/impl/status_bus_impl.hpp" #include "torii/processor/transaction_processor_impl.hpp" +#include "validators/default_validator.hpp" +#include "validators/protobuf/proto_transaction_validator.hpp" using namespace std::chrono_literals; using testing::_; @@ -19,22 +30,25 @@ using testing::Return; struct CommandFixture { std::shared_ptr service_; + std::shared_ptr service_transport_; std::shared_ptr tx_processor_; std::shared_ptr storage_; std::shared_ptr pcs_; std::shared_ptr mst_processor_; std::shared_ptr bq_; - rxcpp::subjects::subject> - prop_notifier_; - rxcpp::subjects::subject< - std::shared_ptr> + rxcpp::subjects::subject prop_notifier_; + rxcpp::subjects::subject vprop_notifier_; rxcpp::subjects::subject commit_notifier_; rxcpp::subjects::subject mst_notifier_; + rxcpp::subjects::subject> + mst_state_notifier_; CommandFixture() { + spdlog::set_level(spdlog::level::err); + pcs_ = std::make_shared(); EXPECT_CALL(*pcs_, onProposal()) .WillRepeatedly(Return(prop_notifier_.get_observable())); @@ -44,18 +58,58 @@ struct CommandFixture { .WillRepeatedly(Return(vprop_notifier_.get_observable())); mst_processor_ = std::make_shared(); - EXPECT_CALL(*mst_processor_, onPreparedTransactionsImpl()) + EXPECT_CALL(*mst_processor_, onStateUpdateImpl()) + .WillRepeatedly(Return(mst_state_notifier_.get_observable())); + EXPECT_CALL(*mst_processor_, onPreparedBatchesImpl()) .WillRepeatedly(Return(mst_notifier_.get_observable())); - EXPECT_CALL(*mst_processor_, onExpiredTransactionsImpl()) + EXPECT_CALL(*mst_processor_, onExpiredBatchesImpl()) .WillRepeatedly(Return(mst_notifier_.get_observable())); + auto status_bus = std::make_shared(); + auto status_factory = + std::make_shared(); + tx_processor_ = std::make_shared( + pcs_, mst_processor_, status_bus, status_factory); + + std::unique_ptr> + transaction_validator = + std::make_unique(); + std::unique_ptr> + proto_transaction_validator = std::make_unique< + shared_model::validation::ProtoTransactionValidator>(); + std::shared_ptr> + transaction_factory = + std::make_shared>( + std::move(transaction_validator), + std::move(proto_transaction_validator)); + std::shared_ptr + batch_parser = std::make_shared< + shared_model::interface::TransactionBatchParserImpl>(); + std::shared_ptr + transaction_batch_factory = std::make_shared< + shared_model::interface::TransactionBatchFactoryImpl>(); + storage_ = std::make_shared(); bq_ = std::make_shared(); EXPECT_CALL(*storage_, getBlockQuery()).WillRepeatedly(Return(bq_)); - tx_processor_ = std::make_shared( - pcs_, mst_processor_); - service_ = std::make_shared( - tx_processor_, storage_, 15s, 15s); + service_ = std::make_shared( + tx_processor_, storage_, status_bus, status_factory); + service_transport_ = std::make_shared( + service_, + status_bus, + 15s, + 15s, + status_factory, + transaction_factory, + batch_parser, + transaction_batch_factory); } }; @@ -64,13 +118,29 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size) { if (size < 1) { return 0; } - EXPECT_CALL(*handler.bq_, hasTxWithHash(_)) - .WillRepeatedly(Return(static_cast(data[0]))); + boost::optional presense; + using namespace iroha::ametsuchi::tx_cache_status_responses; + switch (data[0] % 4) { + case 0: + presense = {}; + break; + case 1: + presense = boost::make_optional(Committed{}); + break; + case 2: + presense = boost::make_optional(Rejected{}); + break; + case 3: + presense = boost::make_optional(Missing{}); + break; + } + EXPECT_CALL(*handler.bq_, checkTxPresence(_)) + .WillRepeatedly(Return(presense)); iroha::protocol::TxStatusRequest tx; if (protobuf_mutator::libfuzzer::LoadProtoInput( true, data + 1, size - 1, &tx)) { iroha::protocol::ToriiResponse resp; - handler.service_->Status(tx, resp); + handler.service_transport_->Status(nullptr, &tx, &resp); } return 0; } From d1e3b462489d02288ba2b67010f8a367a9a99226 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Wed, 26 Dec 2018 23:58:33 +0300 Subject: [PATCH 41/61] Update Torii Fuzzing (#1951) Signed-off-by: Kitsu --- test/fuzzing/torii_fuzz.cpp | 74 +++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/test/fuzzing/torii_fuzz.cpp b/test/fuzzing/torii_fuzz.cpp index 581efbe9d8..7b026c7f06 100644 --- a/test/fuzzing/torii_fuzz.cpp +++ b/test/fuzzing/torii_fuzz.cpp @@ -3,33 +3,45 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "torii/impl/command_service_transport_grpc.hpp" + #include #include +#include "backend/protobuf/proto_transport_factory.hpp" +#include "backend/protobuf/proto_tx_status_factory.hpp" +#include "backend/protobuf/transaction.hpp" +#include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp" +#include "interfaces/iroha_internal/transaction_batch_parser_impl.hpp" #include "libfuzzer/libfuzzer_macro.h" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" #include "module/irohad/multi_sig_transactions/mst_mocks.hpp" #include "module/irohad/network/network_mocks.hpp" #include "synchronizer/synchronizer_common.hpp" -#include "torii/command_service.hpp" +#include "torii/impl/command_service_impl.hpp" +#include "torii/impl/status_bus_impl.hpp" #include "torii/processor/transaction_processor_impl.hpp" +#include "transaction.pb.h" +#include "validators/default_validator.hpp" +#include "validators/protobuf/proto_transaction_validator.hpp" using namespace std::chrono_literals; using testing::Return; struct CommandFixture { std::shared_ptr service_; + std::shared_ptr service_transport_; std::shared_ptr tx_processor_; std::shared_ptr pcs_; std::shared_ptr mst_processor_; - rxcpp::subjects::subject> - prop_notifier_; - rxcpp::subjects::subject< - std::shared_ptr> + rxcpp::subjects::subject prop_notifier_; + rxcpp::subjects::subject vprop_notifier_; rxcpp::subjects::subject commit_notifier_; rxcpp::subjects::subject mst_notifier_; + rxcpp::subjects::subject> + mst_state_notifier_; CommandFixture() { pcs_ = std::make_shared(); @@ -41,19 +53,59 @@ struct CommandFixture { .WillRepeatedly(Return(vprop_notifier_.get_observable())); mst_processor_ = std::make_shared(); - EXPECT_CALL(*mst_processor_, onPreparedTransactionsImpl()) + EXPECT_CALL(*mst_processor_, onStateUpdateImpl()) + .WillRepeatedly(Return(mst_state_notifier_.get_observable())); + EXPECT_CALL(*mst_processor_, onPreparedBatchesImpl()) .WillRepeatedly(Return(mst_notifier_.get_observable())); - EXPECT_CALL(*mst_processor_, onExpiredTransactionsImpl()) + EXPECT_CALL(*mst_processor_, onExpiredBatchesImpl()) .WillRepeatedly(Return(mst_notifier_.get_observable())); + auto status_bus = std::make_shared(); + auto status_factory = + std::make_shared(); tx_processor_ = std::make_shared( - pcs_, mst_processor_); - service_ = std::make_shared( - tx_processor_, nullptr, 15s, 15s); + pcs_, mst_processor_, status_bus, status_factory); + auto storage = std::make_shared(); + service_ = std::make_shared( + tx_processor_, storage, status_bus, status_factory); + + std::unique_ptr> + transaction_validator = + std::make_unique(); + std::unique_ptr> + proto_transaction_validator = std::make_unique< + shared_model::validation::ProtoTransactionValidator>(); + std::shared_ptr> + transaction_factory = + std::make_shared>( + std::move(transaction_validator), + std::move(proto_transaction_validator)); + std::shared_ptr + batch_parser = std::make_shared< + shared_model::interface::TransactionBatchParserImpl>(); + std::shared_ptr + transaction_batch_factory = std::make_shared< + shared_model::interface::TransactionBatchFactoryImpl>(); + service_transport_ = std::make_shared( + service_, + status_bus, + 15s, + 15s, + status_factory, + transaction_factory, + batch_parser, + transaction_batch_factory); } }; DEFINE_BINARY_PROTO_FUZZER(const iroha::protocol::Transaction &tx) { static CommandFixture handler; - handler.service_->Torii(tx); + handler.service_transport_->Torii(nullptr, &tx, nullptr); } From 1decc4244c69463b04394daf4330030789b005f1 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 27 Dec 2018 00:37:52 +0300 Subject: [PATCH 42/61] Checked and fixed query documentation (#1971) Signed-off-by: Sara --- docs/source/api/queries.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/source/api/queries.rst b/docs/source/api/queries.rst index 8af0c649b5..6cdd0178be 100644 --- a/docs/source/api/queries.rst +++ b/docs/source/api/queries.rst @@ -205,7 +205,8 @@ Purpose ------- In a case when a list of transactions per account is needed, `GetAccountTransactions` query can be formed. -.. note:: This query uses pagination for query responses. + +.. note:: This query uses pagination for quicker and more convenient query responses. Request Schema -------------- @@ -266,6 +267,7 @@ Purpose ------- `GetAccountAssetTransactions` query returns all transactions associated with given account and asset. + .. note:: This query uses pagination for query responses. Request Schema @@ -359,7 +361,7 @@ Response Schema message AccountAsset { string asset_id = 1; string account_id = 2; - Amount balance = 3; + string balance = 3; } Response Structure @@ -371,7 +373,7 @@ Response Structure "Asset ID", "identifier of asset used for checking the balance", "#", "jpy#japan" "Account ID", "account which has this balance", "@", "makoto@soramitsu" - "Balance", "balance of the asset", "Not less than 0", "200.20" + "Balance", "balance of the asset", "No less than 0", "200.20" Get Account Detail ^^^^^^^^^^^^^^^^^^ @@ -379,7 +381,7 @@ Get Account Detail Purpose ------- -To get details of the account, `GetAccountDetail` query can be used. Account details are key-value pairs, splitted into writers categories. Writers are accounts, which added the corresponding account detail. Example of such structure is: +To get details of the account, `GetAccountDetail` query can be used. Account details are key-value pairs, splitted into writers categories. Writers are accounts, that added the corresponding account detail. Example of such structure is: .. code-block:: json @@ -448,7 +450,7 @@ Response Structure Usage Examples -------------- -Let's again consider the example of details from the beginning and see, how different variants of `GetAccountDetail` queries will change the resulting response. +Again, let's consider the example of details from the beginning and see how different variants of `GetAccountDetail` queries will change the resulting response. .. code-block:: json @@ -514,7 +516,7 @@ Now, the response will contain all details about this account, added by one spec **account_id, key and writer are set** -Lastly, if all three field are set, result will contain details, added the specific writer and under the specific key, for example, if we asked for key "age" and writer "account@a_domain", we would get: +Finally, if all three field are set, result will contain details, added the specific writer and under the specific key, for example, if we asked for key "age" and writer "account@a_domain", we would get: .. code-block:: json @@ -530,7 +532,7 @@ Get Asset Info Purpose ------- -In order to know precision for given asset, and other related info in the future, such as a description of the asset, etc. user can send `GetAssetInfo` query. +In order to get information on the given asset (as for now - its precision), user can send `GetAssetInfo` query. Request Schema -------------- @@ -573,7 +575,7 @@ Response Structure :header: "Field", "Description", "Constraint", "Example" :widths: 15, 30, 20, 15 - "Asset ID", "identifier of asset used for checking the balance", "#", "jpy" + "Asset ID", "identifier of asset used for checking the balance", "#", "jpy#japan" "Domain ID", "domain related to this asset", "RFC1035 [#f1]_, RFC1123 [#f2]_", "japan" "Precision", "number of digits after comma", "0 <= precision <= 255", "2" From 65c914f78abe6c6c590446356c0cbb5f3cd5ffe5 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Thu, 27 Dec 2018 00:46:42 +0300 Subject: [PATCH 43/61] Remove client_test (#1833) Signed-off-by: Kitsu --- test/module/CMakeLists.txt | 1 - test/module/iroha-cli/CMakeLists.txt | 14 - test/module/iroha-cli/client_test.cpp | 455 -------------------------- 3 files changed, 470 deletions(-) delete mode 100644 test/module/iroha-cli/CMakeLists.txt delete mode 100644 test/module/iroha-cli/client_test.cpp diff --git a/test/module/CMakeLists.txt b/test/module/CMakeLists.txt index 78b4a7da64..c0af2c7818 100644 --- a/test/module/CMakeLists.txt +++ b/test/module/CMakeLists.txt @@ -4,7 +4,6 @@ # # Reusable tests -add_subdirectory(iroha-cli) add_subdirectory(irohad) add_subdirectory(libs) add_subdirectory(vendor) diff --git a/test/module/iroha-cli/CMakeLists.txt b/test/module/iroha-cli/CMakeLists.txt deleted file mode 100644 index 1a22b30491..0000000000 --- a/test/module/iroha-cli/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -addtest(client_test client_test.cpp) -target_link_libraries(client_test - client - processors - server_runner - ) -target_include_directories(client_test PUBLIC - ${PROJECT_SOURCE_DIR}/iroha-cli - ) diff --git a/test/module/iroha-cli/client_test.cpp b/test/module/iroha-cli/client_test.cpp deleted file mode 100644 index 83622de5aa..0000000000 --- a/test/module/iroha-cli/client_test.cpp +++ /dev/null @@ -1,455 +0,0 @@ -/** - * Copyright Soramitsu Co., Ltd. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "model/sha3_hash.hpp" -#include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" -#include "module/irohad/multi_sig_transactions/mst_mocks.hpp" -#include "module/irohad/network/network_mocks.hpp" -#include "module/irohad/pending_txs_storage/pending_txs_storage_mock.hpp" -#include "module/irohad/validation/validation_mocks.hpp" -#include "module/shared_model/builders/protobuf/common_objects/proto_account_builder.hpp" -#include "module/shared_model/builders/protobuf/proposal.hpp" -#include "module/shared_model/builders/protobuf/test_proposal_builder.hpp" -#include "module/shared_model/builders/protobuf/test_query_builder.hpp" -#include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" - -#include "client.hpp" - -#include "main/server_runner.hpp" -#include "torii/impl/command_service_impl.hpp" -#include "torii/impl/command_service_transport_grpc.hpp" -#include "torii/impl/status_bus_impl.hpp" -#include "torii/processor/query_processor_impl.hpp" -#include "torii/processor/transaction_processor_impl.hpp" -#include "torii/query_service.hpp" - -#include "model/converters/json_common.hpp" -#include "model/converters/json_query_factory.hpp" -#include "model/converters/json_transaction_factory.hpp" -#include "model/converters/pb_transaction_factory.hpp" - -#include "backend/protobuf/proto_query_response_factory.hpp" -#include "backend/protobuf/proto_transport_factory.hpp" -#include "backend/protobuf/proto_tx_status_factory.hpp" -#include "builders/protobuf/queries.hpp" -#include "builders/protobuf/transaction.hpp" -#include "interfaces/iroha_internal/query_response_factory.hpp" -#include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp" -#include "interfaces/iroha_internal/transaction_batch_parser_impl.hpp" -#include "validators/protobuf/proto_query_validator.hpp" -#include "validators/protobuf/proto_transaction_validator.hpp" - -using ::testing::_; -using ::testing::A; -using ::testing::AtLeast; -using ::testing::ByMove; -using ::testing::Return; - -using namespace iroha::ametsuchi; -using namespace iroha::network; -using namespace iroha::validation; -using namespace shared_model::proto; - -using namespace std::chrono_literals; -constexpr std::chrono::milliseconds initial_timeout = 1s; -constexpr std::chrono::milliseconds nonfinal_timeout = 2 * 10s; - -/** -Here we imitate the behavior of StatusStram client but on a bit lower level. So -the do-while cycle imitates client resubscription to the stream. Stream -"expiration" is a valid designed case (see pr #1615 for the details). - -The number of attempts (3) is a magic constant here. The idea behind this number -is the following: only one resubscription is usually enough to pass the test; if -three resubscribes were not enough, then most likely there is another bug. - */ -constexpr uint32_t status_read_attempts = 3; - -class ClientServerTest : public testing::Test { - public: - virtual void SetUp() { - spdlog::set_level(spdlog::level::off); - // Run a server - runner = std::make_unique(ip + ":0"); - - // ----------- Command Service -------------- - pcsMock = std::make_shared(); - mst = std::make_shared(); - wsv_query = std::make_shared(); - block_query = std::make_shared(); - query_executor = std::make_shared(); - storage = std::make_shared(); - - rxcpp::subjects::subject prop_notifier; - rxcpp::subjects::subject - commit_notifier; - EXPECT_CALL(*pcsMock, onProposal()) - .WillRepeatedly(Return(prop_notifier.get_observable())); - EXPECT_CALL(*pcsMock, on_commit()) - .WillRepeatedly(Return(commit_notifier.get_observable())); - EXPECT_CALL(*pcsMock, onVerifiedProposal()) - .WillRepeatedly(Return(verified_prop_notifier.get_observable())); - - EXPECT_CALL(*mst, onStateUpdateImpl()) - .WillRepeatedly(Return(mst_update_notifier.get_observable())); - EXPECT_CALL(*mst, onPreparedBatchesImpl()) - .WillRepeatedly(Return(mst_prepared_notifier.get_observable())); - EXPECT_CALL(*mst, onExpiredBatchesImpl()) - .WillRepeatedly(Return(mst_expired_notifier.get_observable())); - - EXPECT_CALL(*storage, createQueryExecutor(_, _)) - .WillRepeatedly(Return(boost::make_optional( - std::shared_ptr(query_executor)))); - - auto status_bus = std::make_shared(); - auto tx_processor = - std::make_shared( - pcsMock, - mst, - status_bus, - std::make_shared()); - - auto pb_tx_factory = - std::make_shared(); - - auto pending_txs_storage = - std::make_shared(); - - query_response_factory = - std::make_shared(); - - //----------- Query Service ---------- - EXPECT_CALL(*storage, getWsvQuery()).WillRepeatedly(Return(wsv_query)); - EXPECT_CALL(*storage, getBlockQuery()).WillRepeatedly(Return(block_query)); - - auto qpi = std::make_shared( - storage, storage, pending_txs_storage, query_response_factory); - - //----------- Server run ---------------- - auto status_factory = - std::make_shared(); - std::unique_ptr> - interface_transaction_validator = std::make_unique< - shared_model::validation::DefaultUnsignedTransactionValidator>(); - std::unique_ptr> - proto_transaction_validator = std::make_unique< - shared_model::validation::ProtoTransactionValidator>(); - auto transaction_factory = - std::make_shared>( - std::move(interface_transaction_validator), - std::move(proto_transaction_validator)); - auto batch_parser = - std::make_shared(); - auto batch_factory = std::make_shared< - shared_model::interface::TransactionBatchFactoryImpl>(); - initQueryFactory(); - runner - ->append(std::make_unique( - std::make_shared( - tx_processor, storage, status_bus, status_factory), - status_bus, - initial_timeout, - nonfinal_timeout, - status_factory, - transaction_factory, - batch_parser, - batch_factory)) - .append(std::make_unique(qpi, query_factory)) - .run() - .match( - [this](iroha::expected::Value port) { - this->port = port.value; - }, - [](iroha::expected::Error err) { - FAIL() << err.error; - }); - - runner->waitForServersReady(); - } - - void initQueryFactory() { - std::unique_ptr> - query_validator = std::make_unique< - shared_model::validation::DefaultSignedQueryValidator>(); - std::unique_ptr< - shared_model::validation::AbstractValidator> - proto_query_validator = - std::make_unique(); - query_factory = std::make_shared>(std::move(query_validator), - std::move(proto_query_validator)); - } - - decltype(shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair()) - pair = - shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair(); - std::vector signatories = { - pair.publicKey()}; - - std::unique_ptr runner; - std::shared_ptr pcsMock; - std::shared_ptr mst; - std::shared_ptr query_factory; - std::shared_ptr - query_response_factory; - - rxcpp::subjects::subject - verified_prop_notifier; - rxcpp::subjects::subject> - mst_update_notifier; - rxcpp::subjects::subject mst_prepared_notifier; - rxcpp::subjects::subject mst_expired_notifier; - - std::shared_ptr wsv_query; - std::shared_ptr block_query; - std::shared_ptr query_executor; - std::shared_ptr storage; - - iroha::consensus::Round round; - const std::string ip = "127.0.0.1"; - int port; -}; - -TEST_F(ClientServerTest, SendTxWhenValid) { - iroha_cli::CliClient client(ip, port); - EXPECT_CALL(*pcsMock, propagate_batch(_)).Times(1); - - auto shm_tx = shared_model::proto::TransactionBuilder() - .creatorAccountId("some@account") - .createdTime(iroha::time::now()) - .setAccountQuorum("some@account", 2) - .quorum(1) - .build() - .signAndAddSignature( - shared_model::crypto::DefaultCryptoAlgorithmType:: - generateKeypair()) - .finish(); - - auto status = client.sendTx(shm_tx); - ASSERT_EQ(status.answer, iroha_cli::CliClient::OK); -} - -TEST_F(ClientServerTest, SendTxWhenInvalidJson) { - iroha_cli::CliClient client(ip, port); - // Must not call stateful validation since json is invalid - // Json with no Transaction - auto json_string = - R"({"creator_account_id": "test", - "commands":[{ - "command_type": "AddPeer", - "peer": { - "address": "localhost", - "peer_key": "2323232323232323232323232323232323232323232323232323232323232323" - } - }] - })"; - iroha::model::converters::JsonTransactionFactory tx_factory; - auto json_doc = iroha::model::converters::stringToJson(json_string); - ASSERT_TRUE(json_doc); - auto model_tx = tx_factory.deserialize(json_doc.value()); - ASSERT_FALSE(model_tx); -} - -TEST_F(ClientServerTest, SendTxWhenStatelessInvalid) { - // creating stateless invalid tx - auto shm_tx = TestTransactionBuilder() - .creatorAccountId("some@account") - .createdTime(iroha::time::now()) - .setAccountQuorum("some@@account", 2) - .build(); - - ASSERT_EQ(iroha_cli::CliClient(ip, port).sendTx(shm_tx).answer, - iroha_cli::CliClient::OK); - auto getAnswer = [&]() { - return iroha_cli::CliClient(ip, port) - .getTxStatus(shared_model::crypto::toBinaryString(shm_tx.hash())) - .answer; - }; - decltype(getAnswer()) answer; - auto read_attempt_counter(status_read_attempts); - do { - answer = getAnswer(); - } while (answer.tx_status() - != iroha::protocol::TxStatus::STATELESS_VALIDATION_FAILED - and --read_attempt_counter); - ASSERT_EQ(answer.tx_status(), - iroha::protocol::TxStatus::STATELESS_VALIDATION_FAILED); - ASSERT_NE(answer.err_or_cmd_name().size(), 0); -} - -/** - * This test checks, if tx, which did not pass stateful validation, is shown to - * client with a corresponding status and error message - * - * @given real client and mocked pcs - * @when sending a stateless valid transaction @and failing it at stateful - * validation - * @then ensure that client sees: - * - status of this transaction as STATEFUL_VALIDATION_FAILED - * - error message is the same, as the one with which transaction was - * failed - */ -TEST_F(ClientServerTest, SendTxWhenStatefulInvalid) { - iroha_cli::CliClient client(ip, port); - EXPECT_CALL(*pcsMock, propagate_batch(_)).Times(1); - - // creating stateful invalid tx - auto tx = TransactionBuilder() - .creatorAccountId("some@account") - .createdTime(iroha::time::now()) - .transferAsset("some@account", - "another@account", - "doge#doge", - "some transfer", - "100.0") - .quorum(1) - .build() - .signAndAddSignature( - shared_model::crypto::DefaultCryptoAlgorithmType:: - generateKeypair()) - .finish(); - ASSERT_EQ(client.sendTx(tx).answer, iroha_cli::CliClient::OK); - - // fail the tx - auto cmd_name = "CommandName"; - size_t cmd_index = 2; - uint32_t error_code = 3; - auto verified_proposal_and_errors = - std::make_shared(); - verified_proposal_and_errors - ->verified_proposal = std::make_unique( - TestProposalBuilder().height(0).createdTime(iroha::time::now()).build()); - verified_proposal_and_errors->rejected_transactions.emplace_back( - iroha::validation::TransactionError{ - tx.hash(), - iroha::validation::CommandError{ - cmd_name, error_code, "", true, cmd_index}}); - verified_prop_notifier.get_subscriber().on_next( - iroha::simulator::VerifiedProposalCreatorEvent{ - verified_proposal_and_errors, round}); - - auto getAnswer = [&]() { - return client.getTxStatus(shared_model::crypto::toBinaryString(tx.hash())) - .answer; - }; - decltype(getAnswer()) answer; - auto read_attempt_counter(status_read_attempts); - do { - // check it really failed with specific message - answer = getAnswer(); - } while (answer.tx_status() - != iroha::protocol::TxStatus::STATEFUL_VALIDATION_FAILED - and --read_attempt_counter); - ASSERT_EQ(answer.tx_status(), - iroha::protocol::TxStatus::STATEFUL_VALIDATION_FAILED); - ASSERT_EQ(answer.err_or_cmd_name(), cmd_name); - ASSERT_EQ(answer.failed_cmd_index(), cmd_index); - ASSERT_EQ(answer.error_code(), error_code); -} - -TEST_F(ClientServerTest, SendQueryWhenInvalidJson) { - iroha_cli::CliClient client(ip, port); - // Must not call stateful validation since json is invalid and shouldn't be - // passed to stateless validation - - auto json_query = - R"({"creator_account_id": "test", - "commands":[{ - "command_type": "AddPeer", - "peer": { - "address": "localhost", - "peer_key": "2323232323232323232323232323232323232323232323232323232323232323" - } - }] - })"; - - iroha::model::converters::JsonQueryFactory queryFactory; - auto model_query = queryFactory.deserialize(json_query); - ASSERT_FALSE(model_query); -} - -TEST_F(ClientServerTest, SendQueryWhenStatelessInvalid) { - iroha_cli::CliClient client(ip, port); - - shared_model::proto::Query query = TestQueryBuilder() - .createdTime(0) - .creatorAccountId("123") - .getAccount("asd") - .build(); - auto proto_query = query.getTransport(); - - auto res = client.sendQuery(query); - ASSERT_TRUE(res.status.ok()); - ASSERT_TRUE(res.answer.has_error_response()); - ASSERT_EQ(res.answer.error_response().reason(), - iroha::protocol::ErrorResponse::STATELESS_INVALID); - ASSERT_NE(res.answer.error_response().message().size(), 0); -} - -TEST_F(ClientServerTest, SendQueryWhenValid) { - // TODO: 30/04/2018 x3medima17, fix Uninteresting mock function call, IR-1187 - iroha_cli::CliClient client(ip, port); - - std::shared_ptr account_test = clone( - shared_model::proto::AccountBuilder().accountId("test@test").build()); - - EXPECT_CALL(*wsv_query, getSignatories("admin@test")) - .WillRepeatedly(Return(signatories)); - - auto query = QueryBuilder() - .createdTime(iroha::time::now()) - .creatorAccountId("admin@test") - .queryCounter(1) - .getAccountDetail("test@test") - .build() - .signAndAddSignature(pair) - .finish(); - - auto *resp = - query_response_factory->createAccountDetailResponse("value", query.hash()) - .release(); - - EXPECT_CALL(*query_executor, validateAndExecute_(_)).WillOnce(Return(resp)); - - auto res = client.sendQuery(query); - ASSERT_EQ(res.answer.account_detail_response().detail(), "value"); -} - -TEST_F(ClientServerTest, SendQueryWhenStatefulInvalid) { - iroha_cli::CliClient client(ip, port); - - EXPECT_CALL(*wsv_query, getSignatories("admin@test")) - .WillRepeatedly(Return(signatories)); - - auto query = QueryBuilder() - .createdTime(iroha::time::now()) - .creatorAccountId("admin@test") - .queryCounter(1) - .getAccountDetail("test@test") - .build() - .signAndAddSignature(pair) - .finish(); - - auto *resp = query_response_factory - ->createErrorQueryResponse( - shared_model::interface::QueryResponseFactory:: - ErrorQueryType::kStatefulFailed, - "", - 1, - query.hash()) - .release(); - - EXPECT_CALL(*query_executor, validateAndExecute_(_)).WillOnce(Return(resp)); - - auto res = client.sendQuery(query); - ASSERT_EQ(res.answer.error_response().reason(), - iroha::protocol::ErrorResponse::STATEFUL_INVALID); -} From 59da405638e48dd127c6d68bb97fbfe2ce7d6a76 Mon Sep 17 00:00:00 2001 From: Mikhail Boldyrev Date: Thu, 27 Dec 2018 08:27:22 +0300 Subject: [PATCH 44/61] Better irohad config error reporting (#1956) * irohad config reportJsonParsingError(...) Signed-off-by: Mikhail Boldyrev --- irohad/main/iroha_conf_loader.hpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/irohad/main/iroha_conf_loader.hpp b/irohad/main/iroha_conf_loader.hpp index ed90829f3a..b197de1d61 100644 --- a/irohad/main/iroha_conf_loader.hpp +++ b/irohad/main/iroha_conf_loader.hpp @@ -28,6 +28,25 @@ namespace config_members { const char *MstSupport = "mst_enable"; } // namespace config_members +static constexpr size_t kBadJsonPrintLength = 15; +static constexpr size_t kBadJsonPrintOffsset = 5; +static_assert(kBadJsonPrintOffsset <= kBadJsonPrintLength, + "The place of error is out of the printed string boundaries!"); + +std::string reportJsonParsingError(const rapidjson::Document &doc, + const std::string &conf_path, + std::istream &input) { + const size_t error_offset = doc.GetErrorOffset(); + // This ensures the unsigned string beginning position does not cross zero: + const size_t print_offset = + std::max(error_offset, kBadJsonPrintOffsset) - kBadJsonPrintOffsset; + input.seekg(print_offset); + std::string json_error_buf(kBadJsonPrintLength, 0); + input.readsome(&json_error_buf[0], kBadJsonPrintLength); + return "JSON parse error [" + conf_path + "] " + "(near `" + json_error_buf + + "'): " + std::string(rapidjson::GetParseError_En(doc.GetParseError())); +} + /** * parse and assert trusted peers json in `iroha.conf` * @param conf_path is a path to iroha's config @@ -43,10 +62,8 @@ inline rapidjson::Document parse_iroha_config(const std::string &conf_path) { const std::string kUintType = "uint"; const std::string kBoolType = "bool"; doc.ParseStream(isw); - ac::assert_fatal( - not doc.HasParseError(), - "JSON parse error [" + conf_path + "]: " - + std::string(rapidjson::GetParseError_En(doc.GetParseError()))); + ac::assert_fatal(not doc.HasParseError(), + reportJsonParsingError(doc, conf_path, ifs_iroha)); ac::assert_fatal(doc.HasMember(mbr::BlockStorePath), ac::no_member_error(mbr::BlockStorePath)); From f8a51dd33a2f96f8510b7843ca5ee123489140b6 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Thu, 27 Dec 2018 16:28:20 +0300 Subject: [PATCH 45/61] Refactor torii_service_test (#1853) - Rework deserializeTransaction with for-each, since it calls pipeline callback twice for some reason - Use Mocks for tx validator and tx batch validator - Remove transactions, where useless - Remove redundant stuff from CommandSyncClient Signed-off-by: Kitsu --- irohad/torii/command_client.hpp | 9 - irohad/torii/impl/command_client.cpp | 30 +- .../impl/command_service_transport_grpc.cpp | 42 +-- test/module/irohad/torii/CMakeLists.txt | 18 +- .../irohad/torii/command_sync_client_test.cpp | 100 ++++++ test/module/irohad/torii/torii_mocks.hpp | 42 +++ .../torii/torii_transport_command_test.cpp | 286 ++++++++++++++++++ test/module/vendor/grpc_mocks.hpp | 23 +- test/system/irohad_test.cpp | 2 +- 9 files changed, 470 insertions(+), 82 deletions(-) create mode 100644 test/module/irohad/torii/command_sync_client_test.cpp create mode 100644 test/module/irohad/torii/torii_transport_command_test.cpp diff --git a/irohad/torii/command_client.hpp b/irohad/torii/command_client.hpp index 7f3b4cdb31..85aaa8ad2d 100644 --- a/irohad/torii/command_client.hpp +++ b/irohad/torii/command_client.hpp @@ -24,12 +24,6 @@ namespace torii { size_t port, logger::Logger log = logger::log("CommandSyncClient")); - CommandSyncClient(const CommandSyncClient &); - CommandSyncClient &operator=(CommandSyncClient); - - CommandSyncClient(CommandSyncClient &&) noexcept; - CommandSyncClient &operator=(CommandSyncClient &&) noexcept; - /** * requests tx to a torii server and returns response (blocking, sync) * @param tx @@ -63,9 +57,6 @@ namespace torii { std::vector &response) const; private: - void swap(CommandSyncClient &lhs, CommandSyncClient &rhs); - std::string ip_; - size_t port_; std::unique_ptr stub_; logger::Logger log_; }; diff --git a/irohad/torii/impl/command_client.cpp b/irohad/torii/impl/command_client.cpp index f3b8f4241a..17d1dd3590 100644 --- a/irohad/torii/impl/command_client.cpp +++ b/irohad/torii/impl/command_client.cpp @@ -20,30 +20,10 @@ namespace torii { CommandSyncClient::CommandSyncClient(const std::string &ip, size_t port, logger::Logger log) - : ip_(ip), - port_(port), - stub_(iroha::network::createClient( + : stub_(iroha::network::createClient( ip + ":" + std::to_string(port))), log_(std::move(log)) {} - CommandSyncClient::CommandSyncClient(const CommandSyncClient &rhs) - : CommandSyncClient(rhs.ip_, rhs.port_, rhs.log_) {} - - CommandSyncClient &CommandSyncClient::operator=(CommandSyncClient rhs) { - swap(*this, rhs); - return *this; - } - - CommandSyncClient::CommandSyncClient(CommandSyncClient &&rhs) noexcept { - swap(*this, rhs); - } - - CommandSyncClient &CommandSyncClient::operator=( - CommandSyncClient &&rhs) noexcept { - swap(*this, rhs); - return *this; - } - grpc::Status CommandSyncClient::Torii(const Transaction &tx) const { google::protobuf::Empty a; grpc::ClientContext context; @@ -80,12 +60,4 @@ namespace torii { reader->Finish(); } - void CommandSyncClient::swap(CommandSyncClient &lhs, CommandSyncClient &rhs) { - using std::swap; - swap(lhs.ip_, rhs.ip_); - swap(lhs.port_, rhs.port_); - swap(lhs.stub_, rhs.stub_); - swap(lhs.log_, rhs.log_); - } - } // namespace torii diff --git a/irohad/torii/impl/command_service_transport_grpc.cpp b/irohad/torii/impl/command_service_transport_grpc.cpp index 098500acc6..3358ecc0a6 100644 --- a/irohad/torii/impl/command_service_transport_grpc.cpp +++ b/irohad/torii/impl/command_service_transport_grpc.cpp @@ -86,32 +86,22 @@ namespace torii { shared_model::interface::types::SharedTxsCollectionType CommandServiceTransportGrpc::deserializeTransactions( const iroha::protocol::TxList *request) { - return boost::copy_range< - shared_model::interface::types::SharedTxsCollectionType>( - request->transactions() - | boost::adaptors::transformed( - [&](const auto &tx) { return transaction_factory_->build(tx); }) - | boost::adaptors::filtered([&](const auto &result) { - return result.match( - [](const iroha::expected::Value< - std::unique_ptr> &) { - return true; - }, - [&](const iroha::expected::Error - &error) { - status_bus_->publish(status_factory_->makeStatelessFail( - error.error.hash, - shared_model::interface::TxStatusFactory:: - TransactionError{error.error.error, 0, 0})); - return false; - }); - }) - | boost::adaptors::transformed([&](auto result) { - return std::move( - boost::get>( - result)) - .value; - })); + shared_model::interface::types::SharedTxsCollectionType tx_collection; + for (const auto &tx : request->transactions()) { + transaction_factory_->build(tx).match( + [&tx_collection]( + iroha::expected::Value< + std::unique_ptr> &v) { + tx_collection.emplace_back(std::move(v).value); + }, + [this](iroha::expected::Error &error) { + status_bus_->publish(status_factory_->makeStatelessFail( + error.error.hash, + shared_model::interface::TxStatusFactory::TransactionError{ + error.error.error, 0, 0})); + }); + } + return tx_collection; } grpc::Status CommandServiceTransportGrpc::ListTorii( diff --git a/test/module/irohad/torii/CMakeLists.txt b/test/module/irohad/torii/CMakeLists.txt index fe361dfbe0..15da630d04 100644 --- a/test/module/irohad/torii/CMakeLists.txt +++ b/test/module/irohad/torii/CMakeLists.txt @@ -6,15 +6,10 @@ add_subdirectory(processor) # command service test -addtest(torii_service_test torii_service_test.cpp) -target_link_libraries(torii_service_test +addtest(torii_transport_command_test torii_transport_command_test.cpp) +target_link_libraries(torii_transport_command_test torii_service command_client - query_client - server_runner - processors - consensus_round - on_demand_common ) addtest(torii_queries_test torii_queries_test.cpp) @@ -38,3 +33,12 @@ target_link_libraries(torii_service_query_test server_runner query_client ) + +addtest(command_sync_client_test + command_sync_client_test.cpp + ) +target_link_libraries(command_sync_client_test + command_client + server_runner + endpoint + ) diff --git a/test/module/irohad/torii/command_sync_client_test.cpp b/test/module/irohad/torii/command_sync_client_test.cpp new file mode 100644 index 0000000000..b2d1518810 --- /dev/null +++ b/test/module/irohad/torii/command_sync_client_test.cpp @@ -0,0 +1,100 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "torii/command_client.hpp" + +#include +#include +#include "endpoint_mock.grpc.pb.h" +#include "main/server_runner.hpp" +#include "module/irohad/torii/torii_mocks.hpp" + +using testing::_; +using testing::Invoke; +using testing::Return; + +class CommandSyncClientTest : public testing::Test { + public: + void SetUp() override { + runner = std::make_unique(ip + ":0"); + server = std::make_shared(); + runner->append(server).run().match( + [this](iroha::expected::Value port) { this->port = port.value; }, + [](iroha::expected::Error err) { FAIL() << err.error; }); + } + + std::unique_ptr runner; + std::shared_ptr server; + + const std::string ip = "127.0.0.1"; + const size_t kHashLength = 32; + int port; +}; + +/** + * @given command client + * @when Status is called + * @then the same method of the server is called and client successfully return + */ +TEST_F(CommandSyncClientTest, Status) { + iroha::protocol::TxStatusRequest tx_request; + tx_request.set_tx_hash(std::string(kHashLength, '1')); + iroha::protocol::ToriiResponse toriiResponse; + + torii::CommandSyncClient client(ip, port); + EXPECT_CALL(*server, Status(_, _, _)).WillOnce(Return(grpc::Status::OK)); + auto stat = client.Status(tx_request, toriiResponse); + ASSERT_TRUE(stat.ok()); +} + +/** + * @given command client + * @when Torii is called + * @then the same method of the server is called and client successfully return + */ +TEST_F(CommandSyncClientTest, Torii) { + iroha::protocol::Transaction tx; + EXPECT_CALL(*server, Torii(_, _, _)).WillOnce(Return(grpc::Status())); + torii::CommandSyncClient client(ip, port); + auto stat = client.Torii(tx); + ASSERT_TRUE(stat.ok()); +} + +/** + * @given command client + * @when ListTorii is called + * @then the same method of the server is called and client successfully return + */ +TEST_F(CommandSyncClientTest, ListTorii) { + iroha::protocol::TxList tx; + EXPECT_CALL(*server, ListTorii(_, _, _)).WillOnce(Return(grpc::Status())); + torii::CommandSyncClient client(ip, port); + auto stat = client.ListTorii(tx); + ASSERT_TRUE(stat.ok()); +} + +/** + * @given command client + * @when StatusStream is called + * @then the same method of the server is called and client successfully return + */ +TEST_F(CommandSyncClientTest, StatusStream) { + iroha::protocol::TxStatusRequest tx; + iroha::protocol::ToriiResponse resp; + resp.set_tx_hash(std::string(kHashLength, '1')); + std::vector responses; + EXPECT_CALL(*server, StatusStream(_, _, _)) + .WillOnce(Invoke([&](auto, + auto, + grpc::ServerWriter + *response_writer) { + response_writer->Write(resp); + return grpc::Status(); + })); + torii::CommandSyncClient client(ip, port); + client.StatusStream(tx, responses); + ASSERT_EQ(responses.size(), 1); + ASSERT_EQ(responses[0].tx_hash(), resp.tx_hash()); +} diff --git a/test/module/irohad/torii/torii_mocks.hpp b/test/module/irohad/torii/torii_mocks.hpp index cdc4a72123..2bdfbcbded 100644 --- a/test/module/irohad/torii/torii_mocks.hpp +++ b/test/module/irohad/torii/torii_mocks.hpp @@ -8,8 +8,11 @@ #include +#include "endpoint.grpc.pb.h" +#include "endpoint.pb.h" #include "interfaces/query_responses/block_query_response.hpp" #include "interfaces/query_responses/query_response.hpp" +#include "torii/command_service.hpp" #include "torii/processor/query_processor.hpp" #include "torii/status_bus.hpp" @@ -33,6 +36,45 @@ namespace iroha { MOCK_METHOD1(publish, void(StatusBus::Objects)); MOCK_METHOD0(statuses, rxcpp::observable()); }; + + class MockCommandServiceTransport + : public iroha::protocol::CommandService_v1::Service { + public: + MOCK_METHOD3(Torii, + grpc::Status(grpc::ServerContext *, + const iroha::protocol::Transaction *, + google::protobuf::Empty *)); + MOCK_METHOD3(ListTorii, + grpc::Status(grpc::ServerContext *, + const iroha::protocol::TxList *, + google::protobuf::Empty *)); + MOCK_METHOD3(Status, + grpc::Status(grpc::ServerContext *, + const iroha::protocol::TxStatusRequest *, + iroha::protocol::ToriiResponse *)); + MOCK_METHOD3( + StatusStream, + grpc::Status(grpc::ServerContext *, + const iroha::protocol::TxStatusRequest *, + grpc::ServerWriter *)); + }; + + class MockCommandService : public ::torii::CommandService { + public: + MOCK_METHOD1(handleTransactionBatch, + void(std::shared_ptr< + shared_model::interface::TransactionBatch> batch)); + MOCK_METHOD1( + getStatus, + std::shared_ptr( + const shared_model::crypto::Hash &request)); + MOCK_METHOD1( + getStatusStream, + rxcpp::observable< + std::shared_ptr>( + const shared_model::crypto::Hash &hash)); + }; + } // namespace torii } // namespace iroha diff --git a/test/module/irohad/torii/torii_transport_command_test.cpp b/test/module/irohad/torii/torii_transport_command_test.cpp new file mode 100644 index 0000000000..11c9fe4004 --- /dev/null +++ b/test/module/irohad/torii/torii_transport_command_test.cpp @@ -0,0 +1,286 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "torii/impl/command_service_transport_grpc.hpp" + +#include +#include +#include +#include + +#include "backend/protobuf/proto_transport_factory.hpp" +#include "backend/protobuf/proto_tx_status_factory.hpp" +#include "backend/protobuf/transaction.hpp" +#include "cryptography/public_key.hpp" +#include "endpoint.pb.h" +#include "endpoint_mock.grpc.pb.h" +#include "interfaces/iroha_internal/transaction_batch.hpp" +#include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp" +#include "interfaces/iroha_internal/transaction_batch_parser_impl.hpp" +#include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" +#include "module/irohad/torii/torii_mocks.hpp" +#include "module/shared_model/interface/mock_transaction_batch_factory.hpp" +#include "module/shared_model/validators/validators.hpp" +#include "module/vendor/grpc_mocks.hpp" +#include "torii/impl/status_bus_impl.hpp" +#include "validators/protobuf/proto_transaction_validator.hpp" + +using ::testing::_; +using ::testing::A; +using ::testing::Invoke; +using ::testing::Property; +using ::testing::Return; +using ::testing::StrEq; + +using namespace iroha::ametsuchi; +using namespace iroha::torii; + +using namespace std::chrono_literals; +constexpr std::chrono::milliseconds initial_timeout = 1s; +constexpr std::chrono::milliseconds nonfinal_timeout = 2 * 10s; + +class CommandServiceTransportGrpcTest : public testing::Test { + private: + using ProtoTxTransportFactory = shared_model::proto::ProtoTransportFactory< + shared_model::interface::Transaction, + shared_model::proto::Transaction>; + using TxTransportFactory = shared_model::interface::AbstractTransportFactory< + shared_model::interface::Transaction, + shared_model::proto::Transaction::TransportType>; + using MockTxValidator = shared_model::validation::MockValidator< + shared_model::interface::Transaction>; + using MockProtoTxValidator = + shared_model::validation::MockValidator; + + public: + /** + * Initialize factory dependencies + */ + void init() { + status_factory = + std::make_shared(); + + auto validator = std::make_unique(); + tx_validator = validator.get(); + auto proto_validator = std::make_unique(); + proto_tx_validator = proto_validator.get(); + transaction_factory = std::make_shared( + std::move(validator), std::move(proto_validator)); + + batch_parser = + std::make_shared(); + batch_factory = std::make_shared(); + } + + void SetUp() override { + init(); + + status_bus = std::make_shared(); + command_service = std::make_shared(); + + transport_grpc = std::make_shared( + command_service, + status_bus, + initial_timeout, + nonfinal_timeout, + status_factory, + transaction_factory, + batch_parser, + batch_factory); + } + + std::shared_ptr status_bus; + const MockTxValidator *tx_validator; + const MockProtoTxValidator *proto_tx_validator; + + std::shared_ptr transaction_factory; + std::shared_ptr batch_parser; + std::shared_ptr batch_factory; + + std::shared_ptr status_factory; + + std::shared_ptr command_service; + std::shared_ptr transport_grpc; + + const size_t kHashLength = 32; + const size_t kTimes = 5; +}; + +/** + * @given torii service + * @when transaction status for given hash is requested + * @then protobuf message with corresponding hash and status is returned + */ +TEST_F(CommandServiceTransportGrpcTest, Status) { + grpc::ServerContext context; + + iroha::protocol::TxStatusRequest tx_request; + const shared_model::crypto::Hash hash(std::string(kHashLength, '1')); + tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); + + iroha::protocol::ToriiResponse toriiResponse; + std::shared_ptr response = + status_factory->makeEnoughSignaturesCollected(hash, {}); + + EXPECT_CALL(*command_service, getStatus(hash)).WillOnce(Return(response)); + + transport_grpc->Status(&context, &tx_request, &toriiResponse); + + ASSERT_EQ(toriiResponse.tx_status(), + iroha::protocol::TxStatus::ENOUGH_SIGNATURES_COLLECTED); +} + +/** + * @given torii service and number of transactions + * @when calling ListTorii + * @then ensure that CommandService called handleTransactionBatch as the tx num + */ +TEST_F(CommandServiceTransportGrpcTest, ListTorii) { + grpc::ServerContext context; + google::protobuf::Empty response; + + iroha::protocol::TxList request; + for (size_t i = 0; i < kTimes; ++i) { + request.add_transactions(); + } + + EXPECT_CALL(*proto_tx_validator, validate(_)) + .Times(kTimes) + .WillRepeatedly(Return(shared_model::validation::Answer{})); + EXPECT_CALL(*tx_validator, validate(_)) + .Times(kTimes) + .WillRepeatedly(Return(shared_model::validation::Answer{})); + EXPECT_CALL( + *batch_factory, + createTransactionBatch( + A())) + .Times(kTimes); + + EXPECT_CALL(*command_service, handleTransactionBatch(_)).Times(kTimes); + transport_grpc->ListTorii(&context, &request, &response); +} + +/** + * @given torii service and number of invalid transactions + * @when calling ListTorii + * @then ensure that CommandService haven't called handleTransactionBatch + * and StatusBus update status tx num times + */ +TEST_F(CommandServiceTransportGrpcTest, ListToriiInvalid) { + grpc::ServerContext context; + google::protobuf::Empty response; + + iroha::protocol::TxList request; + for (size_t i = 0; i < kTimes; ++i) { + request.add_transactions(); + } + + shared_model::validation::Answer error; + error.addReason(std::make_pair("some error", std::vector{})); + EXPECT_CALL(*proto_tx_validator, validate(_)) + .Times(kTimes) + .WillRepeatedly(Return(shared_model::validation::Answer{})); + EXPECT_CALL(*tx_validator, validate(_)) + .Times(kTimes) + .WillRepeatedly(Return(error)); + EXPECT_CALL(*command_service, handleTransactionBatch(_)).Times(0); + EXPECT_CALL(*status_bus, publish(_)).Times(kTimes); + + transport_grpc->ListTorii(&context, &request, &response); +} + +/** + * @given torii service + * and some number of valid transactions + * and one stateless invalid tx + * @when calling ListTorii + * @then handleTransactionBatch is called kTimes - 1 times + * and statelessInvalid status is published for invalid transaction + */ +TEST_F(CommandServiceTransportGrpcTest, ListToriiPartialInvalid) { + grpc::ServerContext context; + google::protobuf::Empty response; + const std::string kError = "some error"; + + iroha::protocol::TxList request{}; + for (size_t i = 0; i < kTimes; ++i) { + request.add_transactions(); + } + + size_t counter = 0; + EXPECT_CALL(*proto_tx_validator, validate(_)) + .Times(kTimes) + .WillRepeatedly(Return(shared_model::validation::Answer{})); + EXPECT_CALL(*tx_validator, validate(_)) + .Times(kTimes) + .WillRepeatedly(Invoke([this, &counter, kError](const auto &) mutable { + shared_model::validation::Answer res; + if (counter++ == kTimes - 1) { + res.addReason(std::make_pair(kError, std::vector{})); + } + return res; + })); + EXPECT_CALL( + *batch_factory, + createTransactionBatch( + A())) + .Times(kTimes - 1); + + EXPECT_CALL(*command_service, handleTransactionBatch(_)).Times(kTimes - 1); + EXPECT_CALL(*status_bus, publish(_)).WillOnce(Invoke([&kError](auto status) { + EXPECT_THAT(status->statelessErrorOrCommandName(), + testing::HasSubstr(kError)); + })); + + transport_grpc->ListTorii(&context, &request, &response); +} + +/** + * @given torii service and command_service with empty status stream + * @when calling StatusStream on transport + * @then Ok status is eventually returned without any fault + * and nothing is written to the status stream + */ +TEST_F(CommandServiceTransportGrpcTest, StatusStreamEmpty) { + grpc::ServerContext context; + iroha::protocol::TxStatusRequest request; + + EXPECT_CALL(*command_service, getStatusStream(_)) + .WillOnce(Return(rxcpp::observable<>::empty>())); + + ASSERT_TRUE(transport_grpc->StatusStream(&context, &request, nullptr).ok()); +} + +/** + * @given torii service with changed timeout, a transaction + * and a status stream with one NotRecieved status + * @when calling StatusStream + * @then ServerWriter calls Write method + */ +TEST_F(CommandServiceTransportGrpcTest, StatusStreamOnNotReceived) { + grpc::ServerContext context; + iroha::protocol::TxStatusRequest request; + iroha::MockServerWriter response_writer; + std::vector> + responses; + shared_model::crypto::Hash hash("1"); + responses.emplace_back(status_factory->makeNotReceived(hash, {})); + EXPECT_CALL(*command_service, getStatusStream(_)) + .WillOnce(Return(rxcpp::observable<>::iterate(responses))); + EXPECT_CALL(response_writer, + Write(Property(&iroha::protocol::ToriiResponse::tx_hash, + StrEq(shared_model::crypto::toBinaryString(hash))), + _)) + .WillOnce(Return(true)); + ASSERT_TRUE(transport_grpc + ->StatusStream( + &context, + &request, + reinterpret_cast< + grpc::ServerWriter *>( + &response_writer)) + .ok()); +} diff --git a/test/module/vendor/grpc_mocks.hpp b/test/module/vendor/grpc_mocks.hpp index b60025328e..cffdb5a946 100644 --- a/test/module/vendor/grpc_mocks.hpp +++ b/test/module/vendor/grpc_mocks.hpp @@ -3,18 +3,21 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef IROHA_GRPC_MOCKS_HPP -#define IROHA_GRPC_MOCKS_HPP +#ifndef VENDOR_GRPC_MOCKS_HPP +#define VENDOR_GRPC_MOCKS_HPP -namespace testing { - class MockServerWriter - : public grpc::ServerWriterInterface { - MOCK_METHOD1(Write, void(iroha::protocol::Block)); - MOCK_METHOD2(Write, - bool(const iroha::protocol::Block &, grpc::WriteOptions)); +#include +#include + +namespace iroha { + template + class MockServerWriter : public grpc::ServerWriterInterface { + public: + MOCK_METHOD1_T(Write, void(T)); + MOCK_METHOD2_T(Write, bool(const T &, grpc::WriteOptions)); MOCK_METHOD0(SendInitialMetadata, void()); MOCK_METHOD1(NextMessageSize, bool(uint32_t *)); }; -} // namespace testing +} // namespace iroha -#endif // IROHA_GRPC_MOCKS_HPP +#endif // VENDOR_GRPC_MOCKS_HPP diff --git a/test/system/irohad_test.cpp b/test/system/irohad_test.cpp index 50fbd45e7c..8c962e1ca6 100644 --- a/test/system/irohad_test.cpp +++ b/test/system/irohad_test.cpp @@ -146,7 +146,7 @@ class IrohadTest : public AcceptanceFixture { complete(baseTx(kAdminId).setAccountQuorum(kAdminId, 1), key_pair); tx_request.set_tx_hash(shared_model::crypto::toBinaryString(tx.hash())); - auto client = torii::CommandSyncClient(kAddress, kPort); + torii::CommandSyncClient client(kAddress, kPort); client.Torii(tx.getTransport()); auto resub_counter(resubscribe_attempts); From 0c373792a7a21afca6f5644013457238af01b43f Mon Sep 17 00:00:00 2001 From: Andrei Lebedev Date: Thu, 27 Dec 2018 17:07:00 +0300 Subject: [PATCH 46/61] irohad and iroha-cli MSVC build (#1988) Signed-off-by: Andrei Lebedev --- CMakeLists.txt | 25 ++++- cmake/Modules/Findgflags.cmake | 7 +- cmake/Modules/Findgrpc.cmake | 7 +- cmake/Modules/Findpq.cmake | 39 +++++-- cmake/Modules/Findsoci.cmake | 11 +- cmake/dependencies.cmake | 101 ++++++++++++++++-- cmake/functions.cmake | 13 ++- example/config-win.sample | 11 ++ example/genesis.block | 2 +- .../interactive/impl/interactive_cli.cpp | 8 +- .../interactive/interactive_common_cli.hpp | 4 +- iroha-cli/validators.cpp | 1 + irohad/ametsuchi/impl/flat_file/flat_file.cpp | 8 +- irohad/ametsuchi/impl/postgres_options.cpp | 4 +- ...gres_ordering_service_persistent_state.cpp | 2 +- irohad/ametsuchi/impl/postgres_wsv_query.cpp | 37 ++++--- irohad/ametsuchi/impl/soci_utils.hpp | 6 +- irohad/ametsuchi/impl/storage_impl.cpp | 18 ++-- irohad/ametsuchi/wsv_query.hpp | 2 +- irohad/consensus/impl/gate_object.cpp | 12 +-- irohad/consensus/impl/round.cpp | 3 +- irohad/consensus/yac/yac_hash_provider.hpp | 1 + irohad/main/impl/on_demand_ordering_init.cpp | 4 +- irohad/main/irohad.cpp | 7 +- irohad/model/impl/model_operators.cpp | 3 + .../impl/on_demand_connection_manager.cpp | 1 + .../impl/on_demand_ordering_service_impl.cpp | 1 + .../impl/on_demand_os_client_grpc.cpp | 2 + .../impl/on_demand_os_server_grpc.cpp | 2 +- .../impl/ordering_gate_transport_grpc.cpp | 1 + .../impl/ordering_service_transport_grpc.cpp | 1 + libs/common/bind.hpp | 1 + libs/common/files.cpp | 3 +- libs/parser/parser.cpp | 5 +- libs/parser/parser.hpp | 3 +- .../protobuf/impl/proto_block_factory.cpp | 1 + .../impl/proto_query_response.cpp | 2 +- .../interfaces/commands/impl/command.cpp | 10 +- .../interfaces/queries/impl/query.cpp | 10 +- .../query_responses/impl/query_response.cpp | 10 +- .../impl/tx_response.cpp | 10 +- 41 files changed, 297 insertions(+), 102 deletions(-) create mode 100644 example/config-win.sample diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a94495eb0..7e8db37479 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,12 +12,31 @@ endif() PROJECT(iroha C CXX) SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE) -SET(CMAKE_CXX_FLAGS "-std=c++14 -Wall -fdiagnostics-color=always") -SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-error=deprecated-declarations") -SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -O0") +if (NOT MSVC) + SET(CMAKE_CXX_FLAGS "-std=c++14 -Wall -fdiagnostics-color=always") + SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-error=deprecated-declarations") + SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -O0") +endif() SET(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1) SET(CMAKE_INSTALL_RPATH "../lib") +if(WIN32) + # We have to set _WIN32_WINNT for gRPC + if(${CMAKE_SYSTEM_VERSION} EQUAL 10) # Windows 10 + add_definitions(-D _WIN32_WINNT=0x0A00) + elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.3) # Windows 8.1 + add_definitions(-D _WIN32_WINNT=0x0603) + elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.2) # Windows 8 + add_definitions(-D _WIN32_WINNT=0x0602) + elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.1) # Windows 7 + add_definitions(-D _WIN32_WINNT=0x0601) + elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.0) # Windows Vista + add_definitions(-D _WIN32_WINNT=0x0600) + else() # Windows XP (5.1) + add_definitions(-D _WIN32_WINNT=0x0501) + endif() +endif() + if(COVERAGE) find_program(LCOV_PROGRAM lcov) if(NOT LCOV_PROGRAM) diff --git a/cmake/Modules/Findgflags.cmake b/cmake/Modules/Findgflags.cmake index 3d3c375cfb..7af7c3df12 100644 --- a/cmake/Modules/Findgflags.cmake +++ b/cmake/Modules/Findgflags.cmake @@ -36,5 +36,10 @@ endif () set_target_properties(gflags PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${gflags_INCLUDE_DIR} IMPORTED_LOCATION ${gflags_LIBRARY} - INTERFACE_LINK_LIBRARIES "pthread" ) + +if (NOT MSVC) + set_target_properties(gflags PROPERTIES + INTERFACE_LINK_LIBRARIES "pthread" + ) +endif () diff --git a/cmake/Modules/Findgrpc.cmake b/cmake/Modules/Findgrpc.cmake index a9fd9923e3..0e0dd5b3f4 100644 --- a/cmake/Modules/Findgrpc.cmake +++ b/cmake/Modules/Findgrpc.cmake @@ -75,10 +75,15 @@ endif () set_target_properties(grpc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${grpc_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES "pthread;dl" IMPORTED_LOCATION ${grpc_LIBRARY} ) +if (NOT MSVC) + set_target_properties(grpc PROPERTIES + INTERFACE_LINK_LIBRARIES "pthread;dl" + ) +endif () + set_target_properties(grpc++ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${grpc_INCLUDE_DIR} INTERFACE_LINK_LIBRARIES grpc diff --git a/cmake/Modules/Findpq.cmake b/cmake/Modules/Findpq.cmake index 2a018af746..b20f6c6c45 100644 --- a/cmake/Modules/Findpq.cmake +++ b/cmake/Modules/Findpq.cmake @@ -7,17 +7,29 @@ mark_as_advanced(pq_INCLUDE_DIR) find_path(postgres_INCLUDE_DIR postgres_ext.h PATH_SUFFIXES postgresql) mark_as_advanced(postgres_INCLUDE_DIR) -find_library(pq_LIBRARY pq) +# Windows libraries are usually not prefixed with 'lib', however this library +# has such a prefix, therefore we need to search for libpq instead of pq on +# Windows +find_library(pq_LIBRARY NAMES pq libpq) mark_as_advanced(pq_LIBRARY) -find_program(pg_config_EXECUTABLE pg_config) -mark_as_advanced(pg_config_EXECUTABLE) +# Debug library has 'd' suffix on Windows +if (MSVC) + find_library(pqd_LIBRARY NAMES pqd libpqd) + mark_as_advanced(pqd_LIBRARY) +endif () + +if (NOT MSVC) + find_program(pg_config_EXECUTABLE pg_config) + mark_as_advanced(pg_config_EXECUTABLE) + set(pg_config_REQUIRED pg_config_EXECUTABLE) +endif () find_package_handle_standard_args(pq DEFAULT_MSG pq_INCLUDE_DIR postgres_INCLUDE_DIR pq_LIBRARY - pg_config_EXECUTABLE + ${pg_config_REQUIRED} ) set(URL https://git.postgresql.org/git/postgresql.git) @@ -50,17 +62,26 @@ endif () get_filename_component(pq_LIBRARY_DIR ${pq_LIBRARY} DIRECTORY) mark_as_advanced(pq_LIBRARY_DIR) -get_filename_component(pg_config_EXECUTABLE_DIR ${pg_config_EXECUTABLE} DIRECTORY) -mark_as_advanced(pg_config_EXECUTABLE_DIR) +if (MSVC) + set_target_properties(pq PROPERTIES + IMPORTED_LOCATION_DEBUG ${pqd_LIBRARY} + IMPORTED_LOCATION_RELEASE ${pq_LIBRARY} + ) +endif () set_target_properties(pq PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${pq_INCLUDE_DIR};${postgres_INCLUDE_DIR}" IMPORTED_LOCATION ${pq_LIBRARY} ) -set_target_properties(pg_config PROPERTIES - IMPORTED_LOCATION ${pg_config_EXECUTABLE} - ) +if (NOT MSVC) + get_filename_component(pg_config_EXECUTABLE_DIR ${pg_config_EXECUTABLE} DIRECTORY) + mark_as_advanced(pg_config_EXECUTABLE_DIR) + + set_target_properties(pg_config PROPERTIES + IMPORTED_LOCATION ${pg_config_EXECUTABLE} + ) +endif () if(ENABLE_LIBS_PACKAGING) add_install_step_for_lib(${pq_LIBRARY}) diff --git a/cmake/Modules/Findsoci.cmake b/cmake/Modules/Findsoci.cmake index 4b5c891c51..897ff40d46 100644 --- a/cmake/Modules/Findsoci.cmake +++ b/cmake/Modules/Findsoci.cmake @@ -14,14 +14,14 @@ mark_as_advanced(SOCI_INCLUDE_DIRS) find_library( SOCI_LIBRARY - NAMES soci_core + NAMES soci_core soci_core_3_2 HINTS ${SOCI_INCLUDE_DIR}/.. PATH_SUFFIXES lib${LIB_SUFFIX}) mark_as_advanced(SOCI_LIBRARY) find_library( SOCI_postgresql_PLUGIN - NAMES soci_postgresql + NAMES soci_postgresql soci_postgresql_3_2 HINTS ${SOCI_INCLUDE_DIR}/.. PATH_SUFFIXES lib${LIB_SUFFIX}) mark_as_advanced(SOCI_postgresql_PLUGIN) @@ -76,9 +76,14 @@ endif () set_target_properties(SOCI::core PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIRS}" IMPORTED_LOCATION "${SOCI_LIBRARY}" - INTERFACE_LINK_LIBRARIES dl ) +if (NOT MSVC) + set_target_properties(SOCI::core PROPERTIES + INTERFACE_LINK_LIBRARIES dl + ) +endif () + set_target_properties(SOCI::postgresql PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIRS}" IMPORTED_LOCATION "${SOCI_postgresql_PLUGIN}" diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 854b22b768..0d4259ef3c 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -27,13 +27,73 @@ find_package(spdlog) # protobuf # ################################ option(FIND_PROTOBUF "Try to find protobuf in system" ON) -find_package(protobuf) +if (MSVC) + find_package(Protobuf REQUIRED CONFIG) + add_library(protobuf INTERFACE IMPORTED) + target_link_libraries(protobuf INTERFACE + protobuf::libprotobuf + ) + + get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf + INTERFACE_INCLUDE_DIRECTORIES) + + get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc + IMPORTED_LOCATION_RELEASE) + if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") + get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc + IMPORTED_LOCATION_DEBUG) + endif() + if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") + get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc + IMPORTED_LOCATION_NOCONFIG) + endif() + + add_executable(protoc IMPORTED) + set_target_properties(protoc PROPERTIES + IMPORTED_LOCATION ${Protobuf_PROTOC_EXECUTABLE} + ) +else () + find_package(protobuf) +endif() ######################### # gRPC # ######################### option(FIND_GRPC "Try to find gRPC in system" ON) -find_package(grpc) +if (MSVC) + find_package(gRPC REQUIRED CONFIG) + + add_library(grpc INTERFACE IMPORTED) + target_link_libraries(grpc INTERFACE + gRPC::grpc + ) + add_library(grpc++ INTERFACE IMPORTED) + target_link_libraries(grpc++ INTERFACE + gRPC::grpc++ + ) + add_library(gpr INTERFACE IMPORTED) + target_link_libraries(gpr INTERFACE + gRPC::gpr + ) + + get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin + IMPORTED_LOCATION_RELEASE) + if(NOT EXISTS "${gRPC_CPP_PLUGIN_EXECUTABLE}") + get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin + IMPORTED_LOCATION_DEBUG) + endif() + if(NOT EXISTS "${gRPC_CPP_PLUGIN_EXECUTABLE}") + get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin + IMPORTED_LOCATION_NOCONFIG) + endif() + + add_executable(grpc_cpp_plugin IMPORTED) + set_target_properties(grpc_cpp_plugin PROPERTIES + IMPORTED_LOCATION ${gRPC_CPP_PLUGIN_EXECUTABLE} + ) +else () + find_package(grpc) +endif() ################################ # rapidjson # @@ -53,7 +113,11 @@ find_package(soci) ################################ # gflags # ################################ -find_package(gflags) +if (MSVC) + find_package(gflags REQUIRED CONFIG) +else () + find_package(gflags) +endif() ########################## # rx c++ # @@ -63,7 +127,15 @@ find_package(rxcpp) ########################## # TBB # ########################## -find_package(tbb) +if (MSVC) + find_package(TBB REQUIRED CONFIG) + add_library(tbb INTERFACE IMPORTED) + target_link_libraries(tbb INTERFACE + TBB::tbb + ) +else () + find_package(tbb) +endif() ########################## # boost # @@ -74,12 +146,21 @@ find_package(Boost 1.65.0 REQUIRED system thread ) - -add_library(boost INTERFACE IMPORTED) -set_target_properties(boost PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS} - INTERFACE_LINK_LIBRARIES "${Boost_LIBRARIES}" - ) +if (MSVC) + add_library(boost INTERFACE IMPORTED) + target_link_libraries(boost INTERFACE + Boost::boost + Boost::filesystem + Boost::system + Boost::thread + ) +else () + add_library(boost INTERFACE IMPORTED) + set_target_properties(boost PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS} + INTERFACE_LINK_LIBRARIES "${Boost_LIBRARIES}" + ) +endif() if(ENABLE_LIBS_PACKAGING) foreach (library ${Boost_LIBRARIES}) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 64179cc28a..574e1b6dc6 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -88,10 +88,19 @@ function(compile_proto_only_grpc_to_cpp PROTO) string(REGEX REPLACE "\\.proto$" "_mock.grpc.pb.h" GEN_GRPC_PB_MOCK_HEADER ${PROTO}) set(TEST_OUTPUT ${SCHEMA_OUT_DIR}/${GEN_GRPC_PB_MOCK_HEADER}) endif(TESTING) + if (MSVC) + set(GEN_COMMAND "${Protobuf_PROTOC_EXECUTABLE}") + set(GEN_ARGS ${Protobuf_INCLUDE_DIR}) + set(GEN_PLUGIN "${gRPC_CPP_PLUGIN_EXECUTABLE}") + else() + set(GEN_COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${protobuf_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH} "${protoc_EXECUTABLE}") + set(GEN_ARGS ${protobuf_INCLUDE_DIR}) + set(GEN_PLUGIN "${grpc_CPP_PLUGIN}") + endif() add_custom_command( OUTPUT ${SCHEMA_OUT_DIR}/${GEN_GRPC_PB_HEADER} ${SCHEMA_OUT_DIR}/${GEN_GRPC_PB} ${TEST_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${protobuf_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH} "${protoc_EXECUTABLE}" - ARGS -I${protobuf_INCLUDE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR} ${ARGN} --grpc_out=${GENERATE_MOCKS}${SCHEMA_OUT_DIR} --plugin=protoc-gen-grpc="${grpc_CPP_PLUGIN}" ${PROTO} + COMMAND ${GEN_COMMAND} + ARGS -I${GEN_ARGS} -I${CMAKE_CURRENT_SOURCE_DIR} ${ARGN} --grpc_out=${GENERATE_MOCKS}${SCHEMA_OUT_DIR} --plugin=protoc-gen-grpc=${GEN_PLUGIN} ${PROTO} DEPENDS grpc_cpp_plugin ${SCHEMA_PATH}/${PROTO} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) diff --git a/example/config-win.sample b/example/config-win.sample new file mode 100644 index 0000000000..7100d8a9bc --- /dev/null +++ b/example/config-win.sample @@ -0,0 +1,11 @@ +{ + "block_store_path" : "C:\\block_store", + "torii_port" : 50051, + "internal_port" : 10001, + "pg_opt" : "host=localhost port=5432 user=postgres password=mysecretpassword", + "max_proposal_size" : 10, + "proposal_delay" : 5000, + "vote_delay" : 5000, + "mst_enable" : false +} + diff --git a/example/genesis.block b/example/genesis.block index ff3f993787..3148bfc034 100644 --- a/example/genesis.block +++ b/example/genesis.block @@ -9,7 +9,7 @@ { "addPeer":{ "peer":{ - "address":"0.0.0.0:10001", + "address":"127.0.0.1:10001", "peerKey":"vd1YQE0TFeDrJ5AsXXyOsGAsFiOPAFdz30BrwZEwiSk=" } } diff --git a/iroha-cli/interactive/impl/interactive_cli.cpp b/iroha-cli/interactive/impl/interactive_cli.cpp index 9220e76b4f..3b4bd5a5b0 100644 --- a/iroha-cli/interactive/impl/interactive_cli.cpp +++ b/iroha-cli/interactive/impl/interactive_cli.cpp @@ -3,10 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include - #include "interactive/interactive_cli.hpp" +#include +#include + namespace iroha_cli { namespace interactive { @@ -35,8 +36,7 @@ namespace iroha_cli { uint64_t qry_counter, const std::shared_ptr &provider) : creator_(account_name), - tx_cli_( - creator_, default_peer_ip, default_port, provider), + tx_cli_(creator_, default_peer_ip, default_port, provider), query_cli_( creator_, default_peer_ip, default_port, qry_counter, provider), statusCli_(default_peer_ip, default_port) { diff --git a/iroha-cli/interactive/interactive_common_cli.hpp b/iroha-cli/interactive/interactive_common_cli.hpp index e97d9c16cd..e4a4fae7fe 100644 --- a/iroha-cli/interactive/interactive_common_cli.hpp +++ b/iroha-cli/interactive/interactive_common_cli.hpp @@ -7,13 +7,15 @@ #define IROHA_CLI_INTERACTIVE_COMMON_CLI_HPP #include -#include +#include #include #include #include #include #include +#include + namespace parser { boost::optional parseFirstCommand(std::string line); } diff --git a/iroha-cli/validators.cpp b/iroha-cli/validators.cpp index 4abe45178e..b416450189 100644 --- a/iroha-cli/validators.cpp +++ b/iroha-cli/validators.cpp @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include diff --git a/irohad/ametsuchi/impl/flat_file/flat_file.cpp b/irohad/ametsuchi/impl/flat_file/flat_file.cpp index b9833db508..4bd9aa11ba 100644 --- a/irohad/ametsuchi/impl/flat_file/flat_file.cpp +++ b/irohad/ametsuchi/impl/flat_file/flat_file.cpp @@ -5,12 +5,14 @@ #include "ametsuchi/impl/flat_file/flat_file.hpp" -#include -#include -#include +#include #include #include #include + +#include +#include +#include #include "common/files.hpp" using namespace iroha::ametsuchi; diff --git a/irohad/ametsuchi/impl/postgres_options.cpp b/irohad/ametsuchi/impl/postgres_options.cpp index cb5439f4c5..7a6290a5b1 100644 --- a/irohad/ametsuchi/impl/postgres_options.cpp +++ b/irohad/ametsuchi/impl/postgres_options.cpp @@ -5,9 +5,11 @@ #include "ametsuchi/impl/postgres_options.hpp" -#include +#include #include +#include + namespace iroha { namespace ametsuchi { diff --git a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp index f045488d83..e9501e25d9 100644 --- a/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp +++ b/irohad/ametsuchi/impl/postgres_ordering_service_persistent_state.cpp @@ -29,7 +29,7 @@ namespace iroha { std::unique_ptr sql; try { sql = - std::make_unique(soci::postgresql, postgres_options); + std::make_unique(*soci::factory_postgresql(), postgres_options); } catch (std::exception &e) { return expected::makeError( diff --git a/irohad/ametsuchi/impl/postgres_wsv_query.cpp b/irohad/ametsuchi/impl/postgres_wsv_query.cpp index 89da2a87bc..9d2cf0f4e0 100644 --- a/irohad/ametsuchi/impl/postgres_wsv_query.cpp +++ b/irohad/ametsuchi/impl/postgres_wsv_query.cpp @@ -87,7 +87,7 @@ namespace iroha { soci::use(perm_str, "permission")); }); - return flatMapValue( + return flatMapValue>( result, [](auto &count) { return boost::make_optional(count == 1); }) .value_or(false); @@ -150,7 +150,8 @@ namespace iroha { soci::use(account_id, "account_id")); }); - return flatMapValue( + return flatMapValue< + boost::optional>>( result, [&](auto &domain_id, auto quorum, auto &data) { return this->fromResult( factory_->createAccount(account_id, domain_id, quorum, data)); @@ -218,7 +219,7 @@ namespace iroha { }); } - return flatMapValue( + return flatMapValue>( result, [&](auto &json) { return boost::make_optional(json); }); } @@ -249,10 +250,12 @@ namespace iroha { soci::use(asset_id)); }); - return flatMapValue(result, [&](auto &domain_id, auto precision) { - return this->fromResult( - factory_->createAsset(asset_id, domain_id, precision)); - }); + return flatMapValue< + boost::optional>>( + result, [&](auto &domain_id, auto precision) { + return this->fromResult( + factory_->createAsset(asset_id, domain_id, precision)); + }); } boost::optional< @@ -287,10 +290,12 @@ namespace iroha { soci::use(asset_id)); }); - return flatMapValue(result, [&](auto &amount) { - return this->fromResult(factory_->createAccountAsset( - account_id, asset_id, shared_model::interface::Amount(amount))); - }); + return flatMapValue>>( + result, [&](auto &amount) { + return this->fromResult(factory_->createAccountAsset( + account_id, asset_id, shared_model::interface::Amount(amount))); + }); } boost::optional> @@ -302,10 +307,12 @@ namespace iroha { soci::use(domain_id)); }); - return flatMapValue(result, [&](auto &default_role) { - return this->fromResult( - factory_->createDomain(domain_id, default_role)); - }); + return flatMapValue< + boost::optional>>( + result, [&](auto &default_role) { + return this->fromResult( + factory_->createDomain(domain_id, default_role)); + }); } boost::optional>> diff --git a/irohad/ametsuchi/impl/soci_utils.hpp b/irohad/ametsuchi/impl/soci_utils.hpp index 346ebd003d..5947d75744 100644 --- a/irohad/ametsuchi/impl/soci_utils.hpp +++ b/irohad/ametsuchi/impl/soci_utils.hpp @@ -142,11 +142,9 @@ namespace iroha { }; } - template + template auto flatMapValue(T &t, F &&f) { - return t | [&](auto &st) -> decltype( - apply(boost::make_iterator_range(st).front(), - std::forward(f))) { + return t | [&](auto &st) -> R { auto range = boost::make_iterator_range(st); if (range.empty()) { diff --git a/irohad/ametsuchi/impl/storage_impl.cpp b/irohad/ametsuchi/impl/storage_impl.cpp index 801be5b554..634400760a 100644 --- a/irohad/ametsuchi/impl/storage_impl.cpp +++ b/irohad/ametsuchi/impl/storage_impl.cpp @@ -7,7 +7,6 @@ #include #include - #include "ametsuchi/impl/flat_file/flat_file.hpp" #include "ametsuchi/impl/mutable_storage_impl.hpp" #include "ametsuchi/impl/peer_query_wsv.hpp" @@ -258,7 +257,7 @@ namespace iroha { std::unique_lock lock(drop_mutex); log_->info("Drop database {}", db); freeConnections(); - soci::session sql(soci::postgresql, + soci::session sql(*soci::factory_postgresql(), postgres_options_.optionsStringWithoutDbName()); // perform dropping try { @@ -299,7 +298,8 @@ namespace iroha { const std::string &dbname, const std::string &options_str_without_dbname) { try { - soci::session sql(soci::postgresql, options_str_without_dbname); + soci::session sql(*soci::factory_postgresql(), + options_str_without_dbname); int size; std::string name = dbname; @@ -342,12 +342,16 @@ namespace iroha { size_t pool_size) { auto pool = std::make_shared(pool_size); - for (size_t i = 0; i != pool_size; i++) { - soci::session &session = pool->at(i); - session.open(soci::postgresql, options_str); + try { + for (size_t i = 0; i != pool_size; i++) { + soci::session &session = pool->at(i); + session.open(*soci::factory_postgresql(), options_str); + } + } catch (const std::exception &e) { + return expected::makeError(e.what()); } return expected::makeValue(pool); - }; + } expected::Result, std::string> StorageImpl::create( diff --git a/irohad/ametsuchi/wsv_query.hpp b/irohad/ametsuchi/wsv_query.hpp index f0ebe45ce8..a498eb3d8c 100644 --- a/irohad/ametsuchi/wsv_query.hpp +++ b/irohad/ametsuchi/wsv_query.hpp @@ -6,10 +6,10 @@ #ifndef IROHA_WSV_QUERY_HPP #define IROHA_WSV_QUERY_HPP -#include #include #include +#include #include "interfaces/common_objects/account.hpp" #include "interfaces/common_objects/account_asset.hpp" #include "interfaces/common_objects/asset.hpp" diff --git a/irohad/consensus/impl/gate_object.cpp b/irohad/consensus/impl/gate_object.cpp index 1b67d69461..0ae0a6cd67 100644 --- a/irohad/consensus/impl/gate_object.cpp +++ b/irohad/consensus/impl/gate_object.cpp @@ -8,10 +8,10 @@ using GateObject = iroha::consensus::GateObject; template GateObject::~variant(); -template GateObject::variant(GateObject &&); +template GateObject::variant(GateObject &&) noexcept; template GateObject::variant(const GateObject &); -template void GateObject::destroy_content(); -template int GateObject::which() const; -template void GateObject::indicate_which(int); -template bool GateObject::using_backup() const; -template GateObject::convert_copy_into::convert_copy_into(void *); +template void GateObject::destroy_content() noexcept; +template int GateObject::which() const noexcept; +template void GateObject::indicate_which(int) noexcept; +template bool GateObject::using_backup() const noexcept; +template GateObject::convert_copy_into::convert_copy_into(void *) noexcept; diff --git a/irohad/consensus/impl/round.cpp b/irohad/consensus/impl/round.cpp index 8fe1b658d1..203c1b9233 100644 --- a/irohad/consensus/impl/round.cpp +++ b/irohad/consensus/impl/round.cpp @@ -5,10 +5,11 @@ #include "consensus/round.hpp" -#include +#include #include #include +#include #include "utils/string_builder.hpp" namespace iroha { diff --git a/irohad/consensus/yac/yac_hash_provider.hpp b/irohad/consensus/yac/yac_hash_provider.hpp index 07bfcb14c4..52c4475c4b 100644 --- a/irohad/consensus/yac/yac_hash_provider.hpp +++ b/irohad/consensus/yac/yac_hash_provider.hpp @@ -6,6 +6,7 @@ #ifndef IROHA_YAC_HASH_PROVIDER_HPP #define IROHA_YAC_HASH_PROVIDER_HPP +#include #include #include diff --git a/irohad/main/impl/on_demand_ordering_init.cpp b/irohad/main/impl/on_demand_ordering_init.cpp index 4bf0dd18a6..32a78a997a 100644 --- a/irohad/main/impl/on_demand_ordering_init.cpp +++ b/irohad/main/impl/on_demand_ordering_init.cpp @@ -193,7 +193,9 @@ namespace iroha { // reject_counter and local_counter are local mutable variables of lambda auto delay = [reject_counter = kCounter, local_counter = kCounter, - &time_generator](const auto &commit) mutable { + &time_generator, + // MSVC requires const variables to be captured + kMaxLocalCounter](const auto &commit) mutable { using iroha::synchronizer::SynchronizationOutcomeType; if (commit.sync_outcome == SynchronizationOutcomeType::kReject or commit.sync_outcome == SynchronizationOutcomeType::kNothing) { diff --git a/irohad/main/irohad.cpp b/irohad/main/irohad.cpp index 8a687d1385..6fa67362d6 100644 --- a/irohad/main/irohad.cpp +++ b/irohad/main/irohad.cpp @@ -3,11 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include #include #include #include + +#include +#include #include "common/result.hpp" #include "crypto/keys_manager_impl.hpp" #include "main/application.hpp" @@ -228,7 +229,9 @@ int main(int argc, char *argv[]) { auto handler = [](int s) { exit_requested.set_value(); }; std::signal(SIGINT, handler); std::signal(SIGTERM, handler); +#ifdef SIGQUIT std::signal(SIGQUIT, handler); +#endif // runs iroha log->info("Running iroha"); diff --git a/irohad/model/impl/model_operators.cpp b/irohad/model/impl/model_operators.cpp index 7eb5c70751..c756141f35 100644 --- a/irohad/model/impl/model_operators.cpp +++ b/irohad/model/impl/model_operators.cpp @@ -2,6 +2,9 @@ * Copyright Soramitsu Co., Ltd. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ + +#include + #include "common/instanceof.hpp" #include "model/block.hpp" #include "model/commands/add_asset_quantity.hpp" diff --git a/irohad/ordering/impl/on_demand_connection_manager.cpp b/irohad/ordering/impl/on_demand_connection_manager.cpp index 127a611e89..27c7971cd2 100644 --- a/irohad/ordering/impl/on_demand_connection_manager.cpp +++ b/irohad/ordering/impl/on_demand_connection_manager.cpp @@ -9,6 +9,7 @@ #include "interfaces/iroha_internal/proposal.hpp" #include "ordering/impl/on_demand_common.hpp" +using namespace iroha; using namespace iroha::ordering; OnDemandConnectionManager::OnDemandConnectionManager( diff --git a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp index 5679620966..fede5789a1 100644 --- a/irohad/ordering/impl/on_demand_ordering_service_impl.cpp +++ b/irohad/ordering/impl/on_demand_ordering_service_impl.cpp @@ -20,6 +20,7 @@ #include "interfaces/iroha_internal/transaction_batch.hpp" #include "interfaces/transaction.hpp" +using namespace iroha; using namespace iroha::ordering; OnDemandOrderingServiceImpl::OnDemandOrderingServiceImpl( diff --git a/irohad/ordering/impl/on_demand_os_client_grpc.cpp b/irohad/ordering/impl/on_demand_os_client_grpc.cpp index 262c2781c2..f61f34f0d8 100644 --- a/irohad/ordering/impl/on_demand_os_client_grpc.cpp +++ b/irohad/ordering/impl/on_demand_os_client_grpc.cpp @@ -11,6 +11,8 @@ #include "interfaces/iroha_internal/transaction_batch.hpp" #include "network/impl/grpc_channel_builder.hpp" +using namespace iroha; +using namespace iroha::ordering; using namespace iroha::ordering::transport; OnDemandOsClientGrpc::OnDemandOsClientGrpc( diff --git a/irohad/ordering/impl/on_demand_os_server_grpc.cpp b/irohad/ordering/impl/on_demand_os_server_grpc.cpp index 1d8225f5aa..f059d090c5 100644 --- a/irohad/ordering/impl/on_demand_os_server_grpc.cpp +++ b/irohad/ordering/impl/on_demand_os_server_grpc.cpp @@ -9,11 +9,11 @@ #include #include - #include "backend/protobuf/proposal.hpp" #include "common/bind.hpp" #include "interfaces/iroha_internal/transaction_batch.hpp" +using namespace iroha::ordering; using namespace iroha::ordering::transport; OnDemandOsServerGrpc::OnDemandOsServerGrpc( diff --git a/irohad/ordering/impl/ordering_gate_transport_grpc.cpp b/irohad/ordering/impl/ordering_gate_transport_grpc.cpp index 45d04998eb..a340a59943 100644 --- a/irohad/ordering/impl/ordering_gate_transport_grpc.cpp +++ b/irohad/ordering/impl/ordering_gate_transport_grpc.cpp @@ -10,6 +10,7 @@ #include "interfaces/common_objects/types.hpp" #include "network/impl/grpc_channel_builder.hpp" +using namespace iroha; using namespace iroha::ordering; grpc::Status OrderingGateTransportGrpc::onProposal( diff --git a/irohad/ordering/impl/ordering_service_transport_grpc.cpp b/irohad/ordering/impl/ordering_service_transport_grpc.cpp index 7e1c8bd1d1..e81411b0ac 100644 --- a/irohad/ordering/impl/ordering_service_transport_grpc.cpp +++ b/irohad/ordering/impl/ordering_service_transport_grpc.cpp @@ -10,6 +10,7 @@ #include "interfaces/common_objects/transaction_sequence_common.hpp" #include "network/impl/grpc_channel_builder.hpp" +using namespace iroha; using namespace iroha::ordering; void OrderingServiceTransportGrpc::subscribe( diff --git a/libs/common/bind.hpp b/libs/common/bind.hpp index 38177d3b04..1310839b10 100644 --- a/libs/common/bind.hpp +++ b/libs/common/bind.hpp @@ -6,6 +6,7 @@ #ifndef IROHA_COMMON_BIND_HPP #define IROHA_COMMON_BIND_HPP +#include #include #include diff --git a/libs/common/files.cpp b/libs/common/files.cpp index 1957901786..075254a7f4 100644 --- a/libs/common/files.cpp +++ b/libs/common/files.cpp @@ -5,8 +5,9 @@ #include "common/files.hpp" -#include +#include +#include #include "logger/logger.hpp" void iroha::remove_dir_contents(const std::string &dump_dir) { diff --git a/libs/parser/parser.cpp b/libs/parser/parser.cpp index 5d851ce4f9..d0ec23690c 100644 --- a/libs/parser/parser.cpp +++ b/libs/parser/parser.cpp @@ -3,7 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "parser.hpp" +#include "parser/parser.hpp" + +#include +#include namespace parser { diff --git a/libs/parser/parser.hpp b/libs/parser/parser.hpp index f05c185342..461c8f48f8 100644 --- a/libs/parser/parser.hpp +++ b/libs/parser/parser.hpp @@ -5,11 +5,12 @@ #include #include -#include #include #include #include +#include + #ifndef IROHA_PARSER_HPP #define IROHA_PARSER_HPP diff --git a/shared_model/backend/protobuf/impl/proto_block_factory.cpp b/shared_model/backend/protobuf/impl/proto_block_factory.cpp index 36b1b2cab1..24242ac243 100644 --- a/shared_model/backend/protobuf/impl/proto_block_factory.cpp +++ b/shared_model/backend/protobuf/impl/proto_block_factory.cpp @@ -7,6 +7,7 @@ #include "backend/protobuf/block.hpp" +using namespace shared_model; using namespace shared_model::proto; ProtoBlockFactory::ProtoBlockFactory( diff --git a/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp b/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp index 20d13e5543..955c107b13 100644 --- a/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp +++ b/shared_model/backend/protobuf/query_responses/impl/proto_query_response.cpp @@ -13,8 +13,8 @@ #include "backend/protobuf/query_responses/proto_role_permissions_response.hpp" #include "backend/protobuf/query_responses/proto_roles_response.hpp" #include "backend/protobuf/query_responses/proto_signatories_response.hpp" -#include "backend/protobuf/query_responses/proto_transactions_page_response.hpp" #include "backend/protobuf/query_responses/proto_transaction_response.hpp" +#include "backend/protobuf/query_responses/proto_transactions_page_response.hpp" #include "common/byteutils.hpp" #include "utils/variant_deserializer.hpp" diff --git a/shared_model/interfaces/commands/impl/command.cpp b/shared_model/interfaces/commands/impl/command.cpp index c2324b4a60..6d3a8ae5eb 100644 --- a/shared_model/interfaces/commands/impl/command.cpp +++ b/shared_model/interfaces/commands/impl/command.cpp @@ -27,11 +27,11 @@ using Variant = shared_model::interface::Command::CommandVariantType; template Variant::~variant(); template Variant::variant(Variant &&); template bool Variant::operator==(const Variant &) const; -template void Variant::destroy_content(); -template int Variant::which() const; -template void Variant::indicate_which(int); -template bool Variant::using_backup() const; -template Variant::convert_copy_into::convert_copy_into(void *); +template void Variant::destroy_content() noexcept; +template int Variant::which() const noexcept; +template void Variant::indicate_which(int) noexcept; +template bool Variant::using_backup() const noexcept; +template Variant::convert_copy_into::convert_copy_into(void *) noexcept; namespace shared_model { namespace interface { diff --git a/shared_model/interfaces/queries/impl/query.cpp b/shared_model/interfaces/queries/impl/query.cpp index 2d7b181e7e..3778754037 100644 --- a/shared_model/interfaces/queries/impl/query.cpp +++ b/shared_model/interfaces/queries/impl/query.cpp @@ -23,11 +23,11 @@ using Variant = shared_model::interface::Query::QueryVariantType; template Variant::~variant(); template Variant::variant(Variant &&); template bool Variant::operator==(const Variant &) const; -template void Variant::destroy_content(); -template int Variant::which() const; -template void Variant::indicate_which(int); -template bool Variant::using_backup() const; -template Variant::convert_copy_into::convert_copy_into(void *); +template void Variant::destroy_content() noexcept; +template int Variant::which() const noexcept; +template void Variant::indicate_which(int) noexcept; +template bool Variant::using_backup() const noexcept; +template Variant::convert_copy_into::convert_copy_into(void *) noexcept; namespace shared_model { namespace interface { diff --git a/shared_model/interfaces/query_responses/impl/query_response.cpp b/shared_model/interfaces/query_responses/impl/query_response.cpp index 3e44e50478..e0b479183c 100644 --- a/shared_model/interfaces/query_responses/impl/query_response.cpp +++ b/shared_model/interfaces/query_responses/impl/query_response.cpp @@ -22,11 +22,11 @@ using Variant = template Variant::~variant(); template Variant::variant(Variant &&); template bool Variant::operator==(const Variant &) const; -template void Variant::destroy_content(); -template int Variant::which() const; -template void Variant::indicate_which(int); -template bool Variant::using_backup() const; -template Variant::convert_copy_into::convert_copy_into(void *); +template void Variant::destroy_content() noexcept; +template int Variant::which() const noexcept; +template void Variant::indicate_which(int) noexcept; +template bool Variant::using_backup() const noexcept; +template Variant::convert_copy_into::convert_copy_into(void *) noexcept; namespace shared_model { namespace interface { diff --git a/shared_model/interfaces/transaction_responses/impl/tx_response.cpp b/shared_model/interfaces/transaction_responses/impl/tx_response.cpp index d82db40552..9cc4ac8b04 100644 --- a/shared_model/interfaces/transaction_responses/impl/tx_response.cpp +++ b/shared_model/interfaces/transaction_responses/impl/tx_response.cpp @@ -23,11 +23,11 @@ using Variant = template Variant::~variant(); template Variant::variant(Variant &&); template bool Variant::operator==(const Variant &) const; -template void Variant::destroy_content(); -template int Variant::which() const; -template void Variant::indicate_which(int); -template bool Variant::using_backup() const; -template Variant::convert_copy_into::convert_copy_into(void *); +template void Variant::destroy_content() noexcept; +template int Variant::which() const noexcept; +template void Variant::indicate_which(int) noexcept; +template bool Variant::using_backup() const noexcept; +template Variant::convert_copy_into::convert_copy_into(void *) noexcept; namespace shared_model { namespace interface { From 5805ec5d451801102974869144fde7742407a668 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Thu, 27 Dec 2018 18:53:08 +0300 Subject: [PATCH 47/61] Remove torii_service_test (#1996) Signed-off-by: Kitsu --- .../irohad/torii/torii_service_test.cpp | 651 ------------------ 1 file changed, 651 deletions(-) delete mode 100644 test/module/irohad/torii/torii_service_test.cpp diff --git a/test/module/irohad/torii/torii_service_test.cpp b/test/module/irohad/torii/torii_service_test.cpp deleted file mode 100644 index eb666f4fa7..0000000000 --- a/test/module/irohad/torii/torii_service_test.cpp +++ /dev/null @@ -1,651 +0,0 @@ -/** - * Copyright Soramitsu Co., Ltd. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "backend/protobuf/proto_transport_factory.hpp" -#include "backend/protobuf/proto_tx_status_factory.hpp" -#include "builders/protobuf/transaction.hpp" -#include "endpoint.pb.h" -#include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp" -#include "interfaces/iroha_internal/transaction_batch_parser_impl.hpp" -#include "main/server_runner.hpp" -#include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" -#include "module/irohad/multi_sig_transactions/mst_mocks.hpp" -#include "module/irohad/network/network_mocks.hpp" -#include "module/shared_model/builders/protobuf/block.hpp" -#include "module/shared_model/builders/protobuf/proposal.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/on_demand_common.hpp" -#include "torii/command_client.hpp" -#include "torii/impl/command_service_impl.hpp" -#include "torii/impl/command_service_transport_grpc.hpp" -#include "torii/impl/status_bus_impl.hpp" -#include "torii/processor/transaction_processor_impl.hpp" -#include "validation/stateful_validator_common.hpp" -#include "validators/protobuf/proto_transaction_validator.hpp" - -constexpr size_t TimesToriiBlocking = 5; - -using ::testing::_; -using ::testing::A; -using ::testing::AtLeast; -using ::testing::HasSubstr; -using ::testing::Return; - -using namespace iroha::network; -using namespace iroha::ametsuchi; -using namespace iroha::torii; -using namespace iroha::synchronizer; - -using namespace std::chrono_literals; -constexpr std::chrono::milliseconds initial_timeout = 1s; -constexpr std::chrono::milliseconds nonfinal_timeout = 2 * 10s; - -/** -The do-while cycle imitates client resubscription to the stream. Stream -"expiration" is a valid designed case (see pr #1615 for the details). - -The number of attempts (3) is a magic constant here. The idea behind this number -is the following: only one resubscription is usually enough to pass the test; if -three resubscribes were not enough, then most likely there is another bug. - */ -constexpr uint32_t resubscribe_attempts = 3; - -class CustomPeerCommunicationServiceMock : public PeerCommunicationService { - public: - CustomPeerCommunicationServiceMock( - rxcpp::subjects::subject prop_notifier, - rxcpp::subjects::subject commit_notifier, - rxcpp::subjects::subject - verified_prop_notifier) - : prop_notifier_(prop_notifier), - commit_notifier_(commit_notifier), - verified_prop_notifier_(verified_prop_notifier) {} - - void propagate_batch( - std::shared_ptr batch) - const override {} - - rxcpp::observable onProposal() const override { - return prop_notifier_.get_observable(); - } - - rxcpp::observable on_commit() const override { - return commit_notifier_.get_observable(); - } - - rxcpp::observable - onVerifiedProposal() const override { - return verified_prop_notifier_.get_observable(); - } - - private: - rxcpp::subjects::subject prop_notifier_; - rxcpp::subjects::subject commit_notifier_; - rxcpp::subjects::subject - verified_prop_notifier_; -}; - -class ToriiServiceTest : public testing::Test { - public: - virtual void SetUp() { - runner = std::make_unique(ip + ":0"); - - // ----------- Command Service -------------- - pcsMock = std::make_shared( - prop_notifier_, commit_notifier_, verified_prop_notifier_); - mst = std::make_shared(); - block_query = std::make_shared(); - storage = std::make_shared(); - - EXPECT_CALL(*mst, onStateUpdateImpl()) - .WillRepeatedly(Return(mst_update_notifier.get_observable())); - EXPECT_CALL(*mst, onPreparedBatchesImpl()) - .WillRepeatedly(Return(mst_prepared_notifier.get_observable())); - EXPECT_CALL(*mst, onExpiredBatchesImpl()) - .WillRepeatedly(Return(mst_expired_notifier.get_observable())); - - auto status_bus = std::make_shared(); - auto tx_processor = - std::make_shared( - pcsMock, - mst, - status_bus, - std::make_shared()); - - EXPECT_CALL(*storage, getBlockQuery()).WillRepeatedly(Return(block_query)); - - //----------- Server run ---------------- - auto status_factory = - std::make_shared(); - std::unique_ptr> - interface_transaction_validator = std::make_unique< - shared_model::validation::DefaultUnsignedTransactionValidator>(); - std::unique_ptr> - proto_transaction_validator = std::make_unique< - shared_model::validation::ProtoTransactionValidator>(); - auto transaction_factory = - std::make_shared>( - std::move(interface_transaction_validator), - std::move(proto_transaction_validator)); - auto batch_parser = - std::make_shared(); - auto batch_factory = std::make_shared< - shared_model::interface::TransactionBatchFactoryImpl>(); - runner - ->append(std::make_unique( - std::make_shared( - tx_processor, storage, status_bus, status_factory), - status_bus, - initial_timeout, - nonfinal_timeout, - status_factory, - transaction_factory, - batch_parser, - batch_factory)) - .run() - .match( - [this](iroha::expected::Value port) { - this->port = port.value; - }, - [](iroha::expected::Error err) { - FAIL() << err.error; - }); - - runner->waitForServersReady(); - } - - std::unique_ptr runner; - - std::shared_ptr block_query; - std::shared_ptr storage; - - rxcpp::subjects::subject prop_notifier_; - rxcpp::subjects::subject commit_notifier_; - rxcpp::subjects::subject - verified_prop_notifier_; - rxcpp::subjects::subject> - mst_update_notifier; - rxcpp::subjects::subject mst_prepared_notifier; - rxcpp::subjects::subject mst_expired_notifier; - - std::shared_ptr pcsMock; - std::shared_ptr mst; - - shared_model::crypto::Keypair keypair = - shared_model::crypto::DefaultCryptoAlgorithmType::generateKeypair(); - - iroha::consensus::Round round; - const std::string ip = "127.0.0.1"; - int port; -}; - -/** - * @given chain of CommandClient copies and moves - * @when status is asked - * @then grpc returns ok - */ -TEST_F(ToriiServiceTest, CommandClient) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(std::string(32, '1')); - iroha::protocol::ToriiResponse toriiResponse; - - auto client1 = torii::CommandSyncClient(ip, port); - // Copy ctor - torii::CommandSyncClient client2(client1); - // copy assignment - auto client3 = client2; - // move ctor - torii::CommandSyncClient client4(std::move(client3)); - // move assignment - auto client5 = std::move(client4); - auto stat = client5.Status(tx_request, toriiResponse); - - ASSERT_TRUE(stat.ok()); -} -/** - * @given torii service and number of transactions - * @when retrieving their status - * @then ensure those are not received - */ -TEST_F(ToriiServiceTest, StatusWhenTxWasNotReceivedBlocking) { - std::vector tx_hashes; - - ON_CALL(*block_query, checkTxPresence(_)) - .WillByDefault( - Return(boost::make_optional( - iroha::ametsuchi::tx_cache_status_responses::Missing()))); - - // create transactions, but do not send them - for (size_t i = 0; i < TimesToriiBlocking; ++i) { - tx_hashes.push_back(shared_model::crypto::Hash{std::to_string(i)}); - } - - // get statuses of unsent transactions - auto client = torii::CommandSyncClient(ip, port); - - for (size_t i = 0; i < TimesToriiBlocking; ++i) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); - iroha::protocol::ToriiResponse toriiResponse; - // this test does not require the fix for thread scheduling issues - client.Status(tx_request, toriiResponse); - ASSERT_EQ(toriiResponse.tx_status(), - iroha::protocol::TxStatus::NOT_RECEIVED); - } -} - -/** - * That test simulates the real behavior of the blocking Torii. - * - * @given torii service with mocked CommunicationService - * that is subscribed on custom rxcpp::subjects - * @when sending some number of transactions to the Torii - * @then ensure it perform as real one: - * - Torii returns ok status - * - Proper txs responses in Status are STATELESS_VALIDATION_SUCCESS, - * then STATEFUL_VALIDATION_SUCCESS and COMMITTED (order matters) - * - Tx that not in a block returns STATELESS_VALIDATION_SUCCESS and - then STATEFUL_VALIDATION_FAILED - */ -TEST_F(ToriiServiceTest, StatusWhenBlocking) { - std::vector txs; - std::vector tx_hashes; - - auto client1 = torii::CommandSyncClient(ip, port); - - // create transactions and send them to Torii - std::string account_id = "some@account"; - auto now = iroha::time::now(); - for (size_t i = 0; i < TimesToriiBlocking; ++i) { - auto shm_tx = shared_model::proto::TransactionBuilder() - .creatorAccountId(account_id) - .createdTime(now + i) - .setAccountQuorum(account_id, 2) - .quorum(1) - .build() - .signAndAddSignature( - shared_model::crypto::DefaultCryptoAlgorithmType:: - generateKeypair()) - .finish(); - const auto &new_tx = shm_tx.getTransport(); - - auto stat = client1.Torii(new_tx); - txs.push_back(shm_tx); - tx_hashes.push_back(shm_tx.hash()); - - ASSERT_TRUE(stat.ok()); - } - - // create proposal from these transactions - std::shared_ptr proposal = - std::make_shared( - TestProposalBuilder() - .height(1) - .createdTime(iroha::time::now()) - .transactions(txs) - .build()); - prop_notifier_.get_subscriber().on_next(OrderingEvent{ - proposal, {proposal->height(), iroha::ordering::kFirstRejectRound}}); - - torii::CommandSyncClient client2(client1); - - // check if stateless validation passed - for (size_t i = 0; i < TimesToriiBlocking; ++i) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); - iroha::protocol::ToriiResponse toriiResponse; - client2.Status(tx_request, toriiResponse); - - ASSERT_EQ(toriiResponse.tx_status(), - iroha::protocol::TxStatus::ENOUGH_SIGNATURES_COLLECTED); - } - - // create block from the all transactions but the last one - auto failed_tx_hash = txs.back().hash(); - txs.pop_back(); - auto block = - clone(TestBlockBuilder() - .transactions(txs) - .height(1) - .createdTime(0) - .prevHash(shared_model::crypto::Hash(std::string(32, '0'))) - .build()); - - // notify the verified proposal event about txs, which passed stateful - // validation - auto validation_result = - std::make_shared(); - validation_result->verified_proposal = - std::make_unique( - TestProposalBuilder() - .height(1) - .createdTime(iroha::time::now()) - .transactions(txs) - .build()); - - auto cmd_name = "FailedCommand"; - size_t cmd_index = 2; - uint32_t error_code = 3; - validation_result->rejected_transactions.emplace_back( - iroha::validation::TransactionError{ - failed_tx_hash, - iroha::validation::CommandError{ - cmd_name, error_code, "", true, cmd_index}}); - verified_prop_notifier_.get_subscriber().on_next( - iroha::simulator::VerifiedProposalCreatorEvent{validation_result, round}); - - // create commit from block notifier's observable - rxcpp::subjects::subject> - block_notifier_; - SynchronizationEvent commit{block_notifier_.get_observable(), - SynchronizationOutcomeType::kCommit, - {}}; - - // invoke on next of commit_notifier by sending new block to commit - commit_notifier_.get_subscriber().on_next(commit); - block_notifier_.get_subscriber().on_next(std::move(block)); - - auto client3 = client2; - // check if all transactions but the last one passed stateful validation - for (size_t i = 0; i < TimesToriiBlocking - 1; ++i) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); - iroha::protocol::ToriiResponse toriiResponse; - - auto resub_counter(resubscribe_attempts); - do { - client3.Status(tx_request, toriiResponse); - } while (toriiResponse.tx_status() - != iroha::protocol::TxStatus::STATEFUL_VALIDATION_SUCCESS - and --resub_counter); - - ASSERT_EQ(toriiResponse.tx_status(), - iroha::protocol::TxStatus::STATEFUL_VALIDATION_SUCCESS); - } - - // end current commit - block_notifier_.get_subscriber().on_completed(); - - auto client4 = client3; - // check if all transactions but the last have committed state - for (size_t i = 0; i < TimesToriiBlocking - 1; ++i) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash( - shared_model::crypto::toBinaryString(tx_hashes.at(i))); - iroha::protocol::ToriiResponse toriiResponse; - client4.Status(tx_request, toriiResponse); - - ASSERT_EQ(toriiResponse.tx_status(), iroha::protocol::TxStatus::COMMITTED); - } - - torii::CommandSyncClient client5(client4); - // check if the last transaction from txs has failed stateful validation - iroha::protocol::TxStatusRequest last_tx_request; - last_tx_request.set_tx_hash(shared_model::crypto::toBinaryString( - tx_hashes.at(TimesToriiBlocking - 1))); - iroha::protocol::ToriiResponse stful_invalid_response; - client5.Status(last_tx_request, stful_invalid_response); - ASSERT_EQ(stful_invalid_response.tx_status(), - iroha::protocol::TxStatus::STATEFUL_VALIDATION_FAILED); - ASSERT_EQ(stful_invalid_response.err_or_cmd_name(), cmd_name); - ASSERT_EQ(stful_invalid_response.failed_cmd_index(), cmd_index); - ASSERT_EQ(stful_invalid_response.error_code(), error_code); -} - -/** - * @given torii service and some number of transactions with hashes - * @when sending request on this txs - * @then ensure that response has the same hash as sent tx - */ -TEST_F(ToriiServiceTest, CheckHash) { - // given - std::vector tx_hashes; - const int tx_num = 10; - - // create transactions, but do not send them - for (size_t i = 0; i < tx_num; ++i) { - auto tx = TestTransactionBuilder().build(); - tx_hashes.push_back(tx.hash()); - } - - auto client = torii::CommandSyncClient(ip, port); - - // get statuses of transactions - for (auto &hash : tx_hashes) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); - iroha::protocol::ToriiResponse toriiResponse; - const auto binary_hash = shared_model::crypto::toBinaryString(hash); - auto resub_counter(resubscribe_attempts); - do { - client.Status(tx_request, toriiResponse); - } while (toriiResponse.tx_hash() != binary_hash and --resub_counter); - ASSERT_EQ(toriiResponse.tx_hash(), binary_hash); - } -} - -/** - * @given torii service and one valid transaction - * @when starting StatusStream and then sending transaction to Iroha - * @then ensure that response will have at least 3 statuses - * (it should contain STATELESS_VALIDATION_SUCCESS, STATEFUL_VALIDATION_SUCCESS - * and COMMITTED) and the last status should be COMMITTED - */ -TEST_F(ToriiServiceTest, StreamingFullPipelineTest) { - using namespace shared_model; - - auto client = torii::CommandSyncClient(ip, port); - auto iroha_tx = proto::TransactionBuilder() - .creatorAccountId("a@domain") - .setAccountQuorum("a@domain", 2) - .createdTime(iroha::time::now()) - .quorum(1) - .build() - .signAndAddSignature(keypair) - .finish(); - - std::string txhash = crypto::toBinaryString(iroha_tx.hash()); - - std::vector torii_response; - // StatusStream is a blocking call and returns only when the last status - // (Committed in this case) will be received. We start request before - // transaction sending so we need in a separate thread for it. - std::thread t([&] { - auto resub_counter(resubscribe_attempts); - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(txhash); - do { - client.StatusStream(tx_request, torii_response); - } while (torii_response.back().tx_status() - != iroha::protocol::TxStatus::COMMITTED - and --resub_counter); - }); - - client.Torii(iroha_tx.getTransport()); - - std::vector txs; - txs.push_back(iroha_tx); - std::shared_ptr proposal = - std::make_shared(proto::ProposalBuilder() - .createdTime(iroha::time::now()) - .transactions(txs) - .height(1) - .build()); - prop_notifier_.get_subscriber().on_next(OrderingEvent{ - proposal, {proposal->height(), iroha::ordering::kFirstRejectRound}}); - - auto validation_result = - std::make_shared(); - validation_result->verified_proposal = proposal; - verified_prop_notifier_.get_subscriber().on_next( - iroha::simulator::VerifiedProposalCreatorEvent{validation_result, round}); - - auto block = clone(proto::BlockBuilder() - .height(1) - .createdTime(iroha::time::now()) - .transactions(txs) - .prevHash(crypto::Hash(std::string(32, '0'))) - .build() - .signAndAddSignature(keypair) - .finish()); - - // create commit from block notifier's observable - rxcpp::subjects::subject> - block_notifier_; - SynchronizationEvent commit{block_notifier_.get_observable(), - SynchronizationOutcomeType::kCommit, - {}}; - - // invoke on next of commit_notifier by sending new block to commit - commit_notifier_.get_subscriber().on_next(commit); - block_notifier_.get_subscriber().on_next(std::move(block)); - - block_notifier_.get_subscriber().on_completed(); - t.join(); - - // we can be sure only about final status - // it can be only one or to follow by some non-final - ASSERT_EQ(torii_response.back().tx_status(), - iroha::protocol::TxStatus::COMMITTED); -} - -/** - * @given torii service and fake transaction hash - * @when sending streaming request for this hash - * @then ensure that response will have exactly 1 status - NOT_RECEIVED - */ -TEST_F(ToriiServiceTest, StreamingNoTx) { - auto client = torii::CommandSyncClient(ip, port); - std::vector torii_response; - std::thread t([&]() { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash("0123456789abcdef"); - // this test does not require the fix for thread scheduling issues - client.StatusStream(tx_request, torii_response); - }); - - t.join(); - ASSERT_EQ(torii_response.size(), 1); - ASSERT_EQ(torii_response.at(0).tx_status(), - iroha::protocol::TxStatus::NOT_RECEIVED); -} - -/** - * Checks that torii is able to handle lists (sequences) of transactions - * - * @given torii service and collection of transactions - * @when that collection is asked to be processed by Torii - * @then statuses of all transactions from that request are - * ENOUGH_SIGNATURES_COLLECTED - */ -TEST_F(ToriiServiceTest, ListOfTxs) { - const auto test_txs_number = 5; - - // initial preparations: creation of variables and txs - auto client = torii::CommandSyncClient(ip, port); - std::vector tx_hashes( - test_txs_number); - iroha::protocol::TxList tx_list; - - for (auto i = 0; i < test_txs_number; ++i) { - auto shm_tx = shared_model::proto::TransactionBuilder() - .creatorAccountId("doge@master" + std::to_string(i)) - .createdTime(iroha::time::now()) - .setAccountQuorum("doge@master", 2) - .quorum(1) - .build() - .signAndAddSignature( - shared_model::crypto::DefaultCryptoAlgorithmType:: - generateKeypair()) - .finish(); - tx_hashes[i] = shm_tx.hash(); - new (tx_list.add_transactions()) - iroha::protocol::Transaction(shm_tx.getTransport()); - } - - // send the txs - client.ListTorii(tx_list); - - // check their statuses - std::for_each( - std::begin(tx_hashes), std::end(tx_hashes), [&client](auto &hash) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); - iroha::protocol::ToriiResponse toriiResponse; - - auto resub_counter(resubscribe_attempts); - do { - client.Status(tx_request, toriiResponse); - } while (toriiResponse.tx_status() - != iroha::protocol::TxStatus::ENOUGH_SIGNATURES_COLLECTED - and --resub_counter); - - ASSERT_EQ(toriiResponse.tx_status(), - iroha::protocol::TxStatus::ENOUGH_SIGNATURES_COLLECTED); - }); -} - -/** - * Checks that in case of failed transactions list every transaction has a - * related status and error message - * - * @given torii service and a list of bad-formed transactions - * @when checking those transactions after sending them to Torii - * @then every transaction from this list will have STATELESS_FAILED status @and - * the same corresponding error message - */ -TEST_F(ToriiServiceTest, FailedListOfTxs) { - const auto test_txs_number = 5; - - // initial preparations: creation of variables and txs - auto client = torii::CommandSyncClient(ip, port); - std::vector tx_hashes( - test_txs_number); - iroha::protocol::TxList tx_list; - - for (auto i = 0; i < test_txs_number; ++i) { - auto shm_tx = TestTransactionBuilder() - .creatorAccountId("doge@master" + std::to_string(i)) - .createdTime(iroha::time::now(std::chrono::hours(24) - + std::chrono::minutes(1))) - .setAccountQuorum("doge@master", 2) - .quorum(1) - .build(); - tx_hashes[i] = shm_tx.hash(); - new (tx_list.add_transactions()) - iroha::protocol::Transaction(shm_tx.getTransport()); - } - - // send the txs - client.ListTorii(tx_list); - - // check their statuses - std::for_each( - std::begin(tx_hashes), std::end(tx_hashes), [&client](auto &hash) { - iroha::protocol::TxStatusRequest tx_request; - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); - iroha::protocol::ToriiResponse toriiResponse; - auto resub_counter(resubscribe_attempts); - do { - client.Status(tx_request, toriiResponse); - } while (toriiResponse.tx_status() - != iroha::protocol::TxStatus::STATELESS_VALIDATION_FAILED - and --resub_counter); - - ASSERT_EQ(toriiResponse.tx_status(), - iroha::protocol::TxStatus::STATELESS_VALIDATION_FAILED); - auto msg = toriiResponse.err_or_cmd_name(); - ASSERT_THAT(msg, HasSubstr("bad timestamp: sent from future")); - }); -} From 6e53bd33c5725f1801f6097007b773bfe59cc179 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Thu, 27 Dec 2018 19:26:55 +0300 Subject: [PATCH 48/61] Feature/hex validators (#1993) * Add hex validators Signed-off-by: kamilsa --- shared_model/validators/CMakeLists.txt | 3 + .../protobuf/proto_block_validator.cpp | 27 +- .../protobuf/proto_query_validator.cpp | 59 ++++ .../protobuf/proto_query_validator.hpp | 17 +- .../protobuf/proto_transaction_validator.cpp | 94 ++++++ .../protobuf/proto_transaction_validator.hpp | 57 +--- shared_model/validators/validators_common.cpp | 19 ++ shared_model/validators/validators_common.hpp | 24 ++ .../shared_model/validators/CMakeLists.txt | 1 + .../protobuf/proto_block_validator_test.cpp | 66 ++++ .../protobuf/proto_query_validator_test.cpp | 58 ++++ .../protobuf/proto_tx_validator_test.cpp | 303 +++++++++--------- 12 files changed, 501 insertions(+), 227 deletions(-) create mode 100644 shared_model/validators/protobuf/proto_query_validator.cpp create mode 100644 shared_model/validators/protobuf/proto_transaction_validator.cpp create mode 100644 shared_model/validators/validators_common.cpp create mode 100644 shared_model/validators/validators_common.hpp diff --git a/shared_model/validators/CMakeLists.txt b/shared_model/validators/CMakeLists.txt index 7ce9e4b6d0..ee0b4da8b7 100644 --- a/shared_model/validators/CMakeLists.txt +++ b/shared_model/validators/CMakeLists.txt @@ -3,9 +3,12 @@ add_library(shared_model_stateless_validation field_validator.cpp + validators_common.cpp transactions_collection/transactions_collection_validator.cpp transactions_collection/batch_order_validator.cpp protobuf/proto_block_validator.cpp + protobuf/proto_query_validator.cpp + protobuf/proto_transaction_validator.cpp ) target_link_libraries(shared_model_stateless_validation diff --git a/shared_model/validators/protobuf/proto_block_validator.cpp b/shared_model/validators/protobuf/proto_block_validator.cpp index 5b41ef9a3c..2c9ddc982e 100644 --- a/shared_model/validators/protobuf/proto_block_validator.cpp +++ b/shared_model/validators/protobuf/proto_block_validator.cpp @@ -5,6 +5,12 @@ #include "validators/protobuf/proto_block_validator.hpp" +#include +#include +#include + +#include "validators/validators_common.hpp" + namespace shared_model { namespace validation { Answer ProtoBlockValidator::validate( @@ -18,7 +24,26 @@ namespace shared_model { == iroha::protocol::Block::BLOCK_VERSION_NOT_SET) { reason.second.emplace_back("Block version is not set"); answer.addReason(std::move(reason)); - return answer; + } + + const auto &rejected_hashes = + block.block_v1().payload().rejected_transactions_hashes(); + + boost::for_each(rejected_hashes | boost::adaptors::indexed(0), + [&reason](const auto &hash) { + if (not validateHexString(hash.value())) { + reason.second.emplace_back( + (boost::format("Rejected hash '%s' with index " + "'%d' is not in hash format") + % hash.value() % hash.index()) + .str()); + } + }); + if (not validateHexString(block.block_v1().payload().prev_block_hash())) { + reason.second.emplace_back("Prev block hash has incorrect format"); + } + if (not reason.second.empty()) { + answer.addReason(std::move(reason)); } return answer; diff --git a/shared_model/validators/protobuf/proto_query_validator.cpp b/shared_model/validators/protobuf/proto_query_validator.cpp new file mode 100644 index 0000000000..2fcd3fb6ec --- /dev/null +++ b/shared_model/validators/protobuf/proto_query_validator.cpp @@ -0,0 +1,59 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "validators/protobuf/proto_query_validator.hpp" + +#include "validators/validators_common.hpp" + +namespace shared_model { + namespace validation { + + void validatePaginationMeta( + const iroha::protocol::TxPaginationMeta &paginationMeta, + ReasonsGroupType &reason) { + if (paginationMeta.opt_first_tx_hash_case() + != iroha::protocol::TxPaginationMeta::OPT_FIRST_TX_HASH_NOT_SET) { + if (not validateHexString(paginationMeta.first_tx_hash())) { + reason.second.emplace_back( + "First tx hash from pagination meta has invalid format"); + } + } + } + + Answer validateProtoQuery(const iroha::protocol::Query &qry) { + Answer answer; + std::string tx_reason_name = "Protobuf Query"; + ReasonsGroupType reason(tx_reason_name, GroupedReasons()); + switch (qry.payload().query_case()) { + case iroha::protocol::Query_Payload::QUERY_NOT_SET: { + reason.second.emplace_back("query is undefined"); + break; + } + case iroha::protocol::Query_Payload::kGetAccountTransactions: { + const auto &gat = qry.payload().get_account_transactions(); + validatePaginationMeta(gat.pagination_meta(), reason); + break; + } + case iroha::protocol::Query_Payload::kGetAccountAssetTransactions: { + const auto &gaat = qry.payload().get_account_asset_transactions(); + validatePaginationMeta(gaat.pagination_meta(), reason); + break; + } + default: + break; + } + if (not reason.second.empty()) { + answer.addReason(std::move(reason)); + } + return answer; + } + + Answer ProtoQueryValidator::validate( + const iroha::protocol::Query &query) const { + return validateProtoQuery(query); + } + + } // namespace validation +} // namespace shared_model diff --git a/shared_model/validators/protobuf/proto_query_validator.hpp b/shared_model/validators/protobuf/proto_query_validator.hpp index 45f4c6a38c..b8668f06c2 100644 --- a/shared_model/validators/protobuf/proto_query_validator.hpp +++ b/shared_model/validators/protobuf/proto_query_validator.hpp @@ -15,23 +15,8 @@ namespace shared_model { class ProtoQueryValidator : public AbstractValidator { - private: - Answer validateProtoQuery(const iroha::protocol::Query &qry) const { - Answer answer; - if (qry.payload().query_case() - == iroha::protocol::Query_Payload::QUERY_NOT_SET) { - ReasonsGroupType reason; - reason.first = "Undefined"; - reason.second.emplace_back("query is undefined"); - answer.addReason(std::move(reason)); - } - return answer; - } - public: - Answer validate(const iroha::protocol::Query &query) const override { - return validateProtoQuery(query); - } + Answer validate(const iroha::protocol::Query &query) const override; }; } // namespace validation diff --git a/shared_model/validators/protobuf/proto_transaction_validator.cpp b/shared_model/validators/protobuf/proto_transaction_validator.cpp new file mode 100644 index 0000000000..18ccf7a454 --- /dev/null +++ b/shared_model/validators/protobuf/proto_transaction_validator.cpp @@ -0,0 +1,94 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "validators/protobuf/proto_transaction_validator.hpp" + +#include "validators/validators_common.hpp" + +namespace shared_model { + namespace validation { + + void validateHexField(const std::string &public_key, + ReasonsGroupType &reason) { + if (not validateHexString(public_key)) { + reason.second.emplace_back("Public key is not in hex format"); + } + } + + Answer validateProtoTx(const iroha::protocol::Transaction &transaction) { + Answer answer; + std::string tx_reason_name = "Protobuf Transaction"; + ReasonsGroupType reason(tx_reason_name, GroupedReasons()); + for (const auto &command : + transaction.payload().reduced_payload().commands()) { + switch (command.command_case()) { + case iroha::protocol::Command::COMMAND_NOT_SET: { + reason.second.emplace_back("Undefined command is found"); + answer.addReason(std::move(reason)); + return answer; + } + case iroha::protocol::Command::kAddSignatory: { + const auto &as = command.add_signatory(); + validateHexField(as.public_key(), reason); + break; + } + case iroha::protocol::Command::kCreateAccount: { + const auto &ca = command.create_account(); + validateHexField(ca.public_key(), reason); + break; + } + case iroha::protocol::Command::kRemoveSignatory: { + const auto &rs = command.remove_signatory(); + validateHexField(rs.public_key(), reason); + break; + } + case iroha::protocol::Command::kAddPeer: { + const auto &ap = command.add_peer(); + validateHexField(ap.peer().peer_key(), reason); + break; + } + case iroha::protocol::Command::kCreateRole: { + const auto &cr = command.create_role(); + bool all_permissions_valid = std::all_of( + cr.permissions().begin(), + cr.permissions().end(), + [](const auto &perm) { + return iroha::protocol::RolePermission_IsValid(perm); + }); + if (not all_permissions_valid) { + reason.second.emplace_back("Invalid role permission"); + } + break; + } + case iroha::protocol::Command::kGrantPermission: { + if (not iroha::protocol::GrantablePermission_IsValid( + command.grant_permission().permission())) { + reason.second.emplace_back("Invalid grantable permission"); + } + break; + } + case iroha::protocol::Command::kRevokePermission: { + if (not iroha::protocol::GrantablePermission_IsValid( + command.revoke_permission().permission())) { + reason.second.emplace_back("Invalid grantable permission"); + } + break; + } + default: + break; + } + } + if (not reason.second.empty()) { + answer.addReason(std::move(reason)); + } + return answer; + } + + Answer ProtoTransactionValidator::validate( + const iroha::protocol::Transaction &tx) const { + return validateProtoTx(tx); + } + } // namespace validation +} // namespace shared_model diff --git a/shared_model/validators/protobuf/proto_transaction_validator.hpp b/shared_model/validators/protobuf/proto_transaction_validator.hpp index 0861978b38..5bc708736d 100644 --- a/shared_model/validators/protobuf/proto_transaction_validator.hpp +++ b/shared_model/validators/protobuf/proto_transaction_validator.hpp @@ -15,63 +15,8 @@ namespace shared_model { class ProtoTransactionValidator : public AbstractValidator { - private: - Answer validateProtoTx( - const iroha::protocol::Transaction &transaction) const { - Answer answer; - std::string tx_reason_name = "Protobuf Transaction"; - ReasonsGroupType reason(tx_reason_name, GroupedReasons()); - for (const auto &command : - transaction.payload().reduced_payload().commands()) { - switch (command.command_case()) { - case iroha::protocol::Command::COMMAND_NOT_SET: { - reason.second.emplace_back("Undefined command is found"); - answer.addReason(std::move(reason)); - return answer; - } - case iroha::protocol::Command::kCreateRole: { - const auto &cr = command.create_role(); - bool all_permissions_valid = std::all_of( - cr.permissions().begin(), - cr.permissions().end(), - [](const auto &perm) { - return iroha::protocol::RolePermission_IsValid(perm); - }); - if (not all_permissions_valid) { - reason.second.emplace_back("Invalid role permission"); - answer.addReason(std::move(reason)); - return answer; - } - break; - } - case iroha::protocol::Command::kGrantPermission: { - if (not iroha::protocol::GrantablePermission_IsValid( - command.grant_permission().permission())) { - reason.second.emplace_back("Invalid grantable permission"); - answer.addReason(std::move(reason)); - return answer; - } - break; - } - case iroha::protocol::Command::kRevokePermission: { - if (not iroha::protocol::GrantablePermission_IsValid( - command.revoke_permission().permission())) { - reason.second.emplace_back("Invalid grantable permission"); - answer.addReason(std::move(reason)); - return answer; - } - break; - } - default: { break; } - } - } - return answer; - } - public: - Answer validate(const iroha::protocol::Transaction &tx) const override { - return validateProtoTx(tx); - }; + Answer validate(const iroha::protocol::Transaction &tx) const override; }; } // namespace validation } // namespace shared_model diff --git a/shared_model/validators/validators_common.cpp b/shared_model/validators/validators_common.cpp new file mode 100644 index 0000000000..33ccaba2a8 --- /dev/null +++ b/shared_model/validators/validators_common.cpp @@ -0,0 +1,19 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "validators/validators_common.hpp" + +#include + +namespace shared_model { + namespace validation { + + bool validateHexString(const std::string &str) { + static const std::regex hex_regex{R"([0-9a-fA-F]*)"}; + return std::regex_match(str, hex_regex); + } + + } // namespace validation +} // namespace shared_model diff --git a/shared_model/validators/validators_common.hpp b/shared_model/validators/validators_common.hpp new file mode 100644 index 0000000000..9a1054aa4e --- /dev/null +++ b/shared_model/validators/validators_common.hpp @@ -0,0 +1,24 @@ +/** + * Copyright Soramitsu Co., Ltd. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef IROHA_VALIDATORS_COMMON_HPP +#define IROHA_VALIDATORS_COMMON_HPP + +#include + +namespace shared_model { + namespace validation { + + /** + * Check if given string has hex format + * @param str string to check + * @return true if string is in hex, false otherwise + */ + bool validateHexString(const std::string &str); + + } // namespace validation +} // namespace shared_model + +#endif // IROHA_VALIDATORS_COMMON_HPP diff --git a/test/module/shared_model/validators/CMakeLists.txt b/test/module/shared_model/validators/CMakeLists.txt index 005f4dc481..14a23c61e5 100644 --- a/test/module/shared_model/validators/CMakeLists.txt +++ b/test/module/shared_model/validators/CMakeLists.txt @@ -36,6 +36,7 @@ addtest(proto_query_validator_test ) target_link_libraries(proto_query_validator_test shared_model_proto_backend + shared_model_stateless_validation ) addtest(field_validator_test diff --git a/test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp b/test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp index a7ed970dc4..734473bccb 100644 --- a/test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp +++ b/test/module/shared_model/validators/protobuf/proto_block_validator_test.cpp @@ -42,3 +42,69 @@ TEST_F(ProtoBlockValidatorTest, ValidBlock) { auto answer = validator.validate(valid_block); ASSERT_FALSE(answer.hasErrors()); } + +/** + * @given block object with invalid hash format in rejected hashes + * @when validating this object + * @then validation is failed + */ +TEST_F(ProtoBlockValidatorTest, BlockWithInvalidRejectedHash) { + iroha::protocol::Block invalid_block; + + iroha::protocol::Block_v1 versioned_block; + *versioned_block.mutable_payload()->add_rejected_transactions_hashes() = + std::string("not_hex_value"); + *invalid_block.mutable_block_v1() = versioned_block; + + auto answer = validator.validate(invalid_block); + ASSERT_TRUE(answer.hasErrors()); +} + +/** + * @given block object with valid hash format in rejected hashes + * @when validating this object + * @then validation is successful + */ +TEST_F(ProtoBlockValidatorTest, BlockWithValidRejectedHash) { + iroha::protocol::Block valid_block; + + iroha::protocol::Block_v1 versioned_block; + *versioned_block.mutable_payload()->add_rejected_transactions_hashes() = + std::string("123abc"); + *valid_block.mutable_block_v1() = versioned_block; + + auto answer = validator.validate(valid_block); + ASSERT_FALSE(answer.hasErrors()) << answer.reason(); +} + +/** + * @given block object with valid hash format previous block hash + * @when validating this object + * @then validation is successful + */ +TEST_F(ProtoBlockValidatorTest, BlockWithValidPrevHash) { + iroha::protocol::Block valid_block; + + iroha::protocol::Block_v1 versioned_block; + versioned_block.mutable_payload()->set_prev_block_hash("123abc"); + *valid_block.mutable_block_v1() = versioned_block; + + auto answer = validator.validate(valid_block); + ASSERT_FALSE(answer.hasErrors()) << answer.reason(); +} + +/** + * @given block object with invalid hash format previous block hash + * @when validating this object + * @then validation is failed + */ +TEST_F(ProtoBlockValidatorTest, BlockWithInvalidPrevHash) { + iroha::protocol::Block invalid_block; + + iroha::protocol::Block_v1 versioned_block; + versioned_block.mutable_payload()->set_prev_block_hash("not_hex"); + *invalid_block.mutable_block_v1() = versioned_block; + + auto answer = validator.validate(invalid_block); + ASSERT_TRUE(answer.hasErrors()) << invalid_block.DebugString(); +} diff --git a/test/module/shared_model/validators/protobuf/proto_query_validator_test.cpp b/test/module/shared_model/validators/protobuf/proto_query_validator_test.cpp index 6883be7070..946553ad02 100644 --- a/test/module/shared_model/validators/protobuf/proto_query_validator_test.cpp +++ b/test/module/shared_model/validators/protobuf/proto_query_validator_test.cpp @@ -44,3 +44,61 @@ TEST_F(ProtoQueryValidatorTest, SetQuery) { auto answer = validator.validate(qry); ASSERT_FALSE(answer.hasErrors()); } + +iroha::protocol::Query generateGetAccountAssetTransactionsQuery( + const std::string &first_tx_hash) { + iroha::protocol::Query result; + result.mutable_payload() + ->mutable_get_account_asset_transactions() + ->mutable_pagination_meta() + ->set_first_tx_hash(first_tx_hash); + return result; +} + +iroha::protocol::Query generateGetAccountTransactionsQuery( + const std::string &first_tx_hash) { + iroha::protocol::Query result; + result.mutable_payload() + ->mutable_get_account_transactions() + ->mutable_pagination_meta() + ->set_first_tx_hash(first_tx_hash); + return result; +} + +static std::string valid_tx_hash("123abc"); +static std::string invalid_tx_hash("not_hex"); + +// valid pagination query tests + +class ValidProtoPaginationQueryValidatorTest + : public ProtoQueryValidatorTest, + public ::testing::WithParamInterface {}; + +TEST_P(ValidProtoPaginationQueryValidatorTest, ValidPaginationQuery) { + auto answer = validator.validate(GetParam()); + ASSERT_FALSE(answer.hasErrors()) << GetParam().DebugString() << std::endl + << answer.reason(); +} + +INSTANTIATE_TEST_CASE_P( + ProtoPaginationQueryTest, + ValidProtoPaginationQueryValidatorTest, + ::testing::Values(generateGetAccountAssetTransactionsQuery(valid_tx_hash), + generateGetAccountTransactionsQuery(valid_tx_hash)), ); + +// invalid pagination query tests + +class InvalidProtoPaginationQueryTest + : public ProtoQueryValidatorTest, + public ::testing::WithParamInterface {}; + +TEST_P(InvalidProtoPaginationQueryTest, InvalidPaginationQuery) { + auto answer = validator.validate(GetParam()); + ASSERT_TRUE(answer.hasErrors()) << GetParam().DebugString(); +} + +INSTANTIATE_TEST_CASE_P( + InvalidProtoPaginationQueryTest, + InvalidProtoPaginationQueryTest, + ::testing::Values(generateGetAccountAssetTransactionsQuery(invalid_tx_hash), + generateGetAccountTransactionsQuery(invalid_tx_hash)), ); diff --git a/test/module/shared_model/validators/protobuf/proto_tx_validator_test.cpp b/test/module/shared_model/validators/protobuf/proto_tx_validator_test.cpp index e5dc1ef00b..7a3a999247 100644 --- a/test/module/shared_model/validators/protobuf/proto_tx_validator_test.cpp +++ b/test/module/shared_model/validators/protobuf/proto_tx_validator_test.cpp @@ -6,184 +6,179 @@ #include "validators/protobuf/proto_transaction_validator.hpp" #include -#include "module/shared_model/builders/protobuf/test_transaction_builder.hpp" #include "module/shared_model/validators/validators_fixture.hpp" -class ProtoTxValidatorTest : public ValidatorsTest { - protected: - iroha::protocol::Transaction generateEmptyTransaction() { - std::string creator_account_id = "admin@test"; - - TestTransactionBuilder builder; - auto tx = builder.creatorAccountId(creator_account_id) - .createdTime(created_time) - .quorum(1) - .build() - .getTransport(); - return tx; - } - - iroha::protocol::Transaction generateCreateRoleTransaction( - const std::string &role_name, - iroha::protocol::RolePermission permission) { - auto tx = generateEmptyTransaction(); - - auto cr = tx.mutable_payload() - ->mutable_reduced_payload() - ->add_commands() - ->mutable_create_role(); - cr->set_role_name(role_name); - cr->add_permissions(permission); - return tx; - } - - iroha::protocol::Transaction generateGrantPermissionTransaction( - const std::string &account_id, - iroha::protocol::GrantablePermission permission) { - auto tx = generateEmptyTransaction(); - - auto gp = tx.mutable_payload() - ->mutable_reduced_payload() - ->add_commands() - ->mutable_grant_permission(); - gp->set_account_id(account_id); - gp->set_permission(permission); - return tx; - } - - iroha::protocol::Transaction generateRevokePermissionTransaction( - const std::string &account_id, - iroha::protocol::GrantablePermission permission) { - auto tx = generateEmptyTransaction(); - - auto gp = tx.mutable_payload() - ->mutable_reduced_payload() - ->add_commands() - ->mutable_revoke_permission(); - gp->set_account_id(account_id); - gp->set_permission(permission); - return tx; - } - - shared_model::validation::ProtoTransactionValidator validator; -}; - -/** - * @given iroha::protocol::Transaction with defined command - * @when it is validated - * @then answer with no errors is returned - */ -TEST_F(ProtoTxValidatorTest, CommandIsSet) { - auto tx = generateEmptyTransaction(); - - iroha::protocol::CreateDomain cd; - cd.set_domain_id(domain_id); - cd.set_default_role(role_name); - - tx.mutable_payload() - ->mutable_reduced_payload() - ->add_commands() - ->mutable_create_domain() - ->CopyFrom(cd); - - auto answer = validator.validate(tx); - ASSERT_FALSE(answer.hasErrors()) << answer.reason(); +const static std::string rolename = "rolename"; +const static std::string account_id = "account@domain"; +const static std::string account_name = "account"; +const static std::string domain_id = "domain"; +const static std::string address_ipv4 = "127.0.0.1"; + +const static std::string valid_pubkey(32, '1'); +const static std::string invalid_pubkey("not_hex"); + +const static iroha::protocol::RolePermission valid_role_permission = + iroha::protocol::RolePermission::can_read_assets; +const static iroha::protocol::RolePermission invalid_role_permission = + static_cast(-1); + +const static iroha::protocol::GrantablePermission valid_grantable_permission = + iroha::protocol::GrantablePermission::can_add_my_signatory; +const static iroha::protocol::GrantablePermission invalid_grantable_permission = + static_cast(-1); + +iroha::protocol::Transaction generateCreateRoleTransaction( + iroha::protocol::RolePermission permission) { + auto tx = iroha::protocol::Transaction(); + + auto cr = tx.mutable_payload() + ->mutable_reduced_payload() + ->add_commands() + ->mutable_create_role(); + cr->set_role_name(rolename); + cr->add_permissions(permission); + return tx; } -/** - * @given iroha::protocol::Transaction with undefined command - * @when it is validated - * @then answer with errors is returned - */ -TEST_F(ProtoTxValidatorTest, CommandNotSet) { - auto tx = generateEmptyTransaction(); - // add not set command - tx.mutable_payload()->mutable_reduced_payload()->add_commands(); - - auto answer = validator.validate(tx); - ASSERT_TRUE(answer.hasErrors()); +iroha::protocol::Transaction generateGrantPermissionTransaction( + iroha::protocol::GrantablePermission permission) { + auto tx = iroha::protocol::Transaction(); + + auto gp = tx.mutable_payload() + ->mutable_reduced_payload() + ->add_commands() + ->mutable_grant_permission(); + gp->set_account_id(account_id); + gp->set_permission(permission); + return tx; } -/** - * @given iroha::protocol::Transaction containing create role transaction with - * valid role permission - * @when it is validated - * @then answer with no errors is returned - */ -TEST_F(ProtoTxValidatorTest, CreateRoleValid) { - auto tx = generateCreateRoleTransaction( - role_name, iroha::protocol::RolePermission::can_read_assets); - - auto answer = validator.validate(tx); - ASSERT_FALSE(answer.hasErrors()); +iroha::protocol::Transaction generateRevokePermissionTransaction( + iroha::protocol::GrantablePermission permission) { + auto tx = iroha::protocol::Transaction(); + + auto gp = tx.mutable_payload() + ->mutable_reduced_payload() + ->add_commands() + ->mutable_revoke_permission(); + gp->set_account_id(account_id); + gp->set_permission(permission); + return tx; } -/** - * @given iroha::protocol::Transaction containing create role transaction with - * undefined role permission - * @when it is validated - * @then answer with errors is returned - */ -TEST_F(ProtoTxValidatorTest, CreateRoleInvalid) { - auto tx = generateCreateRoleTransaction( - role_name, static_cast(-1)); +iroha::protocol::Transaction generateAddSignatoryTransaction( + const std::string &signatory) { + auto tx = iroha::protocol::Transaction(); + auto as = tx.mutable_payload() + ->mutable_reduced_payload() + ->add_commands() + ->mutable_add_signatory(); + as->set_account_id(account_id); + as->set_public_key(signatory); + return tx; +} - auto answer = validator.validate(tx); - ASSERT_TRUE(answer.hasErrors()); +iroha::protocol::Transaction generateCreateAccountTransaction( + const std::string &pubkey) { + auto tx = iroha::protocol::Transaction(); + auto ca = tx.mutable_payload() + ->mutable_reduced_payload() + ->add_commands() + ->mutable_create_account(); + ca->set_account_name(account_name); + ca->set_domain_id(domain_id); + ca->set_public_key(pubkey); + return tx; } -/** - * @given iroha::protocol::Transaction containing grant permission transaction - * with valid grantable permission - * @when it is validated - * @then answer with no errors is returned - */ -TEST_F(ProtoTxValidatorTest, GrantPermissionValid) { - auto tx = generateGrantPermissionTransaction( - account_id, iroha::protocol::GrantablePermission::can_add_my_signatory); +iroha::protocol::Transaction generateRemoveSignatoryTransaction( + const std::string &signatory) { + auto tx = iroha::protocol::Transaction(); + auto rs = tx.mutable_payload() + ->mutable_reduced_payload() + ->add_commands() + ->mutable_remove_signatory(); + rs->set_account_id(account_id); + rs->set_public_key(signatory); + return tx; +} - auto answer = validator.validate(tx); - ASSERT_FALSE(answer.hasErrors()) << answer.reason(); +iroha::protocol::Transaction generateAddPeerTransaction( + const std::string &pubkey) { + auto tx = iroha::protocol::Transaction(); + auto as = tx.mutable_payload() + ->mutable_reduced_payload() + ->add_commands() + ->mutable_add_peer(); + as->mutable_peer()->set_address(address_ipv4); + as->mutable_peer()->set_peer_key(pubkey); + return tx; } -/** - * @given iroha::protocol::Transaction containing grant permission transaction - * with invalid grantable permission - * @when it is validated - * @then answer with errors is returned - */ -TEST_F(ProtoTxValidatorTest, GrantPermissionInvalid) { - auto tx = generateGrantPermissionTransaction( - account_id, static_cast(-1)); +class ProtoTxValidatorTest : public ValidatorsTest { + protected: + shared_model::validation::ProtoTransactionValidator validator; +}; - auto answer = validator.validate(tx); - ASSERT_TRUE(answer.hasErrors()); -} +// valid transaction tests + +class ValidProtoTxValidatorTest + : public ProtoTxValidatorTest, + public ::testing::WithParamInterface {}; /** - * @given iroha::protocol::Transaction containing revoke permission transaction - * with valid grantable permission - * @when it is validated - * @then answer with no errors is returned + * @given valid protocol transaction + * @when proto tx validator validates it + * @then answer does not contain errors */ -TEST_F(ProtoTxValidatorTest, RevokePermissionValid) { - auto tx = generateRevokePermissionTransaction( - account_id, iroha::protocol::GrantablePermission::can_add_my_signatory); +TEST_P(ValidProtoTxValidatorTest, ValidTxsTest) { + auto tx = GetParam(); auto answer = validator.validate(tx); - ASSERT_FALSE(answer.hasErrors()) << answer.reason(); + ASSERT_FALSE(answer.hasErrors()) << answer.reason() << std::endl + << tx.DebugString(); } +INSTANTIATE_TEST_CASE_P( + ValidProtoTxs, + ValidProtoTxValidatorTest, + ::testing::Values( + generateAddSignatoryTransaction(valid_pubkey), + generateCreateAccountTransaction(valid_pubkey), + generateRemoveSignatoryTransaction(valid_pubkey), + generateCreateAccountTransaction(valid_pubkey), + generateAddPeerTransaction(valid_pubkey), + generateCreateRoleTransaction(valid_role_permission), + generateGrantPermissionTransaction(valid_grantable_permission), + generateRevokePermissionTransaction(valid_grantable_permission)), ); + +// invalid transaction tests + +class InvalidProtoTxValidatorTest + : public ProtoTxValidatorTest, + public ::testing::WithParamInterface {}; + /** - * @given iroha::protocol::Transaction containing revoke permission transaction - * with invalid grantable permission - * @when it is validated - * @then answer with errors is returned + * @given invalid protocol transaction + * @when proto tx validator validates it + * @then answer contains errors */ -TEST_F(ProtoTxValidatorTest, RevokePermissionInvalid) { - auto tx = generateRevokePermissionTransaction( - account_id, static_cast(-1)); +TEST_P(InvalidProtoTxValidatorTest, InvalidTxssTest) { + auto tx = GetParam(); auto answer = validator.validate(tx); - ASSERT_TRUE(answer.hasErrors()); + ASSERT_TRUE(answer.hasErrors()) << tx.DebugString(); } + +INSTANTIATE_TEST_CASE_P( + InvalidProtoTxs, + InvalidProtoTxValidatorTest, + ::testing::Values( + generateAddSignatoryTransaction(invalid_pubkey), + generateCreateAccountTransaction(invalid_pubkey), + generateRemoveSignatoryTransaction(invalid_pubkey), + generateCreateAccountTransaction(invalid_pubkey), + generateAddPeerTransaction(invalid_pubkey), + generateCreateRoleTransaction(invalid_role_permission), + generateGrantPermissionTransaction(invalid_grantable_permission), + generateRevokePermissionTransaction(invalid_grantable_permission)), ); From 68b0e366c0d9914a2a6b7f27e36e9134df216b47 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Thu, 27 Dec 2018 20:06:41 +0300 Subject: [PATCH 49/61] Refactor transport test with hex Signed-off-by: kamilsa --- test/module/irohad/torii/torii_transport_command_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/module/irohad/torii/torii_transport_command_test.cpp b/test/module/irohad/torii/torii_transport_command_test.cpp index 11c9fe4004..61ad41c501 100644 --- a/test/module/irohad/torii/torii_transport_command_test.cpp +++ b/test/module/irohad/torii/torii_transport_command_test.cpp @@ -118,7 +118,7 @@ TEST_F(CommandServiceTransportGrpcTest, Status) { iroha::protocol::TxStatusRequest tx_request; const shared_model::crypto::Hash hash(std::string(kHashLength, '1')); - tx_request.set_tx_hash(shared_model::crypto::toBinaryString(hash)); + tx_request.set_tx_hash(hash.hex()); iroha::protocol::ToriiResponse toriiResponse; std::shared_ptr response = From 34bf8704d0dc8649a0a24ee0f75351d50e64094c Mon Sep 17 00:00:00 2001 From: kamilsa Date: Thu, 27 Dec 2018 20:07:49 +0300 Subject: [PATCH 50/61] Refactor transport streaming test with hex Signed-off-by: kamilsa --- test/module/irohad/torii/torii_transport_command_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/module/irohad/torii/torii_transport_command_test.cpp b/test/module/irohad/torii/torii_transport_command_test.cpp index 61ad41c501..f7d2fcaf5e 100644 --- a/test/module/irohad/torii/torii_transport_command_test.cpp +++ b/test/module/irohad/torii/torii_transport_command_test.cpp @@ -272,7 +272,7 @@ TEST_F(CommandServiceTransportGrpcTest, StatusStreamOnNotReceived) { .WillOnce(Return(rxcpp::observable<>::iterate(responses))); EXPECT_CALL(response_writer, Write(Property(&iroha::protocol::ToriiResponse::tx_hash, - StrEq(shared_model::crypto::toBinaryString(hash))), + StrEq(hash.hex())), _)) .WillOnce(Return(true)); ASSERT_TRUE(transport_grpc From 14f8334435311054b5d7e2479973ab56383089be Mon Sep 17 00:00:00 2001 From: Akvinikym Date: Thu, 27 Dec 2018 20:12:13 +0300 Subject: [PATCH 51/61] Round-based status stream break-off (#1980) * Started implementing SubscriptionWatcher Signed-off-by: Akvinikym * Torii test and application are up Signed-off-by: Akvinikym * Project is build and everything works Signed-off-by: Akvinikym * Removed timeouts Signed-off-by: Akvinikym * Rewritten the algorithm Signed-off-by: Akvinikym * Nearly all issues Signed-off-by: Akvinikym * Improved the test Signed-off-by: Akvinikym * Improved the test Signed-off-by: Akvinikym --- irohad/main/application.cpp | 6 +-- .../impl/command_service_transport_grpc.cpp | 49 ++++++++++++------- .../impl/command_service_transport_grpc.hpp | 40 ++++++++++----- test/module/iroha-cli/client_test.cpp | 0 test/module/irohad/torii/CMakeLists.txt | 1 + .../torii/torii_transport_command_test.cpp | 26 +++++++--- 6 files changed, 83 insertions(+), 39 deletions(-) create mode 100644 test/module/iroha-cli/client_test.cpp diff --git a/irohad/main/application.cpp b/irohad/main/application.cpp index 68104b7c12..e87d57eb82 100644 --- a/irohad/main/application.cpp +++ b/irohad/main/application.cpp @@ -421,12 +421,12 @@ void Irohad::initTransactionCommandService() { std::make_shared<::torii::CommandServiceTransportGrpc>( command_service, status_bus_, - std::chrono::seconds(1), - 2 * proposal_delay_, status_factory, transaction_factory, batch_parser, - transaction_batch_factory_); + transaction_batch_factory_, + consensus_gate, + 2); log_->info("[Init] => command service"); } diff --git a/irohad/torii/impl/command_service_transport_grpc.cpp b/irohad/torii/impl/command_service_transport_grpc.cpp index 3358ecc0a6..452a432feb 100644 --- a/irohad/torii/impl/command_service_transport_grpc.cpp +++ b/irohad/torii/impl/command_service_transport_grpc.cpp @@ -7,39 +7,44 @@ #include "torii/impl/command_service_transport_grpc.hpp" +#include #include #include #include #include #include "backend/protobuf/transaction_responses/proto_tx_response.hpp" -#include "common/timeout.hpp" #include "interfaces/iroha_internal/transaction_batch.hpp" +#include "interfaces/iroha_internal/transaction_batch_factory.hpp" +#include "interfaces/iroha_internal/transaction_batch_parser.hpp" +#include "interfaces/iroha_internal/tx_status_factory.hpp" #include "interfaces/transaction.hpp" +#include "network/consensus_gate.hpp" +#include "torii/status_bus.hpp" namespace torii { CommandServiceTransportGrpc::CommandServiceTransportGrpc( std::shared_ptr command_service, std::shared_ptr status_bus, - std::chrono::milliseconds initial_timeout, - std::chrono::milliseconds nonfinal_timeout, std::shared_ptr status_factory, std::shared_ptr transaction_factory, std::shared_ptr batch_parser, std::shared_ptr transaction_batch_factory, + std::shared_ptr consensus_gate, + int maximum_rounds_without_update, logger::Logger log) : command_service_(std::move(command_service)), status_bus_(std::move(status_bus)), - initial_timeout_(initial_timeout), - nonfinal_timeout_(nonfinal_timeout), status_factory_(std::move(status_factory)), transaction_factory_(std::move(transaction_factory)), batch_parser_(std::move(batch_parser)), batch_factory_(std::move(transaction_batch_factory)), - log_(std::move(log)) {} + log_(std::move(log)), + consensus_gate_(std::move(consensus_gate)), + maximum_rounds_without_update_(maximum_rounds_without_update) {} grpc::Status CommandServiceTransportGrpc::Torii( grpc::ServerContext *context, @@ -180,6 +185,20 @@ namespace torii { std::string client_id = (client_id_format % context->peer() % hash.toString()).str(); + // in each round, increment the round counter, showing number of consecutive + // rounds without status update; if it becomes greater than some predefined + // value, stop the status streaming + std::atomic_int round_counter{0}; + consensus_gate_->onOutcome().subscribe( + [this, &subscription, &round_counter](const auto &) { + auto new_val = round_counter.load() + 1; + if (new_val >= maximum_rounds_without_update_) { + subscription.unsubscribe(); + } else { + round_counter++; + } + }); + command_service_ ->getStatusStream(hash) // convert to transport objects @@ -189,16 +208,6 @@ namespace torii { shared_model::proto::TransactionResponse>(response) ->getTransport(); }) - // set a corresponding observable timeout based on status value - .lift( - iroha::makeTimeout( - [&](const auto &response) { - return response.tx_status() - == iroha::protocol::TxStatus::NOT_RECEIVED - ? initial_timeout_ - : nonfinal_timeout_; - }, - current_thread)) // complete the observable if client is disconnected .take_while([=](const auto &) { auto is_cancelled = context->IsCancelled(); @@ -208,13 +217,17 @@ namespace torii { return not is_cancelled; }) .subscribe(subscription, - [&](iroha::protocol::ToriiResponse response) { + [this, &response_writer, &client_id, &round_counter]( + iroha::protocol::ToriiResponse response) { if (response_writer->Write(response)) { log_->debug("status written, {}", client_id); + // reset consecutive rounds counter for this tx + round_counter.store(0); } }, [&](std::exception_ptr ep) { - log_->debug("processing timeout, {}", client_id); + log_->error("something bad happened, client_id {}", + client_id); }, [&] { log_->debug("stream done, {}", client_id); }); diff --git a/irohad/torii/impl/command_service_transport_grpc.hpp b/irohad/torii/impl/command_service_transport_grpc.hpp index b094bca15c..07b889bec9 100644 --- a/irohad/torii/impl/command_service_transport_grpc.hpp +++ b/irohad/torii/impl/command_service_transport_grpc.hpp @@ -8,16 +8,31 @@ #include "torii/command_service.hpp" -#include - #include "endpoint.grpc.pb.h" #include "endpoint.pb.h" +#include "interfaces/common_objects/transaction_sequence_common.hpp" #include "interfaces/iroha_internal/abstract_transport_factory.hpp" -#include "interfaces/iroha_internal/transaction_batch_factory.hpp" -#include "interfaces/iroha_internal/transaction_batch_parser.hpp" -#include "interfaces/iroha_internal/tx_status_factory.hpp" #include "logger/logger.hpp" -#include "torii/status_bus.hpp" + +namespace iroha { + namespace torii { + class StatusBus; + } +} // namespace iroha + +namespace shared_model { + namespace interface { + class TxStatusFactory; + class TransactionBatchParser; + class TransactionBatchFactory; + } // namespace interface +} // namespace shared_model + +namespace iroha { + namespace network { + class ConsensusGate; + } +} // namespace iroha namespace torii { class CommandServiceTransportGrpc @@ -32,19 +47,17 @@ namespace torii { * Creates a new instance of CommandServiceTransportGrpc * @param command_service - to delegate logic work * @param status_bus is a common notifier for tx statuses - * @param initial_timeout - streaming timeout when tx is not received - * @param nonfinal_timeout - streaming timeout when tx is being processed * @param status_factory - factory of statuses * @param transaction_factory - factory of transactions * @param batch_parser - parses of batches * @param transaction_batch_factory - factory of batches + * @param initial_timeout - streaming timeout when tx is not received + * @param nonfinal_timeout - streaming timeout when tx is being processed * @param log to print progress */ CommandServiceTransportGrpc( std::shared_ptr command_service, std::shared_ptr status_bus, - std::chrono::milliseconds initial_timeout, - std::chrono::milliseconds nonfinal_timeout, std::shared_ptr status_factory, std::shared_ptr transaction_factory, @@ -52,6 +65,8 @@ namespace torii { batch_parser, std::shared_ptr transaction_batch_factory, + std::shared_ptr consensus_gate, + int maximum_rounds_without_update, logger::Logger log = logger::log("CommandServiceTransportGrpc")); /** @@ -112,8 +127,6 @@ namespace torii { std::shared_ptr command_service_; std::shared_ptr status_bus_; - const std::chrono::milliseconds initial_timeout_; - const std::chrono::milliseconds nonfinal_timeout_; std::shared_ptr status_factory_; std::shared_ptr transaction_factory_; std::shared_ptr @@ -121,6 +134,9 @@ namespace torii { std::shared_ptr batch_factory_; logger::Logger log_; + + std::shared_ptr consensus_gate_; + const int maximum_rounds_without_update_; }; } // namespace torii diff --git a/test/module/iroha-cli/client_test.cpp b/test/module/iroha-cli/client_test.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/module/irohad/torii/CMakeLists.txt b/test/module/irohad/torii/CMakeLists.txt index 15da630d04..3a7b905c04 100644 --- a/test/module/irohad/torii/CMakeLists.txt +++ b/test/module/irohad/torii/CMakeLists.txt @@ -10,6 +10,7 @@ addtest(torii_transport_command_test torii_transport_command_test.cpp) target_link_libraries(torii_transport_command_test torii_service command_client + gate_object ) addtest(torii_queries_test torii_queries_test.cpp) diff --git a/test/module/irohad/torii/torii_transport_command_test.cpp b/test/module/irohad/torii/torii_transport_command_test.cpp index 11c9fe4004..4307ff5cdb 100644 --- a/test/module/irohad/torii/torii_transport_command_test.cpp +++ b/test/module/irohad/torii/torii_transport_command_test.cpp @@ -20,6 +20,7 @@ #include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp" #include "interfaces/iroha_internal/transaction_batch_parser_impl.hpp" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" +#include "module/irohad/network/network_mocks.hpp" #include "module/irohad/torii/torii_mocks.hpp" #include "module/shared_model/interface/mock_transaction_batch_factory.hpp" #include "module/shared_model/validators/validators.hpp" @@ -34,12 +35,12 @@ using ::testing::Property; using ::testing::Return; using ::testing::StrEq; +using iroha::consensus::BlockReject; +using iroha::consensus::GateObject; + using namespace iroha::ametsuchi; using namespace iroha::torii; - using namespace std::chrono_literals; -constexpr std::chrono::milliseconds initial_timeout = 1s; -constexpr std::chrono::milliseconds nonfinal_timeout = 2 * 10s; class CommandServiceTransportGrpcTest : public testing::Test { private: @@ -72,6 +73,11 @@ class CommandServiceTransportGrpcTest : public testing::Test { batch_parser = std::make_shared(); batch_factory = std::make_shared(); + + mock_consensus_gate = std::make_shared(); + ON_CALL(*mock_consensus_gate, onOutcome()) + .WillByDefault( + Return(rxcpp::observable<>::empty())); } void SetUp() override { @@ -83,12 +89,12 @@ class CommandServiceTransportGrpcTest : public testing::Test { transport_grpc = std::make_shared( command_service, status_bus, - initial_timeout, - nonfinal_timeout, status_factory, transaction_factory, batch_parser, - batch_factory); + batch_factory, + mock_consensus_gate, + 2); } std::shared_ptr status_bus; @@ -104,6 +110,8 @@ class CommandServiceTransportGrpcTest : public testing::Test { std::shared_ptr command_service; std::shared_ptr transport_grpc; + std::shared_ptr mock_consensus_gate; + const size_t kHashLength = 32; const size_t kTimes = 5; }; @@ -264,6 +272,7 @@ TEST_F(CommandServiceTransportGrpcTest, StatusStreamOnNotReceived) { grpc::ServerContext context; iroha::protocol::TxStatusRequest request; iroha::MockServerWriter response_writer; + std::vector> responses; shared_model::crypto::Hash hash("1"); @@ -275,6 +284,11 @@ TEST_F(CommandServiceTransportGrpcTest, StatusStreamOnNotReceived) { StrEq(shared_model::crypto::toBinaryString(hash))), _)) .WillOnce(Return(true)); + + std::vector gate_objects{BlockReject{}, BlockReject{}}; + EXPECT_CALL(*mock_consensus_gate, onOutcome()) + .WillOnce(Return(rxcpp::observable<>::iterate(gate_objects))); + ASSERT_TRUE(transport_grpc ->StatusStream( &context, From 6d99255cceec81dddef5abf8ac4c0e498dccc671 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Fri, 28 Dec 2018 09:33:53 +0300 Subject: [PATCH 52/61] Fix naming Signed-off-by: kamilsa --- .../module/irohad/model/converters/json_commands_test.cpp | 8 ++++---- test/module/irohad/model/converters/pb_commands_test.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/module/irohad/model/converters/json_commands_test.cpp b/test/module/irohad/model/converters/json_commands_test.cpp index b8bf6e7361..6a34189cfc 100644 --- a/test/module/irohad/model/converters/json_commands_test.cpp +++ b/test/module/irohad/model/converters/json_commands_test.cpp @@ -127,14 +127,14 @@ TEST_F(JsonCommandTest, add_peer) { auto orig_addPeer = std::make_shared(); orig_addPeer->peer.address = "10.90.129.23"; auto proto_add_peer = factory.serializeAddPeer(orig_addPeer); - auto serial_addPeer = factory.deserializeAddPeer(proto_add_peer); + auto deserialized_addPeer = factory.deserializeAddPeer(proto_add_peer); - ASSERT_TRUE(serial_addPeer); - ASSERT_EQ(*orig_addPeer, **serial_addPeer); + ASSERT_TRUE(deserialized_addPeer); + ASSERT_EQ(*orig_addPeer, **deserialized_addPeer); command_converter_test(orig_addPeer); orig_addPeer->peer.address = "134"; - ASSERT_NE(**serial_addPeer, *orig_addPeer); + ASSERT_NE(**deserialized_addPeer, *orig_addPeer); } TEST_F(JsonCommandTest, add_signatory) { diff --git a/test/module/irohad/model/converters/pb_commands_test.cpp b/test/module/irohad/model/converters/pb_commands_test.cpp index 57d86f9c76..3efe183d72 100644 --- a/test/module/irohad/model/converters/pb_commands_test.cpp +++ b/test/module/irohad/model/converters/pb_commands_test.cpp @@ -74,13 +74,13 @@ TEST(CommandTest, add_peer) { auto factory = iroha::model::converters::PbCommandFactory(); auto proto_add_peer = factory.serializeAddPeer(orig_addPeer); - const auto& serial_addPeer = factory.deserializeAddPeer(proto_add_peer); + const auto &deserialized_addPeer = factory.deserializeAddPeer(proto_add_peer); - ASSERT_EQ(orig_addPeer, serial_addPeer); + ASSERT_EQ(orig_addPeer, deserialized_addPeer); command_converter_test(orig_addPeer); orig_addPeer.peer.address = "134"; - ASSERT_NE(serial_addPeer, orig_addPeer); + ASSERT_NE(deserialized_addPeer, orig_addPeer); } TEST(CommandTest, add_signatory) { From bf667bdda09d04ee1301064a0ce83daa6efca701 Mon Sep 17 00:00:00 2001 From: kamilsa Date: Fri, 28 Dec 2018 09:48:32 +0300 Subject: [PATCH 53/61] Update naming in proto transaction validator Signed-off-by: kamilsa --- .../validators/protobuf/proto_block_validator.cpp | 1 + .../protobuf/proto_transaction_validator.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shared_model/validators/protobuf/proto_block_validator.cpp b/shared_model/validators/protobuf/proto_block_validator.cpp index 2c9ddc982e..d3cffee852 100644 --- a/shared_model/validators/protobuf/proto_block_validator.cpp +++ b/shared_model/validators/protobuf/proto_block_validator.cpp @@ -24,6 +24,7 @@ namespace shared_model { == iroha::protocol::Block::BLOCK_VERSION_NOT_SET) { reason.second.emplace_back("Block version is not set"); answer.addReason(std::move(reason)); + return answer; } const auto &rejected_hashes = diff --git a/shared_model/validators/protobuf/proto_transaction_validator.cpp b/shared_model/validators/protobuf/proto_transaction_validator.cpp index 18ccf7a454..5956966db5 100644 --- a/shared_model/validators/protobuf/proto_transaction_validator.cpp +++ b/shared_model/validators/protobuf/proto_transaction_validator.cpp @@ -10,8 +10,8 @@ namespace shared_model { namespace validation { - void validateHexField(const std::string &public_key, - ReasonsGroupType &reason) { + void validatePublicKey(const std::string &public_key, + ReasonsGroupType &reason) { if (not validateHexString(public_key)) { reason.second.emplace_back("Public key is not in hex format"); } @@ -31,22 +31,22 @@ namespace shared_model { } case iroha::protocol::Command::kAddSignatory: { const auto &as = command.add_signatory(); - validateHexField(as.public_key(), reason); + validatePublicKey(as.public_key(), reason); break; } case iroha::protocol::Command::kCreateAccount: { const auto &ca = command.create_account(); - validateHexField(ca.public_key(), reason); + validatePublicKey(ca.public_key(), reason); break; } case iroha::protocol::Command::kRemoveSignatory: { const auto &rs = command.remove_signatory(); - validateHexField(rs.public_key(), reason); + validatePublicKey(rs.public_key(), reason); break; } case iroha::protocol::Command::kAddPeer: { const auto &ap = command.add_peer(); - validateHexField(ap.peer().peer_key(), reason); + validatePublicKey(ap.peer().peer_key(), reason); break; } case iroha::protocol::Command::kCreateRole: { From 0e645f4aa78ae7af835bbc5e70a5ed12f53b025d Mon Sep 17 00:00:00 2001 From: Igor Egorov Date: Fri, 28 Dec 2018 12:25:09 +0300 Subject: [PATCH 54/61] Improve and make delay func pluggable to ordering gate init (#1997) Signed-off-by: Igor Egorov --- irohad/main/application.cpp | 28 ++++++++++++- irohad/main/impl/on_demand_ordering_init.cpp | 41 +++++--------------- irohad/main/impl/on_demand_ordering_init.hpp | 8 +++- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/irohad/main/application.cpp b/irohad/main/application.cpp index e87d57eb82..9ab1f391cd 100644 --- a/irohad/main/application.cpp +++ b/irohad/main/application.cpp @@ -267,6 +267,31 @@ void Irohad::initOrderingGate() { auto factory = std::make_unique>(); + const uint64_t kCounter = 0, kMaxLocalCounter = 2; + // reject_counter and local_counter are local mutable variables of lambda + const uint64_t kMaxDelaySeconds = 5; + auto delay = [reject_counter = kCounter, + local_counter = kCounter, + // MSVC requires const variables to be captured + kMaxDelaySeconds, + kMaxLocalCounter](const auto &commit) mutable { + using iroha::synchronizer::SynchronizationOutcomeType; + if (commit.sync_outcome == SynchronizationOutcomeType::kReject + or commit.sync_outcome == SynchronizationOutcomeType::kNothing) { + // Increment reject_counter each local_counter calls of function + ++local_counter; + if (local_counter == kMaxLocalCounter) { + local_counter = 0; + if (reject_counter < kMaxDelaySeconds) { + reject_counter++; + } + } + } else { + reject_counter = 0; + } + return std::chrono::seconds(reject_counter); + }; + ordering_gate = ordering_init.initOrderingGate(max_proposal_size_, proposal_delay_, std::move(hashes), @@ -277,7 +302,8 @@ void Irohad::initOrderingGate() { async_call_, std::move(factory), persistent_cache, - {blocks.back()->height(), 1}); + {blocks.back()->height(), 1}, + delay); log_->info("[Init] => init ordering gate - [{}]", logger::logBool(ordering_gate)); } diff --git a/irohad/main/impl/on_demand_ordering_init.cpp b/irohad/main/impl/on_demand_ordering_init.cpp index 32a78a997a..9da8a17d32 100644 --- a/irohad/main/impl/on_demand_ordering_init.cpp +++ b/irohad/main/impl/on_demand_ordering_init.cpp @@ -184,35 +184,9 @@ namespace iroha { std::shared_ptr proposal_factory, std::shared_ptr tx_cache, - consensus::Round initial_round) { - // TODO andrei 06.12.18 IR-75 Make counter and generator parametrizable - const uint64_t kCounter = 0, kMaxLocalCounter = 2; - auto time_generator = [](auto reject_counter) { - return std::chrono::seconds(reject_counter); - }; - // reject_counter and local_counter are local mutable variables of lambda - auto delay = [reject_counter = kCounter, - local_counter = kCounter, - &time_generator, - // MSVC requires const variables to be captured - kMaxLocalCounter](const auto &commit) mutable { - using iroha::synchronizer::SynchronizationOutcomeType; - if (commit.sync_outcome == SynchronizationOutcomeType::kReject - or commit.sync_outcome == SynchronizationOutcomeType::kNothing) { - // Increment reject_counter each local_counter calls of function - ++local_counter; - if (local_counter == kMaxLocalCounter) { - local_counter = 0; - if (reject_counter - < std::numeric_limits::max()) { - reject_counter++; - } - } - } else { - reject_counter = 0; - } - return time_generator(reject_counter); - }; + consensus::Round initial_round, + std::function delay_func) { auto map = [](auto commit) { return matchEvent( @@ -251,7 +225,7 @@ namespace iroha { notifier.get_observable() .lift( iroha::makeDelay( - delay, rxcpp::identity_current_thread())) + delay_func, rxcpp::identity_current_thread())) .map(map), std::move(cache), std::move(proposal_factory), @@ -290,7 +264,9 @@ namespace iroha { std::shared_ptr proposal_factory, std::shared_ptr tx_cache, - consensus::Round initial_round) { + consensus::Round initial_round, + std::function delay_func) { auto ordering_service = createService(max_size, proposal_factory, tx_cache); service = std::make_shared( @@ -306,7 +282,8 @@ namespace iroha { std::make_shared(), std::move(proposal_factory), std::move(tx_cache), - initial_round); + initial_round, + std::move(delay_func)); } } // namespace network diff --git a/irohad/main/impl/on_demand_ordering_init.hpp b/irohad/main/impl/on_demand_ordering_init.hpp index e7a199fb62..a546a78b5c 100644 --- a/irohad/main/impl/on_demand_ordering_init.hpp +++ b/irohad/main/impl/on_demand_ordering_init.hpp @@ -61,7 +61,9 @@ namespace iroha { std::shared_ptr proposal_factory, std::shared_ptr tx_cache, - consensus::Round initial_round); + consensus::Round initial_round, + std::function delay_func); /** * Creates on-demand ordering service. \see initOrderingGate for @@ -116,7 +118,9 @@ namespace iroha { std::shared_ptr proposal_factory, std::shared_ptr tx_cache, - consensus::Round initial_round); + consensus::Round initial_round, + std::function delay_func); /// gRPC service for ordering service std::shared_ptr service; From 2dd468e012bd14507215437808fa896cda998917 Mon Sep 17 00:00:00 2001 From: Igor Egorov Date: Fri, 28 Dec 2018 12:25:52 +0300 Subject: [PATCH 55/61] Make CreateAccount cmd validation stronger (#1966) CreateAccount command now respects a set of perms of tx creator It should not be possible to create an account in a domain which default role has some permissions that does not have a creator of a transaction. Signed-off-by: Igor Egorov --- .../impl/postgres_command_executor.cpp | 26 +++++++++++--- .../acceptance/create_account_test.cpp | 36 +++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/irohad/ametsuchi/impl/postgres_command_executor.cpp b/irohad/ametsuchi/impl/postgres_command_executor.cpp index 929a867bc4..ab8a207f53 100644 --- a/irohad/ametsuchi/impl/postgres_command_executor.cpp +++ b/irohad/ametsuchi/impl/postgres_command_executor.cpp @@ -283,7 +283,8 @@ namespace { END ELSE false END )") % checkAccountRolePermission(global_permission, creator_id) - % checkAccountRolePermission(domain_permission, creator_id) + % checkAccountRolePermission(domain_permission, + creator_id) % creator_id % id_with_target_domain) .str(); return query; @@ -1286,13 +1287,30 @@ namespace iroha { {"createAccount", createAccountBase, {(boost::format(R"( - has_perm AS (%s),)") + domain_role_permissions_bits AS ( + SELECT COALESCE(bit_or(rhp.permission), '0'::bit(%1%)) AS bits + FROM role_has_permissions AS rhp + WHERE rhp.role_id = (SELECT * FROM get_domain_default_role)), + account_permissions AS ( + SELECT COALESCE(bit_or(rhp.permission), '0'::bit(%1%)) AS perm + FROM role_has_permissions AS rhp + JOIN account_has_roles AS ar ON ar.role_id = rhp.role_id + WHERE ar.account_id = $1 + ), + creator_has_enough_permissions AS ( + SELECT ap.perm & dpb.bits = dpb.bits + FROM account_permissions AS ap, domain_role_permissions_bits AS dpb + ), + has_perm AS (%2%), + )") % bits % checkAccountRolePermission( shared_model::interface::permissions::Role::kCreateAccount, "$1")) .str(), - R"(AND (SELECT * FROM has_perm))", - R"(WHEN NOT (SELECT * FROM has_perm) THEN 2)"}}); + R"(AND (SELECT * FROM has_perm) + AND (SELECT * FROM creator_has_enough_permissions))", + R"(WHEN NOT (SELECT * FROM has_perm) THEN 2 + WHEN NOT (SELECT * FROM creator_has_enough_permissions) THEN 2)"}}); statements.push_back( {"createAsset", diff --git a/test/integration/acceptance/create_account_test.cpp b/test/integration/acceptance/create_account_test.cpp index 60e4f5770f..8dd2955400 100644 --- a/test/integration/acceptance/create_account_test.cpp +++ b/test/integration/acceptance/create_account_test.cpp @@ -11,6 +11,11 @@ using namespace integration_framework; using namespace shared_model; using namespace common_constants; +// TODO igor-egorov, 2018-12-27, IR-148, move all check macroses to +// acceptance_fixture.hpp +#define check(i) \ + [](const auto &resp) { ASSERT_EQ(resp->transactions().size(), i); } + class CreateAccount : public AcceptanceFixture { public: auto makeUserWithPerms(const interface::RolePermissionSet &perms = { @@ -156,3 +161,34 @@ TEST_F(CreateAccount, EmptyName) { empty_name, kDomain, kNewUserKeypair.publicKey())), CHECK_STATELESS_INVALID); } + +/** + * Checks that there is no privelege elevation issue via CreateAccount + * + * @given two domains: the first domain has default role that contain + * can_create_account permission, the second domain has default role that + * contains more permissions than default role of the first domain + * @when the user of an account from the first domain tries to create an account + * in the second domain + * @then transaction should fail stateful validation + */ +TEST_F(CreateAccount, PrivelegeElevation) { + auto second_domain_tx = complete( + baseTx(kAdminId).createDomain(kSecondDomain, kAdminRole), kAdminKeypair); + auto create_elevated_user = complete(baseTx().createAccount( + kNewUser, kSecondDomain, kNewUserKeypair.publicKey())); + auto rejected_hash = create_elevated_user.hash(); + + IntegrationTestFramework(1) + .setInitialState(kAdminKeypair) + .sendTxAwait(second_domain_tx, check(1)) + .sendTxAwait(makeUserWithPerms(), check(1)) + .sendTx(create_elevated_user) + .skipProposal() + .checkVerifiedProposal(check(0)) + .checkBlock([&rejected_hash](const auto &block) { + const auto rejected_hashes = block->rejected_transactions_hashes(); + ASSERT_THAT(rejected_hashes, ::testing::Contains(rejected_hash)); + ASSERT_EQ(boost::size(rejected_hashes), 1); + }); +} From 6a345867c3bae91280bce8e2c13f3bdc47ba6cd5 Mon Sep 17 00:00:00 2001 From: Mikhail Boldyrev Date: Fri, 28 Dec 2018 12:38:33 +0300 Subject: [PATCH 56/61] more precize status logging (#1965) Signed-off-by: Mikhail Boldyrev --- irohad/main/application.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/irohad/main/application.cpp b/irohad/main/application.cpp index 9ab1f391cd..fbfce0118d 100644 --- a/irohad/main/application.cpp +++ b/irohad/main/application.cpp @@ -384,11 +384,26 @@ void Irohad::initPeerCommunicationService() { pcs = std::make_shared( ordering_gate, synchronizer, simulator); - pcs->onProposal().subscribe( - [this](auto) { log_->info("~~~~~~~~~| PROPOSAL ^_^ |~~~~~~~~~ "); }); + pcs->onProposal().subscribe([this](const auto &) { + log_->info("~~~~~~~~~| PROPOSAL ^_^ |~~~~~~~~~ "); + }); - pcs->on_commit().subscribe( - [this](auto) { log_->info("~~~~~~~~~| COMMIT =^._.^= |~~~~~~~~~ "); }); + pcs->on_commit().subscribe([this](const auto &event) { + using iroha::synchronizer::SynchronizationOutcomeType; + switch (event.sync_outcome) { + case SynchronizationOutcomeType::kCommit: + log_->info(R"(~~~~~~~~~| COMMIT =^._.^= |~~~~~~~~~ )"); + break; + case SynchronizationOutcomeType::kReject: + log_->info(R"(~~~~~~~~~| REJECT \(*.*)/ |~~~~~~~~~ )"); + break; + case SynchronizationOutcomeType::kNothing: + log_->info(R"(~~~~~~~~~| EMPTY (-_-)zzz |~~~~~~~~~ )"); + break; + default: + break; + } + }); log_->info("[Init] => pcs"); } From 840c9183fa267f3969d6718c9e0213d80c0547a3 Mon Sep 17 00:00:00 2001 From: Victor Drobny Date: Fri, 28 Dec 2018 19:36:38 +0100 Subject: [PATCH 57/61] remove common object builders from postgres executor test (#1995) * remove common object builders from postgres executor test Signed-off-by: Victor Drobny --- test/module/irohad/ametsuchi/CMakeLists.txt | 1 - .../ametsuchi/postgres_executor_test.cpp | 762 ++++++++---------- 2 files changed, 317 insertions(+), 446 deletions(-) diff --git a/test/module/irohad/ametsuchi/CMakeLists.txt b/test/module/irohad/ametsuchi/CMakeLists.txt index d5ccaaea39..484203143a 100644 --- a/test/module/irohad/ametsuchi/CMakeLists.txt +++ b/test/module/irohad/ametsuchi/CMakeLists.txt @@ -50,7 +50,6 @@ addtest(postgres_executor_test postgres_executor_test.cpp) target_link_libraries(postgres_executor_test integration_framework_config_helper shared_model_proto_backend - shared_model_default_builders ametsuchi commands_mocks_factory ) diff --git a/test/module/irohad/ametsuchi/postgres_executor_test.cpp b/test/module/irohad/ametsuchi/postgres_executor_test.cpp index 9580d59c74..7e2cc7c053 100644 --- a/test/module/irohad/ametsuchi/postgres_executor_test.cpp +++ b/test/module/irohad/ametsuchi/postgres_executor_test.cpp @@ -10,11 +10,8 @@ #include "framework/result_fixture.hpp" #include "module/irohad/ametsuchi/ametsuchi_fixture.hpp" #include "module/irohad/ametsuchi/ametsuchi_mocks.hpp" -#include "module/shared_model/builders/protobuf/test_account_builder.hpp" -#include "module/shared_model/builders/protobuf/test_asset_builder.hpp" -#include "module/shared_model/builders/protobuf/test_domain_builder.hpp" -#include "module/shared_model/builders/protobuf/test_peer_builder.hpp" #include "module/shared_model/mock_objects_factories/mock_command_factory.hpp" +#include "module/shared_model/interface_mocks.hpp" namespace iroha { namespace ametsuchi { @@ -27,15 +24,10 @@ namespace iroha { // TODO [IR-1831] Akvinikym 31.10.18: rework the CommandExecutorTest public: CommandExecutorTest() { - domain = clone( - TestDomainBuilder().domainId("domain").defaultRole(role).build()); - - account = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id@" + domain->domainId()) - .quorum(1) - .jsonData(R"({"id@domain": {"key": "value"}})") - .build()); + domain_id = "domain"; + name = "id"; + account_id = name + "@" + domain_id; + role_permissions.set( shared_model::interface::permissions::Role::kAddMySignatory); grantable_permission = @@ -154,16 +146,15 @@ namespace iroha { } void createDefaultDomain() { - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain->domainId(), role), - true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain_id, role), + true)); } void createDefaultAccount() { CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), + name, domain_id, *pubkey), true)); } @@ -171,8 +162,8 @@ namespace iroha { const std::string another_role = "role2"; shared_model::interface::RolePermissionSet role_permissions; shared_model::interface::permissions::Grantable grantable_permission; - std::unique_ptr account; - std::unique_ptr domain; + shared_model::interface::types::DomainIdType domain_id; + shared_model::interface::types::AccountIdType account_id, name; std::unique_ptr pubkey; std::unique_ptr sql; @@ -216,7 +207,7 @@ namespace iroha { } shared_model::interface::types::AssetIdType asset_id = - "coin#" + domain->domainId(); + "coin#" + domain_id; }; /** @@ -232,8 +223,7 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero))); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -241,7 +231,7 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero))); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); } @@ -260,8 +250,7 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero))); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -269,7 +258,7 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero))); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); } @@ -280,26 +269,22 @@ namespace iroha { * @then account asset is not added */ TEST_F(AddAccountAssetTest, DomainPermInvalid) { - std::unique_ptr domain2; - domain2 = clone( - TestDomainBuilder().domainId("domain2").defaultRole(role).build()); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role), - true)); - addAsset(domain2->domainId()); + shared_model::interface::types::DomainIdType domain2_id = "domain2"; + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain2_id, role), + true)); + addAsset(domain2_id); addOnePerm( shared_model::interface::permissions::Role::kAddDomainAssetQty); - auto asset2_id = "coin#" + domain2->domainId(); + auto asset2_id = "coin#" + domain2_id; CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( asset2_id, asset_amount_one_zero), true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset2_id); + auto account_asset = query->getAccountAsset(account_id, asset2_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -307,10 +292,8 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset2_id, asset_amount_one_zero)); - std::vector query_args{account->accountId(), - asset_amount_one_zero.toStringRepr(), - asset2_id, - "1"}; + std::vector query_args{ + account_id, asset_amount_one_zero.toStringRepr(), asset2_id, "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -326,17 +309,14 @@ namespace iroha { asset_id, asset_amount_one_zero); CHECK_SUCCESSFUL_RESULT(execute(*add_asset, true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); auto cmd_result = execute(*add_asset); - std::vector query_args{account->accountId(), - asset_amount_one_zero.toStringRepr(), - asset_id, - "1"}; + std::vector query_args{ + account_id, asset_amount_one_zero.toStringRepr(), asset_id, "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -351,10 +331,8 @@ namespace iroha { asset_id, asset_amount_one_zero), true); - std::vector query_args{account->accountId(), - asset_amount_one_zero.toStringRepr(), - asset_id, - "1"}; + std::vector query_args{ + account_id, asset_amount_one_zero.toStringRepr(), asset_id, "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } @@ -373,7 +351,7 @@ namespace iroha { auto cmd_result = execute(*add_asset, true); std::vector query_args{ - account->accountId(), uint256_halfmax.toStringRepr(), asset_id, "1"}; + account_id, uint256_halfmax.toStringRepr(), asset_id, "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -381,12 +359,21 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - peer = clone(TestPeerBuilder().build()); + address = + std::make_unique(""); + pk = std::make_unique(""); + peer = std::make_unique(); + EXPECT_CALL(*peer, address()) + .WillRepeatedly(testing::ReturnRef(*address)); + EXPECT_CALL(*peer, pubkey()).WillRepeatedly(testing::ReturnRef(*pk)); createDefaultRole(); createDefaultDomain(); createDefaultAccount(); } - std::unique_ptr peer; + + std::unique_ptr address; + std::unique_ptr pk; + std::unique_ptr peer; }; /** @@ -420,8 +407,8 @@ namespace iroha { createDefaultDomain(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id", - domain->domainId(), + name, + domain_id, shared_model::interface::types::PubkeyType( std::string('5', 32))), true)); @@ -436,11 +423,10 @@ namespace iroha { TEST_F(AddSignatory, Valid) { addAllPerms(); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId()))); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(*pubkey, account_id))); - auto signatories = query->getSignatories(account->accountId()); + auto signatories = query->getSignatories(account_id); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) != signatories->end()); @@ -455,16 +441,15 @@ namespace iroha { CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateAccount( "id2", - domain->domainId(), + domain_id, shared_model::interface::types::PubkeyType(std::string('2', 32))), true)); auto perm = shared_model::interface::permissions::Grantable::kAddMySignatory; - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain")); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructGrantPermission(account_id, perm), + true, + "id2@domain")); CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructAddSignatory(*pubkey, "id2@domain"))); auto signatories = query->getSignatories("id2@domain"); @@ -479,13 +464,13 @@ namespace iroha { * @then signatory is not added */ TEST_F(AddSignatory, NoPerms) { - auto cmd_result = execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId())); + auto cmd_result = execute( + *mock_command_factory->constructAddSignatory(*pubkey, account_id)); - std::vector query_args{account->accountId(), pubkey->hex()}; + std::vector query_args{account_id, pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - auto signatories = query->getSignatories(account->accountId()); + auto signatories = query->getSignatories(account_id); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) == signatories->end()); @@ -499,14 +484,13 @@ namespace iroha { */ TEST_F(AddSignatory, ExistingPubKey) { addAllPerms(); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId()))); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(*pubkey, account_id))); - auto cmd_result = execute(*mock_command_factory->constructAddSignatory( - *pubkey, account->accountId())); + auto cmd_result = execute( + *mock_command_factory->constructAddSignatory(*pubkey, account_id)); - std::vector query_args{account->accountId(), pubkey->hex()}; + std::vector query_args{account_id, pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -533,9 +517,9 @@ namespace iroha { role_permissions), true)); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role))); - auto roles = query->getAccountRoles(account->accountId()); + execute(*mock_command_factory->constructAppendRole(account_id, + another_role))); + auto roles = query->getAccountRoles(account_id); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) != roles->end()); @@ -551,9 +535,9 @@ namespace iroha { CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(another_role, {}), true)); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role))); - auto roles = query->getAccountRoles(account->accountId()); + execute(*mock_command_factory->constructAppendRole(account_id, + another_role))); + auto roles = query->getAccountRoles(account_id); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) != roles->end()); @@ -572,11 +556,10 @@ namespace iroha { execute(*mock_command_factory->constructCreateRole(another_role, role_permissions2), true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role), - true)); - auto roles = query->getAccountRoles(account->accountId()); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAppendRole(account_id, another_role), + true)); + auto roles = query->getAccountRoles(account_id); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) != roles->end()); @@ -592,13 +575,13 @@ namespace iroha { execute(*mock_command_factory->constructCreateRole(another_role, role_permissions), true)); - auto cmd_result = execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role)); + auto cmd_result = execute( + *mock_command_factory->constructAppendRole(account_id, another_role)); - std::vector query_args{account->accountId(), another_role}; + std::vector query_args{account_id, another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - auto roles = query->getAccountRoles(account->accountId()); + auto roles = query->getAccountRoles(account_id); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) == roles->end()); @@ -616,10 +599,10 @@ namespace iroha { execute(*mock_command_factory->constructCreateRole(another_role, role_permissions2), true)); - auto cmd_result = execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role)); + auto cmd_result = execute( + *mock_command_factory->constructAppendRole(account_id, another_role)); - std::vector query_args{account->accountId(), another_role}; + std::vector query_args{account_id, another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -646,10 +629,10 @@ namespace iroha { */ TEST_F(AppendRole, NoRole) { addAllPerms(); - auto cmd_result = execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role)); + auto cmd_result = execute( + *mock_command_factory->constructAppendRole(account_id, another_role)); - std::vector query_args{account->accountId(), another_role}; + std::vector query_args{account_id, another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -657,24 +640,13 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - account = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id@" + domain->domainId()) - .quorum(1) - .jsonData("{}") - .build()); - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData("{}") - .build()); + account2_id = "id2@" + domain_id; createDefaultRole(); createDefaultDomain(); createDefaultAccount(); } - std::unique_ptr account2; + shared_model::interface::types::AccountIdType account2_id; }; /** @@ -686,10 +658,10 @@ namespace iroha { addAllPerms(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey))); - auto acc = query->getAccount(account2->accountId()); + "id2", domain_id, *pubkey))); + auto acc = query->getAccount(account2_id); ASSERT_TRUE(acc); - ASSERT_EQ(*account2.get(), *acc.get()); + ASSERT_EQ(account2_id, acc.get()->accountId()); } /** @@ -699,12 +671,12 @@ namespace iroha { */ TEST_F(CreateAccount, NoPerms) { auto cmd_result = execute(*mock_command_factory->constructCreateAccount( - account2->accountId(), domain->domainId(), *pubkey)); - auto acc = query->getAccount(account2->accountId()); + account2_id, domain_id, *pubkey)); + auto acc = query->getAccount(account2_id); ASSERT_FALSE(acc); std::vector query_args{ - account2->accountId(), domain->domainId(), pubkey->hex()}; + account2_id, domain_id, pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -730,10 +702,9 @@ namespace iroha { TEST_F(CreateAccount, NameExists) { addAllPerms(); auto cmd_result = execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey)); + name, domain_id, *pubkey)); - std::vector query_args{ - "id", domain->domainId(), pubkey->hex()}; + std::vector query_args{name, domain_id, pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -744,7 +715,7 @@ namespace iroha { } shared_model::interface::types::AssetIdType asset_name = "coin"; shared_model::interface::types::AssetIdType asset_id = - "coin#" + domain->domainId(); + "coin#" + domain_id; }; /** @@ -758,25 +729,17 @@ namespace iroha { CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain->domainId(), role), - true)); - auto asset = clone(TestAccountAssetBuilder() - .domainId(domain->domainId()) - .assetId(asset_id) - .precision(1) - .build()); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain_id, role), true)); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), + name, domain_id, *pubkey), true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1))); - auto ass = query->getAsset(asset->assetId()); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateAsset("coin", domain_id, 1))); + auto ass = query->getAsset(asset_id); ASSERT_TRUE(ass); - ASSERT_EQ(*asset.get(), *ass.get()); + ASSERT_EQ(asset_id, ass.get()->assetId()); } /** @@ -788,25 +751,18 @@ namespace iroha { CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain->domainId(), role), - true)); - auto asset = clone(TestAccountAssetBuilder() - .domainId(domain->domainId()) - .assetId(asset_id) - .precision(1) - .build()); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain_id, role), true)); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), + name, domain_id, *pubkey), true)); - auto cmd_result = execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1)); - auto ass = query->getAsset(asset->assetId()); + auto cmd_result = execute( + *mock_command_factory->constructCreateAsset("coin", domain_id, 1)); + auto ass = query->getAsset(asset_id); ASSERT_FALSE(ass); - std::vector query_args{domain->domainId(), "coin", "1"}; + std::vector query_args{domain_id, "coin", "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -821,13 +777,11 @@ namespace iroha { CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain->domainId(), role), - true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain_id, role), true)); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), + name, domain_id, *pubkey), true)); auto cmd_result = execute(*mock_command_factory->constructCreateAsset( asset_name, "no_domain", 1)); @@ -847,21 +801,18 @@ namespace iroha { CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateRole(role, role_permissions), true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain->domainId(), role), - true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain_id, role), true)); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id", domain->domainId(), *pubkey), + name, domain_id, *pubkey), true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1))); - auto cmd_result = execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateAsset("coin", domain_id, 1))); + auto cmd_result = execute( + *mock_command_factory->constructCreateAsset("coin", domain_id, 1)); - std::vector query_args{"coin", domain->domainId(), "1"}; + std::vector query_args{"coin", domain_id, "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -869,14 +820,13 @@ namespace iroha { public: void SetUp() override { CommandExecutorTest::SetUp(); - domain2 = clone( - TestDomainBuilder().domainId("domain2").defaultRole(role).build()); + domain2_id = "domain2"; createDefaultRole(); createDefaultDomain(); createDefaultAccount(); } - std::unique_ptr domain2; + shared_model::interface::types::DomainIdType domain2_id; }; /** @@ -886,12 +836,11 @@ namespace iroha { */ TEST_F(CreateDomain, Valid) { addAllPerms(); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role))); - auto dom = query->getDomain(domain2->domainId()); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain2_id, role))); + auto dom = query->getDomain(domain2_id); ASSERT_TRUE(dom); - ASSERT_EQ(*dom.get(), *domain2.get()); + ASSERT_EQ(dom.get()->domainId(), domain2_id); } /** @@ -900,12 +849,12 @@ namespace iroha { * @then domain is not created */ TEST_F(CreateDomain, NoPerms) { - auto cmd_result = execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role)); - auto dom = query->getDomain(domain2->domainId()); + auto cmd_result = execute( + *mock_command_factory->constructCreateDomain(domain2_id, role)); + auto dom = query->getDomain(domain2_id); ASSERT_FALSE(dom); - std::vector query_args{domain2->domainId(), role}; + std::vector query_args{domain2_id, role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -916,13 +865,12 @@ namespace iroha { */ TEST_F(CreateDomain, NameNotUnique) { addAllPerms(); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role))); - auto cmd_result = execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain2_id, role))); + auto cmd_result = execute( + *mock_command_factory->constructCreateDomain(domain2_id, role)); - std::vector query_args{domain2->domainId(), role}; + std::vector query_args{domain2_id, role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } @@ -934,9 +882,9 @@ namespace iroha { TEST_F(CreateDomain, NoDefaultRole) { addAllPerms(); auto cmd_result = execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), another_role)); + domain2_id, another_role)); - std::vector query_args{domain2->domainId(), another_role}; + std::vector query_args{domain2_id, another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -1016,8 +964,8 @@ namespace iroha { another_role, role_permissions), true)); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAppendRole( - account->accountId(), another_role), + execute(*mock_command_factory->constructAppendRole(account_id, + another_role), true)); } }; @@ -1030,9 +978,9 @@ namespace iroha { TEST_F(DetachRole, Valid) { addAllPerms(); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructDetachRole( - account->accountId(), another_role))); - auto roles = query->getAccountRoles(account->accountId()); + execute(*mock_command_factory->constructDetachRole(account_id, + another_role))); + auto roles = query->getAccountRoles(account_id); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) == roles->end()); @@ -1044,13 +992,13 @@ namespace iroha { * @then role is detached */ TEST_F(DetachRole, NoPerms) { - auto cmd_result = execute(*mock_command_factory->constructDetachRole( - account->accountId(), another_role)); + auto cmd_result = execute( + *mock_command_factory->constructDetachRole(account_id, another_role)); - std::vector query_args{account->accountId(), another_role}; + std::vector query_args{account_id, another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - auto roles = query->getAccountRoles(account->accountId()); + auto roles = query->getAccountRoles(account_id); ASSERT_TRUE(roles); ASSERT_TRUE(std::find(roles->begin(), roles->end(), another_role) != roles->end()); @@ -1078,12 +1026,12 @@ namespace iroha { TEST_F(DetachRole, NoSuchRoleInAccount) { addAllPerms(); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructDetachRole( - account->accountId(), another_role))); - auto cmd_result = execute(*mock_command_factory->constructDetachRole( - account->accountId(), another_role)); + execute(*mock_command_factory->constructDetachRole(account_id, + another_role))); + auto cmd_result = execute( + *mock_command_factory->constructDetachRole(account_id, another_role)); - std::vector query_args{account->accountId(), another_role}; + std::vector query_args{account_id, another_role}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -1095,10 +1043,9 @@ namespace iroha { TEST_F(DetachRole, NoRole) { addAllPerms(); auto cmd_result = execute(*mock_command_factory->constructDetachRole( - account->accountId(), "not_existing_role")); + account_id, "not_existing_role")); - std::vector query_args{account->accountId(), - "not_existing_role"}; + std::vector query_args{account_id, "not_existing_role"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 5, query_args); } @@ -1124,11 +1071,10 @@ namespace iroha { TEST_F(GrantPermission, Valid) { addAllPerms(); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm))); - auto has_perm = query->hasAccountGrantablePermission( - account->accountId(), account->accountId(), perm); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructGrantPermission(account_id, perm))); + auto has_perm = + query->hasAccountGrantablePermission(account_id, account_id, perm); ASSERT_TRUE(has_perm); } @@ -1139,13 +1085,13 @@ namespace iroha { */ TEST_F(GrantPermission, NoPerms) { auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - auto cmd_result = execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm)); - auto has_perm = query->hasAccountGrantablePermission( - account->accountId(), account->accountId(), perm); + auto cmd_result = execute( + *mock_command_factory->constructGrantPermission(account_id, perm)); + auto has_perm = + query->hasAccountGrantablePermission(account_id, account_id, perm); ASSERT_FALSE(has_perm); - std::vector query_args{account->accountId(), + std::vector query_args{account_id, perm_converter->toString(perm)}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -1192,14 +1138,12 @@ namespace iroha { TEST_F(RemoveSignatory, Valid) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(pk, account_id), true)); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *pubkey))); - auto signatories = query->getSignatories(account->accountId()); + execute(*mock_command_factory->constructRemoveSignatory(account_id, + *pubkey))); + auto signatories = query->getSignatories(account_id); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) == signatories->end()); @@ -1215,15 +1159,14 @@ namespace iroha { TEST_F(RemoveSignatory, ValidGrantablePerm) { CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey), + "id2", domain_id, *pubkey), true)); auto perm = shared_model::interface::permissions::Grantable::kRemoveMySignatory; - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain")); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructGrantPermission(account_id, perm), + true, + "id2@domain")); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructAddSignatory(pk, "id2@domain"), @@ -1249,17 +1192,15 @@ namespace iroha { */ TEST_F(RemoveSignatory, NoPerms) { shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true)); - auto cmd_result = execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *pubkey)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(pk, account_id), true)); + auto cmd_result = execute( + *mock_command_factory->constructRemoveSignatory(account_id, *pubkey)); - std::vector query_args{account->accountId(), pubkey->hex()}; + std::vector query_args{account_id, pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - auto signatories = query->getSignatories(account->accountId()); + auto signatories = query->getSignatories(account_id); ASSERT_TRUE(signatories); ASSERT_TRUE(std::find(signatories->begin(), signatories->end(), *pubkey) != signatories->end()); @@ -1275,10 +1216,8 @@ namespace iroha { TEST_F(RemoveSignatory, NoAccount) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(pk, account_id), true)); auto cmd_result = execute( *mock_command_factory->constructRemoveSignatory("hello", *pubkey)); @@ -1295,24 +1234,21 @@ namespace iroha { TEST_F(RemoveSignatory, NoSuchSignatory) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(pk, account_id), true)); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - *another_pubkey, account->accountId()), + execute(*mock_command_factory->constructAddSignatory(*another_pubkey, + account_id), true)); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *another_pubkey), + account_id, *another_pubkey), true)); auto cmd_result = execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *another_pubkey)); + account_id, *another_pubkey)); - std::vector query_args{account->accountId(), - another_pubkey->hex()}; + std::vector query_args{account_id, another_pubkey->hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -1325,17 +1261,15 @@ namespace iroha { TEST_F(RemoveSignatory, SignatoriesLessThanQuorum) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructAddSignatory(pk, account_id), true)); CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), *pubkey))); - auto cmd_result = execute(*mock_command_factory->constructRemoveSignatory( - account->accountId(), pk)); + execute(*mock_command_factory->constructRemoveSignatory(account_id, + *pubkey))); + auto cmd_result = execute( + *mock_command_factory->constructRemoveSignatory(account_id, pk)); - std::vector query_args{account->accountId(), pk.hex()}; + std::vector query_args{account_id, pk.hex()}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 5, query_args); } @@ -1348,7 +1282,7 @@ namespace iroha { createDefaultAccount(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructGrantPermission( - account->accountId(), grantable_permission), + account_id, grantable_permission), true)); } }; @@ -1362,24 +1296,23 @@ namespace iroha { auto perm = shared_model::interface::permissions::Grantable::kRemoveMySignatory; ASSERT_TRUE(query->hasAccountGrantablePermission( - account->accountId(), account->accountId(), grantable_permission)); + account_id, account_id, grantable_permission)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true)); - ASSERT_TRUE(query->hasAccountGrantablePermission( - account->accountId(), account->accountId(), grantable_permission)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructGrantPermission(account_id, perm), + true)); ASSERT_TRUE(query->hasAccountGrantablePermission( - account->accountId(), account->accountId(), perm)); + account_id, account_id, grantable_permission)); + ASSERT_TRUE( + query->hasAccountGrantablePermission(account_id, account_id, perm)); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructRevokePermission( - account->accountId(), grantable_permission))); + account_id, grantable_permission))); ASSERT_FALSE(query->hasAccountGrantablePermission( - account->accountId(), account->accountId(), grantable_permission)); - ASSERT_TRUE(query->hasAccountGrantablePermission( - account->accountId(), account->accountId(), perm)); + account_id, account_id, grantable_permission)); + ASSERT_TRUE( + query->hasAccountGrantablePermission(account_id, account_id, perm)); } /** @@ -1390,11 +1323,10 @@ namespace iroha { TEST_F(RevokePermission, NoPerms) { auto perm = shared_model::interface::permissions::Grantable::kRemoveMySignatory; - auto cmd_result = - execute(*mock_command_factory->constructRevokePermission( - account->accountId(), perm)); + auto cmd_result = execute( + *mock_command_factory->constructRevokePermission(account_id, perm)); - std::vector query_args{account->accountId(), + std::vector query_args{account_id, perm_converter->toString(perm)}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -1406,21 +1338,16 @@ namespace iroha { createDefaultRole(); createDefaultDomain(); createDefaultAccount(); - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData("") - .build()); + account2_id = "id2@" + domain_id; CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( "id2", - domain->domainId(), + domain_id, shared_model::interface::types::PubkeyType( std::string('2', 32))), true)); } - std::unique_ptr account2; + shared_model::interface::types::AccountIdType account2_id; }; /** @@ -1431,8 +1358,8 @@ namespace iroha { TEST_F(SetAccountDetail, Valid) { CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructSetAccountDetail( - account->accountId(), "key", "value"))); - auto kv = query->getAccountDetail(account->accountId()); + account_id, "key", "value"))); + auto kv = query->getAccountDetail(account_id); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); } @@ -1445,17 +1372,16 @@ namespace iroha { TEST_F(SetAccountDetail, ValidGrantablePerm) { auto perm = shared_model::interface::permissions::Grantable::kSetMyAccountDetail; - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain")); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructGrantPermission(account_id, perm), + true, + "id2@domain")); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructSetAccountDetail( - account2->accountId(), "key", "value"), + account2_id, "key", "value"), false, - account->accountId())); - auto kv = query->getAccountDetail(account2->accountId()); + account_id)); + auto kv = query->getAccountDetail(account2_id); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); } @@ -1469,10 +1395,10 @@ namespace iroha { addAllPerms(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructSetAccountDetail( - account2->accountId(), "key", "value"), + account2_id, "key", "value"), false, - account->accountId())); - auto kv = query->getAccountDetail(account2->accountId()); + account_id)); + auto kv = query->getAccountDetail(account2_id); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{\"id@domain\": {\"key\": \"value\"}}"); } @@ -1485,15 +1411,14 @@ namespace iroha { TEST_F(SetAccountDetail, NoPerms) { auto cmd_result = execute(*mock_command_factory->constructSetAccountDetail( - account2->accountId(), "key", "value"), + account2_id, "key", "value"), false, - account->accountId()); + account_id); - std::vector query_args{ - account2->accountId(), "key", "value"}; + std::vector query_args{account2_id, "key", "value"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - auto kv = query->getAccountDetail(account2->accountId()); + auto kv = query->getAccountDetail(account2_id); ASSERT_TRUE(kv); ASSERT_EQ(kv.get(), "{}"); } @@ -1509,7 +1434,7 @@ namespace iroha { execute(*mock_command_factory->constructSetAccountDetail( "doge@noaccount", "key", "value"), false, - account->accountId()); + account_id); std::vector query_args{"doge@noaccount", "key", "value"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); @@ -1526,7 +1451,7 @@ namespace iroha { createDefaultAccount(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddSignatory( - additional_pubkey_, account->accountId()), + additional_pubkey_, account_id), true)); } shared_model::interface::types::PubkeyType additional_pubkey_; @@ -1540,8 +1465,8 @@ namespace iroha { TEST_F(SetQuorum, Valid) { addAllPerms(); - CHECK_SUCCESSFUL_RESULT(execute( - *mock_command_factory->constructSetQuorum(account->accountId(), 2))); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSetQuorum(account_id, 2))); } /** @@ -1552,14 +1477,13 @@ namespace iroha { TEST_F(SetQuorum, ValidGrantablePerms) { CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey), + "id2", domain_id, *pubkey), true)); auto perm = shared_model::interface::permissions::Grantable::kSetMyQuorum; - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructGrantPermission( - account->accountId(), perm), - true, - "id2@domain")); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructGrantPermission(account_id, perm), + true, + "id2@domain")); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddSignatory( @@ -1577,10 +1501,10 @@ namespace iroha { * @then quorum is not set */ TEST_F(SetQuorum, NoPerms) { - auto cmd_result = execute( - *mock_command_factory->constructSetQuorum(account->accountId(), 3)); + auto cmd_result = + execute(*mock_command_factory->constructSetQuorum(account_id, 3)); - std::vector query_args{account->accountId(), "3"}; + std::vector query_args{account_id, "3"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); } @@ -1592,17 +1516,15 @@ namespace iroha { TEST_F(SetQuorum, LessSignatoriesThanNewQuorum) { addAllPerms(); shared_model::interface::types::PubkeyType pk(std::string('5', 32)); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructAddSignatory( - pk, account->accountId()), - true)); CHECK_SUCCESSFUL_RESULT(execute( - *mock_command_factory->constructSetQuorum(account->accountId(), 3))); + *mock_command_factory->constructAddSignatory(pk, account_id), true)); + CHECK_SUCCESSFUL_RESULT( + execute(*mock_command_factory->constructSetQuorum(account_id, 3))); - auto cmd_result = execute( - *mock_command_factory->constructSetQuorum(account->accountId(), 5)); + auto cmd_result = + execute(*mock_command_factory->constructSetQuorum(account_id, 5)); - std::vector query_args{account->accountId(), "5"}; + std::vector query_args{account_id, "5"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 5, query_args); } @@ -1620,19 +1542,13 @@ namespace iroha { */ void addAsset(const shared_model::interface::types::DomainIdType &domain_id = "domain") { - auto asset = clone(TestAccountAssetBuilder() - .domainId(domain_id) - .assetId(asset_id) - .precision(1) - .build()); - CHECK_SUCCESSFUL_RESULT(execute( *mock_command_factory->constructCreateAsset("coin", domain_id, 1), true)); } shared_model::interface::types::AssetIdType asset_id = - "coin#" + domain->domainId(); + "coin#" + domain_id; }; /** @@ -1647,21 +1563,20 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero), true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero), true)); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, asset_amount_one_zero))); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } @@ -1677,8 +1592,7 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero), true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -1686,13 +1600,11 @@ namespace iroha { execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, asset_amount_one_zero)); - std::vector query_args{account->accountId(), - asset_id, - asset_amount_one_zero.toStringRepr(), - "1"}; + std::vector query_args{ + account_id, asset_id, asset_amount_one_zero.toStringRepr(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } @@ -1712,8 +1624,7 @@ namespace iroha { asset_id, asset_amount_one_zero), true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -1722,7 +1633,7 @@ namespace iroha { asset_id, asset_amount_one_zero), true)); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); @@ -1731,7 +1642,7 @@ namespace iroha { asset_id, asset_amount_one_zero), true)); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } @@ -1742,24 +1653,20 @@ namespace iroha { * @then no account asset is subtracted */ TEST_F(SubtractAccountAssetTest, DomainPermInvalid) { - std::unique_ptr domain2; - domain2 = clone( - TestDomainBuilder().domainId("domain2").defaultRole(role).build()); - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateDomain( - domain2->domainId(), role), - true)); - addAsset(domain2->domainId()); + shared_model::interface::types::DomainIdType domain2_id = "domain2"; + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateDomain(domain2_id, role), + true)); + addAsset(domain2_id); addOnePerm( shared_model::interface::permissions::Role::kSubtractDomainAssetQty); - auto asset2_id = "coin#" + domain2->domainId(); + auto asset2_id = "coin#" + domain2_id; CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( asset2_id, asset_amount_one_zero), true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset2_id); + auto account_asset = query->getAccountAsset(account_id, asset2_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); @@ -1767,13 +1674,11 @@ namespace iroha { execute(*mock_command_factory->constructSubtractAssetQuantity( asset2_id, asset_amount_one_zero)); - std::vector query_args{account->accountId(), - asset2_id, - asset_amount_one_zero.toStringRepr(), - "1"}; + std::vector query_args{ + account_id, asset2_id, asset_amount_one_zero.toStringRepr(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 2, query_args); - account_asset = query->getAccountAsset(account->accountId(), asset2_id); + account_asset = query->getAccountAsset(account_id, asset2_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } @@ -1789,10 +1694,8 @@ namespace iroha { execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, asset_amount_one_zero)); - std::vector query_args{account->accountId(), - asset_id, - asset_amount_one_zero.toStringRepr(), - "1"}; + std::vector query_args{ + account_id, asset_id, asset_amount_one_zero.toStringRepr(), "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } @@ -1808,8 +1711,7 @@ namespace iroha { execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, shared_model::interface::Amount{"1.0000"})); - std::vector query_args{ - account->accountId(), asset_id, "1.0000", "1"}; + std::vector query_args{account_id, asset_id, "1.0000", "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 3, query_args); } @@ -1829,8 +1731,7 @@ namespace iroha { execute(*mock_command_factory->constructSubtractAssetQuantity( asset_id, shared_model::interface::Amount{"2.0"})); - std::vector query_args{ - account->accountId(), asset_id, "2.0", "1"}; + std::vector query_args{account_id, asset_id, "2.0", "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 4, query_args); } @@ -1838,19 +1739,14 @@ namespace iroha { void SetUp() override { CommandExecutorTest::SetUp(); - account2 = clone(TestAccountBuilder() - .domainId(domain->domainId()) - .accountId("id2@" + domain->domainId()) - .quorum(1) - .jsonData("{}") - .build()); + account2_id = "id2@" + domain_id; createDefaultRole(); createDefaultDomain(); createDefaultAccount(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructCreateAccount( - "id2", domain->domainId(), *pubkey), + "id2", domain_id, *pubkey), true)); } @@ -1859,21 +1755,14 @@ namespace iroha { * Add default asset and check that it is done */ void addAsset() { - auto asset = clone(TestAccountAssetBuilder() - .domainId(domain->domainId()) - .assetId(asset_id) - .precision(1) - .build()); - - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructCreateAsset( - "coin", domain->domainId(), 1), - true)); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructCreateAsset("coin", domain_id, 1), + true)); } shared_model::interface::types::AssetIdType asset_id = - "coin#" + domain->domainId(); - std::unique_ptr account2; + "coin#" + domain_id; + shared_model::interface::types::AccountIdType account2_id; }; /** @@ -1883,34 +1772,33 @@ namespace iroha { */ TEST_F(TransferAccountAssetTest, Valid) { addAllPerms(); - addAllPerms(account2->accountId(), "all2"); + addAllPerms(account2_id, "all2"); addAsset(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero), true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero), true)); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructTransferAsset( - account->accountId(), - account2->accountId(), + account_id, + account2_id, asset_id, "desc", asset_amount_one_zero))); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - account_asset = query->getAccountAsset(account2->accountId(), asset_id); + account_asset = query->getAccountAsset(account2_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } @@ -1921,36 +1809,31 @@ namespace iroha { * @then account asset is successfully transferred */ TEST_F(TransferAccountAssetTest, ValidGrantablePerms) { - addAllPerms(account2->accountId(), "all2"); + addAllPerms(account2_id, "all2"); addAsset(); auto perm = shared_model::interface::permissions::Grantable::kTransferMyAssets; - CHECK_SUCCESSFUL_RESULT( - execute(*mock_command_factory->constructGrantPermission( - account2->accountId(), perm), - true, - account->accountId())); + CHECK_SUCCESSFUL_RESULT(execute( + *mock_command_factory->constructGrantPermission(account2_id, perm), + true, + account_id)); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( asset_id, shared_model::interface::Amount{"2.0"}), true)); - auto account_asset = - query->getAccountAsset(account->accountId(), asset_id); + auto account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ("2.0", account_asset.get()->balance().toStringRepr()); CHECK_SUCCESSFUL_RESULT(execute( - *mock_command_factory->constructTransferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero), + *mock_command_factory->constructTransferAsset( + account_id, account2_id, asset_id, "desc", asset_amount_one_zero), false, - account2->accountId())); - account_asset = query->getAccountAsset(account->accountId(), asset_id); + account2_id)); + account_asset = query->getAccountAsset(account_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); - account_asset = query->getAccountAsset(account2->accountId(), asset_id); + account_asset = query->getAccountAsset(account2_id, asset_id); ASSERT_TRUE(account_asset); ASSERT_EQ(asset_amount_one_zero, account_asset.get()->balance()); } @@ -1961,15 +1844,11 @@ namespace iroha { * @then account asset fails to be transferred */ TEST_F(TransferAccountAssetTest, NoPerms) { - auto cmd_result = execute( - *mock_command_factory->constructTransferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero)); + auto cmd_result = execute(*mock_command_factory->constructTransferAsset( + account_id, account2_id, asset_id, "desc", asset_amount_one_zero)); - std::vector query_args{account->accountId(), - account2->accountId(), + std::vector query_args{account_id, + account2_id, asset_id, asset_amount_one_zero.toStringRepr(), "1"}; @@ -1983,7 +1862,7 @@ namespace iroha { */ TEST_F(TransferAccountAssetTest, NoAccount) { addAllPerms(); - addAllPerms(account2->accountId(), "all2"); + addAllPerms(account2_id, "all2"); addAsset(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( @@ -1991,7 +1870,7 @@ namespace iroha { true)); auto cmd_result = execute( *mock_command_factory->constructTransferAsset("some@domain", - account2->accountId(), + account2_id, asset_id, "desc", asset_amount_one_zero), @@ -2000,7 +1879,7 @@ namespace iroha { { std::vector query_args{ "some@domain", - account2->accountId(), + account2_id, asset_id, asset_amount_one_zero.toStringRepr(), "1"}; @@ -2008,7 +1887,7 @@ namespace iroha { } cmd_result = execute( - *mock_command_factory->constructTransferAsset(account->accountId(), + *mock_command_factory->constructTransferAsset(account_id, "some@domain", asset_id, "desc", @@ -2017,7 +1896,7 @@ namespace iroha { { std::vector query_args{ - account->accountId(), + account_id, "some@domain", asset_id, asset_amount_one_zero.toStringRepr(), @@ -2033,16 +1912,12 @@ namespace iroha { */ TEST_F(TransferAccountAssetTest, NoAsset) { addAllPerms(); - addAllPerms(account2->accountId(), "all2"); - auto cmd_result = execute( - *mock_command_factory->constructTransferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - asset_amount_one_zero)); + addAllPerms(account2_id, "all2"); + auto cmd_result = execute(*mock_command_factory->constructTransferAsset( + account_id, account2_id, asset_id, "desc", asset_amount_one_zero)); - std::vector query_args{account->accountId(), - account2->accountId(), + std::vector query_args{account_id, + account2_id, asset_id, asset_amount_one_zero.toStringRepr(), "1"}; @@ -2056,21 +1931,21 @@ namespace iroha { */ TEST_F(TransferAccountAssetTest, Overdraft) { addAllPerms(); - addAllPerms(account2->accountId(), "all2"); + addAllPerms(account2_id, "all2"); addAsset(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( asset_id, asset_amount_one_zero), true)); auto cmd_result = execute(*mock_command_factory->constructTransferAsset( - account->accountId(), - account2->accountId(), + account_id, + account2_id, asset_id, "desc", shared_model::interface::Amount{"2.0"})); std::vector query_args{ - account->accountId(), account2->accountId(), asset_id, "2.0", "1"}; + account_id, account2_id, asset_id, "2.0", "1"}; CHECK_ERROR_CODE_AND_MESSAGE(cmd_result, 6, query_args); } @@ -2082,7 +1957,7 @@ namespace iroha { */ TEST_F(TransferAccountAssetTest, OverflowDestination) { addAllPerms(); - addAllPerms(account2->accountId(), "all2"); + addAllPerms(account2_id, "all2"); addAsset(); CHECK_SUCCESSFUL_RESULT( execute(*mock_command_factory->constructAddAssetQuantity( @@ -2092,17 +1967,14 @@ namespace iroha { execute(*mock_command_factory->constructAddAssetQuantity( asset_id, uint256_halfmax), false, - account2->accountId())); + account2_id)); auto cmd_result = execute( - *mock_command_factory->constructTransferAsset(account->accountId(), - account2->accountId(), - asset_id, - "desc", - uint256_halfmax), + *mock_command_factory->constructTransferAsset( + account_id, account2_id, asset_id, "desc", uint256_halfmax), true); - std::vector query_args{account->accountId(), - account2->accountId(), + std::vector query_args{account_id, + account2_id, asset_id, uint256_halfmax.toStringRepr(), "1"}; From 2654f67d2466c9fe62104c40422dc345f1d71b68 Mon Sep 17 00:00:00 2001 From: Victor Drobny Date: Sat, 5 Jan 2019 17:00:29 +0100 Subject: [PATCH 58/61] init connections only once (#1862) * init connections only once Signed-off-by: Victor Drobny --- irohad/ametsuchi/impl/storage_impl.cpp | 6 +- test/framework/test_subscriber.hpp | 10 ++- .../irohad/ametsuchi/ametsuchi_fixture.hpp | 73 ++++++++++--------- .../irohad/ametsuchi/ametsuchi_test.cpp | 8 +- 4 files changed, 59 insertions(+), 38 deletions(-) diff --git a/irohad/ametsuchi/impl/storage_impl.cpp b/irohad/ametsuchi/impl/storage_impl.cpp index 634400760a..65d3930b89 100644 --- a/irohad/ametsuchi/impl/storage_impl.cpp +++ b/irohad/ametsuchi/impl/storage_impl.cpp @@ -235,8 +235,12 @@ namespace iroha { void StorageImpl::reset() { log_->info("drop wsv records from db tables"); - soci::session sql(*connection_); try { + soci::session sql(*connection_); + // rollback possible prepared transaction + if (block_is_prepared) { + rollbackPrepared(sql); + } sql << reset_; log_->info("drop blocks from disk"); block_store_->dropAll(); diff --git a/test/framework/test_subscriber.hpp b/test/framework/test_subscriber.hpp index 6841892fce..e1f40d419c 100644 --- a/test/framework/test_subscriber.hpp +++ b/test/framework/test_subscriber.hpp @@ -98,7 +98,7 @@ namespace framework { std::function error = [](std::exception_ptr) {}, std::function completed = []() {}) { - unwrapped_.subscribe( + subscription_ = unwrapped_.subscribe( [this, subscriber](T val) { // verify before invariant this->strategy_->on_next_before(val); @@ -133,9 +133,14 @@ namespace framework { return strategy_->validate(); } + void unsubscribe() { + subscription_.unsubscribe(); + } + private: rxcpp::observable unwrapped_; std::unique_ptr> strategy_; + rxcpp::composite_subscription subscription_; }; /** @@ -155,7 +160,8 @@ namespace framework { * auto sub = make_test_subscriber(o, 1); */ template