pw_rpc: Rename test methods for consistency
- Rename TestRpc to TestUnaryRpc.
- Rename TestStreamRpc to TestServerStreamRpc.
Change-Id: I12c81e5da98925f26b23ce7e43747900ddc888c7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/57060
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_rpc/nanopb/client_call_test.cc b/pw_rpc/nanopb/client_call_test.cc
index ae24fd7..774bef3 100644
--- a/pw_rpc/nanopb/client_call_test.cc
+++ b/pw_rpc/nanopb/client_call_test.cc
@@ -29,10 +29,11 @@
class FakeGeneratedServiceClient {
public:
static NanopbClientCall<internal::UnaryCallbacks<pw_rpc_test_TestResponse>>
- TestRpc(Channel& channel,
- const pw_rpc_test_TestRequest& request,
- Function<void(const pw_rpc_test_TestResponse&, Status)> on_response,
- Function<void(Status)> on_error = nullptr) {
+ TestUnaryRpc(
+ Channel& channel,
+ const pw_rpc_test_TestRequest& request,
+ Function<void(const pw_rpc_test_TestResponse&, Status)> on_response,
+ Function<void(Status)> on_error = nullptr) {
auto call = NanopbClientCall(
&channel,
kServiceId,
@@ -46,7 +47,7 @@
static NanopbClientCall<
internal::ServerStreamingCallbacks<pw_rpc_test_TestStreamResponse>>
- TestStreamRpc(
+ TestServerStreamRpc(
Channel& channel,
const pw_rpc_test_TestRequest& request,
Function<void(const pw_rpc_test_TestStreamResponse&)> on_response,
@@ -69,7 +70,7 @@
TEST(NanopbClientCall, Unary_SendsRequestPacket) {
ClientContextForTest context;
- auto call = FakeGeneratedServiceClient::TestRpc(
+ auto call = FakeGeneratedServiceClient::TestUnaryRpc(
context.channel(), {.integer = 123, .status_code = 0}, nullptr);
EXPECT_EQ(context.output().packet_count(), 1u);
@@ -93,7 +94,7 @@
TEST_F(UnaryClientCall, InvokesCallbackOnValidResponse) {
ClientContextForTest context;
- auto call = FakeGeneratedServiceClient::TestRpc(
+ auto call = FakeGeneratedServiceClient::TestUnaryRpc(
context.channel(),
{.integer = 123, .status_code = 0},
[this](const pw_rpc_test_TestResponse& response, Status status) {
@@ -113,7 +114,7 @@
TEST_F(UnaryClientCall, DoesNothingOnNullCallback) {
ClientContextForTest context;
- auto call = FakeGeneratedServiceClient::TestRpc(
+ auto call = FakeGeneratedServiceClient::TestUnaryRpc(
context.channel(), {.integer = 123, .status_code = 0}, nullptr);
PW_ENCODE_PB(pw_rpc_test_TestResponse, response, .value = 42);
@@ -125,7 +126,7 @@
TEST_F(UnaryClientCall, InvokesErrorCallbackOnInvalidResponse) {
ClientContextForTest context;
- auto call = FakeGeneratedServiceClient::TestRpc(
+ auto call = FakeGeneratedServiceClient::TestUnaryRpc(
context.channel(),
{.integer = 123, .status_code = 0},
[this](const pw_rpc_test_TestResponse& response, Status status) {
@@ -146,7 +147,7 @@
TEST_F(UnaryClientCall, InvokesErrorCallbackOnServerError) {
ClientContextForTest context;
- auto call = FakeGeneratedServiceClient::TestRpc(
+ auto call = FakeGeneratedServiceClient::TestUnaryRpc(
context.channel(),
{.integer = 123, .status_code = 0},
[this](const pw_rpc_test_TestResponse& response, Status status) {
@@ -165,7 +166,7 @@
TEST_F(UnaryClientCall, DoesNothingOnErrorWithoutCallback) {
ClientContextForTest context;
- auto call = FakeGeneratedServiceClient::TestRpc(
+ auto call = FakeGeneratedServiceClient::TestUnaryRpc(
context.channel(),
{.integer = 123, .status_code = 0},
[this](const pw_rpc_test_TestResponse& response, Status status) {
@@ -184,7 +185,7 @@
TEST_F(UnaryClientCall, OnlyReceivesOneResponse) {
ClientContextForTest context;
- auto call = FakeGeneratedServiceClient::TestRpc(
+ auto call = FakeGeneratedServiceClient::TestUnaryRpc(
context.channel(),
{.integer = 123, .status_code = 0},
[this](const pw_rpc_test_TestResponse& response, Status status) {
@@ -218,7 +219,7 @@
ClientContextForTest<128, 128, 99, kServiceId, kServerStreamingMethodId>
context;
- auto call = FakeGeneratedServiceClient::TestStreamRpc(
+ auto call = FakeGeneratedServiceClient::TestServerStreamRpc(
context.channel(), {.integer = 71, .status_code = 0}, nullptr, nullptr);
EXPECT_EQ(context.output().packet_count(), 1u);
@@ -235,7 +236,7 @@
ClientContextForTest<128, 128, 99, kServiceId, kServerStreamingMethodId>
context;
- auto call = FakeGeneratedServiceClient::TestStreamRpc(
+ auto call = FakeGeneratedServiceClient::TestServerStreamRpc(
context.channel(),
{.integer = 71, .status_code = 0},
[this](const pw_rpc_test_TestStreamResponse& response) {
@@ -270,7 +271,7 @@
ClientContextForTest<128, 128, 99, kServiceId, kServerStreamingMethodId>
context;
- auto call = FakeGeneratedServiceClient::TestStreamRpc(
+ auto call = FakeGeneratedServiceClient::TestServerStreamRpc(
context.channel(),
{.integer = 71, .status_code = 0},
[this](const pw_rpc_test_TestStreamResponse& response) {
@@ -304,7 +305,7 @@
ClientContextForTest<128, 128, 99, kServiceId, kServerStreamingMethodId>
context;
- auto call = FakeGeneratedServiceClient::TestStreamRpc(
+ auto call = FakeGeneratedServiceClient::TestServerStreamRpc(
context.channel(),
{.integer = 71, .status_code = 0},
[this](const pw_rpc_test_TestStreamResponse& response) {
diff --git a/pw_rpc/nanopb/codegen_test.cc b/pw_rpc/nanopb/codegen_test.cc
index 5c9fbe8..e83d6f5 100644
--- a/pw_rpc/nanopb/codegen_test.cc
+++ b/pw_rpc/nanopb/codegen_test.cc
@@ -24,14 +24,14 @@
class TestService final : public generated::TestService<TestService> {
public:
- Status TestRpc(ServerContext&,
- const pw_rpc_test_TestRequest& request,
- pw_rpc_test_TestResponse& response) {
+ Status TestUnaryRpc(ServerContext&,
+ const pw_rpc_test_TestRequest& request,
+ pw_rpc_test_TestResponse& response) {
response.value = request.integer + 1;
return static_cast<Status::Code>(request.status_code);
}
- static void TestStreamRpc(
+ static void TestServerStreamRpc(
ServerContext&,
const pw_rpc_test_TestRequest& request,
ServerWriter<pw_rpc_test_TestStreamResponse>& writer) {
@@ -67,7 +67,7 @@
}
TEST(NanopbCodegen, Server_InvokeUnaryRpc) {
- PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestRpc) context;
+ PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestUnaryRpc) context;
EXPECT_EQ(OkStatus(),
context.call({.integer = 123, .status_code = OkStatus().code()}));
@@ -81,7 +81,7 @@
}
TEST(NanopbCodegen, Server_InvokeStreamingRpc) {
- PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestStreamRpc) context;
+ PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestServerStreamRpc) context;
context.call({.integer = 0, .status_code = Status::Aborted().code()});
@@ -104,7 +104,8 @@
TEST(NanopbCodegen,
Server_InvokeStreamingRpc_ContextKeepsFixedNumberOfResponses) {
- PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestStreamRpc, 3) context;
+ PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestServerStreamRpc, 3)
+ context;
ASSERT_EQ(3u, context.responses().max_size());
@@ -119,7 +120,8 @@
}
TEST(NanopbCodegen, Server_InvokeStreamingRpc_ManualWriting) {
- PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestStreamRpc, 3) context;
+ PW_NANOPB_TEST_METHOD_CONTEXT(test::TestService, TestServerStreamRpc, 3)
+ context;
ASSERT_EQ(3u, context.responses().max_size());
@@ -147,23 +149,23 @@
TEST(NanopbCodegen, Client_GeneratesCallAliases) {
static_assert(
- std::is_same_v<TestServiceClient::TestRpcCall,
+ std::is_same_v<TestServiceClient::TestUnaryRpcCall,
NanopbClientCall<
internal::UnaryCallbacks<pw_rpc_test_TestResponse>>>);
static_assert(
- std::is_same_v<TestServiceClient::TestStreamRpcCall,
+ std::is_same_v<TestServiceClient::TestServerStreamRpcCall,
NanopbClientCall<internal::ServerStreamingCallbacks<
pw_rpc_test_TestStreamResponse>>>);
}
TEST(NanopbCodegen, ClientCall_DefaultConstructor) {
- TestServiceClient::TestRpcCall unary_call;
- TestServiceClient::TestStreamRpcCall server_streaming_call;
+ TestServiceClient::TestUnaryRpcCall unary_call;
+ TestServiceClient::TestServerStreamRpcCall server_streaming_call;
}
TEST(NanopbCodegen, Client_InvokesUnaryRpcWithCallback) {
constexpr uint32_t service_id = internal::Hash("pw.rpc.test.TestService");
- constexpr uint32_t method_id = internal::Hash("TestRpc");
+ constexpr uint32_t method_id = internal::Hash("TestUnaryRpc");
ClientContextForTest<128, 128, 99, service_id, method_id> context;
@@ -172,7 +174,7 @@
int response_value = -1;
} result;
- auto call = TestServiceClient::TestRpc(
+ auto call = TestServiceClient::TestUnaryRpc(
context.channel(),
{.integer = 123, .status_code = 0},
[&result](const pw_rpc_test_TestResponse& response, Status status) {
@@ -196,7 +198,7 @@
TEST(NanopbCodegen, Client_InvokesServerStreamingRpcWithCallback) {
constexpr uint32_t service_id = internal::Hash("pw.rpc.test.TestService");
- constexpr uint32_t method_id = internal::Hash("TestStreamRpc");
+ constexpr uint32_t method_id = internal::Hash("TestServerStreamRpc");
ClientContextForTest<128, 128, 99, service_id, method_id> context;
@@ -206,7 +208,7 @@
int response_value = -1;
} result;
- auto call = TestServiceClient::TestStreamRpc(
+ auto call = TestServiceClient::TestServerStreamRpc(
context.channel(),
{.integer = 123, .status_code = 0},
[&result](const pw_rpc_test_TestStreamResponse& response) {
diff --git a/pw_rpc/nanopb/method_lookup_test.cc b/pw_rpc/nanopb/method_lookup_test.cc
index cc28a35..29340a3 100644
--- a/pw_rpc/nanopb/method_lookup_test.cc
+++ b/pw_rpc/nanopb/method_lookup_test.cc
@@ -22,13 +22,13 @@
class MixedService1 : public test::generated::TestService<MixedService1> {
public:
- StatusWithSize TestRpc(ServerContext&, ConstByteSpan, ByteSpan) {
+ StatusWithSize TestUnaryRpc(ServerContext&, ConstByteSpan, ByteSpan) {
return StatusWithSize(123);
}
- void TestStreamRpc(ServerContext&,
- const pw_rpc_test_TestRequest&,
- ServerWriter<pw_rpc_test_TestStreamResponse>&) {
+ void TestServerStreamRpc(ServerContext&,
+ const pw_rpc_test_TestRequest&,
+ ServerWriter<pw_rpc_test_TestStreamResponse>&) {
called_server_streaming_method = true;
}
@@ -50,13 +50,13 @@
class MixedService2 : public test::generated::TestService<MixedService2> {
public:
- Status TestRpc(ServerContext&,
- const pw_rpc_test_TestRequest&,
- pw_rpc_test_TestResponse&) {
+ Status TestUnaryRpc(ServerContext&,
+ const pw_rpc_test_TestRequest&,
+ pw_rpc_test_TestResponse&) {
return Status::Unauthenticated();
}
- void TestStreamRpc(ServerContext&, ConstByteSpan, RawServerWriter&) {
+ void TestServerStreamRpc(ServerContext&, ConstByteSpan, RawServerWriter&) {
called_server_streaming_method = true;
}
@@ -76,14 +76,14 @@
};
TEST(MixedService1, CallRawMethod_Unary) {
- PW_RAW_TEST_METHOD_CONTEXT(MixedService1, TestRpc) context;
+ PW_RAW_TEST_METHOD_CONTEXT(MixedService1, TestUnaryRpc) context;
StatusWithSize sws = context.call({});
EXPECT_TRUE(sws.ok());
EXPECT_EQ(123u, sws.size());
}
TEST(MixedService1, CallNanopbMethod_ServerStreaming) {
- PW_NANOPB_TEST_METHOD_CONTEXT(MixedService1, TestStreamRpc) context;
+ PW_NANOPB_TEST_METHOD_CONTEXT(MixedService1, TestServerStreamRpc) context;
ASSERT_FALSE(context.service().called_server_streaming_method);
context.call({});
EXPECT_TRUE(context.service().called_server_streaming_method);
@@ -101,13 +101,13 @@
}
TEST(MixedService2, CallNanopbMethod_Unary) {
- PW_NANOPB_TEST_METHOD_CONTEXT(MixedService2, TestRpc) context;
+ PW_NANOPB_TEST_METHOD_CONTEXT(MixedService2, TestUnaryRpc) context;
Status status = context.call({});
EXPECT_EQ(Status::Unauthenticated(), status);
}
TEST(MixedService2, CallRawMethod_ServerStreaming) {
- PW_RAW_TEST_METHOD_CONTEXT(MixedService2, TestStreamRpc) context;
+ PW_RAW_TEST_METHOD_CONTEXT(MixedService2, TestServerStreamRpc) context;
ASSERT_FALSE(context.service().called_server_streaming_method);
context.call({});
EXPECT_TRUE(context.service().called_server_streaming_method);
diff --git a/pw_rpc/pw_rpc_test_protos/test.proto b/pw_rpc/pw_rpc_test_protos/test.proto
index bd31fb9..d792370 100644
--- a/pw_rpc/pw_rpc_test_protos/test.proto
+++ b/pw_rpc/pw_rpc_test_protos/test.proto
@@ -32,8 +32,8 @@
message Empty {}
service TestService {
- rpc TestRpc(TestRequest) returns (TestResponse);
- rpc TestStreamRpc(TestRequest) returns (stream TestStreamResponse);
+ rpc TestUnaryRpc(TestRequest) returns (TestResponse);
+ rpc TestServerStreamRpc(TestRequest) returns (stream TestStreamResponse);
rpc TestClientStreamRpc(stream TestRequest) returns (TestStreamResponse);
rpc TestBidirectionalStreamRpc(stream TestRequest)
returns (stream TestStreamResponse);
diff --git a/pw_rpc/raw/codegen_test.cc b/pw_rpc/raw/codegen_test.cc
index f03596e..889f863 100644
--- a/pw_rpc/raw/codegen_test.cc
+++ b/pw_rpc/raw/codegen_test.cc
@@ -51,9 +51,9 @@
class TestService final : public generated::TestService<TestService> {
public:
- static StatusWithSize TestRpc(ServerContext&,
- ConstByteSpan request,
- ByteSpan response) {
+ static StatusWithSize TestUnaryRpc(ServerContext&,
+ ConstByteSpan request,
+ ByteSpan response) {
int64_t integer;
Status status;
@@ -67,9 +67,9 @@
return StatusWithSize(status, test_response.size());
}
- void TestStreamRpc(ServerContext&,
- ConstByteSpan request,
- RawServerWriter& writer) {
+ void TestServerStreamRpc(ServerContext&,
+ ConstByteSpan request,
+ RawServerWriter& writer) {
int64_t integer;
Status status;
@@ -170,7 +170,7 @@
}
TEST(RawCodegen, Server_InvokeUnaryRpc) {
- PW_RAW_TEST_METHOD_CONTEXT(test::TestService, TestRpc) context;
+ PW_RAW_TEST_METHOD_CONTEXT(test::TestService, TestUnaryRpc) context;
auto sws = context.call(EncodeRequest(123, OkStatus()));
EXPECT_EQ(OkStatus(), sws.status());
@@ -190,7 +190,7 @@
}
TEST(RawCodegen, Server_InvokeServerStreamingRpc) {
- PW_RAW_TEST_METHOD_CONTEXT(test::TestService, TestStreamRpc) context;
+ PW_RAW_TEST_METHOD_CONTEXT(test::TestService, TestServerStreamRpc) context;
context.call(EncodeRequest(5, Status::Unauthenticated()));
EXPECT_TRUE(context.done());