Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Reuse default tx validator from application.cpp
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Munichev <toobwn@gmail.com>
  • Loading branch information
luckychess committed Nov 14, 2018
1 parent d85cd31 commit fa3b6ef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
12 changes: 9 additions & 3 deletions irohad/main/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "ametsuchi/impl/postgres_ordering_service_persistent_state.hpp"
#include "ametsuchi/impl/wsv_restorer_impl.hpp"
#include "application.hpp"
#include "backend/protobuf/common_objects/proto_common_objects_factory.hpp"
#include "backend/protobuf/proto_block_json_converter.hpp"
#include "backend/protobuf/proto_permission_to_string.hpp"
Expand Down Expand Up @@ -193,9 +194,7 @@ void Irohad::initFactories() {
std::make_shared<shared_model::interface::TransactionBatchFactoryImpl>();
std::unique_ptr<shared_model::validation::AbstractValidator<
shared_model::interface::Transaction>>
transaction_validator =
std::make_unique<shared_model::validation::
DefaultOptionalSignedTransactionValidator>();
transaction_validator = getTxValidator();
transaction_factory =
std::make_shared<shared_model::proto::ProtoTransportFactory<
shared_model::interface::Transaction,
Expand Down Expand Up @@ -443,3 +442,10 @@ Irohad::~Irohad() {
// called in irohad destructor
storage->freeConnections();
}

std::unique_ptr<shared_model::validation::AbstractValidator<
shared_model::interface::Transaction>>
Irohad::getTxValidator() {
return std::make_unique<
shared_model::validation::DefaultOptionalSignedTransactionValidator>();
}
9 changes: 8 additions & 1 deletion irohad/main/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace iroha {

class Irohad {
public:

using RunResult = iroha::expected::Result<void, std::string>;

/**
Expand Down Expand Up @@ -106,6 +105,14 @@ class Irohad {

virtual ~Irohad();

/**
* Creates transaction validator
* @return unique_ptr to the validator created
*/
static std::unique_ptr<shared_model::validation::AbstractValidator<
shared_model::interface::Transaction>>
getTxValidator();

protected:
// -----------------------| component initialization |------------------------

Expand Down
1 change: 1 addition & 0 deletions test/fuzzing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ add_executable(mst_fuzz mst_fuzz.cpp)
target_link_libraries(mst_fuzz
gtest::gtest
gmock::gmock
application
mst_transport
protobuf-mutator
)
5 changes: 2 additions & 3 deletions test/fuzzing/mst_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#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 "main/application.hpp"
#include "module/irohad/multi_sig_transactions/mst_test_helpers.hpp"
#include "multi_sig_transactions/transport/mst_transport_grpc.hpp"

Expand All @@ -26,9 +27,7 @@ namespace fuzzing {
iroha::network::AsyncGrpcClient<google::protobuf::Empty>>();
std::unique_ptr<shared_model::validation::AbstractValidator<
shared_model::interface::Transaction>>
tx_validator =
std::make_unique<shared_model::validation::
DefaultOptionalSignedTransactionValidator>();
tx_validator = Irohad::getTxValidator();
auto tx_factory =
std::make_shared<shared_model::proto::ProtoTransportFactory<
shared_model::interface::Transaction,
Expand Down

0 comments on commit fa3b6ef

Please sign in to comment.