From b83d7478efa61f0dd88b39739a8aba58c85d21cc Mon Sep 17 00:00:00 2001 From: cyan317 <120398799+cindyyan317@users.noreply.github.com> Date: Fri, 14 Jul 2023 14:44:40 +0100 Subject: [PATCH] Unsupported Error when request server stream (#772) Fixes #773 --- src/rpc/common/Validators.cpp | 3 ++- unittests/rpc/handlers/SubscribeTest.cpp | 5 +++++ unittests/rpc/handlers/UnsubscribeTest.cpp | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/rpc/common/Validators.cpp b/src/rpc/common/Validators.cpp index ce19ea3c..58ed1cf9 100644 --- a/src/rpc/common/Validators.cpp +++ b/src/rpc/common/Validators.cpp @@ -163,7 +163,8 @@ CustomValidator SubscribeStreamValidator = static std::unordered_set const validStreams = { "ledger", "transactions", "transactions_proposed", "book_changes", "manifests", "validations"}; - static std::unordered_set const reportingNotSupportStreams = {"peer_status", "consensus"}; + static std::unordered_set const reportingNotSupportStreams = { + "peer_status", "consensus", "server"}; for (auto const& v : value.as_array()) { if (!v.is_string()) diff --git a/unittests/rpc/handlers/SubscribeTest.cpp b/unittests/rpc/handlers/SubscribeTest.cpp index c50460d9..f7fcb85f 100644 --- a/unittests/rpc/handlers/SubscribeTest.cpp +++ b/unittests/rpc/handlers/SubscribeTest.cpp @@ -136,6 +136,11 @@ generateTestValuesForParametersTest() R"({"streams": ["consensus"]})", "reportingUnsupported", "Requested operation not supported by reporting mode server"}, + SubscribeParamTestCaseBundle{ + "StreamServerNotSupport", + R"({"streams": ["server"]})", + "reportingUnsupported", + "Requested operation not supported by reporting mode server"}, SubscribeParamTestCaseBundle{"BooksNotArray", R"({"books": "1"})", "invalidParams", "booksNotArray"}, SubscribeParamTestCaseBundle{ "BooksItemNotObject", R"({"books": ["1"]})", "invalidParams", "booksItemNotObject"}, diff --git a/unittests/rpc/handlers/UnsubscribeTest.cpp b/unittests/rpc/handlers/UnsubscribeTest.cpp index 8c210997..79f1f042 100644 --- a/unittests/rpc/handlers/UnsubscribeTest.cpp +++ b/unittests/rpc/handlers/UnsubscribeTest.cpp @@ -465,6 +465,21 @@ generateTestValuesForParametersTest() })", "invalidParams", "bothNotBool"}, + UnsubscribeParamTestCaseBundle{ + "StreamPeerStatusNotSupport", + R"({"streams": ["peer_status"]})", + "reportingUnsupported", + "Requested operation not supported by reporting mode server"}, + UnsubscribeParamTestCaseBundle{ + "StreamConsensusNotSupport", + R"({"streams": ["consensus"]})", + "reportingUnsupported", + "Requested operation not supported by reporting mode server"}, + UnsubscribeParamTestCaseBundle{ + "StreamServerNotSupport", + R"({"streams": ["server"]})", + "reportingUnsupported", + "Requested operation not supported by reporting mode server"}, }; }