From e5abcca0e51d5048e14a7051706ef2961819b569 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Fri, 22 Nov 2024 09:59:51 +0200 Subject: [PATCH] fix: `NodeUpdateTransaction` sets description as empty string (#2096) Signed-off-by: Ivan Ivanov --- .../java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java | 4 +++- .../com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java index 19312002f..de5a31575 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java @@ -454,7 +454,9 @@ void initFromTransactionBody() { accountId = AccountId.fromProtobuf(body.getAccountId()); } - description = body.getDescription().getValue(); + if (body.hasDescription()) { + description = body.getDescription().getValue(); + } for (var gossipEndpoint : body.getGossipEndpointList()) { gossipEndpoints.add(Endpoint.fromProtobuf(gossipEndpoint)); diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java index 2d976e435..f56474b57 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java @@ -118,12 +118,13 @@ void shouldBytes() throws Exception { } @Test - void testNullCertificates() throws Exception { + void testNullOptionalValues() throws Exception { var tx = new NodeUpdateTransaction(); var tx2Bytes = tx.toBytes(); NodeUpdateTransaction deserializedTx = (NodeUpdateTransaction) Transaction.fromBytes(tx2Bytes); assertThat(deserializedTx.getGossipCaCertificate()).isNull(); assertThat(deserializedTx.getGrpcCertificateHash()).isNull(); + assertThat(deserializedTx.getDescription()).isNull(); } @Test