Skip to content

Commit

Permalink
Fix torii-related issues:
Browse files Browse the repository at this point in the history
- Return correct status in case of transaction finalizing before subscription
- Check only final transaction status in streaming test
- Fix of same timestamp for different transactions issue

Signed-off-by: luckychess <[email protected]>
  • Loading branch information
luckychess committed Jun 4, 2018
1 parent e1b9457 commit dc6b0a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions irohad/torii/impl/command_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,17 @@ namespace torii {

auto cache_second_check =
cache_->findItem(shared_model::crypto::Hash(request.tx_hash()));
log_->debug("Status in cache: {}", cache_second_check->tx_status());
log_->debug("Status of tx {} in cache: {}",
request_hash->hex(),
cache_second_check->tx_status());

/// final status means the case from a comment above
/// if it's not - let's ignore it for now
if (isFinalStatus(cache_second_check->tx_status())) {
log_->warn("Transaction was finalized before subscription");
response_writer.WriteLast(*resp, grpc::WriteOptions());
log_->warn("Transaction {} was finalized before subscription",
request_hash->hex());
response_writer.WriteLast(*cache_second_check,
grpc::WriteOptions());
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/module/irohad/torii/torii_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,11 @@ TEST_F(ToriiServiceTest, StatusWhenBlocking) {

// 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(iroha::time::now())
.createdTime(now + i)
.setAccountQuorum(account_id, 2)
.quorum(1)
.build()
Expand Down Expand Up @@ -406,7 +407,8 @@ TEST_F(ToriiServiceTest, StreamingFullPipelineTest) {
block_notifier_.get_subscriber().on_completed();
t.join();

ASSERT_GE(torii_response.size(), 2);
// 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);
}
Expand Down

0 comments on commit dc6b0a4

Please sign in to comment.