Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Merge branch 'devel' into task/parchard/KEP-1247
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruck committed Mar 18, 2019
2 parents 1cfe3aa + 8b4964f commit 7406c62
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 9 additions & 1 deletion crud/crud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ crud::send_response(const database_msg& request, const bzn::storage_result resul
{
if (bzn::storage_result_msg.count(result))
{
response.mutable_error()->set_message(bzn::storage_result_msg.at(result));
// special response error case...
if (request.msg_case() == database_msg::kQuickRead)
{
response.mutable_quick_read()->set_error(bzn::storage_result_msg.at(result));
}
else
{
response.mutable_error()->set_message(bzn::storage_result_msg.at(result));
}
}
else
{
Expand Down
10 changes: 7 additions & 3 deletions crud/test/crud_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,11 @@ TEST(crud, test_that_read_sends_proper_response)

// quick read invalid key...
msg.mutable_quick_read()->set_key("invalid-key");
expect_response(session, "uuid", uint64_t(123), database_response::kError, bzn::storage_result_msg.at(bzn::storage_result::not_found));
expect_response(session, "uuid", uint64_t(123), database_response::kQuickRead, std::nullopt,
[](const auto& resp)
{
ASSERT_EQ(resp.quick_read().error(), bzn::storage_result_msg.at(bzn::storage_result::not_found));
});

crud->handle_request("caller_id", msg, session);

Expand Down Expand Up @@ -561,8 +565,8 @@ TEST(crud, test_that_point_of_contact_read_sends_proper_response)
ASSERT_TRUE(parse_env_to_db_resp(resp, msg->SerializeAsString()));
ASSERT_EQ(resp.header().db_uuid(), "uuid");
ASSERT_EQ(resp.header().nonce(), uint64_t(123));
ASSERT_EQ(resp.response_case(), database_response::kError);
ASSERT_EQ(resp.error().message(), bzn::storage_result_msg.at(bzn::storage_result::not_found));
ASSERT_EQ(resp.response_case(), database_response::kQuickRead);
ASSERT_EQ(resp.quick_read().error(), bzn::storage_result_msg.at(bzn::storage_result::not_found));
}));

crud->handle_request("caller_id", msg, nullptr);
Expand Down
9 changes: 8 additions & 1 deletion proto/database.proto
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ message database_read_response
bytes value = 2;
}

message database_quick_read_response
{
string key = 1;
bytes value = 2;
string error = 3;
}

message database_size_response
{
int32 bytes = 1;
Expand Down Expand Up @@ -196,7 +203,7 @@ message database_response
database_redirect_response redirect = 2;
database_subscription_update subscription_update = 3;
database_read_response read = 4;
database_read_response quick_read = 5;
database_quick_read_response quick_read = 5;
database_has_response has = 6;
database_keys_response keys = 7;
database_size_response size = 8;
Expand Down

0 comments on commit 7406c62

Please sign in to comment.