Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Hip 991 submit message last tests #17185

Open
wants to merge 5 commits into
base: hip-991-submit-message
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -386,6 +387,87 @@ final Stream<DynamicTest> collectorSubmitMessageToTopicWithHbarFee() {
}));
}

@HapiTest
@DisplayName("Submit message to a topic after fee update")
// TOPIC_FEE_126
final Stream<DynamicTest> 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<DynamicTest> 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<DynamicTest> 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<DynamicTest> collectorSubmitMessageToTopicWith2differentFees() {
Expand Down
Loading