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 failing tests in ContractCallServicePrecompileModificationTest #10116

Merged
merged 11 commits into from
Jan 15, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ public int numberPositiveBalances() {
return numberPositiveBalancesSupplier.get();
}

public Long numberOwnedNfts() {
public long numberOwnedNfts() {
return numberOwnedNftsSupplier.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,7 @@
@Import(Web3jTestConfiguration.class)
public abstract class AbstractContractCallServiceTest extends Web3IntegrationTest {

@Resource
protected TestWeb3jService testWeb3jService;

@Resource
protected MirrorNodeEvmProperties mirrorNodeEvmProperties;

@Resource
protected State state;

protected RecordFile genesisRecordFile;

protected Entity treasuryEntity;

protected static final String TREASURY_ADDRESS = EvmTokenUtils.toAddress(2).toHexString();

protected static final byte[] EXCHANGE_RATES_SET = ExchangeRateSet.newBuilder()
.setCurrentRate(ExchangeRate.newBuilder()
.setCentEquiv(12)
Expand All @@ -94,6 +80,19 @@ public abstract class AbstractContractCallServiceTest extends Web3IntegrationTes
.build()
.toByteArray();

@Resource
protected TestWeb3jService testWeb3jService;

@Resource
protected MirrorNodeEvmProperties mirrorNodeEvmProperties;

@Resource
protected State state;

protected RecordFile genesisRecordFile;

protected Entity treasuryEntity;

public static Key getKeyWithDelegatableContractId(final Contract contract) {
final var contractAddress = Address.fromHexString(contract.getContractAddress());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.hedera.mirror.web3.service;

import static com.hedera.mirror.web3.evm.utils.EvmTokenUtils.entityIdFromEvmAddress;
import static com.hedera.mirror.web3.evm.utils.EvmTokenUtils.toAddress;
import static com.hedera.mirror.web3.utils.ContractCallTestUtil.EMPTY_UNTRIMMED_ADDRESS;
import static com.hedera.mirror.web3.utils.ContractCallTestUtil.ESTIMATE_GAS_ERROR_MESSAGE;
import static com.hedera.mirror.web3.utils.ContractCallTestUtil.NEW_ECDSA_KEY;
Expand Down Expand Up @@ -62,6 +63,7 @@
import com.swirlds.base.time.Time;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
Expand Down Expand Up @@ -273,12 +275,21 @@ void dissociateToken(final Boolean single) throws Exception {

final var tokenEntity =
domainBuilder.entity().customize(e -> e.type(EntityType.TOKEN)).persist();

domainBuilder
.token()
.customize(t -> t.tokenId(tokenEntity.getId()).type(TokenTypeEnum.FUNGIBLE_COMMON))
.persist();

tokenAccountPersist(tokenEntity, associatedAccount);
domainBuilder
.tokenAccount()
.customize(ta -> ta.tokenId(tokenEntity.getId())
.accountId(associatedAccount.getId())
.freezeStatus(TokenFreezeStatusEnum.UNFROZEN)
.kycStatus(TokenKycStatusEnum.GRANTED)
.balance(0L)
.associated(true))
.persist();

final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);

Expand Down Expand Up @@ -538,10 +549,13 @@ void revokeTokenKyc() throws Exception {
@Test
void deleteToken() throws Exception {
// Given
final var treasury = accountEntityPersist();
final var tokenEntity = tokenEntityPersist();
domainBuilder
.token()
.customize(t -> t.tokenId(tokenEntity.getId()).type(TokenTypeEnum.FUNGIBLE_COMMON))
.customize(t -> t.tokenId(tokenEntity.getId())
.type(TokenTypeEnum.FUNGIBLE_COMMON)
.treasuryAccountId(treasury.toEntityId()))
.persist();

final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);
Expand Down Expand Up @@ -603,10 +617,13 @@ void unfreezeToken() throws Exception {
@Test
void pauseToken() throws Exception {
// Given
final var treasury = accountEntityPersist();
final var tokenEntity = tokenEntityPersist();
domainBuilder
.token()
.customize(t -> t.tokenId(tokenEntity.getId()).type(TokenTypeEnum.FUNGIBLE_COMMON))
.customize(t -> t.tokenId(tokenEntity.getId())
.type(TokenTypeEnum.FUNGIBLE_COMMON)
.treasuryAccountId(treasury.toEntityId()))
.persist();

final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);
Expand Down Expand Up @@ -1318,15 +1335,15 @@ void updateTokenInfo() throws Exception {
@Test
void updateTokenExpiry() throws Exception {
// Given
final var treasuryAccount = accountEntityWithEvmAddressPersist();
final var treasuryAccount = accountEntityPersist();
final var tokenWithAutoRenewPair =
persistTokenWithAutoRenewAndTreasuryAccounts(TokenTypeEnum.FUNGIBLE_COMMON, treasuryAccount);

final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);

final var tokenExpiry = new Expiry(
BigInteger.valueOf(Time.getCurrent().currentTimeMillis() + 1_000_000_000),
getAliasFromEntity(tokenWithAutoRenewPair.getRight()),
BigInteger.valueOf(Instant.now().getEpochSecond() + 8_000_000L),
toAddress(tokenWithAutoRenewPair.getRight().toEntityId()).toHexString(),
BigInteger.valueOf(8_000_000));

// When
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ hedera:
properties:
contracts.allowCreate2: "false"
contracts.chainId: "297"
contracts.maxGasPerSec: "15000000"
contracts.maxRefundPercentOfGasLimit: "100"
evm_versions:
0: 0.30.0
50: 0.34.0
Expand Down
Loading