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

Commit

Permalink
Move OrderingGateFixture to fuzzing namespace
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 8, 2018
1 parent c6eaa2d commit efa4be3
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions test/fuzzing/ordering_gate_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,43 @@
using namespace iroha::ordering;
using namespace testing;

struct OrderingGateFixture {
std::shared_ptr<shared_model::proto::ProtoBlockFactory> block_factory_;
std::shared_ptr<NiceMock<MockOnDemandOrderingService>> ordering_service_;
std::shared_ptr<NiceMock<transport::MockOdOsNotification>> network_client_;
namespace fuzzing {
struct OrderingGateFixture {
std::shared_ptr<shared_model::proto::ProtoBlockFactory> block_factory_;
std::shared_ptr<NiceMock<MockOnDemandOrderingService>> ordering_service_;
std::shared_ptr<NiceMock<transport::MockOdOsNotification>> network_client_;

rxcpp::subjects::subject<OnDemandOrderingGate::BlockRoundEventType> rounds_;
NiceMock<MockUnsafeProposalFactory> *proposal_factory_;
std::shared_ptr<OnDemandOrderingGate> ordering_gate_;
iroha::consensus::Round initial_round_ = {2, 1};
rxcpp::subjects::subject<OnDemandOrderingGate::BlockRoundEventType> rounds_;
NiceMock<MockUnsafeProposalFactory> *proposal_factory_;
std::shared_ptr<OnDemandOrderingGate> 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<NiceMock<MockOnDemandOrderingService>>()),
network_client_(
std::make_shared<NiceMock<transport::MockOdOsNotification>>()) {
auto proposal_factory =
std::make_unique<NiceMock<MockUnsafeProposalFactory>>();
proposal_factory_ = proposal_factory.get();
ordering_gate_ =
std::make_shared<OnDemandOrderingGate>(ordering_service_,
network_client_,
rounds_.get_observable(),
std::move(proposal_factory),
initial_round_);
}
};
OrderingGateFixture()
: block_factory_(std::make_shared<
shared_model::proto::ProtoBlockFactory>(
std::make_unique<
shared_model::validation::DefaultUnsignedBlockValidator>())),
ordering_service_(
std::make_shared<NiceMock<MockOnDemandOrderingService>>

()),
network_client_(
std::make_shared<NiceMock<transport::MockOdOsNotification>>()) {
auto proposal_factory =
std::make_unique<NiceMock<MockUnsafeProposalFactory>>();
proposal_factory_ = proposal_factory.get();
ordering_gate_ =
std::make_shared<OnDemandOrderingGate>(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 OrderingGateFixture ordering_gate_fixture;
static fuzzing::OrderingGateFixture ordering_gate_fixture;
if (size < 1) {
return 0;
}
Expand Down

0 comments on commit efa4be3

Please sign in to comment.