diff --git a/irohad/ametsuchi/CMakeLists.txt b/irohad/ametsuchi/CMakeLists.txt index 62e6a4eeb3..c3aecf66e3 100644 --- a/irohad/ametsuchi/CMakeLists.txt +++ b/irohad/ametsuchi/CMakeLists.txt @@ -1,19 +1,11 @@ -#add_subdirectory(block_store) -#add_subdirectory(index) -#add_subdirectory(wsv) - -add_library(storage -# impl/ametsuchi_impl.cpp -# index_mediator.cpp +add_library(ametsuchi + command_executor_stub.cpp + temporary_wsv_stub.cpp + mutable_storage_stub.cpp + ametsuchi_stub.cpp ) -target_link_libraries(storage PUBLIC - schema - cpp_redis - pqxx - optional - block_store - index - wsv +target_link_libraries(ametsuchi rxcpp + optional ) \ No newline at end of file diff --git a/irohad/ametsuchi/ametsuchi.hpp b/irohad/ametsuchi/ametsuchi.hpp index 59ca207f1f..4ac03ea8f2 100644 --- a/irohad/ametsuchi/ametsuchi.hpp +++ b/irohad/ametsuchi/ametsuchi.hpp @@ -56,7 +56,7 @@ namespace iroha { * MutableStorage. * @param mutableStorage */ - virtual void commit(std::unique_ptr& mutableStorage) = 0; + virtual void commit(MutableStorage& mutableStorage) = 0; }; } // namespace ametsuchi diff --git a/irohad/ametsuchi/ametsuchi_stub.cpp b/irohad/ametsuchi/ametsuchi_stub.cpp new file mode 100644 index 0000000000..576e22582b --- /dev/null +++ b/irohad/ametsuchi/ametsuchi_stub.cpp @@ -0,0 +1,89 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 + +namespace iroha { + namespace ametsuchi { + + std::unique_ptr AmetsuchiStub::createTemporaryWsv() { + return std::make_unique(*this); + } + + std::unique_ptr AmetsuchiStub::createMutableStorage() { + return std::make_unique(*this); + } + + void AmetsuchiStub::commit(MutableStorage &mutableStorage) { return; } + + rxcpp::observable AmetsuchiStub::get_account_transactions( + iroha::crypto::ed25519::pubkey_t pub_key) { + return rxcpp::observable<>::create( + [](rxcpp::subscriber s) { + s.on_next(dao::Transaction{}); + s.on_completed(); + }); + } + + rxcpp::observable AmetsuchiStub::get_asset_transactions( + std::string asset_full_name) { + return rxcpp::observable<>::create( + [](rxcpp::subscriber s) { + s.on_next(dao::Transaction{}); + s.on_completed(); + }); + } + + rxcpp::observable AmetsuchiStub::get_wallet_transactions( + std::string wallet_id) { + return rxcpp::observable<>::create( + [](rxcpp::subscriber s) { + s.on_next(dao::Transaction{}); + s.on_completed(); + }); + } + + dao::Account AmetsuchiStub::get_account( + iroha::crypto::ed25519::pubkey_t pub_key) { + return dao::Account{}; + } + + dao::Asset AmetsuchiStub::get_asset(std::string asset_full_name) { + return dao::Asset{}; + } + + dao::Domain AmetsuchiStub::get_domain(std::string domain_full_name) { + return dao::Domain{}; + } + + dao::Wallet AmetsuchiStub::get_wallet(std::string wallet_id) { + return dao::Wallet{}; + } + + std::vector AmetsuchiStub::get_account_wallets( + iroha::crypto::ed25519::pubkey_t pub_key) { + return std::vector{dao::Wallet{}}; + } + + std::vector AmetsuchiStub::get_domain_assets( + std::string domain_full_name) { + return std::vector{dao::Asset{}}; + } + } // namespace ametsuchi +} // namespace iroha \ No newline at end of file diff --git a/irohad/ametsuchi/ametsuchi_stub.hpp b/irohad/ametsuchi/ametsuchi_stub.hpp new file mode 100644 index 0000000000..0d6b1b7679 --- /dev/null +++ b/irohad/ametsuchi/ametsuchi_stub.hpp @@ -0,0 +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. + */ + +#ifndef IROHA_AMETSUCHI_STUB_HPP +#define IROHA_AMETSUCHI_STUB_HPP + +#include +#include + +namespace iroha { + namespace ametsuchi { + + class AmetsuchiStub : public Ametsuchi { + public: + std::unique_ptr createTemporaryWsv() override; + std::unique_ptr createMutableStorage() override; + void commit(MutableStorage &mutableStorage) override; + rxcpp::observable get_account_transactions( + iroha::crypto::ed25519::pubkey_t pub_key) override; + rxcpp::observable get_asset_transactions( + std::string asset_full_name) override; + rxcpp::observable get_wallet_transactions( + std::string wallet_id) override; + dao::Account get_account( + iroha::crypto::ed25519::pubkey_t pub_key) override; + dao::Asset get_asset(std::string asset_full_name) override; + dao::Domain get_domain(std::string domain_full_name) override; + dao::Wallet get_wallet(std::string wallet_id) override; + std::vector get_account_wallets( + iroha::crypto::ed25519::pubkey_t pub_key) override; + std::vector get_domain_assets( + std::string domain_full_name) override; + }; + + } // namespace ametsuchi +} // namespace iroha + +#endif // IROHA_AMETSUCHI_STUB_HPP diff --git a/irohad/ametsuchi/block_query.hpp b/irohad/ametsuchi/block_query.hpp index 0926a4e748..abfeba1677 100644 --- a/irohad/ametsuchi/block_query.hpp +++ b/irohad/ametsuchi/block_query.hpp @@ -18,6 +18,9 @@ #ifndef IROHA_BLOCK_QUERY_HPP #define IROHA_BLOCK_QUERY_HPP +#include +#include + namespace iroha { namespace ametsuchi { diff --git a/irohad/ametsuchi/command_executor.hpp b/irohad/ametsuchi/command_executor.hpp index bef5435748..6207be4805 100644 --- a/irohad/ametsuchi/command_executor.hpp +++ b/irohad/ametsuchi/command_executor.hpp @@ -27,13 +27,14 @@ namespace iroha { * Applies command to the world state view */ class CommandExecutor { + public: /** * Executes a command in a temporary state * @see TemporaryWsv, MutableStorage * @param command Command to execute * @return True if the command is successfully executed, false otherwise */ - virtual bool execute(dao::Command command) = 0; + virtual bool execute(const dao::Command& command) = 0; }; } // namespace ametsuchi diff --git a/irohad/ametsuchi/command_executor_stub.cpp b/irohad/ametsuchi/command_executor_stub.cpp new file mode 100644 index 0000000000..01cab158ec --- /dev/null +++ b/irohad/ametsuchi/command_executor_stub.cpp @@ -0,0 +1,39 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 + +namespace iroha { + namespace ametsuchi { + + bool CommandExecutorStub::execute(const dao::Command &command) { + auto handler = map_.find(command); + return handler.value_or([](const dao::Command &) { return false; })( + command); + } + + bool CommandExecutorStub::executeAddPeer(const dao::AddPeer &command) { + return true; + } + + CommandExecutorStub::CommandExecutorStub(WsvQuery &query) : query_(query) { + // https://stackoverflow.com/questions/9998402/c11-does-not-deduce-type-when-stdfunction-or-lambda-functions-are-involved + map_.insert(std::bind(&CommandExecutorStub::executeAddPeer, + this, std::placeholders::_1)); + } + } // namespace ametsuchi +} // namespace iroha \ No newline at end of file diff --git a/irohad/ametsuchi/command_executor_stub.hpp b/irohad/ametsuchi/command_executor_stub.hpp new file mode 100644 index 0000000000..4097b65b28 --- /dev/null +++ b/irohad/ametsuchi/command_executor_stub.hpp @@ -0,0 +1,46 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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_COMMAND_EXECUTOR_STUB_HPP +#define IROHA_COMMAND_EXECUTOR_STUB_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace iroha { + namespace ametsuchi { + + class CommandExecutorStub : public CommandExecutor { + public: + CommandExecutorStub(WsvQuery &query); + bool execute(const dao::Command &command) override; + + private: + bool executeAddPeer(const dao::AddPeer &command); + WsvQuery &query_; + HandlerMap map_; + }; + + } // namespace ametsuchi +} // namespace iroha + +#endif // IROHA_COMMAND_EXECUTOR_STUB_HPP diff --git a/irohad/ametsuchi/index_mediator.cpp b/irohad/ametsuchi/index/index_mediator.cpp similarity index 100% rename from irohad/ametsuchi/index_mediator.cpp rename to irohad/ametsuchi/index/index_mediator.cpp diff --git a/irohad/ametsuchi/index_mediator.hpp b/irohad/ametsuchi/index/index_mediator.hpp similarity index 100% rename from irohad/ametsuchi/index_mediator.hpp rename to irohad/ametsuchi/index/index_mediator.hpp diff --git a/irohad/ametsuchi/mutable_storage.hpp b/irohad/ametsuchi/mutable_storage.hpp index ad420c8921..0660b5af05 100644 --- a/irohad/ametsuchi/mutable_storage.hpp +++ b/irohad/ametsuchi/mutable_storage.hpp @@ -19,6 +19,8 @@ #define IROHA_MUTABLESTORAGE_HPP #include +#include +#include namespace iroha { namespace ametsuchi { @@ -27,6 +29,7 @@ namespace iroha { * Allows to query the world state view, transactions, and blocks. */ class MutableStorage : public WsvQuery, public BlockQuery { + public: /** * Applies a block to current mutable state * using logic specified in function @@ -44,7 +47,7 @@ namespace iroha { */ virtual bool apply( dao::Block block, - std::function + std::function function) = 0; }; diff --git a/irohad/ametsuchi/mutable_storage_stub.cpp b/irohad/ametsuchi/mutable_storage_stub.cpp new file mode 100644 index 0000000000..f13efdc4f4 --- /dev/null +++ b/irohad/ametsuchi/mutable_storage_stub.cpp @@ -0,0 +1,75 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 + +namespace iroha { + namespace ametsuchi { + + rxcpp::observable + MutableStorageStub::get_account_transactions( + iroha::crypto::ed25519::pubkey_t pub_key) { + return ametsuchi_.get_account_transactions(pub_key); + } + + rxcpp::observable + MutableStorageStub::get_asset_transactions(std::string asset_full_name) { + return ametsuchi_.get_asset_transactions(asset_full_name); + } + + rxcpp::observable + MutableStorageStub::get_wallet_transactions(std::string wallet_id) { + return ametsuchi_.get_wallet_transactions(wallet_id); + } + + dao::Account MutableStorageStub::get_account( + iroha::crypto::ed25519::pubkey_t pub_key) { + return ametsuchi_.get_account(pub_key); + } + + dao::Asset MutableStorageStub::get_asset(std::string asset_full_name) { + return ametsuchi_.get_asset(asset_full_name); + } + + dao::Domain MutableStorageStub::get_domain(std::string domain_full_name) { + return ametsuchi_.get_domain(domain_full_name); + } + + dao::Wallet MutableStorageStub::get_wallet(std::string wallet_id) { + return ametsuchi_.get_wallet(wallet_id); + } + + std::vector MutableStorageStub::get_account_wallets( + iroha::crypto::ed25519::pubkey_t pub_key) { + return ametsuchi_.get_account_wallets(pub_key); + } + + std::vector MutableStorageStub::get_domain_assets( + std::string domain_full_name) { + return ametsuchi_.get_domain_assets(domain_full_name); + } + + bool MutableStorageStub::apply( + dao::Block block, + std::function function) { + return function(block, executor_, ametsuchi_); + } + + MutableStorageStub::MutableStorageStub(AmetsuchiStub &ametsuchi) + : ametsuchi_(ametsuchi), executor_(*this) {} + } // namespace ametsuchi +} // namespace iroha \ No newline at end of file diff --git a/irohad/ametsuchi/mutable_storage_stub.hpp b/irohad/ametsuchi/mutable_storage_stub.hpp new file mode 100644 index 0000000000..be883a6506 --- /dev/null +++ b/irohad/ametsuchi/mutable_storage_stub.hpp @@ -0,0 +1,55 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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_MUTABLE_STORAGE_STUB_HPP +#define IROHA_MUTABLE_STORAGE_STUB_HPP + +#include +#include +#include + +namespace iroha { + namespace ametsuchi { + class MutableStorageStub : public MutableStorage { + public: + MutableStorageStub(AmetsuchiStub& ametsuchi); + bool apply(dao::Block block, + std::function + function) override; + rxcpp::observable get_account_transactions( + iroha::crypto::ed25519::pubkey_t pub_key) override; + rxcpp::observable get_asset_transactions( + std::string asset_full_name) override; + rxcpp::observable get_wallet_transactions( + std::string wallet_id) override; + dao::Account get_account( + iroha::crypto::ed25519::pubkey_t pub_key) override; + dao::Asset get_asset(std::string asset_full_name) override; + dao::Domain get_domain(std::string domain_full_name) override; + dao::Wallet get_wallet(std::string wallet_id) override; + std::vector get_account_wallets( + iroha::crypto::ed25519::pubkey_t pub_key) override; + std::vector get_domain_assets( + std::string domain_full_name) override; + private: + AmetsuchiStub& ametsuchi_; + CommandExecutorStub executor_; + }; + } // namespace ametsuchi +} // namespace iroha + +#endif // IROHA_MUTABLE_STORAGE_STUB_HPP diff --git a/irohad/ametsuchi/temporary_wsv.hpp b/irohad/ametsuchi/temporary_wsv.hpp index c980c1b4ac..0c5f81d27d 100644 --- a/irohad/ametsuchi/temporary_wsv.hpp +++ b/irohad/ametsuchi/temporary_wsv.hpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace iroha { diff --git a/irohad/ametsuchi/temporary_wsv_stub.cpp b/irohad/ametsuchi/temporary_wsv_stub.cpp new file mode 100644 index 0000000000..363a08b902 --- /dev/null +++ b/irohad/ametsuchi/temporary_wsv_stub.cpp @@ -0,0 +1,63 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 + +namespace iroha { + + namespace ametsuchi { + + bool TemporaryWsvStub::apply( + dao::Transaction transaction, + std::function + function) { + return function(transaction, executor_, ametsuchi_); + } + + dao::Account TemporaryWsvStub::get_account( + iroha::crypto::ed25519::pubkey_t pub_key) { + return ametsuchi_.get_account(pub_key); + } + + dao::Asset TemporaryWsvStub::get_asset(std::string asset_full_name) { + return ametsuchi_.get_asset(asset_full_name); + } + + dao::Domain TemporaryWsvStub::get_domain(std::string domain_full_name) { + return ametsuchi_.get_domain(domain_full_name); + } + + dao::Wallet TemporaryWsvStub::get_wallet(std::string wallet_id) { + return ametsuchi_.get_wallet(wallet_id); + } + + std::vector TemporaryWsvStub::get_account_wallets( + iroha::crypto::ed25519::pubkey_t pub_key) { + return ametsuchi_.get_account_wallets(pub_key); + } + + std::vector TemporaryWsvStub::get_domain_assets( + std::string domain_full_name) { + return ametsuchi_.get_domain_assets(domain_full_name); + } + + TemporaryWsvStub::TemporaryWsvStub(AmetsuchiStub &ametsuchi) + : ametsuchi_(ametsuchi), executor_(*this) {} + } + +} // namespace iroha \ No newline at end of file diff --git a/irohad/ametsuchi/temporary_wsv_stub.hpp b/irohad/ametsuchi/temporary_wsv_stub.hpp new file mode 100644 index 0000000000..3b2ae7850e --- /dev/null +++ b/irohad/ametsuchi/temporary_wsv_stub.hpp @@ -0,0 +1,48 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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_TEMPORARY_WSV_STUB_HPP +#define IROHA_TEMPORARY_WSV_STUB_HPP + +#include +#include +#include +#include "command_executor_stub.hpp" + +namespace iroha { + namespace ametsuchi { + class TemporaryWsvStub : public TemporaryWsv { + public: + TemporaryWsvStub(AmetsuchiStub& ametsuchi); + bool apply(dao::Transaction transaction, + std::function function) override; + dao::Account get_account(iroha::crypto::ed25519::pubkey_t pub_key) override; + dao::Asset get_asset(std::string asset_full_name) override; + dao::Domain get_domain(std::string domain_full_name) override; + dao::Wallet get_wallet(std::string wallet_id) override; + std::vector get_account_wallets(iroha::crypto::ed25519::pubkey_t pub_key) override; + std::vector get_domain_assets(std::string domain_full_name) override; + private: + AmetsuchiStub& ametsuchi_; + CommandExecutorStub executor_; + }; + } // namespace ametsuchi +} // namespace iroha + +#endif // IROHA_TEMPORARY_WSV_STUB_HPP diff --git a/irohad/ametsuchi/wsv_query.hpp b/irohad/ametsuchi/wsv_query.hpp index 535d1c69f0..dad23506aa 100644 --- a/irohad/ametsuchi/wsv_query.hpp +++ b/irohad/ametsuchi/wsv_query.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include diff --git a/libs/common.hpp b/libs/common.hpp index ec13da3de3..83fa48c8f1 100644 --- a/libs/common.hpp +++ b/libs/common.hpp @@ -18,9 +18,8 @@ #ifndef AMETSUCHI_COMMON_HPP #define AMETSUCHI_COMMON_HPP -#include -#include #include +#include namespace iroha { @@ -31,10 +30,10 @@ namespace iroha { * For std::array it is possible, so we prefer it over std::string. */ - template + template using blob_t = std::array; - template + template using hash_t = blob_t; using hash224_t = hash_t<224 / 8>; @@ -54,30 +53,5 @@ namespace iroha { using ts64_t = uint64_t; using ts32_t = uint32_t; - /* - * Remove all files in directory dump_dir and the directory itself - */ - void remove_all(const std::string &dump_dir) { - if (!dump_dir.empty()) { - // Directory iterator: - struct dirent **namelist; - auto status = scandir(dump_dir.c_str(), &namelist, NULL, alphasort); - if (status < 0) { - // TODO: handle internal error - } else { - uint n = status; - uint i = 1; - while (++i < n) { - if (std::remove((dump_dir + "/" + namelist[i]->d_name).c_str())) - perror("Error deleting file"); - } - for (uint j = 0; j < n; ++j) { - free(namelist[j]); - } - free(namelist); - } - if (std::remove(dump_dir.c_str())) perror("Error deleting file"); - } - } } // namespace iroha #endif // AMETSUCHI_COMMON_HPP diff --git a/libs/dao/account.hpp b/libs/dao/account.hpp index 4a97f188bc..7b82c05e9e 100644 --- a/libs/dao/account.hpp +++ b/libs/dao/account.hpp @@ -35,12 +35,12 @@ namespace iroha { /* * Account state */ - const State state; + State state; /* * Minimum quorum of signatures need for transactions */ - const uint32_t quorum; + uint32_t quorum; }; } } diff --git a/libs/dao/command.hpp b/libs/dao/command.hpp index 8f5082ec95..8464fd382e 100644 --- a/libs/dao/command.hpp +++ b/libs/dao/command.hpp @@ -25,6 +25,7 @@ namespace iroha { */ struct Command { // TODO: implement + virtual ~Command(){} }; } } diff --git a/libs/dao/commands/add_peer.hpp b/libs/dao/commands/add_peer.hpp index cbc0fa3d13..678e8e1920 100644 --- a/libs/dao/commands/add_peer.hpp +++ b/libs/dao/commands/add_peer.hpp @@ -27,9 +27,8 @@ namespace iroha { /** * Provide user's intent for adding peer to current network */ - class AddPeer : Command { + struct AddPeer : public Command { public: - /** * Peer for adding */ diff --git a/libs/dao/dao.hpp b/libs/dao/dao.hpp index 136c2937a7..61ecce917f 100644 --- a/libs/dao/dao.hpp +++ b/libs/dao/dao.hpp @@ -27,15 +27,21 @@ #include "peer.hpp" #include "singature.hpp" #include "domain.hpp" -#include "command.hpp" #include "client.hpp" -#include "query.hpp" + #include "query_response.hpp" #include "peer.hpp" #include "singature.hpp" #include "dao_crypto_provider.hpp" #include "dao_hash_provider.hpp" +// commands +#include "command.hpp" +#include + +// query +#include "query.hpp" + /** * DAO - Data Access Object. * DAO module provides objects that are useful for all other modules in system. diff --git a/libs/dao/peer.hpp b/libs/dao/peer.hpp index ef7a170718..43a3c32fb7 100644 --- a/libs/dao/peer.hpp +++ b/libs/dao/peer.hpp @@ -29,17 +29,17 @@ namespace iroha { /** * Address of peer for connection */ - const std::string address; + std::string address; /** * Public key of peer */ - const iroha::crypto::ed25519::pubkey_t pubkey; + iroha::crypto::ed25519::pubkey_t pubkey; /* * Peer account */ - const Account account; + Account account; }; } } diff --git a/test/module/irohad/ametsuchi/CMakeLists.txt b/test/module/irohad/ametsuchi/CMakeLists.txt index a6424032e1..112d93ba6c 100644 --- a/test/module/irohad/ametsuchi/CMakeLists.txt +++ b/test/module/irohad/ametsuchi/CMakeLists.txt @@ -1,6 +1,11 @@ set(CMAKE_BUILD_TYPE Debug) -SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test_bin) +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test_bin) + +addtest(command_executor_test command_executor_test.cpp) +target_link_libraries(command_executor_test + ametsuchi + ) # #addtest(bstore_test block_store/block_store_flat_test.cpp) diff --git a/test/module/irohad/ametsuchi/command_executor_test.cpp b/test/module/irohad/ametsuchi/command_executor_test.cpp new file mode 100644 index 0000000000..5fd2c918df --- /dev/null +++ b/test/module/irohad/ametsuchi/command_executor_test.cpp @@ -0,0 +1,32 @@ +/** + * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. + * http://soramitsu.co.jp + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 + +using iroha::ametsuchi::AmetsuchiStub; +using iroha::ametsuchi::CommandExecutorStub; +using namespace iroha::dao; + +TEST(CommandExecutorTest, SampleTest) { + AmetsuchiStub ametsuchi; + CommandExecutorStub executor(ametsuchi); + + ASSERT_TRUE(executor.execute(AddPeer{})); + ASSERT_FALSE(executor.execute(Command{})); +} \ No newline at end of file