diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip991/TopicCustomFeeSubmitMessageTest.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip991/TopicCustomFeeSubmitMessageTest.java index eb5afb86e6ee..aaf08548d06a 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip991/TopicCustomFeeSubmitMessageTest.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip991/TopicCustomFeeSubmitMessageTest.java @@ -25,6 +25,7 @@ import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer; import static com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo; import static com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate; +import static com.hedera.services.bdd.spec.transactions.TxnVerbs.updateTopic; import static com.hedera.services.bdd.spec.transactions.token.CustomFeeSpecs.fixedConsensusHbarFee; import static com.hedera.services.bdd.spec.transactions.token.CustomFeeSpecs.fixedConsensusHtsFee; import static com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving; @@ -386,6 +387,87 @@ final Stream collectorSubmitMessageToTopicWithHbarFee() { })); } + @HapiTest + @DisplayName("Submit message to a topic after fee update") + // TOPIC_FEE_126 + final Stream submitMessageAfterUpdate() { + final var collector = "collector"; + final var fee = fixedConsensusHtsFee(1, BASE_TOKEN, collector); + final var updatedFee = fixedConsensusHtsFee(2, BASE_TOKEN, collector); + return hapiTest( + newKeyNamed("adminKey"), + newKeyNamed("feeScheduleKey"), + cryptoCreate(collector).balance(ONE_HBAR), + tokenAssociate(collector, BASE_TOKEN), + createTopic(TOPIC) + .withConsensusCustomFee(fee) + .adminKeyName("adminKey") + .feeScheduleKeyName("feeScheduleKey"), + submitMessageTo(TOPIC) + .maxCustomFee(fee) + .message("TEST") + .payingWith(SUBMITTER) + .via("submit"), + getAccountBalance(collector).hasTokenBalance(BASE_TOKEN, 1), + updateTopic(TOPIC) + .withConsensusCustomFee(updatedFee) + .signedByPayerAnd("adminKey", "feeScheduleKey"), + submitMessageTo(TOPIC) + .maxCustomFee(updatedFee) + .message("TEST") + .payingWith(SUBMITTER) + .via("submit2"), + getAccountBalance(collector).hasTokenBalance(BASE_TOKEN, 3)); + } + + @HapiTest + @DisplayName("Submit message to a topic after key is removed from FEKL") + // TOPIC_FEE_129 + final Stream submitMessageAfterFEKLisRemoved() { + final var collector = "collector"; + final var fee = fixedConsensusHtsFee(1, BASE_TOKEN, collector); + return hapiTest( + newKeyNamed("adminKey"), + cryptoCreate(collector).balance(ONE_HBAR), + tokenAssociate(collector, BASE_TOKEN), + createTopic(TOPIC) + .withConsensusCustomFee(fee) + .adminKeyName("adminKey") + .feeExemptKeys(SUBMITTER), + submitMessageTo(TOPIC).message("TEST").payingWith(SUBMITTER).via("submit"), + getAccountBalance(collector).hasTokenBalance(BASE_TOKEN, 0), + updateTopic(TOPIC).feeExemptKeys().signedByPayerAnd("adminKey"), + submitMessageTo(TOPIC) + .maxCustomFee(fee) + .message("TEST") + .payingWith(SUBMITTER) + .via("submit2"), + getAccountBalance(collector).hasTokenBalance(BASE_TOKEN, 1)); + } + + @HapiTest + @DisplayName("Submit message to a topic after fee is added with update") + // TOPIC_FEE_130 + final Stream submitMessageAfterFeeIsAdded() { + final var collector = "collector"; + final var fee = fixedConsensusHtsFee(1, BASE_TOKEN, collector); + return hapiTest( + newKeyNamed("adminKey"), + newKeyNamed("feeScheduleKey"), + cryptoCreate(collector).balance(ONE_HBAR), + tokenAssociate(collector, BASE_TOKEN), + createTopic(TOPIC).adminKeyName("adminKey").feeScheduleKeyName("feeScheduleKey"), + submitMessageTo(TOPIC).message("TEST").payingWith(SUBMITTER).via("submit"), + getAccountBalance(collector).hasTokenBalance(BASE_TOKEN, 0), + updateTopic(TOPIC).withConsensusCustomFee(fee).signedByPayerAnd("adminKey", "feeScheduleKey"), + submitMessageTo(TOPIC) + .maxCustomFee(fee) + .message("TEST") + .payingWith(SUBMITTER) + .via("submit2"), + getAccountBalance(collector).hasTokenBalance(BASE_TOKEN, 1)); + } + @HapiTest @DisplayName("Collector submits a message to a topic with 2 different FT fees.") final Stream collectorSubmitMessageToTopicWith2differentFees() {