Skip to content

Commit

Permalink
refactoring so that tests with modularized flag = true do not break
Browse files Browse the repository at this point in the history
Signed-off-by: filev94 <[email protected]>
  • Loading branch information
filev94 committed Feb 5, 2025
1 parent 8ee44e6 commit d4aa17f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
public abstract class AbstractContractCallServiceTest extends Web3IntegrationTest {

protected static final String TREASURY_ADDRESS = EvmTokenUtils.toAddress(2).toHexString();
public static final long DEFAULT_ACCOUNT_BALANCE = 1_000_000_000_000_000L;
public static final long DEFAULT_ACCOUNT_BALANCE = 100_000_000_000_000_000L;

@Resource
protected TestWeb3jService testWeb3jService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ContractCallNestedCallsTest extends AbstractContractCallServiceOpcodeTrace
void updateTokenKeysAndGetUpdatedTokenKeyForFungibleToken(final KeyValueType keyValueType, final KeyType keyType)
throws Exception {
// Given
final var tokenEntityId = fungibleTokenPersist();
final var tokenEntityId = fungibleTokenPersistWithTreasuryAccount(domainBuilder.entity().persist().toEntityId());
final var tokenAddress = toAddress(tokenEntityId.getTokenId());
final var contract = testWeb3jService.deploy(NestedCalls::deploy);
final var contractAddress = contract.getContractAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ void approveFungibleTokenWithAlias() {
// Given
final var spender =
accountPersistWithAlias(SPENDER_ALIAS, SPENDER_PUBLIC_KEY).toEntityId();
final var token = fungibleTokenPersist();
final var treasury = accountEntityPersist().toEntityId();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var amountGranted = 13L;
final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
final var tokenAddress = toAddress(token.getTokenId());
Expand Down Expand Up @@ -202,7 +203,8 @@ void approveNFTWithAlias() {
void transfer() {
// Given
final var recipient = accountEntityPersist().toEntityId();
final var token = fungibleTokenPersist();
final var treasury = accountEntityPersist().toEntityId();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
final var tokenAddress = toAddress(tokenEntity.getId());
tokenAssociateAccountPersist(recipient, entityIdFromEvmAddress(toAddress(tokenEntity.getId())));
Expand All @@ -223,10 +225,11 @@ void transfer() {
@Test
void transferFrom() {
// Given
final var treasury = accountEntityPersist().toEntityId();
final var owner = accountEntityPersist().toEntityId();
final var recipient = accountEntityPersist().toEntityId();

final var token = fungibleTokenPersist();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
tokenAssociateAccountPersist(owner, tokenEntity);
tokenAssociateAccountPersist(recipient, tokenEntity);
Expand Down Expand Up @@ -314,7 +317,8 @@ void transferFromNFT() {
void transferWithAlias() {
// Given
final var recipient = accountPersistWithAlias(SPENDER_ALIAS, SPENDER_PUBLIC_KEY);
final var token = fungibleTokenPersist();
final var treasury = accountPersistWithAlias(SENDER_ALIAS, SENDER_PUBLIC_KEY).toEntityId();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
tokenAssociateAccountPersist(recipient.toEntityId(), entityIdFromEvmAddress(toAddress(token.getTokenId())));

final var contract = testWeb3jService.deploy(ERCTestContract::deploy);
Expand All @@ -333,11 +337,12 @@ void transferWithAlias() {
@Test
void transferFromWithAlias() {
// Given
final var treasury = accountEntityPersist().toEntityId();
final var owner =
accountPersistWithAlias(SENDER_ALIAS, SENDER_PUBLIC_KEY).toEntityId();
final var recipient =
accountPersistWithAlias(SPENDER_ALIAS, SPENDER_PUBLIC_KEY).toEntityId();
final var token = fungibleTokenPersist();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
tokenAssociateAccountPersist(owner, tokenEntity);
tokenAssociateAccountPersist(recipient, tokenEntity);
Expand Down Expand Up @@ -491,7 +496,8 @@ void approveNFTWithAliasRedirect() {
void transferRedirect() {
// Given
final var recipient = accountEntityPersist().toEntityId();
final var token = fungibleTokenPersist();
final var treasury = accountEntityPersist().toEntityId();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var amount = 10L;

final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
Expand All @@ -512,10 +518,11 @@ void transferRedirect() {
@Test
void transferFromRedirect() {
// Given
final var treasury = accountEntityPersist().toEntityId();
final var owner = accountEntityPersist().toEntityId();
final var recipient = accountEntityPersist().toEntityId();

final var token = fungibleTokenPersist();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
tokenAssociateAccountPersist(owner, tokenEntity);
tokenAssociateAccountPersist(recipient, tokenEntity);
Expand Down Expand Up @@ -607,7 +614,8 @@ void transferWithAliasRedirect() {
// Given
final var recipient =
accountPersistWithAlias(SPENDER_ALIAS, SPENDER_PUBLIC_KEY).toEntityId();
final var token = fungibleTokenPersist();
final var treasury = accountPersistWithAlias(SENDER_ALIAS, SENDER_PUBLIC_KEY).toEntityId();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
tokenAssociateAccountPersist(recipient, entityIdFromEvmAddress(toAddress(token.getTokenId())));

final var contract = testWeb3jService.deploy(RedirectTestContract::deploy);
Expand All @@ -626,11 +634,12 @@ void transferWithAliasRedirect() {
@Test
void transferFromWithAliasRedirect() {
// Given
final var treasury = accountEntityPersist().toEntityId();
final var owner =
accountPersistWithAlias(SENDER_ALIAS, SENDER_PUBLIC_KEY).toEntityId();
final var recipient =
accountPersistWithAlias(SPENDER_ALIAS, SPENDER_PUBLIC_KEY).toEntityId();
final var token = fungibleTokenPersist();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
tokenAssociateAccountPersist(owner, tokenEntity);
tokenAssociateAccountPersist(recipient, tokenEntity);
Expand Down Expand Up @@ -683,7 +692,8 @@ void transferFromNFTWithAliasRedirect() {
void delegateTransferDoesNotExecuteAndReturnEmpty() throws Exception {
// Given
final var recipient = accountEntityPersist().toEntityId();
final var token = fungibleTokenPersist();
final var treasury = accountEntityPersist().toEntityId();
final var token = fungibleTokenPersistWithTreasuryAccount(treasury);
final var tokenEntity = entityIdFromEvmAddress(toAddress(token.getTokenId()));
final var tokenAddress = toAddress(tokenEntity.getId());
tokenAssociateAccountPersist(recipient, entityIdFromEvmAddress(toAddress(tokenEntity.getId())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.hedera.mirror.web3.service;

import static com.hedera.mirror.common.domain.entity.EntityType.TOKEN;
import static com.hedera.mirror.common.domain.transaction.TransactionType.ETHEREUMTRANSACTION;
import static com.hedera.mirror.common.util.CommonUtils.instant;
import static com.hedera.mirror.web3.evm.utils.EvmTokenUtils.entityIdFromEvmAddress;
Expand Down Expand Up @@ -112,7 +113,7 @@ class OpcodeServiceTest extends AbstractContractCallServiceOpcodeTracerTest {
""")
void updateTokenKeysAndGetUpdatedTokenKeyForFungibleToken(final KeyValueType keyValueType, final KeyType keyType) {
// Given
final var tokenEntity = fungibleTokenPersist();
final var tokenEntity = fungibleTokenPersistWithTreasuryAccount(domainBuilder.entity().persist().toEntityId());
final var tokenAddress = toAddress(tokenEntity.getTokenId());
final var contract = testWeb3jService.deploy(NestedCalls::deploy);
final var contractAddress = contract.getContractAddress();
Expand Down Expand Up @@ -894,7 +895,7 @@ private NestedCalls.HederaToken populateHederaToken(
// expiration
final var tokenEntity = domainBuilder
.entity()
.customize(e -> e.type(EntityType.TOKEN).autoRenewAccountId(autoRenewAccount.getId()))
.customize(e -> e.type(TOKEN).autoRenewAccountId(autoRenewAccount.getId()))
.persist();
final var token = domainBuilder
.token()
Expand Down Expand Up @@ -953,7 +954,7 @@ private NestedCalls.HederaToken populateHederaToken(
// expiration
final var tokenEntity = domainBuilder
.entity()
.customize(e -> e.type(EntityType.TOKEN).autoRenewAccountId(autoRenewAccount.getId()))
.customize(e -> e.type(TOKEN).autoRenewAccountId(autoRenewAccount.getId()))
.persist();
final var token = domainBuilder
.token()
Expand Down

0 comments on commit d4aa17f

Please sign in to comment.