diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/Endpoint.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/Endpoint.java index f9f6642c0..fc542450e 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/Endpoint.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/Endpoint.java @@ -53,10 +53,6 @@ public Endpoint() { static Endpoint fromProtobuf(ServiceEndpoint serviceEndpoint) { var port = (int) (serviceEndpoint.getPort() & 0x00000000ffffffffL); - if (port == 0 || port == 50111) { - port = 50211; - } - return new Endpoint() .setAddress(serviceEndpoint.getIpAddressV4().toByteArray()) .setPort(port) diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java index 3c4577b2d..af814fb1f 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java @@ -61,7 +61,7 @@ public class NodeCreateTransactionTest { private static final byte[] TEST_GRPC_CERTIFICATE_HASH = new byte[]{5, 6, 7, 8, 9}; private static final PublicKey TEST_ADMIN_KEY = PrivateKey.fromString( - "302e020100300506032b65700422042062c4b69e9f45a554e5424fb5a6fe5e6ac1f19ead31dc7718c2d980fd1f998d4b") + "302e020100300506032b65700422042062c4b69e9f45a554e5424fb5a6fe5e6ac1f19ead31dc7718c2d980fd1f998d4b") .getPublicKey(); final Instant TEST_VALID_START = Instant.ofEpochSecond(1554158542); @@ -83,7 +83,7 @@ void shouldSerialize() { private static Endpoint spawnTestEndpoint(byte offset) { return new Endpoint() - .setAddress(new byte[] {0x00, 0x01, 0x02, 0x03}) + .setAddress(new byte[]{0x00, 0x01, 0x02, 0x03}) .setDomainName(offset + "unit.test.com") .setPort(42 + offset); } @@ -123,17 +123,26 @@ void fromScheduledTransaction() { } @Test - void testSerializeDeserialize() throws Exception { - var tx = new NodeCreateTransaction().setDescription(TEST_DESCRIPTION); - var tx2 = new NodeCreateTransaction().setDescription(TEST_DESCRIPTION); - var tx2Bytes = tx2.toBytes(); - NodeCreateTransaction deserializedTx2 = (NodeCreateTransaction) Transaction.fromBytes(tx2Bytes); - assertThat(tx.getGossipCaCertificate()).isEqualTo(deserializedTx2.getGossipCaCertificate()); - assertThat(tx.getGrpcCertificateHash()).isEqualTo(deserializedTx2.getGrpcCertificateHash()); + void testUnrecognizedServicePort() throws Exception { + var tx = new NodeCreateTransaction() + .setServiceEndpoints( + List.of(new Endpoint() + .setAddress(new byte[]{0x00, 0x01, 0x02, 0x03}) + .setDomainName("unit.test.com") + .setPort(50111))); + var tx2 = NodeCreateTransaction.fromBytes(tx.toBytes()); + assertThat(tx2.toString()).isEqualTo(tx.toString()); + } + + @Test + void testNullOptionalValues() throws Exception { + var tx = new NodeCreateTransaction(); + var tx2 = NodeCreateTransaction.fromBytes(tx.toBytes()); + assertThat(tx2.toString()).isEqualTo(tx.toString()); } @Test - void testSetNull() { + void testSetNull() { new NodeCreateTransaction() .setDescription(null) .setAccountId(null) 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 f56474b57..e79f6e156 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java @@ -87,7 +87,7 @@ void shouldSerialize() { private static Endpoint spawnTestEndpoint(byte offset) { return new Endpoint() - .setAddress(new byte[] {0x00, 0x01, 0x02, 0x03}) + .setAddress(new byte[]{0x00, 0x01, 0x02, 0x03}) .setDomainName(offset + "unit.test.com") .setPort(42 + offset); } @@ -120,11 +120,20 @@ void shouldBytes() throws Exception { @Test 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(); + var tx2 = NodeUpdateTransaction.fromBytes(tx.toBytes()); + assertThat(tx2.toString()).isEqualTo(tx.toString()); + } + + @Test + void testUnrecognizedServicePort() throws Exception { + var tx = new NodeUpdateTransaction() + .setServiceEndpoints( + List.of(new Endpoint() + .setAddress(new byte[]{0x00, 0x01, 0x02, 0x03}) + .setDomainName("unit.test.com") + .setPort(50111))); + var tx2 = NodeUpdateTransaction.fromBytes(tx.toBytes()); + assertThat(tx2.toString()).isEqualTo(tx.toString()); } @Test @@ -139,7 +148,7 @@ void testEmptyCertificates() throws Exception { } @Test - void testSetNull() { + void testSetNull() { new NodeUpdateTransaction() .setDescription(null) .setAccountId(null)