From 66d8919613e49de41141ab35aabc5da28d5f6df7 Mon Sep 17 00:00:00 2001 From: Michael Tinker Date: Wed, 17 Jul 2024 22:49:51 -0500 Subject: [PATCH] Revert HapiTest expectations for inline charging Signed-off-by: Michael Tinker --- .../SingleTransactionRecordBuilder.java | 13 ++++- .../AssociateTokenRecipientsStep.java | 6 +-- .../handlers/CryptoTransferHandlerTest.java | 2 + .../AdjustFungibleTokenChangesStepTest.java | 15 ++++++ .../transfer/AdjustHbarChangesStepTest.java | 8 +++ .../AssociateTokenRecipientsStepTest.java | 6 +++ .../transfer/CustomFeeAssessmentStepTest.java | 14 +++--- .../transfer/NFTOwnersChangeStepTest.java | 10 ++++ .../test/handlers/transfer/StepsBase.java | 1 - .../AtomicCryptoTransferHTSSuite.java | 2 - .../precompile/ContractMintHTSSuite.java | 1 - .../precompile/CreatePrecompileSuite.java | 1 - .../precompile/CryptoTransferHTSSuite.java | 2 - .../LazyCreateThroughPrecompileSuite.java | 5 -- .../crypto/AutoAccountCreationSuite.java | 50 ++++++++----------- ...untCreationUnlimitedAssociationsSuite.java | 4 +- .../HollowAccountFinalizationSuite.java | 6 +-- 17 files changed, 88 insertions(+), 58 deletions(-) diff --git a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/workflows/record/SingleTransactionRecordBuilder.java b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/workflows/record/SingleTransactionRecordBuilder.java index 805a721c5c11..a112729db617 100644 --- a/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/workflows/record/SingleTransactionRecordBuilder.java +++ b/hedera-node/hedera-app-spi/src/main/java/com/hedera/node/app/spi/workflows/record/SingleTransactionRecordBuilder.java @@ -18,6 +18,8 @@ import static com.hedera.node.app.spi.workflows.HandleContext.TransactionCategory.CHILD; import static com.hedera.node.app.spi.workflows.HandleContext.TransactionCategory.PRECEDING; +import static com.hedera.node.app.spi.workflows.HandleContext.TransactionCategory.SCHEDULED; +import static com.hedera.node.app.spi.workflows.HandleContext.TransactionCategory.USER; import com.hedera.hapi.node.base.ResponseCodeEnum; import com.hedera.hapi.node.base.Transaction; @@ -65,7 +67,7 @@ public interface SingleTransactionRecordBuilder { HandleContext.TransactionCategory category(); /** - * Returns true if this transaction originated from inside another handler or workflow; and not + * Returns true if this builder's transaction originated from inside another handler or workflow; and not * a user transaction (or scheduled user transaction). * @return true if this transaction is internal */ @@ -73,6 +75,15 @@ default boolean isInternalDispatch() { return category() == CHILD || category() == PRECEDING; } + /** + * Returns true if this builder's transaction originated from a user transaction or scheduled user transaction; and + * not from inside another handler or workflow. + * @return true if this transaction is internal + */ + default boolean isUserDispatch() { + return category() == USER || category() == SCHEDULED; + } + /** * Convenience method to package as {@link TransactionBody} as a {@link Transaction} . * diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java index 858d8d8bf8b1..d77473f61989 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java @@ -195,11 +195,11 @@ private TokenAssociation validateAndBuildAutoAssociation( validateFalse(token.hasKycKey(), ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN); validateFalse(token.accountsFrozenByDefault(), ACCOUNT_FROZEN_FOR_TOKEN); - // We only charge auto-association fees inline if this is NOT an internal dispatch; in that case the + // We only charge auto-association fees inline if this is a user disaptch; in that case the // contract service will take the auto-association costs from the remaining EVM gas - if (!context.recordBuilders() + if (context.recordBuilders() .getOrCreate(SingleTransactionRecordBuilder.class) - .isInternalDispatch()) { + .isUserDispatch()) { final var unlimitedAssociationsEnabled = config.getConfigData(EntitiesConfig.class).unlimitedAutoAssociationsEnabled(); // And the "sender pays" fee model only applies when using unlimited auto-associations diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java index c75033b4cdd9..0bccf07ca457 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java @@ -535,6 +535,8 @@ void happyPathWorksWithAutoCreation() { writableAccountStore.get(feeCollectorId).tinybarBalance(); given(handleContext.expiryValidator()).willReturn(expiryValidator); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(transferRecordBuilder); subject.handle(handleContext); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustFungibleTokenChangesStepTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustFungibleTokenChangesStepTest.java index 874ab5880f8a..92115a0018c1 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustFungibleTokenChangesStepTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustFungibleTokenChangesStepTest.java @@ -41,14 +41,19 @@ import com.hedera.node.app.service.token.impl.handlers.transfer.EnsureAliasesStep; import com.hedera.node.app.service.token.impl.handlers.transfer.ReplaceAliasesWithIDsInOp; import com.hedera.node.app.service.token.impl.handlers.transfer.TransferContextImpl; +import com.hedera.node.app.service.token.records.CryptoTransferRecordBuilder; import com.hedera.node.app.spi.workflows.HandleException; import com.hedera.node.app.spi.workflows.record.SingleTransactionRecordBuilder; import com.hedera.node.app.workflows.handle.record.SingleTransactionRecordBuilderImpl; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.Mock; class AdjustFungibleTokenChangesStepTest extends StepsBase { + @Mock + private CryptoTransferRecordBuilder builder; + @Override @BeforeEach public void setUp() { @@ -81,6 +86,8 @@ void doesTokenBalanceChangesWithoutAllowances() { final var receiver = asAccount(tokenReceiver); given(handleContext.payer()).willReturn(spenderId); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); final var replacedOp = getReplacedOp(); adjustFungibleTokenChangesStep = new AdjustFungibleTokenChangesStep(replacedOp.tokenTransfers(), payerId); @@ -122,6 +129,8 @@ void doesTokenBalanceChangesWithAllowances() { replaceAliasesWithIDsInOp = new ReplaceAliasesWithIDsInOp(); associateTokenRecepientsStep = new AssociateTokenRecipientsStep(body); given(handleContext.body()).willReturn(txn); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); final var receiver = asAccount(tokenReceiver); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); @@ -185,6 +194,8 @@ void failsWhenExpectedDecimalsDiffer() { associateTokenRecepientsStep = new AssociateTokenRecipientsStep(body); given(handleContext.body()).willReturn(txn); given(handleContext.payer()).willReturn(spenderId); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); final var replacedOp = getReplacedOp(); @@ -213,6 +224,8 @@ void allowanceWithGreaterThanAllowedAllowanceFails() { replaceAliasesWithIDsInOp = new ReplaceAliasesWithIDsInOp(); associateTokenRecepientsStep = new AssociateTokenRecipientsStep(body); given(handleContext.body()).willReturn(txn); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); final var replacedOp = getReplacedOp(); @@ -246,6 +259,8 @@ void transferGreaterThanTokenRelBalanceFails() { given(handleContext.body()).willReturn(txn); given(handleContext.payer()).willReturn(spenderId); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); final var replacedOp = getReplacedOp(); adjustFungibleTokenChangesStep = new AdjustFungibleTokenChangesStep(replacedOp.tokenTransfers(), spenderId); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustHbarChangesStepTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustHbarChangesStepTest.java index d825bf009781..e81fdb843226 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustHbarChangesStepTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AdjustHbarChangesStepTest.java @@ -41,14 +41,18 @@ import com.hedera.node.app.service.token.impl.handlers.transfer.EnsureAliasesStep; import com.hedera.node.app.service.token.impl.handlers.transfer.ReplaceAliasesWithIDsInOp; import com.hedera.node.app.service.token.impl.handlers.transfer.TransferContextImpl; +import com.hedera.node.app.service.token.records.CryptoTransferRecordBuilder; import com.hedera.node.app.spi.workflows.HandleException; import com.hedera.node.app.spi.workflows.record.SingleTransactionRecordBuilder; import com.hedera.node.app.workflows.handle.record.SingleTransactionRecordBuilderImpl; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.Mock; class AdjustHbarChangesStepTest extends StepsBase { + @Mock + private CryptoTransferRecordBuilder builder; @BeforeEach public void setUp() { @@ -86,6 +90,8 @@ void doesHbarBalanceChangesWithoutAllowances() { final var receiver = asAccount(hbarReceiver); given(handleContext.payer()).willReturn(spenderId); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); final var replacedOp = getReplacedOp(); adjustHbarChangesStep = new AdjustHbarChangesStep(replacedOp, payerId); @@ -112,6 +118,8 @@ void doesHbarBalanceChangesWithAllowances() { replaceAliasesWithIDsInOp = new ReplaceAliasesWithIDsInOp(); associateTokenRecepientsStep = new AssociateTokenRecipientsStep(body); given(handleContext.body()).willReturn(txn); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); final var receiver = asAccount(hbarReceiver); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AssociateTokenRecipientsStepTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AssociateTokenRecipientsStepTest.java index 5912c896aad0..bb19a8ec6674 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AssociateTokenRecipientsStepTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AssociateTokenRecipientsStepTest.java @@ -31,6 +31,7 @@ import com.hedera.hapi.node.token.CryptoTransferTransactionBody; import com.hedera.node.app.service.token.impl.handlers.transfer.AssociateTokenRecipientsStep; import com.hedera.node.app.service.token.impl.handlers.transfer.TransferContextImpl; +import com.hedera.node.app.service.token.records.CryptoTransferRecordBuilder; import com.hedera.node.app.spi.records.RecordBuilders; import com.hedera.node.app.spi.validation.ExpiryValidator; import com.hedera.node.app.spi.workflows.HandleContext; @@ -56,6 +57,9 @@ public class AssociateTokenRecipientsStepTest extends StepsBase { @Mock private RecordBuilders recordBuilders; + @Mock + private CryptoTransferRecordBuilder builder; + private AssociateTokenRecipientsStep subject; private CryptoTransferTransactionBody txn; private TransferContextImpl transferContext; @@ -83,6 +87,8 @@ void associatesTokenRecepients() { .withValue("entities.unlimitedAutoAssociationsEnabled", false) .getOrCreateConfig(); given(handleContext.configuration()).willReturn(modifiedConfiguration); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); subject.doIn(transferContext); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/CustomFeeAssessmentStepTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/CustomFeeAssessmentStepTest.java index 6929c7ea0c03..e0e629ec4775 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/CustomFeeAssessmentStepTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/CustomFeeAssessmentStepTest.java @@ -53,6 +53,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.mockito.Mock; class CustomFeeAssessmentStepTest extends StepsBase { private TransferContextImpl transferContext; @@ -60,6 +61,9 @@ class CustomFeeAssessmentStepTest extends StepsBase { private Token fungibleWithNoKyc; private Token nonFungibleWithNoKyc; + @Mock + private CryptoTransferRecordBuilder builder; + @BeforeEach public void setUp() { super.setUp(); @@ -80,7 +84,6 @@ public void setUp() { givenStoresAndConfig(handleContext); givenTxn(); given(handleContext.body()).willReturn(txn); - given(recordBuilders.getOrCreate(CryptoTransferRecordBuilder.class)).willReturn(xferRecordBuilder); givenAutoCreationDispatchEffects(payerId); transferContext = new TransferContextImpl(handleContext); @@ -89,6 +92,7 @@ public void setUp() { associateTokenRecepientsStep = new AssociateTokenRecipientsStep(body); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); + given(recordBuilders.getOrCreate(any())).willReturn(builder); final var replacedOp = getReplacedOp(); subject = new CustomFeeAssessmentStep(replacedOp); } @@ -174,8 +178,6 @@ void htsFixedFeeAndRoyaltyFeeWithFallbackSelfDenomination() { assertThatTransferListContains(level1Op.tokenTransfers(), expectedLevel1TokenTransfers); assertThatTransferListContains(givenOp.tokenTransfers(), expectedGivenOpTokenTransfers); assertThatTransfersContains(givenOp.transfers().accountAmounts(), expectedGivenOpHbarTransfers); - - // verify(xferRecordBuilder).assessedCustomFees(anyList()); } @Test @@ -254,8 +256,6 @@ void htsFixedFeeSelfDenominationAndRoyaltyFeeNoFallback() { assertThatTransferListContains(givenOp.tokenTransfers(), expectedGivenOpTokenTransfers); assertThatTransfersContains(givenOp.transfers().accountAmounts(), expectedGivenOpHbarTransfers); - - // verify(xferRecordBuilder).assessedCustomFees(anyList()); } @Test @@ -367,8 +367,6 @@ void htsFixedFeeAndRoyaltyFeeWithFallbackNetOfTransfersSelfDenomination() { assertThatTransferListContains(level1Op.tokenTransfers(), expectedLevel1TokenTransfers); assertThatTransferListContains(givenOp.tokenTransfers(), expectedGivenOpTokenTransfers); assertThatTransfersContains(givenOp.transfers().accountAmounts(), expectedGivenOpHbarTransfers); - - // verify(xferRecordBuilder).assessedCustomFees(anyList()); } @Test @@ -446,6 +444,8 @@ private void givenDifferentTxn(final CryptoTransferTransactionBody body, final A givenStoresAndConfig(handleContext); givenTxn(body, payerId); givenAutoCreationDispatchEffects(payerId); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); transferContext = new TransferContextImpl(handleContext); ensureAliasesStep = new EnsureAliasesStep(body); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/NFTOwnersChangeStepTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/NFTOwnersChangeStepTest.java index 0d6cbae206d0..b7dd2d2a92d6 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/NFTOwnersChangeStepTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/NFTOwnersChangeStepTest.java @@ -41,13 +41,17 @@ import com.hedera.node.app.service.token.impl.handlers.transfer.NFTOwnersChangeStep; import com.hedera.node.app.service.token.impl.handlers.transfer.ReplaceAliasesWithIDsInOp; import com.hedera.node.app.service.token.impl.handlers.transfer.TransferContextImpl; +import com.hedera.node.app.service.token.records.CryptoTransferRecordBuilder; import com.hedera.node.app.spi.workflows.HandleException; import com.hedera.node.app.spi.workflows.record.SingleTransactionRecordBuilder; import com.hedera.node.app.workflows.handle.record.SingleTransactionRecordBuilderImpl; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.Mock; class NFTOwnersChangeStepTest extends StepsBase { + @Mock + private CryptoTransferRecordBuilder builder; @BeforeEach public void setUp() { @@ -98,6 +102,8 @@ void changesNftOwners() { final var receiver = asAccount(tokenReceiver); given(handleContext.payer()).willReturn(spenderId); given(expiryValidator.expirationStatus(any(), anyBoolean(), anyLong())).willReturn(OK); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); final var replacedOp = getReplacedOp(); changeNFTOwnersStep = new NFTOwnersChangeStep(replacedOp.tokenTransfers(), payerId); final var nft = writableNftStore.get(nftIdSl1); @@ -182,6 +188,8 @@ void changesNftOwnersWithAllowance() { .build()) .build(); givenTxn(body, spenderId); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); ensureAliasesStep = new EnsureAliasesStep(body); replaceAliasesWithIDsInOp = new ReplaceAliasesWithIDsInOp(); associateTokenRecepientsStep = new AssociateTokenRecipientsStep(body); @@ -253,6 +261,8 @@ void failsWhenSpenderNotSameAsPayer() { .build()) .build(); givenTxn(body, spenderId); + given(handleContext.recordBuilders()).willReturn(recordBuilders); + given(recordBuilders.getOrCreate(any())).willReturn(builder); ensureAliasesStep = new EnsureAliasesStep(body); replaceAliasesWithIDsInOp = new ReplaceAliasesWithIDsInOp(); associateTokenRecepientsStep = new AssociateTokenRecipientsStep(body); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/StepsBase.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/StepsBase.java index 57094356733b..bef7b4a0434a 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/StepsBase.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/StepsBase.java @@ -217,7 +217,6 @@ protected void givenAutoCreationDispatchEffects(AccountID syntheticPayer) { return cryptoCreateRecordBuilder.accountID(asAccount(tokenReceiver)); }); given(storeFactory.writableStore(WritableAccountStore.class)).willReturn(writableAccountStore); - given(recordBuilders.getOrCreate(CryptoCreateRecordBuilder.class)).willReturn(cryptoCreateRecordBuilder); given(recordBuilders.getOrCreate(CryptoTransferRecordBuilder.class)).willReturn(xferRecordBuilder); } } diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/AtomicCryptoTransferHTSSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/AtomicCryptoTransferHTSSuite.java index 6d2ad57958e1..7ea5bd24fe16 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/AtomicCryptoTransferHTSSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/AtomicCryptoTransferHTSSuite.java @@ -1162,7 +1162,6 @@ final Stream cryptoTransferAllowanceToContractFT() { childRecordsCheck( successfulTransferFromTxn, SUCCESS, - recordWith().status(SUCCESS), recordWith() .status(SUCCESS) .contractCallResult(resultWith() @@ -1282,7 +1281,6 @@ final Stream cryptoTransferAllowanceToContractNFT() { childRecordsCheck( successfulTransferFromTxn, SUCCESS, - recordWith().status(SUCCESS), recordWith() .status(SUCCESS) .contractCallResult(resultWith() diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/ContractMintHTSSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/ContractMintHTSSuite.java index df808d1ee6ac..ec78b5341c66 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/ContractMintHTSSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/ContractMintHTSSuite.java @@ -422,7 +422,6 @@ final Stream transferNftAfterNestedMint() { childRecordsCheck( nestedTransferTxn, SUCCESS, - recordWith().status(SUCCESS), recordWith() .status(SUCCESS) .contractCallResult(resultWith() diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CreatePrecompileSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CreatePrecompileSuite.java index a0a465119ec9..fd6cb4d3da41 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CreatePrecompileSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CreatePrecompileSuite.java @@ -533,7 +533,6 @@ final Stream fungibleTokenCreateThenQueryAndTransfer() { TransactionRecordAsserts.recordWith().status(SUCCESS), TransactionRecordAsserts.recordWith().status(SUCCESS), TransactionRecordAsserts.recordWith().status(SUCCESS), - TransactionRecordAsserts.recordWith().status(SUCCESS), TransactionRecordAsserts.recordWith().status(SUCCESS)), sourcing(() -> getAccountBalance(ACCOUNT) .hasTokenBalance( diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CryptoTransferHTSSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CryptoTransferHTSSuite.java index 378a1e8e3fcd..28aa8b794f3b 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CryptoTransferHTSSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/CryptoTransferHTSSuite.java @@ -260,7 +260,6 @@ final Stream hapiTransferFromForFungibleToken() { childRecordsCheck( successfulTransferFromTxn, SUCCESS, - recordWith().status(SUCCESS), recordWith() .status(SUCCESS) .contractCallResult(resultWith() @@ -805,7 +804,6 @@ final Stream hapiTransferFromForNFT() { childRecordsCheck( successfulTransferFromTxn, SUCCESS, - recordWith().status(SUCCESS), recordWith() .status(SUCCESS) .contractCallResult(resultWith() diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/LazyCreateThroughPrecompileSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/LazyCreateThroughPrecompileSuite.java index aeccab9592e9..268491c94cd8 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/LazyCreateThroughPrecompileSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/LazyCreateThroughPrecompileSuite.java @@ -341,7 +341,6 @@ final Stream erc20TransferLazyCreate() { TRANSFER_TXN, SUCCESS, recordWith().status(SUCCESS), - recordWith().status(SUCCESS), recordWith().status(SUCCESS)), getTxnRecord(TRANSFER_TXN).exposingTo(record -> { Assertions.assertEquals( @@ -463,7 +462,6 @@ final Stream erc20TransferFromLazyCreate() { TRANSFER_FROM_ACCOUNT_TXN, SUCCESS, recordWith().status(SUCCESS), - recordWith().status(SUCCESS), recordWith().status(SUCCESS)), getTxnRecord(TRANSFER_FROM_ACCOUNT_TXN).exposingTo(record -> { Assertions.assertEquals( @@ -566,7 +564,6 @@ final Stream erc721TransferFromLazyCreate() { TRANSFER_FROM_ACCOUNT_TXN, SUCCESS, recordWith().status(SUCCESS), - recordWith().status(SUCCESS), recordWith().status(SUCCESS)), getTxnRecord(TRANSFER_FROM_ACCOUNT_TXN).exposingTo(record -> { Assertions.assertEquals( @@ -636,7 +633,6 @@ final Stream htsTransferFromFungibleTokenLazyCreate() { successfulTransferFromTxn, SUCCESS, recordWith().status(SUCCESS).memo(LAZY_MEMO), - recordWith().status(SUCCESS), recordWith() .status(SUCCESS) .contractCallResult(resultWith() @@ -706,7 +702,6 @@ final Stream htsTransferFromForNFTLazyCreate() { TRANSFER_TXN, SUCCESS, recordWith().status(SUCCESS).memo(LAZY_MEMO), - recordWith().status(SUCCESS), recordWith() .status(SUCCESS) .contractCallResult(resultWith() diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationSuite.java index 6e3a219ab9a7..ca0306e86376 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationSuite.java @@ -423,14 +423,12 @@ final Stream canAutoCreateWithNftTransfersToAlias() { getTxnRecord(multiNftTransfer) .andAllChildRecords() .hasPriority(recordWith().autoAssociationCount(2)) - .hasNonStakingChildRecordCount(3) + .hasNonStakingChildRecordCount(1) .logged(), childRecordsCheck( multiNftTransfer, SUCCESS, - recordWith().status(SUCCESS).fee(EXPECTED_MULTI_TOKEN_TRANSFER_AUTO_CREATION_FEE), - recordWith().status(SUCCESS).fee(EXPECTED_ASSOCIATION_FEE), - recordWith().status(SUCCESS).fee(EXPECTED_ASSOCIATION_FEE)), + recordWith().status(SUCCESS).fee(EXPECTED_MULTI_TOKEN_TRANSFER_AUTO_CREATION_FEE)), getAliasedAccountInfo(VALID_ALIAS) .has(accountWith() .balance(0) @@ -489,7 +487,7 @@ final Stream canAutoCreateWithNftTransferToEvmAddress() { .exposingAllTo(records -> hasNodeStakeUpdate.set( records.size() > 1 && isEndOfStakingPeriodRecord(records.get(1)))) .andAllChildRecords() - .hasNonStakingChildRecordCount(2) + .hasNonStakingChildRecordCount(1) .hasPriority(recordWith().autoAssociationCount(1)) .logged(), sourcing(() -> childRecordsCheck( @@ -498,8 +496,7 @@ final Stream canAutoCreateWithNftTransferToEvmAddress() { recordWith() .status(SUCCESS) .consensusTimeImpliedByNonce( - parentConsTime.get(), hasNodeStakeUpdate.get() ? -2 : -1), - recordWith().status(SUCCESS)))); + parentConsTime.get(), hasNodeStakeUpdate.get() ? -2 : -1)))); } @HapiTest @@ -555,7 +552,7 @@ final Stream multipleTokenTransfersSucceed() { // auto-creation and token association getTxnRecord(multiTokenXfer) .andAllChildRecords() - .hasNonStakingChildRecordCount(3) + .hasNonStakingChildRecordCount(1) .hasPriority(recordWith() .status(SUCCESS) .tokenTransfers(includingFungibleMovement( @@ -567,9 +564,7 @@ final Stream multipleTokenTransfersSucceed() { childRecordsCheck( multiTokenXfer, SUCCESS, - recordWith().status(SUCCESS).fee(EXPECTED_MULTI_TOKEN_TRANSFER_AUTO_CREATION_FEE), - recordWith().status(SUCCESS).fee(EXPECTED_ASSOCIATION_FEE), - recordWith().status(SUCCESS).fee(EXPECTED_ASSOCIATION_FEE)), + recordWith().status(SUCCESS).fee(EXPECTED_MULTI_TOKEN_TRANSFER_AUTO_CREATION_FEE)), getAliasedAccountInfo(VALID_ALIAS) .hasToken(relationshipWith(A_TOKEN).balance(10)) .hasToken(relationshipWith(B_TOKEN).balance(10)) @@ -692,14 +687,13 @@ final Stream canAutoCreateWithFungibleTokenTransfersToAlias() { .logged(), getTxnRecord(sameTokenXfer) .andAllChildRecords() - .hasNonStakingChildRecordCount(2) + .hasNonStakingChildRecordCount(1) .hasPriority(recordWith().autoAssociationCount(1)) .logged(), childRecordsCheck( sameTokenXfer, SUCCESS, - recordWith().status(SUCCESS).fee(EXPECTED_SINGLE_TOKEN_TRANSFER_AUTO_CREATE_FEE), - recordWith().status(SUCCESS)), + recordWith().status(SUCCESS).fee(EXPECTED_SINGLE_TOKEN_TRANSFER_AUTO_CREATE_FEE)), getAliasedAccountInfo(VALID_ALIAS) .hasToken(relationshipWith(A_TOKEN).balance(20)), getAccountInfo(CIVILIAN) @@ -708,7 +702,7 @@ final Stream canAutoCreateWithFungibleTokenTransfersToAlias() { assertionsHold((spec, opLog) -> { final var lookup = getTxnRecord(sameTokenXfer) .andAllChildRecords() - .hasNonStakingChildRecordCount(2) + .hasNonStakingChildRecordCount(1) .hasPriority(recordWith().autoAssociationCount(1)) .hasNoAliasInChildRecord(0) .logged(); @@ -717,7 +711,8 @@ final Stream canAutoCreateWithFungibleTokenTransfersToAlias() { final var payer = spec.registry().getAccountID(CIVILIAN); final var parent = lookup.getResponseRecord(); final var child = lookup.getFirstNonStakingChildRecord(); - assertAliasBalanceAndFeeInChildRecord(parent, child, sponsor, payer, 0L, approxTransferFee); + assertAliasBalanceAndFeeInChildRecord( + parent, child, sponsor, payer, 0L, approxTransferFee, EXPECTED_ASSOCIATION_FEE); })) .then( /* --- transfer another token to created alias. @@ -1247,7 +1242,7 @@ final Stream autoAccountCreationsHappyPath() { child = lookup.getChildRecord(1); } assertAliasBalanceAndFeeInChildRecord( - parent, child, sponsor, payer, ONE_HUNDRED_HBARS + ONE_HBAR, transferFee); + parent, child, sponsor, payer, ONE_HUNDRED_HBARS + ONE_HBAR, transferFee, 0); creationTime.set(child.getConsensusTimestamp().getSeconds()); }), sourcing(() -> getAliasedAccountInfo(VALID_ALIAS) @@ -1269,7 +1264,8 @@ static void assertAliasBalanceAndFeeInChildRecord( final AccountID sponsor, final AccountID defaultPayer, final long newAccountFunding, - final long approxTransferFee) { + final long approxTransferFee, + final long squashedFees) { long receivedBalance = 0; long payerBalWithAutoCreationFee = 0; for (final var adjust : parent.getTransferList().getAccountAmountsList()) { @@ -1296,11 +1292,11 @@ static void assertAliasBalanceAndFeeInChildRecord( // A single extra byte in the signature map will cost just ~40 tinybar more, so allowing // a delta of 1000 tinybar is sufficient to stabilize this test indefinitely final var permissibleDelta = 1000L; - final var observedDelta = Math.abs(parent.getTransactionFee() - approxTransferFee); + final var observedDelta = Math.abs(parent.getTransactionFee() - approxTransferFee - squashedFees); assertTrue( observedDelta <= permissibleDelta, - "Parent record did not specify the transfer fee (expected ~" + approxTransferFee + " but was " - + parent.getTransactionFee() + ")"); + "Parent record did not specify the transfer fee (expected ~" + (approxTransferFee + squashedFees) + + " but was " + parent.getTransactionFee() + ")"); assertEquals(0, payerBalWithAutoCreationFee, "Auto creation fee is deducted from payer"); } @@ -1533,10 +1529,8 @@ final Stream transferFungibleToEVMAddressAlias() { getHollowAccountInfoAfterTransfers); })) .then(getTxnRecord(FT_XFER) - .hasNonStakingChildRecordCount(2) - .hasChildRecords( - recordWith().status(SUCCESS).memo(LAZY_MEMO), - recordWith().status(SUCCESS)) + .hasNonStakingChildRecordCount(1) + .hasChildRecords(recordWith().status(SUCCESS).memo(LAZY_MEMO)) .hasPriority(recordWith().autoAssociationCount(1))); } @@ -1635,11 +1629,9 @@ final Stream transferNonFungibleToEVMAddressAlias() { getHollowAccountInfoAfterTransfers); })) .then(getTxnRecord(NFT_XFER) - .hasNonStakingChildRecordCount(2) + .hasNonStakingChildRecordCount(1) .hasPriority(recordWith().autoAssociationCount(1)) - .hasChildRecords( - recordWith().status(SUCCESS).memo(LAZY_MEMO), - recordWith().status(SUCCESS))); + .hasChildRecords(recordWith().status(SUCCESS).memo(LAZY_MEMO))); } @HapiTest diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationUnlimitedAssociationsSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationUnlimitedAssociationsSuite.java index 1b0fd48125ec..fd07aafca4a8 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationUnlimitedAssociationsSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/AutoAccountCreationUnlimitedAssociationsSuite.java @@ -143,7 +143,7 @@ final Stream autoAccountCreationsUnlimitedAssociationHappyPath() { child = lookup.getChildRecord(1); } assertAliasBalanceAndFeeInChildRecord( - parent, child, sponsor, payer, ONE_HUNDRED_HBARS + ONE_HBAR, transferFee); + parent, child, sponsor, payer, ONE_HUNDRED_HBARS + ONE_HBAR, transferFee, 0); creationTime.set(child.getConsensusTimestamp().getSeconds()); }), sourcing(() -> getAliasedAccountInfo(VALID_ALIAS) @@ -203,7 +203,7 @@ final Stream autoAccountCreationsUnlimitedAssociationsDisabled() { child = lookup.getChildRecord(1); } assertAliasBalanceAndFeeInChildRecord( - parent, child, sponsor, payer, ONE_HUNDRED_HBARS + ONE_HBAR, transferFee); + parent, child, sponsor, payer, ONE_HUNDRED_HBARS + ONE_HBAR, transferFee, 0); creationTime.set(child.getConsensusTimestamp().getSeconds()); }), sourcing(() -> getAliasedAccountInfo(VALID_ALIAS) diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/HollowAccountFinalizationSuite.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/HollowAccountFinalizationSuite.java index 426dfd8799c4..dce865fdf608 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/HollowAccountFinalizationSuite.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/crypto/HollowAccountFinalizationSuite.java @@ -194,10 +194,8 @@ final Stream hollowAccountCompletionWithTokenTransfer() { .has(accountWith().key(SECP_256K1_SOURCE_KEY).noAlias()); final var hapiGetTxnRecord = getTxnRecord(FT_XFER) - .hasNonStakingChildRecordCount(2) - .hasChildRecords( - recordWith().status(SUCCESS).memo(LAZY_MEMO), - recordWith().status(SUCCESS)); + .hasNonStakingChildRecordCount(1) + .hasChildRecords(recordWith().status(SUCCESS).memo(LAZY_MEMO)); allRunFor( spec,