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

fix: Enable fuzzy matching for HRCPrecompileSuite #11032

Merged
merged 22 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
adf4ea3
fix: enable fuzzy matching for HRCPrecompileSuite
stoyanov-st Jan 18, 2024
d33d3ff
fix: revert commented lines
stoyanov-st Jan 18, 2024
62b023e
refactor: refactor return
stoyanov-st Jan 18, 2024
d3a4b1d
refactor: optimize algorithm
stoyanov-st Jan 18, 2024
e71e63b
refactor: revert SnapshotMatchMode changes
stoyanov-st Jan 19, 2024
803cccf
refactor: set transferList to null when child record fails
stoyanov-st Jan 19, 2024
3e9b039
test: fix tests
stoyanov-st Jan 19, 2024
a70b106
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Jan 22, 2024
9026286
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Jan 23, 2024
5a7ad6d
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Jan 24, 2024
b24746a
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Jan 25, 2024
459fc62
fix: add null check for transferList
stoyanov-st Jan 25, 2024
1e7f94d
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Feb 5, 2024
da6fd6f
fix: fix tests
stoyanov-st Feb 5, 2024
7761097
refactor: return non-null checks
stoyanov-st Feb 5, 2024
5383cb8
test: add nondeterministic transaction fee match mode
stoyanov-st Feb 5, 2024
7fdbccf
fix: correct not null annotation
stoyanov-st Feb 5, 2024
7965c56
refactor: spotless apply
stoyanov-st Feb 5, 2024
4d4504c
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Feb 7, 2024
1e65716
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Feb 12, 2024
5769284
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Feb 12, 2024
5456b98
Merge branch 'develop' into 010874-hrc-precompile-suite-fuzzy-match
stoyanov-st Feb 13, 2024
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 @@ -72,6 +72,9 @@ public void finalizeChildRecord(@NonNull final ChildFinalizeContext context, fin
// set an empty transfer list even if there are no hbar changes but the parent record succeeded
// to be compatible with mono-service
recordBuilder.transferList(TransferList.DEFAULT);
} else if (recordBuilder.status() != ResponseCodeEnum.SUCCESS) {
tinker-michaelj marked this conversation as resolved.
Show resolved Hide resolved
// set null to transfer list if the child record failed to be compatible with mono-service
recordBuilder.transferList(null);
mhess-swl marked this conversation as resolved.
Show resolved Hide resolved
}

// Declare the top-level token transfer list, which list will include BOTH fungible and non-fungible token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package com.hedera.node.app.service.token.impl.test.handlers;

import static com.hedera.hapi.node.base.ResponseCodeEnum.FAIL_INVALID;
import static com.hedera.hapi.node.base.ResponseCodeEnum.SUCCESS;
import static com.hedera.node.app.service.token.impl.handlers.BaseTokenHandler.asToken;
import static com.hedera.node.app.spi.fixtures.workflows.ExceptionConditions.responseCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mock.Strictness.LENIENT;
import static org.mockito.Mockito.atMostOnce;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

Expand Down Expand Up @@ -162,9 +164,12 @@ void handleHbarAccountBalanceDoesntChange() {
context = mockContext();

given(context.configuration()).willReturn(configuration);
given(recordBuilder.status()).willReturn(SUCCESS);
subject.finalizeChildRecord(context, HederaFunctionality.CRYPTO_DELETE);

verify(recordBuilder).status();
BDDMockito.verify(recordBuilder, atMostOnce()).status();
BDDMockito.verify(recordBuilder, atMostOnce()).transferList(TransferList.DEFAULT);
BDDMockito.verifyNoMoreInteractions(recordBuilder);
}

@Test
Expand Down Expand Up @@ -315,10 +320,14 @@ void handleFungibleTransferTokenBalancesDontChange() {
writableTokenRelStore.put(tokenRel.copyBuilder().frozen(true).build());
context = mockContext();
given(context.configuration()).willReturn(configuration);
given(recordBuilder.status()).willReturn(SUCCESS);

subject.finalizeChildRecord(context, HederaFunctionality.CRYPTO_DELETE);

verify(recordBuilder).status();
BDDMockito.verify(recordBuilder, atMostOnce()).status();
BDDMockito.verify(recordBuilder, atMostOnce()).transferList(TransferList.DEFAULT);
BDDMockito.verifyNoMoreInteractions(recordBuilder);
}

@Test
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.overriding;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_ETHEREUM_DATA;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_FUNCTION_PARAMETERS;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_NONCE;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_TRANSACTION_FEES;
import static com.hedera.services.bdd.suites.contract.Utils.asHexedAddress;
import static com.hedera.services.bdd.suites.contract.Utils.asToken;
import static com.hedera.services.bdd.suites.contract.Utils.getABIFor;
Expand All @@ -57,7 +61,7 @@
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Tag;

