From 90540c56bfc56bb5c9deae9d0141895ebc81d999 Mon Sep 17 00:00:00 2001 From: Bilyana Gospodinova Date: Fri, 17 Jan 2025 19:39:06 +0200 Subject: [PATCH] Fix the failing tests in `InternalCallsTest` (#10156) Adapt the failing tests in InternalCallsTest. There is a difference in the behaviour in the mono code and the modularized code, so depending on the modularizedServices flag the test assertions are different. --------- Signed-off-by: Bilyana Gospodinova --- .../web3/service/InternalCallsTest.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/InternalCallsTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/InternalCallsTest.java index 94e2065ce22..08a834a5336 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/InternalCallsTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/InternalCallsTest.java @@ -21,8 +21,11 @@ import static com.hedera.mirror.web3.service.model.CallServiceParameters.CallType.ETH_CALL; import static com.hedera.mirror.web3.utils.ContractCallTestUtil.TRANSACTION_GAS_LIMIT; import static com.hedera.mirror.web3.validation.HexValidator.HEX_PREFIX; +import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import com.hedera.mirror.web3.exception.MirrorEvmTransactionException; import com.hedera.mirror.web3.web3j.generated.InternalCaller; import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.Test; @@ -69,7 +72,12 @@ void sendToNonExistingAccount() throws Exception { meterRegistry.clear(); final var result = contract.call_sendTo(NON_EXISTING_ADDRESS).send(); - assertThat(result).isEqualTo(Boolean.TRUE); + if (!mirrorNodeEvmProperties.isModularizedServices()) { + assertThat(result).isEqualTo(Boolean.TRUE); + } else { + // In the mod code, there is a check if the address is an alias and in this case it is not. + assertThat(result).isEqualTo(Boolean.FALSE); + } assertGasLimit(TRANSACTION_GAS_LIMIT); } @@ -77,9 +85,16 @@ void sendToNonExistingAccount() throws Exception { void transferToNonExistingAccount() throws Exception { final var contract = testWeb3jService.deploy(InternalCaller::deploy); meterRegistry.clear(); - contract.send_transferTo(NON_EXISTING_ADDRESS).send(); - - assertThat(testWeb3jService.getTransactionResult()).isEqualTo(HEX_PREFIX); + final var functionCall = contract.send_transferTo(NON_EXISTING_ADDRESS); + if (!mirrorNodeEvmProperties.isModularizedServices()) { + functionCall.send(); + assertThat(testWeb3jService.getTransactionResult()).isEqualTo(HEX_PREFIX); + } else { + // In the mod code, there is a check if the address is an alias and in this case it is not. + assertThatThrownBy(functionCall::send) + .isInstanceOf(MirrorEvmTransactionException.class) + .hasMessage(CONTRACT_REVERT_EXECUTED.name()); + } assertGasLimit(TRANSACTION_GAS_LIMIT); }