From 50db0dbe67510bd2c8f4370709848673c75b8c4c Mon Sep 17 00:00:00 2001 From: Rob Walworth <110835868+rwalworth@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:03:10 -0500 Subject: [PATCH] fix: don't fill out `accountIdToUpdate` if no account ID was provided (#756) Signed-off-by: Rob Walworth --- src/sdk/main/src/AccountUpdateTransaction.cc | 5 ++++- .../integration/AccountUpdateTransactionIntegrationTests.cc | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sdk/main/src/AccountUpdateTransaction.cc b/src/sdk/main/src/AccountUpdateTransaction.cc index 3a21a5019..9280b66d8 100644 --- a/src/sdk/main/src/AccountUpdateTransaction.cc +++ b/src/sdk/main/src/AccountUpdateTransaction.cc @@ -258,7 +258,10 @@ proto::CryptoUpdateTransactionBody* AccountUpdateTransaction::build() const { auto body = std::make_unique(); - body->set_allocated_accountidtoupdate(mAccountId.toProtobuf().release()); + if (!(mAccountId == AccountId())) + { + body->set_allocated_accountidtoupdate(mAccountId.toProtobuf().release()); + } if (mKey) { diff --git a/src/sdk/tests/integration/AccountUpdateTransactionIntegrationTests.cc b/src/sdk/tests/integration/AccountUpdateTransactionIntegrationTests.cc index 3c21dfddf..47698a138 100644 --- a/src/sdk/tests/integration/AccountUpdateTransactionIntegrationTests.cc +++ b/src/sdk/tests/integration/AccountUpdateTransactionIntegrationTests.cc @@ -31,6 +31,7 @@ #include "TransactionReceipt.h" #include "TransactionResponse.h" #include "TransferTransaction.h" +#include "exceptions/PrecheckStatusException.h" #include "exceptions/ReceiptStatusException.h" #include @@ -158,7 +159,7 @@ TEST_F(AccountUpdateTransactionIntegrationTests, CannotUpdateAccountWithoutAccou .sign(privateKey) .execute(getTestClient()) .getReceipt(getTestClient()), - ReceiptStatusException); // ACCOUNT_ID_DOES_NOT_EXIST + PrecheckStatusException); // ACCOUNT_ID_DOES_NOT_EXIST // Clean up ASSERT_NO_THROW(AccountDeleteTransaction()