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
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
Simplify the fee assessment
Signed-off-by: Zhivko Kelchev <zhivko.kelchev@limechain.tech>
  • Loading branch information
JivkoKelchev committed Dec 11, 2024
commit 5a6f72c85b406289f0bfe777f1751965ec9447d2
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package com.hedera.node.app.service.consensus.impl.handlers.customfee;

import static java.util.Objects.requireNonNull;
import static com.hedera.node.app.spi.workflows.HandleException.validateTrue;

import com.hedera.hapi.node.base.AccountAmount;
import com.hedera.hapi.node.base.AccountID;
import com.hedera.hapi.node.base.ResponseCodeEnum;
import com.hedera.hapi.node.base.TokenID;
import com.hedera.hapi.node.base.TokenTransferList;
import com.hedera.hapi.node.base.TransferList;
Expand All @@ -29,14 +30,9 @@
import com.hedera.hapi.node.transaction.FixedFee;
import com.hedera.node.app.service.token.ReadableTokenStore;
import com.hedera.node.app.spi.workflows.HandleContext;
import com.hedera.node.config.data.LedgerConfig;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;

Expand All @@ -51,150 +47,86 @@
// Needed for Dagger injection
}

public List<CryptoTransferTransactionBody> assessCustomFee(Topic topic, HandleContext context) {
/**
* Build and return a list of synthetic crypto transfer transaction bodies, that represents custom fees payments.
* It will return one body per topic custom fee.
*
* @param topic The topic
* @param context The transaction handle context
* @return List of synthetic crypto transfer transaction bodies
*/
public List<CryptoTransferTransactionBody> assessCustomFee(
@NonNull final Topic topic, @NonNull final HandleContext context) {
final List<CryptoTransferTransactionBody> transactionBodies = new ArrayList<>();

final var op = context.body().consensusSubmitMessageOrThrow();
final var payer = context.payer();
final var tokenStore = context.storeFactory().readableStore(ReadableTokenStore.class);

Check warning on line 62 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L60-L62

Added lines #L60 - L62 were not covered by tests
final var ledgerConfig = context.configuration().getConfigData(LedgerConfig.class);

final var tokenTransfers = new ArrayList<TokenTransferList>();
List<AccountAmount> hbarTransfers = new ArrayList<>();
// we need to count the number of balance adjustments,
// and if needed to split custom fee transfers in to separate dispatches
// todo: add explanation for maxTransfers
final var maxTransfers = ledgerConfig.transfersMaxLen() / 3;
var transferCounts = 0;

// build crypto transfer body for the first layer of custom fees,
// if there is a second layer it will be assessed in crypto transfer handler
// build crypto transfer bodies for the first layer of custom fees,
// if there is a second or third layer it will be assessed in crypto transfer handler
for (ConsensusCustomFee fee : topic.customFees()) {
// check if payer is treasury or collector

// check if payer is collector
if (context.payer().equals(fee.feeCollectorAccountId())) {
continue;

Check warning on line 70 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L70

Added line #L70 was not covered by tests
}

final var fixedFee = fee.fixedFeeOrThrow();
final var tokenTransfers = new ArrayList<TokenTransferList>();
List<AccountAmount> hbarTransfers = new ArrayList<>();

Check warning on line 74 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L73-L74

Added lines #L73 - L74 were not covered by tests

final var fixedFee = fee.fixedFeeOrThrow();

Check warning on line 76 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L76

Added line #L76 was not covered by tests
if (fixedFee.hasDenominatingTokenId()) {
final var tokenId = fixedFee.denominatingTokenIdOrThrow();
final var tokenTreasury = tokenStore.get(tokenId).treasuryAccountIdOrThrow();
final var tokenTreasury = getTokenTreasury(tokenId, tokenStore);

Check warning on line 79 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L78-L79

Added lines #L78 - L79 were not covered by tests
// check if payer is treasury
if (context.payer().equals(tokenTreasury)) {
continue;

Check warning on line 82 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L82

Added line #L82 was not covered by tests
}
tokenTransfers.add(buildCustomFeeTokenTransferList(payer, fee.feeCollectorAccountId(), fixedFee));
} else {
hbarTransfers = mergeTransfers(
hbarTransfers, buildCustomFeeHbarTransferList(payer, fee.feeCollectorAccountId(), fixedFee));
hbarTransfers = buildCustomFeeHbarTransferList(payer, fee.feeCollectorAccountId(), fixedFee);

Check warning on line 86 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L84-L86

Added lines #L84 - L86 were not covered by tests
}
transferCounts++;

if (transferCounts == maxTransfers) {
final var syntheticBodyBuilder = tokenTransfers(tokenTransfers.toArray(TokenTransferList[]::new));

transactionBodies.add(syntheticBodyBuilder
.transfers(
TransferList.newBuilder().accountAmounts(hbarTransfers.toArray(AccountAmount[]::new)))
.build());

// reset lists and counter
transferCounts = 0;
tokenTransfers.clear();
hbarTransfers.clear();
}
// build the synthetic body
final var syntheticBodyBuilder =
CryptoTransferTransactionBody.newBuilder().tokenTransfers(tokenTransfers);
transactionBodies.add(syntheticBodyBuilder
.transfers(TransferList.newBuilder().accountAmounts(hbarTransfers.toArray(AccountAmount[]::new)))
.build());
}

Check warning on line 95 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L91-L95

Added lines #L91 - L95 were not covered by tests

if (tokenTransfers.isEmpty() && hbarTransfers.isEmpty()) {
return transactionBodies;
}

final var syntheticBodyBuilder = tokenTransfers(tokenTransfers.toArray(TokenTransferList[]::new));
transactionBodies.add(syntheticBodyBuilder
.transfers(TransferList.newBuilder().accountAmounts(hbarTransfers.toArray(AccountAmount[]::new)))
.build());

return transactionBodies;

Check warning on line 97 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L97

Added line #L97 was not covered by tests
}

private List<AccountAmount> buildCustomFeeHbarTransferList(AccountID payer, AccountID collector, FixedFee fee) {
return List.of(
AccountAmount.newBuilder()
.accountID(payer)
.amount(-fee.amount())
.build(),
AccountAmount.newBuilder()
.accountID(collector)
.amount(fee.amount())
.build());

Check warning on line 109 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L101-L109

Added lines #L101 - L109 were not covered by tests
}

private TokenTransferList buildCustomFeeTokenTransferList(AccountID payer, AccountID collector, FixedFee fee) {
return TokenTransferList.newBuilder()
.token(fee.denominatingTokenId())
.transfers(
AccountAmount.newBuilder()
.accountID(payer)
.amount(-fee.amount())
.build(),
AccountAmount.newBuilder()
.accountID(collector)
.amount(fee.amount())
.build())
.build();

Check warning on line 124 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L113-L124

Added lines #L113 - L124 were not covered by tests
}

private CryptoTransferTransactionBody.Builder tokenTransfers(@NonNull TokenTransferList... tokenTransferLists) {
if (repeatsTokenId(tokenTransferLists)) {
final Map<TokenID, TokenTransferList> consolidatedTokenTransfers = new LinkedHashMap<>();
for (final var tokenTransferList : tokenTransferLists) {
consolidatedTokenTransfers.merge(
tokenTransferList.tokenOrThrow(),
tokenTransferList,
ConsensusCustomFeeAssessor::mergeTokenTransferLists);
}
tokenTransferLists = consolidatedTokenTransfers.values().toArray(TokenTransferList[]::new);
}
return CryptoTransferTransactionBody.newBuilder().tokenTransfers(tokenTransferLists);
}

private static TokenTransferList mergeTokenTransferLists(
@NonNull final TokenTransferList from, @NonNull final TokenTransferList to) {
return from.copyBuilder()
.transfers(mergeTransfers(from.transfers(), to.transfers()))
.build();
}

private static List<AccountAmount> mergeTransfers(
@NonNull final List<AccountAmount> from, @NonNull final List<AccountAmount> to) {
requireNonNull(from);
requireNonNull(to);
final Map<AccountID, AccountAmount> consolidated = new LinkedHashMap<>();
consolidateInto(consolidated, from);
consolidateInto(consolidated, to);
return new ArrayList<>(consolidated.values());
}

private static void consolidateInto(
@NonNull final Map<AccountID, AccountAmount> consolidated, @NonNull final List<AccountAmount> transfers) {
for (final var transfer : transfers) {
consolidated.merge(transfer.accountID(), transfer, ConsensusCustomFeeAssessor::mergeAdjusts);
}
}

private static AccountAmount mergeAdjusts(@NonNull final AccountAmount from, @NonNull final AccountAmount to) {
return from.copyBuilder()
.amount(from.amount() + to.amount())
.isApproval(from.isApproval() || to.isApproval())
.build();
}

private boolean repeatsTokenId(@NonNull final TokenTransferList[] tokenTransferList) {
return tokenTransferList.length > 1
&& Arrays.stream(tokenTransferList)
.map(TokenTransferList::token)
.collect(Collectors.toSet())
.size()
< tokenTransferList.length;
private AccountID getTokenTreasury(TokenID tokenId, ReadableTokenStore tokenStore) {
final var token = tokenStore.get(tokenId);

Check warning on line 128 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L128

Added line #L128 was not covered by tests
validateTrue(token != null, ResponseCodeEnum.INVALID_TOKEN_ID_IN_CUSTOM_FEES);
return token.treasuryAccountIdOrThrow();

Check warning on line 130 in hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java

View check run for this annotation

Codecov / codecov/patch

hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/customfee/ConsensusCustomFeeAssessor.java#L130

Added line #L130 was not covered by tests
}
}
Loading