Skip to content

Commit

Permalink
HIP-584: Add tests for historical data (#7418)
Browse files Browse the repository at this point in the history
This PR covers acceptance tests for historical data support with various precompile functions.

---------

Signed-off-by: Yordan Iliev <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
Co-authored-by: Ivan Ivanov <[email protected]>
  • Loading branch information
yiliev0 and 0xivanov authored Jan 22, 2024
1 parent 430a28f commit 946f49e
Show file tree
Hide file tree
Showing 16 changed files with 1,065 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ public enum AccountNameEnum {
// used in token.feature
CAROL(false, Key.KeyCase.ED25519),
DAVE(false, Key.KeyCase.ED25519),
DELETABLE(false, KeyCase.ED25519),
OPERATOR(false, Key.KeyCase.ED25519); // These may not be accurate for operator

private final boolean receiverSigRequired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.hedera.mirror.test.e2e.acceptance.response.ContractCallResponse;
import com.hedera.mirror.test.e2e.acceptance.response.ExchangeRateResponse;
import com.hedera.mirror.test.e2e.acceptance.response.MirrorAccountResponse;
import com.hedera.mirror.test.e2e.acceptance.response.MirrorBlockResponse;
import com.hedera.mirror.test.e2e.acceptance.response.MirrorContractResponse;
import com.hedera.mirror.test.e2e.acceptance.response.MirrorContractResultResponse;
import com.hedera.mirror.test.e2e.acceptance.response.MirrorContractResultsResponse;
Expand Down Expand Up @@ -220,6 +221,11 @@ public ContractCallResponse contractsCall(ContractCallRequest request) {
return callPostRestEndpoint("/contracts/call", ContractCallResponse.class, request);
}

public MirrorBlockResponse getBlocks() {
log.debug("Get blocks data by Mirror Node");
return callRestEndpoint("/blocks", MirrorBlockResponse.class);
}

public List<MirrorNetworkNode> getNetworkNodes() {
List<MirrorNetworkNode> nodes = new ArrayList<>();
String next = "/network/nodes?limit=25";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ public enum TokenNameEnum {
TokenType.FUNGIBLE_COMMON,
TokenKycStatus.KycNotApplicable,
TokenFreezeStatus.FreezeNotApplicable),
FUNGIBLEHISTORICAL(
"fungible_historical", TokenType.FUNGIBLE_COMMON, TokenKycStatus.Granted, TokenFreezeStatus.Unfrozen),
FUNGIBLE_DELETABLE(
"fungible_deletable",
TokenType.FUNGIBLE_COMMON,
Expand Down Expand Up @@ -631,6 +633,11 @@ public enum TokenNameEnum {
TokenType.NON_FUNGIBLE_UNIQUE,
TokenKycStatus.KycNotApplicable,
TokenFreezeStatus.FreezeNotApplicable),
NFTHISTORICAL(
"non_fungible_historical",
TokenType.NON_FUNGIBLE_UNIQUE,
TokenKycStatus.Granted,
TokenFreezeStatus.Unfrozen),
NFT_DELETABLE(
"non_fungible_deletable",
TokenType.NON_FUNGIBLE_UNIQUE,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.hedera.mirror.test.e2e.acceptance.props;

import lombok.Data;

@Data
public class MirrorBlock {
private Integer count;
private String hapiVersion;
private String hash;
private String name;
private Integer number;
private String previousHash;
private Integer size;
private TimestampRange timestamp;
private Integer gasUsed;
private String logsBloom;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.hedera.mirror.test.e2e.acceptance.response;

import com.hedera.mirror.test.e2e.acceptance.props.MirrorBlock;
import java.util.List;
import lombok.Data;

@Data
public class MirrorBlockResponse {
private List<MirrorBlock> blocks;
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ protected void assertContractCallReturnsBadRequest(String data, String contractA
.hasMessageContaining("400 Bad Request from POST");
}

protected void assertEthCallReturnsBadRequest(String block, String data, String contractAddress) {
var contractCallRequestBody = ContractCallRequest.builder()
.block(block)
.data(data)
.to(contractAddress)
.estimate(false)
.build();

assertThatThrownBy(() -> mirrorClient.contractsCall(contractCallRequestBody))
.isInstanceOf(WebClientResponseException.class)
.hasMessageContaining("400 Bad Request from POST");
}

private ContractCallRequest buildContractCallRequest(String data, String solidityAddress, Optional<String> sender) {
var requestBuilder =
ContractCallRequest.builder().data(data).to(solidityAddress).estimate(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ protected CompiledSolidityArtifact readCompiledArtifact(InputStream in) throws I
}

protected ContractCallResponse callContract(String data, String contractAddress) {
return callContract("LATEST", data, contractAddress);
}

protected ContractCallResponse callContract(String blockNumber, String data, String contractAddress) {
var contractCallRequestBody = ContractCallRequest.builder()
.block(blockNumber)
.data(data)
.from(contractClient.getClientAddress())
.to(contractAddress)
Expand Down
Loading

0 comments on commit 946f49e

Please sign in to comment.