Skip to content

Commit

Permalink
fix: Fix BytecodeUtilsTest
Browse files Browse the repository at this point in the history
Signed-off-by: Kristiyan Selveliev <[email protected]>
  • Loading branch information
kselveliev committed Dec 20, 2024
1 parent 1423952 commit 24fd576
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ void estimateGasForDirectCreateContractDeploy() {
final var contract = testWeb3jService.deploy(EthCall::deploy);
final var serviceParameters = testWeb3jService.serviceParametersForTopLevelContractCreate(
contract.getContractBinary(), ETH_ESTIMATE_GAS, senderAddress);
final var actualGas = 183552L;
final var actualGas = 175242L;

// When
final var result = contractExecutionService.processCall(serviceParameters);
Expand All @@ -647,7 +647,7 @@ void estimateGasForDirectCreateContractDeployWithMissingSender() {
final var contract = testWeb3jService.deploy(EthCall::deploy);
final var serviceParameters = testWeb3jService.serviceParametersForTopLevelContractCreate(
contract.getContractBinary(), ETH_ESTIMATE_GAS, Address.ZERO);
final var actualGas = 183552L;
final var actualGas = 175242L;

// When
final var result = contractExecutionService.processCall(serviceParameters);
Expand Down Expand Up @@ -725,20 +725,6 @@ void stateChangeWorksWithDynamicEthCall() throws Exception {
assertGasUsedIsPositive(gasUsedBeforeExecution, ETH_CALL);
}

@Test
void ercPrecompileCallForEstimateGas() {
// Given
final var token = tokenPersist();
final var contract = testWeb3jService.deploy(EthCall::deploy);
meterRegistry.clear();

// When
final var result = contract.send_getTokenName(toAddress(token.getId()).toHexString());

// Then
verifyEthCallAndEstimateGas(result, contract);
}

@ParameterizedTest
@EnumSource(
value = CallType.class,
Expand Down Expand Up @@ -782,8 +768,8 @@ void ercPrecompileExceptionalHaltReturnsExpectedGasToBucket(final CallType callT
@MethodSource("ercPrecompileCallTypeArgumentsProvider")
void ercPrecompileContractRevertReturnsExpectedGasToBucket(final CallType callType, final long gasLimit) {
// Given
final var contract = testWeb3jService.deploy(EthCall::deploy);
final var functionCall = contract.call_getTokenName(Address.ZERO.toHexString());
final var contract = testWeb3jService.deploy(ERCTestContract::deploy);
final var functionCall = contract.call_nameNonStatic(Address.ZERO.toHexString());

final var serviceParameters = getContractExecutionParameters(functionCall, contract, callType, gasLimit);
final var expectedGasUsed = gasUsedAfterExecution(serviceParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.hedera.mirror.web3.Web3IntegrationTest;
import com.hedera.mirror.web3.service.AbstractContractCallServiceTest;
import com.hedera.mirror.web3.service.ContractExecutionService;
import com.hedera.mirror.web3.web3j.TestWeb3jService;
import com.hedera.mirror.web3.web3j.TestWeb3jService.Web3jTestConfiguration;
Expand All @@ -43,7 +43,7 @@

@Import(Web3jTestConfiguration.class)
@RequiredArgsConstructor
class BytecodeUtilsTest extends Web3IntegrationTest {
class BytecodeUtilsTest extends AbstractContractCallServiceTest {

private final ContractExecutionService contractExecutionService;
private final TestWeb3jService testWeb3jService;
Expand Down
11 changes: 0 additions & 11 deletions hedera-mirror-web3/src/test/solidity/EthCall.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "./HederaTokenService.sol";
import "./IHederaTokenService.sol";

Expand Down Expand Up @@ -37,16 +36,6 @@ contract EthCall is HederaTokenService {
return storageData;
}

// External view function that has an argument for a token address and using open zeppelin IERC20 interface as a wrapper, returns the token’s name
function getTokenName(address _tokenAddress) external view returns (string memory) {
return IERC20Metadata(_tokenAddress).name();
}

// External view function that has an argument for a token address and using open zeppelin IERC20 interface as a wrapper, returns the token’s symbol
function getTokenSymbol(address _tokenAddress) external view returns (string memory) {
return IERC20Metadata(_tokenAddress).symbol();
}

// External function that freezes a given token for the message sender
function freezeToken(address _tokenAddress) external {
(bool success, bytes memory result) = precompileAddress.call(
Expand Down

0 comments on commit 24fd576

Please sign in to comment.