Skip to content

Commit

Permalink
Fix the failing tests in InternalCallsTest (#10156)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bilyana-gospodinova authored Jan 17, 2025
1 parent e760376 commit 90540c5
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,17 +72,29 @@ 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);
}

@Test
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);
}

Expand Down

0 comments on commit 90540c5

Please sign in to comment.