wasphin commented on code in PR #3485:
URL: https://github.com/apache/brpc/pull/3485#discussion_r3891733787
##########
test/brpc_streaming_rpc_unittest.cpp:
##########
@@ -1130,6 +1131,76 @@ class MyServiceWithExtraStream : public
test::EchoService {
int _n;
};
+class MyServiceWithMismatchedExtraStreamIds : public test::EchoService {
+public:
+ MyServiceWithMismatchedExtraStreamIds(size_t stream_count, int adjustment)
+ : _stream_count(stream_count), _adjustment(adjustment) {}
+
+ void Echo(::google::protobuf::RpcController* controller,
+ const ::test::EchoRequest* request,
+ ::test::EchoResponse* response,
+ ::google::protobuf::Closure* done) override {
+ brpc::ClosureGuard done_guard(done);
+ brpc::Controller* cntl = static_cast<brpc::Controller*>(controller);
+ response->set_message(request->message());
+
+ brpc::ControllerPrivateAccessor accessor(cntl);
+ brpc::StreamSettings* settings = accessor.remote_stream_settings();
+ if (_adjustment < 0) {
+ settings->mutable_extra_stream_ids()->RemoveLast();
+ } else {
+ settings->add_extra_stream_ids(settings->extra_stream_ids(0));
+ }
+
+ brpc::StreamIds response_streams;
+ ASSERT_EQ(0, brpc::StreamAccept(response_streams, *cntl, nullptr));
+ ASSERT_EQ((int)_stream_count + _adjustment,
+ (int)response_streams.size());
+ }
+
+private:
+ size_t _stream_count;
+ int _adjustment;
+};
+
+TEST_F(StreamingRpcTest, reject_mismatched_returned_stream_identifiers) {
Review Comment:
Will re-check it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]