Skip to content

Commit

Permalink
Merge branch 'fix/mst-transport_bugs' into trunk/mst
Browse files Browse the repository at this point in the history
  • Loading branch information
muratovv authored and l4l committed Jan 12, 2018
2 parents c702bae + 430a50f commit 9b6c25e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions irohad/main/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void Irohad::initMstProcessor() {
auto mst_time = std::make_shared<MstTimeProviderImpl>();
mst_processor = std::make_shared<FairMstProcessor>(mst_transport, mst_storage,
mst_propagation, mst_time);
log_->info("[Init] => MST processor");
}

void Irohad::initTransactionCommandService() {
Expand Down
2 changes: 1 addition & 1 deletion irohad/model/converters/impl/pb_transaction_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace iroha {
tx.commands.push_back(
commandFactory.deserializeAbstractCommand(pb_command));
}

tx.tx_hash = iroha::hash(tx);
return std::make_shared<model::Transaction>(tx);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace iroha {
})) {}

rxcpp::observable<PropagationData> GossipPropagationStrategy::emitter() {
return emitent;
return emitent.subscribe_on(rxcpp::observe_on_new_thread());
}

bool GossipPropagationStrategy::initQueue() {
Expand Down
1 change: 1 addition & 0 deletions test/integration/pipeline/tx_pipeline_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TxPipelineIntegrationTest : public TxPipelineIntegrationTestFixture {

auto genesis_tx =
TransactionGenerator().generateGenesisTransaction(0, {"0.0.0.0:10001"});
genesis_tx.quorum = 1;
genesis_block =
iroha::model::generators::BlockGenerator().generateGenesisBlock(
0, {genesis_tx});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ PropagationData subscribe_and_emit(nonstd::optional<PropagationData> data,
auto subscriber = rxcpp::make_subscriber<Peers>([&emitted](auto v) {
std::copy(v.begin(), v.end(), std::back_inserter(emitted));
});
strategy.emitter().take(take).subscribe(subscriber);
strategy.emitter().take(take).as_blocking().subscribe(subscriber);

return emitted;
}
Expand Down
13 changes: 11 additions & 2 deletions test/module/irohad/multi_sig_transactions/mst_test_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
#ifndef IROHA_MST_TEST_HELPERS_HPP
#define IROHA_MST_TEST_HELPERS_HPP

#include <string>
#include "common/types.hpp"
#include "cryptography/ed25519_sha3_impl/internal/sha3_hash.hpp"
#include "model/transaction.hpp"
#include "multi_sig_transactions/mst_types.hpp"
#include <string>

using namespace std;
using namespace iroha;
Expand All @@ -47,11 +48,19 @@ inline auto makeTx(const string &hash_value,
return make_shared<Transaction>(tx);
}

inline auto makeTxWithCorrectHash(const string &signature_value,
uint8_t quorum = 3,
iroha::TimeType created_time = 1) {
auto tx = makeTx("0", signature_value, quorum, created_time);
tx->tx_hash = iroha::hash(*tx);
return tx;
}

inline auto makePeer(const string &address, const string &pub_key) {
iroha::model::Peer p;
p.address = address;
p.pubkey = stringToBytesFiller<iroha::model::Peer::KeyType>(pub_key);
return p;
}

#endif //IROHA_MST_TEST_HELPERS_HPP
#endif // IROHA_MST_TEST_HELPERS_HPP
17 changes: 9 additions & 8 deletions test/module/irohad/multi_sig_transactions/transport_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "cryptography/ed25519_sha3_impl/internal/sha3_hash.hpp"
#include "module/irohad/multi_sig_transactions/mst_mocks.hpp"
#include "module/irohad/multi_sig_transactions/mst_test_helpers.hpp"
#include "multi_sig_transactions/state/mst_state.hpp"
Expand All @@ -30,8 +31,8 @@ using ::testing::AtLeast;
using ::testing::InvokeWithoutArgs;

/**
* @brief Sends data over MstTransportGrpc (MstState and Peer objects) and receives
* them. When received deserializes them end ensures that deserialized
* @brief Sends data over MstTransportGrpc (MstState and Peer objects) and
* receives them. When received deserializes them end ensures that deserialized
* objects equal to objects before sending.
*
* @given Initialized transport
Expand All @@ -53,10 +54,10 @@ TEST(TransportTest, SendAndReceive) {
auto peer = makePeer("localhost:50051", "abcdabcdabcdabcdabcdabcdabcdabcd");

MstState state = MstState::empty();
state += makeTx("1", "5", 3);
state += makeTx("2", "6", 4);
state += makeTx("3", "7", 5);
state += makeTx("4", "8", 5);
state += makeTxWithCorrectHash("5", 3);
state += makeTxWithCorrectHash("6", 4);
state += makeTxWithCorrectHash("7", 5);
state += makeTxWithCorrectHash("8", 5);

// we want to ensure that server side will call onNewState()
// with same parameters as on the client side
Expand All @@ -66,8 +67,8 @@ TEST(TransportTest, SendAndReceive) {

grpc::ServerBuilder builder;
int port = 0;
builder.AddListeningPort(peer.address, grpc::InsecureServerCredentials(),
&port);
builder.AddListeningPort(
peer.address, grpc::InsecureServerCredentials(), &port);
builder.RegisterService(transport.get());
server = builder.BuildAndStart();
ASSERT_TRUE(server);
Expand Down

0 comments on commit 9b6c25e

Please sign in to comment.