Skip to content

Commit 7a11b79

Browse files
naydenovn0xivanov
andauthored
feat(TCK): Topic endpoints (#2435)
Signed-off-by: Naydenov <nikola.naydenov@limechain.tech> Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com> Co-authored-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
1 parent 7d4893f commit 7a11b79

File tree

11 files changed

+643
-33
lines changed

11 files changed

+643
-33
lines changed

sdk/src/main/java/com/hedera/hashgraph/sdk/ChunkedTransaction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ public ScheduleCreateTransaction schedule() {
455455

456456
@Override
457457
int getRequiredChunks() {
458+
if (this.data.isEmpty()) {
459+
throw new IllegalArgumentException("message cannot be empty");
460+
}
458461
var requiredChunks = (this.data.size() + (chunkSize - 1)) / chunkSize;
459462

460463
if (requiredChunks == 0) {

sdk/src/main/java/com/hedera/hashgraph/sdk/TopicUpdateTransaction.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public final class TopicUpdateTransaction extends Transaction<TopicUpdateTransac
4848
@Nullable
4949
private Instant expirationTime = null;
5050

51+
private Duration expirationTimeDuration = null;
52+
5153
private Key feeScheduleKey = null;
5254

5355
private List<Key> feeExemptKeys = null;
@@ -335,6 +337,15 @@ public Instant getExpirationTime() {
335337
public TopicUpdateTransaction setExpirationTime(Instant expirationTime) {
336338
requireNotFrozen();
337339
this.expirationTime = Objects.requireNonNull(expirationTime);
340+
this.expirationTimeDuration = null;
341+
return this;
342+
}
343+
344+
public TopicUpdateTransaction setExpirationTime(Duration expirationTime) {
345+
Objects.requireNonNull(expirationTime);
346+
requireNotFrozen();
347+
this.expirationTime = null;
348+
this.expirationTimeDuration = expirationTime;
338349
return this;
339350
}
340351

@@ -526,6 +537,9 @@ ConsensusUpdateTopicTransactionBody.Builder build() {
526537
if (expirationTime != null) {
527538
builder.setExpirationTime(InstantConverter.toProtobuf(expirationTime));
528539
}
540+
if (expirationTimeDuration != null) {
541+
builder.setExpirationTime(InstantConverter.toProtobuf(expirationTimeDuration));
542+
}
529543
if (feeScheduleKey != null) {
530544
builder.setFeeScheduleKey(feeScheduleKey.toProtobufKey());
531545
}

sdk/src/test/java/com/hedera/hashgraph/sdk/TransactionTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ void transactionWithNoContentShouldReturnSingleBodyChunk() {
256256
var fileAppendTx = new FileAppendTransaction()
257257
.setFileId(new FileId(1))
258258
.setTransactionId(new TransactionId(testAccountId, validStart))
259+
.setContents(" ")
259260
.setNodeAccountIds(testNodeAccountIds)
260261
.freeze();
261262

sdk/src/testIntegration/java/com/hedera/hashgraph/sdk/test/integration/TopicMessageSubmitIntegrationTest.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -142,39 +142,6 @@ void cannotSubmitMessageWhenTopicIDIsNotSet() {
142142
});
143143
}
144144

145-
@Test
146-
@DisplayName("Cannot submit message when message is not set")
147-
void cannotSubmitMessageWhenMessageIsNotSet() {
148-
// Skip if using PreviewNet
149-
Assumptions.assumeTrue(!System.getProperty("HEDERA_NETWORK").equals("previewnet"));
150-
151-
assertThatNoException().isThrownBy(() -> {
152-
try (var testEnv = new IntegrationTestEnv(1)) {
153-
154-
var response = new TopicCreateTransaction()
155-
.setAdminKey(testEnv.operatorKey)
156-
.setTopicMemo("[e2e::TopicCreateTransaction]")
157-
.execute(testEnv.client);
158-
159-
var topicId = Objects.requireNonNull(response.getReceipt(testEnv.client).topicId);
160-
161-
assertThatExceptionOfType(PrecheckStatusException.class)
162-
.isThrownBy(() -> {
163-
new TopicMessageSubmitTransaction()
164-
.setTopicId(topicId)
165-
.execute(testEnv.client)
166-
.getReceipt(testEnv.client);
167-
})
168-
.withMessageContaining(Status.INVALID_TOPIC_MESSAGE.toString());
169-
170-
new TopicDeleteTransaction()
171-
.setTopicId(topicId)
172-
.execute(testEnv.client)
173-
.getReceipt(testEnv.client);
174-
}
175-
});
176-
}
177-
178145
@Test
179146
@DisplayName("Hex Decode Regression Test")
180147
@SuppressWarnings("UnusedVariable")

0 commit comments

Comments
 (0)