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: Add message submit tests 129-145 #17022

Merged
merged 124 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
98a7ac9
Topic get info changes
ibankov Sep 5, 2024
a1e1257
add temporary fix for topic update unit test
ibankov Sep 5, 2024
36d7f4b
Update documentation on protobuf changes
kimbor Sep 8, 2024
dca8c74
Add custom fees to ConsensusCreateTopicHandler
JivkoKelchev Sep 9, 2024
773cbcd
Refactor
JivkoKelchev Sep 10, 2024
e67f50b
consensus custom fee builders and asserts for hapi tests
JivkoKelchev Sep 10, 2024
b9c05bd
Topic create hapi tests
JivkoKelchev Sep 10, 2024
3e4c95f
Merge branch 'refs/heads/develop' into hip-991-topic-fees-get-info
JivkoKelchev Sep 10, 2024
8f48c49
Merge branch 'refs/heads/hip-991-topic-fees-get-info' into hip-991-to…
JivkoKelchev Sep 10, 2024
960cae5
Fix checkModuleDirectivesScope error
JivkoKelchev Sep 10, 2024
a97d4ca
Use copyBuilder()
JivkoKelchev Sep 10, 2024
80c29cb
Fix indentation
JivkoKelchev Sep 10, 2024
54bf31d
Topic create hapi tests
JivkoKelchev Sep 11, 2024
904afa8
Update protobuf messages
JivkoKelchev Sep 11, 2024
3508749
Update protobufs specification text
JivkoKelchev Sep 12, 2024
b695b0d
Merge branch 'refs/heads/hip-991-topic-fees-get-info' into hip-991-to…
JivkoKelchev Sep 12, 2024
a720252
Replace FMLK with FEKL in HapiGetTopicInfo
JivkoKelchev Sep 12, 2024
ee8e728
Merge branch 'refs/heads/hip-991-topic-fees-get-info' into hip-991-to…
JivkoKelchev Sep 12, 2024
0f9a897
Replace FMLK with FEKL in HapiGetTopicInfo
JivkoKelchev Sep 12, 2024
e52365f
Add FEKL and custom fee amount validation
JivkoKelchev Sep 13, 2024
c54f1f5
fix tests
JivkoKelchev Sep 15, 2024
63687f0
spotless
JivkoKelchev Sep 15, 2024
b00e1e8
Merge branch 'refs/heads/hip-991-topic-fees' into hip-991-topic-fees-…
JivkoKelchev Sep 17, 2024
c339784
fix merge conflicts
JivkoKelchev Sep 17, 2024
25ee202
Topic allowances protobufs
ibankov Sep 17, 2024
0ed094c
extend protobufs
ibankov Sep 19, 2024
9ddc6a1
consensus approve allowance proto
ibankov Sep 19, 2024
f473cbb
consensus approve allowance handler
ibankov Sep 19, 2024
11b7bb4
api permissions config
ibankov Sep 19, 2024
1ed4d19
validator and unit tests
ibankov Sep 19, 2024
d620eb6
fix protos and add builders
ibankov Sep 19, 2024
ee2a6b4
fix indentation
ibankov Sep 19, 2024
54afd45
improving descriptions of allowance lists
ibankov Sep 19, 2024
f4cf054
add further documentation
ibankov Sep 19, 2024
c2fdf52
Add grcp endpoint
ibankov Sep 19, 2024
af5e2e3
addressing PR comments
ibankov Sep 20, 2024
34dba09
Merge branch 'hip-991-approve-allowance-proto' into hip-991-allowance…
ibankov Sep 24, 2024
b7c2e84
approve allowance initial commit
ibankov Sep 26, 2024
6633fb8
fix scope
ibankov Sep 26, 2024
32b35c3
add some unit tests
ibankov Sep 26, 2024
9c1f8e9
submit msg
JivkoKelchev Sep 27, 2024
14af58b
Merge branch 'refs/heads/hip-991-allowance-transaction' into hip-991-…
JivkoKelchev Sep 30, 2024
c32fba1
Add hapi tests
JivkoKelchev Sep 30, 2024
ff651bc
Add unit tests and reject contracts
ibankov Oct 1, 2024
38bd23d
Merge branch 'refs/heads/hip-991-allowance-transaction' into hip-991-…
JivkoKelchev Oct 1, 2024
5fec8e3
Split crypto dispatches if we have to many transfers
JivkoKelchev Oct 1, 2024
145a04f
Hapi tests, custom fee assessor refactoring
JivkoKelchev Oct 8, 2024
8598691
Refactor
JivkoKelchev Oct 8, 2024
78c8748
Add hapi tests
JivkoKelchev Oct 8, 2024
dea8af1
Fix tests
JivkoKelchev Oct 10, 2024
ab6ce39
submit msg
JivkoKelchev Sep 27, 2024
b1f07bc
Add hapi tests
JivkoKelchev Sep 30, 2024
83f37e2
Split crypto dispatches if we have to many transfers
JivkoKelchev Oct 1, 2024
5e6d71f
Hapi tests, custom fee assessor refactoring
JivkoKelchev Oct 8, 2024
2cca738
Refactor
JivkoKelchev Oct 8, 2024
44ff622
Add hapi tests
JivkoKelchev Oct 8, 2024
3ef8877
Fix tests
JivkoKelchev Oct 10, 2024
f1de34a
feat: Add custom fees to ConsensusCreateTopicHandler (#15402)
JivkoKelchev Oct 3, 2024
becfa7e
feat: Update ConsensusUpdateTopicHandler with new custom fee function…
vtronkov Oct 3, 2024
cc1d011
fix merge conflict
JivkoKelchev Dec 5, 2024
10dc471
Merge remote-tracking branch 'origin/hip-991-submit-message' into hip…
JivkoKelchev Dec 5, 2024
7483da7
Remove allowances
JivkoKelchev Dec 5, 2024
158ab5b
Remove allowances
JivkoKelchev Dec 5, 2024
fa0445f
Remove allowances
JivkoKelchev Dec 5, 2024
ca60528
Remove allowances
JivkoKelchev Dec 6, 2024
d428b8c
Revert ConsensusCreateTopicHandler
JivkoKelchev Dec 6, 2024
7d5da3a
Remove allowances
JivkoKelchev Dec 6, 2024
ecc3e93
Merge branch 'refs/heads/hip-991-topic-fees' into hip-991-submit-message
JivkoKelchev Dec 6, 2024
e222736
Fix merge conflicts
JivkoKelchev Dec 6, 2024
a0446e0
Revert changes
JivkoKelchev Dec 9, 2024
db637af
Fix dispatching of child transfers
JivkoKelchev Dec 9, 2024
d1b1714
fix unit tests
JivkoKelchev Dec 9, 2024
d472977
Add max_custom_fees and accept_all_custom_fees
JivkoKelchev Dec 10, 2024
2570e43
Revert unnecessary changes
JivkoKelchev Dec 10, 2024
ae381ba
Refactor custom fee validations
JivkoKelchev Dec 10, 2024
0705691
Cleanup
JivkoKelchev Dec 10, 2024
51c7183
add CUSTOM_FEES_LIMIT_EXCEEDED status code
JivkoKelchev Dec 11, 2024
1dfd412
Merge branch 'refs/heads/hip-991-topic-fees' into hip-991-submit-message
JivkoKelchev Dec 11, 2024
5a6f72c
Simplify the fee assessment
JivkoKelchev Dec 11, 2024
9a3c4e1
Add message submit tests 129-145
ibankov Dec 11, 2024
02b3fc9
asdd
ibankov Dec 11, 2024
7773580
spot
ibankov Dec 11, 2024
22de1f8
description
ibankov Dec 11, 2024
4a9f444
Add unit test
JivkoKelchev Dec 11, 2024
b548295
fix module-info.java
JivkoKelchev Dec 12, 2024
5f0acd2
fix module-info.java
JivkoKelchev Dec 12, 2024
7ddd522
fix limit comparison
JivkoKelchev Dec 12, 2024
5c1b466
Merge branch 'hip-991-submit-message' into hip-991-submit-message-129…
ibankov Dec 13, 2024
29dfbba
revert HapiTopicCreate changes
JivkoKelchev Dec 13, 2024
44f9842
Fee limits additional validations
JivkoKelchev Dec 16, 2024
2be0067
Fee limits additional validations
JivkoKelchev Dec 16, 2024
ac943c5
fixed fee limit validation
ibankov Dec 16, 2024
b2dc290
Merge branch 'hip-991-submit-message' into hip-991-submit-message-129…
ibankov Dec 16, 2024
b103957
Merge branch 'hip-991-topic-fees' into hip-991-submit-message
ibankov Dec 17, 2024
c2c4f48
Remove draft test
JivkoKelchev Dec 17, 2024
3afeacd
Filter only payable fees and use this list for limit validation and c…
JivkoKelchev Dec 19, 2024
1379127
Merge branch 'refs/heads/hip-991-topic-fees' into hip-991-submit-message
JivkoKelchev Dec 19, 2024
a9d333a
Fix docs
JivkoKelchev Dec 19, 2024
d9fab19
Merge branch 'hip-991-topic-fees' into hip-991-submit-message
ibankov Jan 2, 2025
28a8f2f
Merge branch 'hip-991-topic-fees' into hip-991-submit-message
ibankov Jan 2, 2025
e236632
spotless
ibankov Jan 2, 2025
42abcdc
Merge branch 'hip-991-submit-message' into hip-991-submit-message-129…
ibankov Jan 2, 2025
2c5413d
Replace FEKL keys validation
JivkoKelchev Jan 6, 2025
c0880ab
Merge remote-tracking branch 'origin/hip-991-submit-message' into hip…
JivkoKelchev Jan 6, 2025
29da0fb
Replace FEKL keys validation
JivkoKelchev Jan 6, 2025
700acbc
Fix unit tests
JivkoKelchev Jan 6, 2025
07d571e
Added more coverage
ibankov Jan 6, 2025
35bac65
java doc
ibankov Jan 7, 2025
aa773a6
Update protobufs
JivkoKelchev Jan 10, 2025
ad28cb8
Merge branch 'refs/heads/hip-991-protobuf-changes' into hip-991-submi…
JivkoKelchev Jan 10, 2025
063d698
Update protobufs
JivkoKelchev Jan 10, 2025
abb9118
Update doc
JivkoKelchev Jan 13, 2025
eae0d98
Merge branch 'refs/heads/hip-991-protobuf-changes' into hip-991-submi…
JivkoKelchev Jan 14, 2025
178b878
Merge branch 'hip-991-submit-message' into hip-991-submit-message-129…
ibankov Jan 14, 2025
a616404
Change ordinal of CustomFeeLimit according to HIP changes
JivkoKelchev Jan 14, 2025
9e70e55
Merge branch 'refs/heads/hip-991-protobuf-changes' into hip-991-submi…
JivkoKelchev Jan 14, 2025
8960c6c
Merge branch 'hip-991-submit-message' into hip-991-submit-message-129…
ibankov Jan 14, 2025
bd148f4
fix tests
ibankov Jan 14, 2025
0adfdbe
fix test name
ibankov Jan 14, 2025
d64317c
Merge branch 'refs/heads/hip-991-topic-fees' into hip-991-protobuf-ch…
JivkoKelchev Jan 14, 2025
45fb7a9
Merge branch 'refs/heads/hip-991-protobuf-changes' into hip-991-submi…
JivkoKelchev Jan 14, 2025
061420e
Merge branch 'hip-991-submit-message' into hip-991-submit-message-129…
ibankov Jan 14, 2025
71bf501
Merge branch 'hip-991-topic-fees' into hip-991-submit-message-129-145
ibankov Jan 20, 2025
7470de9
merge conflicts
ibankov Jan 20, 2025
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
Prev Previous commit
Next Next commit
Topic create hapi tests
Signed-off-by: Zhivko Kelchev <zhivko.kelchev@limechain.tech>
  • Loading branch information
JivkoKelchev committed Sep 10, 2024
commit b9c05bdb41e1c65510e2e627e386e741dae20602
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.hedera.services.bdd.suites.hip991;

import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;

import com.hedera.services.bdd.spec.SpecOperation;
import java.util.ArrayList;

public class TopicCustomFeeBase {
protected static final String TOPIC = "topic";
protected static final String ADMIN_KEY = "adminKey";
protected static final String SUBMIT_KEY = "submitKey";
protected static final String FEE_SCHEDULE_KEY = "feeScheduleKey";
protected static final String FREE_MSG_KEY_PREFIX = "freeMessageKey_";

protected static SpecOperation[] setupBaseKeys() {
return new SpecOperation[] {newKeyNamed(ADMIN_KEY), newKeyNamed(SUBMIT_KEY), newKeyNamed(FEE_SCHEDULE_KEY)};
}

protected static SpecOperation[] newNamedKeysForFMKL(int count) {
final var list = new ArrayList<SpecOperation>();
for (int i = 0; i < count; i++) {
list.add(newKeyNamed(FREE_MSG_KEY_PREFIX + i));
}
return list.toArray(new SpecOperation[0]);
}

protected static String[] freeMsgKeyNames(int count) {
final var list = new ArrayList<String>();
for (int i = 0; i < count; i++) {
list.add(FREE_MSG_KEY_PREFIX + i);
}
return list.toArray(new String[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,114 +26,111 @@
import static com.hedera.services.bdd.spec.transactions.token.CustomFeeSpecs.fixedConsensusHtsFee;
import static com.hedera.services.bdd.spec.transactions.token.CustomFeeTests.expectedConsensusFixedHTSFee;
import static com.hedera.services.bdd.spec.transactions.token.CustomFeeTests.expectedConsensusFixedHbarFee;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;
import static com.hedera.services.bdd.suites.HapiSuite.flattened;

import com.hedera.services.bdd.junit.HapiTest;
import com.hedera.services.bdd.junit.HapiTestLifecycle;
import com.hedera.services.bdd.junit.support.TestLifecycle;
import com.hederahashgraph.api.proto.java.TokenType;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Nested;

public class TopicCustomFeeTest {
@HapiTestLifecycle
@DisplayName("Topic custom fees")
public class TopicCustomFeeTest extends TopicCustomFeeBase {

@HapiTest
@DisplayName("Create topic with all keys")
final Stream<DynamicTest> createTopicWithAllKeys() {
final var adminKey = "adminKey";
final var submitKey = "submitKey";
final var feeScheduleKey = "feeScheduleKey";
return hapiTest(
newKeyNamed(adminKey),
newKeyNamed(submitKey),
newKeyNamed(feeScheduleKey),
newKeyNamed("firstFMK"),
newKeyNamed("secondFMK"),
newKeyNamed("thirdFMK"),
newKeyNamed("fourthFMK"),
cryptoCreate("collector"),
createTopic("testTopic")
.adminKeyName(adminKey)
.submitKeyName(submitKey)
.feeScheduleKeyName(feeScheduleKey)
.freeMessagesKeys("firstFMK", "secondFMK", "thirdFMK"),
getTopicInfo("testTopic")
.hasAdminKey(adminKey)
.hasSubmitKey(submitKey)
.hasFeeScheduleKey(feeScheduleKey)
.hasFreeMessagesKeys(List.of("firstFMK", "secondFMK", "thirdFMK")));
}
@Nested
@DisplayName("Topic create")
class TopicCreate {

@HapiTest
@DisplayName("Create topic with submitKey and feeScheduleKey")
final Stream<DynamicTest> createTopicWithSubmitKeyAndFeeScheduleKey() {
final var submitKey = "submitKey";
final var feeScheduleKey = "feeScheduleKey";
return hapiTest(
newKeyNamed(submitKey),
newKeyNamed(feeScheduleKey),
createTopic("testTopic").submitKeyName(submitKey).feeScheduleKeyName(feeScheduleKey),
getTopicInfo("testTopic").hasSubmitKey(submitKey).hasFeeScheduleKey(feeScheduleKey));
}
@Nested
@DisplayName("Positive scenarios")
class TopicCreatePositiveScenarios {

@HapiTest
@DisplayName("Create topic with only feeScheduleKey")
final Stream<DynamicTest> createTopicWithOnlyFeeScheduleKey() {
final var feeScheduleKey = "feeScheduleKey";
return hapiTest(
newKeyNamed(feeScheduleKey),
createTopic("testTopic").feeScheduleKeyName(feeScheduleKey),
getTopicInfo("testTopic").hasFeeScheduleKey(feeScheduleKey));
}
@BeforeAll
static void beforeAll(@NonNull final TestLifecycle lifecycle) {
lifecycle.doAdhoc(setupBaseKeys());
}

@HapiTest
@DisplayName("Create topic with 1 Hbar fixed fee")
final Stream<DynamicTest> createTopicWithOneHbarFixedFee() {
final var adminKey = "adminKey";
final var submitKey = "submitKey";
final var feeScheduleKey = "feeScheduleKey";
final var collector = "collector";
return hapiTest(
newKeyNamed(adminKey),
newKeyNamed(submitKey),
newKeyNamed(feeScheduleKey),
cryptoCreate(collector),
createTopic("testTopic")
.adminKeyName(adminKey)
.submitKeyName(submitKey)
.feeScheduleKeyName(feeScheduleKey)
.withConsensusCustomFee(fixedConsensusHbarFee(1, collector)),
// todo check if we need to sign with feeScheduleKey on create?
getTopicInfo("testTopic")
.hasAdminKey(adminKey)
.hasSubmitKey(submitKey)
.hasFeeScheduleKey(feeScheduleKey)
.hasCustom(expectedConsensusFixedHbarFee(1, collector)));
}
@HapiTest
@DisplayName("Create topic with all keys")
final Stream<DynamicTest> createTopicWithAllKeys() {
return hapiTest(flattened(
newNamedKeysForFMKL(5),
cryptoCreate("collector"),
createTopic(TOPIC)
.adminKeyName(ADMIN_KEY)
.submitKeyName(SUBMIT_KEY)
.feeScheduleKeyName(FEE_SCHEDULE_KEY)
.freeMessagesKeys(freeMsgKeyNames(5)),
getTopicInfo(TOPIC)
.hasAdminKey(ADMIN_KEY)
.hasSubmitKey(SUBMIT_KEY)
.hasFeeScheduleKey(FEE_SCHEDULE_KEY)
.hasFreeMessagesKeys(List.of(freeMsgKeyNames(5)))));
}

@HapiTest
@DisplayName("Create topic with submitKey and feeScheduleKey")
final Stream<DynamicTest> createTopicWithSubmitKeyAndFeeScheduleKey() {
return hapiTest(
createTopic(TOPIC).submitKeyName(SUBMIT_KEY).feeScheduleKeyName(FEE_SCHEDULE_KEY),
getTopicInfo(TOPIC).hasSubmitKey(SUBMIT_KEY).hasFeeScheduleKey(FEE_SCHEDULE_KEY));
}

@HapiTest
@DisplayName("Create topic with only feeScheduleKey")
final Stream<DynamicTest> createTopicWithOnlyFeeScheduleKey() {
return hapiTest(
createTopic(TOPIC).feeScheduleKeyName(FEE_SCHEDULE_KEY),
getTopicInfo(TOPIC).hasFeeScheduleKey(FEE_SCHEDULE_KEY));
}

@HapiTest
@DisplayName("Create topic with 1 Hbar fixed fee")
final Stream<DynamicTest> createTopicWithOneHbarFixedFee() {
final var collector = "collector";
return hapiTest(
cryptoCreate(collector),
createTopic(TOPIC)
.adminKeyName(ADMIN_KEY)
.submitKeyName(SUBMIT_KEY)
.feeScheduleKeyName(FEE_SCHEDULE_KEY)
.withConsensusCustomFee(fixedConsensusHbarFee(1, collector)),
// todo check if we need to sign with feeScheduleKey on create?
getTopicInfo(TOPIC)
.hasAdminKey(ADMIN_KEY)
.hasSubmitKey(SUBMIT_KEY)
.hasFeeScheduleKey(FEE_SCHEDULE_KEY)
.hasCustom(expectedConsensusFixedHbarFee(1, collector)));
}

@HapiTest
@DisplayName("Create topic with 1 HTS fixed fee")
final Stream<DynamicTest> createTopicWithOneHTSFixedFee() {
final var adminKey = "adminKey";
final var submitKey = "submitKey";
final var feeScheduleKey = "feeScheduleKey";
final var collector = "collector";
return hapiTest(
newKeyNamed(adminKey),
newKeyNamed(submitKey),
newKeyNamed(feeScheduleKey),
cryptoCreate(collector),
tokenCreate("testToken").tokenType(TokenType.FUNGIBLE_COMMON).initialSupply(500),
tokenAssociate(collector, "testToken"),
createTopic("testTopic")
.adminKeyName(adminKey)
.submitKeyName(submitKey)
.feeScheduleKeyName(feeScheduleKey)
.withConsensusCustomFee(fixedConsensusHtsFee(1, "testToken", collector)),
getTopicInfo("testTopic")
.hasAdminKey(adminKey)
.hasSubmitKey(submitKey)
.hasFeeScheduleKey(feeScheduleKey)
.hasCustom(expectedConsensusFixedHTSFee(1, "testToken", collector)));
@HapiTest
@DisplayName("Create topic with 1 HTS fixed fee")
final Stream<DynamicTest> createTopicWithOneHTSFixedFee() {
final var collector = "collector";
return hapiTest(
cryptoCreate(collector),
tokenCreate("testToken")
.tokenType(TokenType.FUNGIBLE_COMMON)
.initialSupply(500),
tokenAssociate(collector, "testToken"),
createTopic(TOPIC)
.adminKeyName(ADMIN_KEY)
.submitKeyName(SUBMIT_KEY)
.feeScheduleKeyName(FEE_SCHEDULE_KEY)
.withConsensusCustomFee(fixedConsensusHtsFee(1, "testToken", collector)),
getTopicInfo(TOPIC)
.hasAdminKey(ADMIN_KEY)
.hasSubmitKey(SUBMIT_KEY)
.hasFeeScheduleKey(FEE_SCHEDULE_KEY)
.hasCustom(expectedConsensusFixedHTSFee(1, "testToken", collector)));
}
}
}
}
Loading