Skip to content

Commit

Permalink
Fix failing tests in ContractCallServicePrecompileModificationTest (#…
Browse files Browse the repository at this point in the history
…10116)

 Fix multiple tests within ContractCallServicePrecompileModificationTest class

---------

Signed-off-by: sdimitrov9 <[email protected]>
Signed-off-by: Kristiyan Selveliev <[email protected]>
Co-authored-by: Kristiyan Selveliev <[email protected]>
  • Loading branch information
sdimitrov9 and kselveliev authored Jan 15, 2025
1 parent dbd5b4a commit 3572784
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
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
2 changes: 2 additions & 0 deletions hedera-mirror-web3/src/test/resources/config/application.yml
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

0 comments on commit 3572784

Please sign in to comment.