From bdf038d0b881a9a5aa5e34ab83df48e75dd53b3c Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Mon, 13 May 2024 10:01:48 -0500 Subject: [PATCH] add more tests Signed-off-by: Neeharika-Sompalli --- .../CustomRoyaltyFeeAssessorTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/customfees/CustomRoyaltyFeeAssessorTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/customfees/CustomRoyaltyFeeAssessorTest.java index 36034ca2a391..bdf64f5d435f 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/customfees/CustomRoyaltyFeeAssessorTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/customfees/CustomRoyaltyFeeAssessorTest.java @@ -192,7 +192,7 @@ void doesntFailIfFallbackNftTransferredToUnknownAlias() { } @Test - void skipsIfRoyaltyAlreadyPaid() { + void skipsIfRoyaltyAlreadyPaidByReceiver() { result = new AssessmentResult(List.of(nftTransferListWithAlias), List.of()); // Include royalty already paid result.addToRoyaltiesPaid(Pair.of(funding, firstFungibleTokenId)); @@ -210,6 +210,25 @@ void skipsIfRoyaltyAlreadyPaid() { verify(fixedFeeAssessor, never()).assessFixedFee(any(), any(), any(), any()); } + @Test + void assessRoyaltyOnlyOncePerTokenType() { + result = new AssessmentResult(List.of(nftTransferListWithAlias), List.of()); + // Include royalty already paid by sender + result.addToRoyaltiesPaid(Pair.of(payer, firstFungibleTokenId)); + + final var royaltyCustomFee = withRoyaltyFee( + royaltyFee.copyBuilder().fallbackFee(htsFallbackFee).build(), targetCollector); + final var fixedFee = withFixedFee(this.fixedFee, otherCollector); + + final CustomFeeMeta feeMeta = withCustomFeeMeta(List.of(fixedFee, royaltyCustomFee), NON_FUNGIBLE_UNIQUE); + + subject.assessRoyaltyFees(feeMeta, payer, funding, result); + + assertThat(result.getAssessedCustomFees()).isEmpty(); + + verify(fixedFeeAssessor, never()).assessFixedFee(any(), any(), any(), any()); + } + @Test void reclaimsFromExchangeValueWhenAvailable() { final var accountAmounts = List.of(AccountAmount.newBuilder()