Skip to content

Commit

Permalink
fix: don't fill out accountIdToUpdate if no account ID was provided (
Browse files Browse the repository at this point in the history
…#756)

Signed-off-by: Rob Walworth <[email protected]>
  • Loading branch information
rwalworth authored Aug 8, 2024
1 parent ce3c619 commit 50db0db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/sdk/main/src/AccountUpdateTransaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ proto::CryptoUpdateTransactionBody* AccountUpdateTransaction::build() const
{
auto body = std::make_unique<proto::CryptoUpdateTransactionBody>();

body->set_allocated_accountidtoupdate(mAccountId.toProtobuf().release());
if (!(mAccountId == AccountId()))
{
body->set_allocated_accountidtoupdate(mAccountId.toProtobuf().release());
}

if (mKey)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "TransactionReceipt.h"
#include "TransactionResponse.h"
#include "TransferTransaction.h"
#include "exceptions/PrecheckStatusException.h"
#include "exceptions/ReceiptStatusException.h"

#include <gtest/gtest.h>
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 50db0db

Please sign in to comment.