From 1548624742546490cbb178dbfb72c689bc4ea633 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Fri, 18 Oct 2024 14:19:00 -0700 Subject: [PATCH] Fix and refactor tests --- shadow/tests/v2ClientTests.cpp | 516 +++++++++++++++++++-------------- 1 file changed, 301 insertions(+), 215 deletions(-) diff --git a/shadow/tests/v2ClientTests.cpp b/shadow/tests/v2ClientTests.cpp index 1a293eea9..a526c2947 100644 --- a/shadow/tests/v2ClientTests.cpp +++ b/shadow/tests/v2ClientTests.cpp @@ -12,13 +12,13 @@ #include #include -#include #include #include #include #include -#include +#include #include +#include #include #include #include @@ -27,189 +27,184 @@ #include -namespace Aws +AWS_STATIC_STRING_FROM_LITERAL(s_rrEnvVariableHost, "AWS_TEST_MQTT5_IOT_CORE_HOST"); +AWS_STATIC_STRING_FROM_LITERAL(s_rrEnvVariableCertificatePath, "AWS_TEST_MQTT5_IOT_CORE_RSA_CERT"); +AWS_STATIC_STRING_FROM_LITERAL(s_rrEnvVariablePrivateKeyPath, "AWS_TEST_MQTT5_IOT_CORE_RSA_KEY"); + +static std::shared_ptr s_createProtocolClient5(Aws::Crt::Allocator *allocator) { - namespace Iot + std::shared_ptr client = nullptr; + + struct aws_string *host = NULL; + struct aws_string *certificatePath = NULL; + struct aws_string *privateKeyPath = NULL; + + if (aws_get_environment_value(allocator, s_rrEnvVariableHost, &host) || host == nullptr) { - namespace ServiceTesting - { + goto done; + } - AWS_STATIC_STRING_FROM_LITERAL(s_rrEnvVariableHost, "AWS_TEST_MQTT5_IOT_CORE_HOST"); - AWS_STATIC_STRING_FROM_LITERAL(s_rrEnvVariableCertificatePath, "AWS_TEST_MQTT5_IOT_CORE_RSA_CERT"); - AWS_STATIC_STRING_FROM_LITERAL(s_rrEnvVariablePrivateKeyPath, "AWS_TEST_MQTT5_IOT_CORE_RSA_KEY"); + if (aws_get_environment_value(allocator, s_rrEnvVariableCertificatePath, &certificatePath) || + certificatePath == nullptr) + { + goto done; + } - inline std::shared_ptr createProtocolClient5(Aws::Crt::Allocator *allocator) - { - std::shared_ptr client = nullptr; + if (aws_get_environment_value(allocator, s_rrEnvVariablePrivateKeyPath, &privateKeyPath) || + privateKeyPath == nullptr) + { + goto done; + } - struct aws_string *host = NULL; - struct aws_string *certificatePath = NULL; - struct aws_string *privateKeyPath = NULL; + { + std::mutex lock; + std::condition_variable signal; + bool connected = false; - if (aws_get_environment_value(allocator, s_rrEnvVariableHost, &host) || host == nullptr) - { - goto done; - } + Aws::Crt::Io::TlsContextOptions tlsCtxOptions = Aws::Crt::Io::TlsContextOptions::InitClientWithMtls( + aws_string_c_str(certificatePath), aws_string_c_str(privateKeyPath), allocator); + Aws::Crt::Io::TlsContext tlsContext(tlsCtxOptions, Aws::Crt::Io::TlsMode::CLIENT, allocator); - if (aws_get_environment_value(allocator, s_rrEnvVariableCertificatePath, &certificatePath) || - certificatePath == nullptr) - { - goto done; - } + Aws::Crt::Mqtt5::Mqtt5ClientOptions mqtt5Options(allocator); + mqtt5Options.WithHostName(Aws::Crt::String(aws_string_c_str(host))); + mqtt5Options.WithPort(8883); + mqtt5Options.WithTlsConnectionOptions(tlsContext.NewConnectionOptions()); - if (aws_get_environment_value(allocator, s_rrEnvVariablePrivateKeyPath, &privateKeyPath) || - privateKeyPath == nullptr) + mqtt5Options.WithClientConnectionSuccessCallback( + [&lock, &signal, &connected](const Aws::Crt::Mqtt5::OnConnectionSuccessEventData &) + { { - goto done; + std::lock_guard guard(lock); + connected = true; } + signal.notify_all(); + }); - { - std::mutex lock; - std::condition_variable signal; - bool connected = false; - - Aws::Crt::Io::TlsContextOptions tlsCtxOptions = Aws::Crt::Io::TlsContextOptions::InitClientWithMtls( - aws_string_c_str(certificatePath), aws_string_c_str(privateKeyPath), allocator); - Aws::Crt::Io::TlsContext tlsContext(tlsCtxOptions, Aws::Crt::Io::TlsMode::CLIENT, allocator); - - Aws::Crt::Mqtt5::Mqtt5ClientOptions mqtt5Options(allocator); - mqtt5Options.WithHostName(Aws::Crt::String(aws_string_c_str(host))); - mqtt5Options.WithPort(8883); - mqtt5Options.WithTlsConnectionOptions(tlsContext.NewConnectionOptions()); - - mqtt5Options.WithClientConnectionSuccessCallback([&lock, &signal, &connected](const Aws::Crt::Mqtt5::OnConnectionSuccessEventData &){ - { - std::lock_guard guard(lock); - connected = true; - } - signal.notify_all(); - }); - - client = Aws::Crt::Mqtt5::Mqtt5Client::NewMqtt5Client(mqtt5Options, allocator); - client->Start(); - - std::unique_lock waitLock(lock); - signal.wait(waitLock, [&connected](){ return connected; }); - } + client = Aws::Crt::Mqtt5::Mqtt5Client::NewMqtt5Client(mqtt5Options, allocator); + client->Start(); - done: + std::unique_lock waitLock(lock); + signal.wait(waitLock, [&connected]() { return connected; }); + } - aws_string_destroy(host); - aws_string_destroy(certificatePath); - aws_string_destroy(privateKeyPath); +done: - return client; - } + aws_string_destroy(host); + aws_string_destroy(certificatePath); + aws_string_destroy(privateKeyPath); - inline std::shared_ptr createProtocolClient311( - Aws::Crt::Allocator *allocator) - { - std::shared_ptr connection = nullptr; + return client; +} - struct aws_string *host = NULL; - struct aws_string *certificatePath = NULL; - struct aws_string *privateKeyPath = NULL; +static std::shared_ptr s_createProtocolClient311(Aws::Crt::Allocator *allocator) +{ + std::shared_ptr connection = nullptr; - if (aws_get_environment_value(allocator, s_rrEnvVariableHost, &host) || host == nullptr) - { - goto done; - } + struct aws_string *host = NULL; + struct aws_string *certificatePath = NULL; + struct aws_string *privateKeyPath = NULL; - if (aws_get_environment_value(allocator, s_rrEnvVariableCertificatePath, &certificatePath) || - certificatePath == nullptr) - { - goto done; - } + if (aws_get_environment_value(allocator, s_rrEnvVariableHost, &host) || host == nullptr) + { + goto done; + } - if (aws_get_environment_value(allocator, s_rrEnvVariablePrivateKeyPath, &privateKeyPath) || - privateKeyPath == nullptr) - { - goto done; - } + if (aws_get_environment_value(allocator, s_rrEnvVariableCertificatePath, &certificatePath) || + certificatePath == nullptr) + { + goto done; + } - { - std::mutex lock; - std::condition_variable signal; - bool connected = false; + if (aws_get_environment_value(allocator, s_rrEnvVariablePrivateKeyPath, &privateKeyPath) || + privateKeyPath == nullptr) + { + goto done; + } - Aws::Crt::Io::TlsContextOptions tlsCtxOptions = Aws::Crt::Io::TlsContextOptions::InitClientWithMtls( - aws_string_c_str(certificatePath), aws_string_c_str(privateKeyPath), allocator); - Aws::Crt::Io::TlsContext tlsContext(tlsCtxOptions, Aws::Crt::Io::TlsMode::CLIENT, allocator); + { + std::mutex lock; + std::condition_variable signal; + bool connected = false; - Aws::Crt::Io::SocketOptions socketOptions; - socketOptions.SetConnectTimeoutMs(3000); + Aws::Crt::Io::TlsContextOptions tlsCtxOptions = Aws::Crt::Io::TlsContextOptions::InitClientWithMtls( + aws_string_c_str(certificatePath), aws_string_c_str(privateKeyPath), allocator); + Aws::Crt::Io::TlsContext tlsContext(tlsCtxOptions, Aws::Crt::Io::TlsMode::CLIENT, allocator); - Aws::Crt::Mqtt::MqttClient client; - connection = client.NewConnection(aws_string_c_str(host), 8883, socketOptions, tlsContext, false); + Aws::Crt::Io::SocketOptions socketOptions; + socketOptions.SetConnectTimeoutMs(3000); - connection->OnConnectionSuccess = [&connected, &lock, &signal](Aws::Crt::Mqtt::MqttConnection &connection, Aws::Crt::Mqtt::OnConnectionSuccessData *callbackData) { - { - std::lock_guard guard(lock); - connected = true; - } - signal.notify_all(); - }; + Aws::Crt::Mqtt::MqttClient client; + connection = client.NewConnection(aws_string_c_str(host), 8883, socketOptions, tlsContext, false); - auto uuid = Aws::Crt::UUID().ToString(); - connection->Connect(uuid.c_str(), true, 30, 15000, 5000); + connection->OnConnectionSuccess = + [&connected, &lock, &signal]( + Aws::Crt::Mqtt::MqttConnection &connection, Aws::Crt::Mqtt::OnConnectionSuccessData *callbackData) + { + { + std::lock_guard guard(lock); + connected = true; + } + signal.notify_all(); + }; - std::unique_lock waitLock(lock); - signal.wait(waitLock, [&connected](){ return connected; }); - } + auto uuid = Aws::Crt::UUID().ToString(); + connection->Connect(uuid.c_str(), true, 30, 15000, 5000); - done: + std::unique_lock waitLock(lock); + signal.wait(waitLock, [&connected]() { return connected; }); + } - aws_string_destroy(host); - aws_string_destroy(certificatePath); - aws_string_destroy(privateKeyPath); +done: - return connection; - } + aws_string_destroy(host); + aws_string_destroy(certificatePath); + aws_string_destroy(privateKeyPath); - template class ResultWaiter - { - public: - ResultWaiter() = default; + return connection; +} - void ApplyResult(R &&result) - { - { - std::lock_guard guard(m_lock); +template class ResultWaiter +{ + public: + ResultWaiter() = default; + + void ApplyResult(R &&result) + { + { + std::lock_guard guard(m_lock); - if (m_result.has_value()) - { - return; - } + if (m_result.has_value()) + { + return; + } - m_result = std::move(result); - } + m_result = std::move(result); + } - m_signal.notify_all(); - } + m_signal.notify_all(); + } - const R &GetResult() - { - { - std::unique_lock guard(m_lock); - m_signal.wait(guard, [this]() { return this->m_result.has_value(); }); - } + const R &GetResult() + { + { + std::unique_lock guard(m_lock); + m_signal.wait(guard, [this]() { return this->m_result.has_value(); }); + } - return m_result.value(); - } + return m_result.value(); + } - private: - std::mutex m_lock; - std::condition_variable m_signal; + private: + std::mutex m_lock; + std::condition_variable m_signal; - Aws::Crt::Optional m_result; - }; - } // namespace ServiceTesting - } // namespace Iot -} // namespace Aws + Aws::Crt::Optional m_result; +}; -static std::shared_ptr s_createShadowClient5(Aws::Crt::Allocator *allocator) +static std::shared_ptr s_createShadowClient5( + std::shared_ptr protocolClient, + Aws::Crt::Allocator *allocator) { - auto protocolClient = Aws::Iot::ServiceTesting::createProtocolClient5(allocator); if (!protocolClient) { return nullptr; @@ -224,9 +219,10 @@ static std::shared_ptr s_createShadowClient5(Aws::Crt return Aws::Iotshadow::NewClientFrom5(*protocolClient, serviceClientOptions, allocator); } -static std::shared_ptr s_createShadowClient311(Aws::Crt::Allocator *allocator) +static std::shared_ptr s_createShadowClient311( + std::shared_ptr protocolClient, + Aws::Crt::Allocator *allocator) { - auto protocolClient = Aws::Iot::ServiceTesting::createProtocolClient311(allocator); if (!protocolClient) { return nullptr; @@ -246,7 +242,8 @@ static int s_ShadowV2ClientCreateDestroy5(Aws::Crt::Allocator *allocator, void * { Aws::Crt::ApiHandle handle; - auto shadowClient = s_createShadowClient5(allocator); + auto protocolClient = s_createProtocolClient5(allocator); + auto shadowClient = s_createShadowClient5(protocolClient, allocator); if (!shadowClient) { return AWS_OP_SKIP; @@ -262,7 +259,8 @@ static int s_ShadowV2ClientCreateDestroy311(Aws::Crt::Allocator *allocator, void { Aws::Crt::ApiHandle handle; - auto shadowClient = s_createShadowClient311(allocator); + auto protocolClient = s_createProtocolClient311(allocator); + auto shadowClient = s_createShadowClient311(protocolClient, allocator); if (!shadowClient) { return AWS_OP_SKIP; @@ -280,15 +278,15 @@ static int s_doGetNonexistentShadowTest(std::shared_ptr getResult; + ResultWaiter getResult; Aws::Iotshadow::GetNamedShadowRequest request; request.ShadowName = Aws::Crt::UUID().ToString(); request.ThingName = Aws::Crt::UUID().ToString(); - shadowClient->GetNamedShadow(request, [&getResult](Aws::Iotshadow::GetNamedShadowResult &&result){ - getResult.ApplyResult(std::move(result)); - }); + shadowClient->GetNamedShadow( + request, + [&getResult](Aws::Iotshadow::GetNamedShadowResult &&result) { getResult.ApplyResult(std::move(result)); }); const auto &result = getResult.GetResult(); ASSERT_FALSE(result.IsSuccess()); @@ -306,28 +304,50 @@ static int s_doGetNonexistentShadowTest(std::shared_ptr shadowClient) { +static void s_deleteNamedShadow( + std::shared_ptr shadowClient, + const Aws::Crt::String &thingName, + const Aws::Crt::String &shadowName) +{ + ResultWaiter deleteResultWaiter; + + Aws::Iotshadow::DeleteNamedShadowRequest deleteRequest; + deleteRequest.ShadowName = shadowName; + deleteRequest.ThingName = thingName; + + shadowClient->DeleteNamedShadow( + deleteRequest, + [&deleteResultWaiter](Aws::Iotshadow::DeleteNamedShadowResult &&result) + { deleteResultWaiter.ApplyResult(std::move(result)); }); + + deleteResultWaiter.GetResult(); +} + +static int s_doCreateDestroyNamedShadowTest( + std::shared_ptr shadowClient, + const Aws::Crt::String &thingName, + const Aws::Crt::String &shadowName) +{ if (!shadowClient) { return AWS_OP_SKIP; } - auto shadowName = Aws::Crt::UUID().ToString();; - auto thingName = Aws::Crt::UUID().ToString(); - // 1. Create the Shadow - Aws::Iot::ServiceTesting::ResultWaiter updateResultWaiter; + ResultWaiter updateResultWaiter; Aws::Crt::JsonObject desired; desired.WithString("color", "green"); @@ -340,9 +360,10 @@ static int s_doCreateDestroyNamedShadowTest(std::shared_ptrUpdateNamedShadow(updateRequest, [&updateResultWaiter](Aws::Iotshadow::UpdateNamedShadowResult &&result){ - updateResultWaiter.ApplyResult(std::move(result)); - }); + shadowClient->UpdateNamedShadow( + updateRequest, + [&updateResultWaiter](Aws::Iotshadow::UpdateNamedShadowResult &&result) + { updateResultWaiter.ApplyResult(std::move(result)); }); const auto &updateResult = updateResultWaiter.GetResult(); ASSERT_TRUE(updateResult.IsSuccess()); @@ -354,15 +375,16 @@ static int s_doCreateDestroyNamedShadowTest(std::shared_ptr deleteResultWaiter; + ResultWaiter deleteResultWaiter; Aws::Iotshadow::DeleteNamedShadowRequest deleteRequest; deleteRequest.ShadowName = shadowName; deleteRequest.ThingName = thingName; - shadowClient->DeleteNamedShadow(deleteRequest, [&deleteResultWaiter](Aws::Iotshadow::DeleteNamedShadowResult &&result){ - deleteResultWaiter.ApplyResult(std::move(result)); - }); + shadowClient->DeleteNamedShadow( + deleteRequest, + [&deleteResultWaiter](Aws::Iotshadow::DeleteNamedShadowResult &&result) + { deleteResultWaiter.ApplyResult(std::move(result)); }); const auto &deleteResult = deleteResultWaiter.GetResult(); ASSERT_TRUE(deleteResult.IsSuccess()); @@ -373,33 +395,60 @@ static int s_doCreateDestroyNamedShadowTest(std::shared_ptr s_createNamedShadowUpdatedStream(std::shared_ptr shadowClient, Aws::Iot::ServiceTesting::ResultWaiter &eventWaiter, const Aws::Crt::String &thingName, const Aws::Crt::String &shadowName) { +static std::shared_ptr s_createNamedShadowUpdatedStream( + std::shared_ptr shadowClient, + ResultWaiter &eventWaiter, + const Aws::Crt::String &thingName, + const Aws::Crt::String &shadowName) +{ Aws::Iotshadow::NamedShadowUpdatedSubscriptionRequest updateStreamRequest; updateStreamRequest.ThingName = thingName; updateStreamRequest.ShadowName = shadowName; - Aws::Iot::ServiceTesting::ResultWaiter subscribeWaiter; + ResultWaiter subscribeWaiter; Aws::Iot::RequestResponse::StreamingOperationOptions updateStreamOptions; - updateStreamOptions.WithStreamHandler([&eventWaiter](Aws::Iotshadow::ShadowUpdatedEvent &&event){ - eventWaiter.ApplyResult(std::move(event)); - }); - updateStreamOptions.WithSubscriptionStatusEventHandler([&subscribeWaiter](Aws::Iot::RequestResponse::SubscriptionStatusEvent &&event) { - if (event.GetType() == Aws::Iot::RequestResponse::SubscriptionStatusEventType::SubscriptionEstablished) { - subscribeWaiter.ApplyResult(std::move(event)); - } - }); + updateStreamOptions.WithStreamHandler([&eventWaiter](Aws::Iotshadow::ShadowUpdatedEvent &&event) + { eventWaiter.ApplyResult(std::move(event)); }); + updateStreamOptions.WithSubscriptionStatusEventHandler( + [&subscribeWaiter](Aws::Iot::RequestResponse::SubscriptionStatusEvent &&event) + { + if (event.GetType() == Aws::Iot::RequestResponse::SubscriptionStatusEventType::SubscriptionEstablished) + { + subscribeWaiter.ApplyResult(std::move(event)); + } + }); auto updateStream = shadowClient->CreateNamedShadowUpdatedStream(updateStreamRequest, updateStreamOptions); updateStream->Open(); @@ -409,24 +458,33 @@ static std::shared_ptr s_createN return updateStream; } -static std::shared_ptr s_createNamedShadowDeltaUpdatedStream(std::shared_ptr shadowClient, Aws::Iot::ServiceTesting::ResultWaiter &eventWaiter, const Aws::Crt::String &thingName, const Aws::Crt::String &shadowName) { +static std::shared_ptr s_createNamedShadowDeltaUpdatedStream( + std::shared_ptr shadowClient, + ResultWaiter &eventWaiter, + const Aws::Crt::String &thingName, + const Aws::Crt::String &shadowName) +{ Aws::Iotshadow::NamedShadowDeltaUpdatedSubscriptionRequest deltaUpdateStreamRequest; deltaUpdateStreamRequest.ThingName = thingName; deltaUpdateStreamRequest.ShadowName = shadowName; - Aws::Iot::ServiceTesting::ResultWaiter subscribeWaiter; + ResultWaiter subscribeWaiter; - Aws::Iot::RequestResponse::StreamingOperationOptions deltaUpdateStreamOptions; - deltaUpdateStreamOptions.WithStreamHandler([&eventWaiter](Aws::Iotshadow::ShadowDeltaUpdatedEvent &&event){ - eventWaiter.ApplyResult(std::move(event)); - }); - deltaUpdateStreamOptions.WithSubscriptionStatusEventHandler([&subscribeWaiter](Aws::Iot::RequestResponse::SubscriptionStatusEvent &&event) { - if (event.GetType() == Aws::Iot::RequestResponse::SubscriptionStatusEventType::SubscriptionEstablished) { - subscribeWaiter.ApplyResult(std::move(event)); - } - }); + Aws::Iot::RequestResponse::StreamingOperationOptions + deltaUpdateStreamOptions; + deltaUpdateStreamOptions.WithStreamHandler([&eventWaiter](Aws::Iotshadow::ShadowDeltaUpdatedEvent &&event) + { eventWaiter.ApplyResult(std::move(event)); }); + deltaUpdateStreamOptions.WithSubscriptionStatusEventHandler( + [&subscribeWaiter](Aws::Iot::RequestResponse::SubscriptionStatusEvent &&event) + { + if (event.GetType() == Aws::Iot::RequestResponse::SubscriptionStatusEventType::SubscriptionEstablished) + { + subscribeWaiter.ApplyResult(std::move(event)); + } + }); - auto deltaUpdateStream = shadowClient->CreateNamedShadowDeltaUpdatedStream(deltaUpdateStreamRequest, deltaUpdateStreamOptions); + auto deltaUpdateStream = + shadowClient->CreateNamedShadowDeltaUpdatedStream(deltaUpdateStreamRequest, deltaUpdateStreamOptions); deltaUpdateStream->Open(); subscribeWaiter.GetResult(); @@ -434,17 +492,18 @@ static std::shared_ptr s_createN return deltaUpdateStream; } -static int s_doDeltaUpdateNamedShadowTest(std::shared_ptr shadowClient) { +static int s_doDeltaUpdateNamedShadowTest( + std::shared_ptr shadowClient, + const Aws::Crt::String &thingName, + const Aws::Crt::String &shadowName) +{ if (!shadowClient) { return AWS_OP_SKIP; } // 1. create the shadow with a specific desired state - auto shadowName = Aws::Crt::UUID().ToString();; - auto thingName = Aws::Crt::UUID().ToString(); - - Aws::Iot::ServiceTesting::ResultWaiter createResultWaiter; + ResultWaiter createResultWaiter; Aws::Crt::JsonObject createDocument; createDocument.WithString("color", "green"); @@ -458,23 +517,26 @@ static int s_doDeltaUpdateNamedShadowTest(std::shared_ptrUpdateNamedShadow(createRequest, [&createResultWaiter](Aws::Iotshadow::UpdateNamedShadowResult &&result){ - createResultWaiter.ApplyResult(std::move(result)); - }); + shadowClient->UpdateNamedShadow( + createRequest, + [&createResultWaiter](Aws::Iotshadow::UpdateNamedShadowResult &&result) + { createResultWaiter.ApplyResult(std::move(result)); }); ASSERT_TRUE(createResultWaiter.GetResult().IsSuccess()); // 2. Create both kinds of streaming operations // Result waiters can work as one-shot notifiers for streams too - Aws::Iot::ServiceTesting::ResultWaiter updateStreamFirstEventWaiter; - auto updateStream = s_createNamedShadowUpdatedStream(shadowClient, updateStreamFirstEventWaiter, thingName, shadowName); + ResultWaiter updateStreamFirstEventWaiter; + auto updateStream = + s_createNamedShadowUpdatedStream(shadowClient, updateStreamFirstEventWaiter, thingName, shadowName); - Aws::Iot::ServiceTesting::ResultWaiter deltaUpdateStreamFirstEventWaiter; - auto updateDeltaStream = s_createNamedShadowDeltaUpdatedStream(shadowClient, deltaUpdateStreamFirstEventWaiter, thingName, shadowName); + ResultWaiter deltaUpdateStreamFirstEventWaiter; + auto updateDeltaStream = + s_createNamedShadowDeltaUpdatedStream(shadowClient, deltaUpdateStreamFirstEventWaiter, thingName, shadowName); // 3. Update the desired state of the shadow to a different color - Aws::Iot::ServiceTesting::ResultWaiter updateResultWaiter; + ResultWaiter updateResultWaiter; Aws::Crt::JsonObject updateDocument; updateDocument.WithString("color", "blue"); @@ -487,18 +549,21 @@ static int s_doDeltaUpdateNamedShadowTest(std::shared_ptrUpdateNamedShadow(updateRequest, [&updateResultWaiter](Aws::Iotshadow::UpdateNamedShadowResult &&result){ - updateResultWaiter.ApplyResult(std::move(result)); - }); + shadowClient->UpdateNamedShadow( + updateRequest, + [&updateResultWaiter](Aws::Iotshadow::UpdateNamedShadowResult &&result) + { updateResultWaiter.ApplyResult(std::move(result)); }); ASSERT_TRUE(updateResultWaiter.GetResult().IsSuccess()); // 4. Verify both streaming operations got an appropriate update - const auto &oldDesiredState = updateStreamFirstEventWaiter.GetResult().Previous.value().State.value().Desired.value(); + const auto &oldDesiredState = + updateStreamFirstEventWaiter.GetResult().Previous.value().State.value().Desired.value(); auto oldColor = oldDesiredState.View().GetString("color"); ASSERT_TRUE(oldColor == "green"); - const auto ¤tDesiredState = updateStreamFirstEventWaiter.GetResult().Current.value().State.value().Desired.value(); + const auto ¤tDesiredState = + updateStreamFirstEventWaiter.GetResult().Current.value().State.value().Desired.value(); auto currentColor = currentDesiredState.View().GetString("color"); ASSERT_TRUE(currentColor == "blue"); @@ -507,15 +572,16 @@ static int s_doDeltaUpdateNamedShadowTest(std::shared_ptr deleteResultWaiter; + ResultWaiter deleteResultWaiter; Aws::Iotshadow::DeleteNamedShadowRequest deleteRequest; deleteRequest.ShadowName = shadowName; deleteRequest.ThingName = thingName; - shadowClient->DeleteNamedShadow(deleteRequest, [&deleteResultWaiter](Aws::Iotshadow::DeleteNamedShadowResult &&result){ - deleteResultWaiter.ApplyResult(std::move(result)); - }); + shadowClient->DeleteNamedShadow( + deleteRequest, + [&deleteResultWaiter](Aws::Iotshadow::DeleteNamedShadowResult &&result) + { deleteResultWaiter.ApplyResult(std::move(result)); }); const auto &deleteResult = deleteResultWaiter.GetResult(); ASSERT_TRUE(deleteResult.IsSuccess()); @@ -526,13 +592,33 @@ static int s_doDeltaUpdateNamedShadowTest(std::shared_ptr