@HapiTestSuite
@HapiTestSuite(fuzzyMatch = true)
@Tag(SMART_CONTRACT)
public class HRCPrecompileSuite extends HapiSuite {

Expand Down Expand Up @@ -106,7 +110,7 @@ final HapiSpec hrcNftAndFungibleTokenAssociateFromEOA() {
final AtomicReference<String> fungibleTokenNum = new AtomicReference<>();
final AtomicReference<String> nonfungibleTokenNum = new AtomicReference<>();

return defaultHapiSpec("hrcNftAndFungibleTokenAssociateFromEOA")
return defaultHapiSpec("hrcNftAndFungibleTokenAssociateFromEOA", NONDETERMINISTIC_FUNCTION_PARAMETERS)
.given(
newKeyNamed(MULTI_KEY),
cryptoCreate(ACCOUNT).balance(100 * ONE_HUNDRED_HBARS),
Expand Down Expand Up @@ -215,7 +219,11 @@ final HapiSpec hrcNftAndFungibleTokenAssociateFromEOA() {

@HapiTest
final HapiSpec hrcNFTAndFungibleTokenAssociateFromContract() {
return defaultHapiSpec("hrcNFTAndFungibleTokenAssociateFromContract")
return defaultHapiSpec(
"hrcNFTAndFungibleTokenAssociateFromContract",
NONDETERMINISTIC_TRANSACTION_FEES,
NONDETERMINISTIC_FUNCTION_PARAMETERS,
NONDETERMINISTIC_NONCE)
.given(
newKeyNamed(MULTI_KEY),
cryptoCreate(ACCOUNT).balance(100 * ONE_HUNDRED_HBARS),
Expand Down Expand Up @@ -324,7 +332,10 @@ final HapiSpec hrcNFTAndFungibleTokenAssociateFromContract() {
final HapiSpec hrcTokenAssociateFromSameEOATwiceShouldFail() {
final AtomicReference<String> fungibleTokenNum = new AtomicReference<>();

return defaultHapiSpec("hrcTokenAssociateFromSameEOATwiceShouldFail")
return defaultHapiSpec(
"hrcTokenAssociateFromSameEOATwiceShouldFail",
NONDETERMINISTIC_FUNCTION_PARAMETERS,
NONDETERMINISTIC_NONCE)
.given(
newKeyNamed(MULTI_KEY),
newKeyNamed(RANDOM_KEY),
Expand Down Expand Up @@ -390,7 +401,7 @@ final HapiSpec hrcTokenAssociateFromSameEOATwiceShouldFail() {
final HapiSpec hrcTokenDissociateWhenNotAssociatedShouldFail() {
final AtomicReference<String> fungibleTokenNum = new AtomicReference<>();

return defaultHapiSpec("hrcTokenDissociateWhenNotAssociatedShouldFail")
return defaultHapiSpec("hrcTokenDissociateWhenNotAssociatedShouldFail", NONDETERMINISTIC_TRANSACTION_FEES)
.given(
newKeyNamed(MULTI_KEY),
newKeyNamed(RANDOM_KEY),
Expand Down Expand Up @@ -438,7 +449,10 @@ final HapiSpec hrcTokenDissociateWhenNotAssociatedShouldFail() {
final HapiSpec hrcTokenDissociateWhenBalanceNotZeroShouldFail() {
final AtomicReference<String> fungibleTokenNum = new AtomicReference<>();

return defaultHapiSpec("hrcTokenDissociateWhenBalanceNotZeroShouldFail")
return defaultHapiSpec(
"hrcTokenDissociateWhenBalanceNotZeroShouldFail",
NONDETERMINISTIC_FUNCTION_PARAMETERS,
NONDETERMINISTIC_ETHEREUM_DATA)
.given(
newKeyNamed(MULTI_KEY),
newKeyNamed(RANDOM_KEY),
Expand Down Expand Up @@ -508,7 +522,10 @@ final HapiSpec hrcTooManyTokenAssociateShouldFail() {
final AtomicReference<String> fungibleTokenNum2 = new AtomicReference<>();
final AtomicReference<String> fungibleTokenNum3 = new AtomicReference<>();

return defaultHapiSpec("hrcTooManyTokenAssociateShouldFail")
return defaultHapiSpec(
"hrcTooManyTokenAssociateShouldFail",
NONDETERMINISTIC_FUNCTION_PARAMETERS,
NONDETERMINISTIC_TRANSACTION_FEES)
.given(
overriding("tokens.maxPerAccount", "2"),
overriding("entities.limitTokenAssociations", "true"),
Expand Down
Loading