Skip to content

Commit

Permalink
Reduce acceptance test costs (hashgraph#4110)
Browse files Browse the repository at this point in the history
* Fix sporadic acceptance tests failures due to min 40 hbar balance check
* Merge customfees.feature and hts.feature into renamed token.feature
* Reduce acceptance test costs from 268h to 115h by consolidating token creation
* Remove unused licenses.xml
* Remove unused setup feature
* Remove unused solidity contract

Signed-off-by: Steven Sheehy <[email protected]>
  • Loading branch information
steven-sheehy authored Jul 18, 2022
1 parent 17d0f2f commit cd5d33e
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 1,191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* 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.
Expand All @@ -38,23 +38,27 @@
@Data
@Validated
public class AcceptanceTestProperties {

private final FeatureProperties featureProperties;
private final RestPollingProperties restPollingProperties;
private final SdkProperties sdkProperties;
private final WebClientProperties webClientProperties;

@NotNull
private Duration backOffPeriod = Duration.ofMillis(5000);

private boolean createOperatorAccount = true;

private boolean emitBackgroundMessages = false;

private final FeatureProperties featureProperties;

@Max(5)
private int maxRetries = 2;

@NotNull
private Long maxTinyBarTransactionFee = 2_000_000_000L;

@NotNull
private Duration messageTimeout = Duration.ofSeconds(60);
private Duration messageTimeout = Duration.ofSeconds(20);

@NotBlank
private String mirrorNodeAddress;
Expand All @@ -64,26 +68,20 @@ public class AcceptanceTestProperties {

private Set<NodeProperties> nodes = new LinkedHashSet<>();

private long operatorBalance = 30_000_000_000L;
private long operatorBalance = 15_000_000_000L;

@NotBlank
private String operatorId;

@NotBlank
private String operatorKey;

private final RestPollingProperties restPollingProperties;

private boolean retrieveAddressBook = true;

private final SdkProperties sdkProperties;

private final WebClientProperties webClientProperties;

public enum HederaNetwork {
MAINNET,
OTHER,
PREVIEWNET,
TESTNET,
OTHER
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,11 @@ public class AccountFeature extends AbstractFeature {
private final AccountClient accountClient;
private final MirrorNodeClient mirrorClient;

private long balance;
private AccountId ownerAccountId;
private AccountId receiverAccountId;
private ExpandedAccountId senderAccountId;
private long startingBalance;

@When("I request balance info for this account")
public void getAccountBalance() {
balance = accountClient.getBalance();
}

@Then("the crypto balance should be greater than or equal to {long}")
public void isGreaterOrEqualThan(long threshold) {
assertTrue(balance >= threshold);
}

@When("I create a new account with balance {long} tℏ")
public void createNewAccount(long initialBalance) {
senderAccountId = accountClient.createNewAccount(initialBalance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import com.hedera.mirror.test.e2e.acceptance.client.AccountClient;
import com.hedera.mirror.test.e2e.acceptance.client.MirrorNodeClient;
import com.hedera.mirror.test.e2e.acceptance.client.TokenClient;
import com.hedera.mirror.test.e2e.acceptance.client.TopicClient;
import com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId;
import com.hedera.mirror.test.e2e.acceptance.props.MirrorAssessedCustomFee;
import com.hedera.mirror.test.e2e.acceptance.props.MirrorCustomFees;
Expand All @@ -84,7 +83,6 @@ public class TokenFeature {
private final TokenClient tokenClient;
private final AccountClient accountClient;
private final MirrorNodeClient mirrorClient;
private final TopicClient topicClient;

private final List<ExpandedAccountId> recipients = new ArrayList<>();
private final List<ExpandedAccountId> senders = new ArrayList<>();
Expand Down Expand Up @@ -119,14 +117,6 @@ public void createNewToken(int freezeStatus, int kycStatus) {
createNewToken(RandomStringUtils.randomAlphabetic(4).toUpperCase(), freezeStatus, kycStatus);
}

@Given("I successfully create a new nft")
public void createNewNft() {
createNewNft(RandomStringUtils.randomAlphabetic(4)
.toUpperCase(), TokenFreezeStatus.FreezeNotApplicable_VALUE,
TokenKycStatus.KycNotApplicable_VALUE,
TokenSupplyType.INFINITE);
}

@Given("I successfully create a new nft with supplyType {string}")
public void createNewNft(String tokenSupplyType) {
createNewNft(RandomStringUtils.randomAlphabetic(4)
Expand Down Expand Up @@ -320,55 +310,56 @@ public void verifyTokenPauseStatus(String status) {
verifyTokenPauseStatus(tokenIds.get(0), status);
}

@Then("the mirror node REST API should return status {int}")
@Then("the mirror node REST API should return the transaction")
@Retryable(value = {AssertionError.class},
backoff = @Backoff(delayExpression = "#{@restPollingProperties.minBackoff.toMillis()}"),
maxAttemptsExpression = "#{@restPollingProperties.maxAttempts}")
public void verifyMirrorAPIResponses(int status) {
verifyTransactions(status);
public void verifyMirrorAPIResponses() {
verifyTransactions();
}

@Then("^the mirror node REST API should return status (.*) for token (:?(.*) )?serial number " +
@Then("^the mirror node REST API should return the transaction for token (:?(.*) )?serial number " +
"(:?(.*) )?transaction flow$")
@Retryable(value = {AssertionError.class},
backoff = @Backoff(delayExpression = "#{@restPollingProperties.minBackoff.toMillis()}"),
maxAttemptsExpression = "#{@restPollingProperties.maxAttempts}")
public void verifyMirrorNftTransactionsAPIResponses(int status, Integer tokenIndex, Integer serialNumberIndex) {
public void verifyMirrorNftTransactionsAPIResponses(Integer tokenIndex, Integer serialNumberIndex) {
TokenId tokenId = tokenIds.get(getIndexOrDefault(tokenIndex));
Long serialNumber = tokenSerialNumbers.get(tokenId).get(getIndexOrDefault(serialNumberIndex));
verifyTransactions(status);
verifyTransactions();
verifyNftTransactions(tokenId, serialNumber);
}

@Then("^the mirror node REST API should return status (.*) for token (:?(.*) )?fund flow$")
@Then("^the mirror node REST API should return the transaction for token (:?(.*) )?fund flow$")
@Retryable(value = {AssertionError.class},
backoff = @Backoff(delayExpression = "#{@restPollingProperties.minBackoff.toMillis()}"),
maxAttemptsExpression = "#{@restPollingProperties.maxAttempts}")
public void verifyMirrorTokenFundFlow(int status, Integer tokenIndex) {
verifyMirrorTokenFundFlow(status, tokenIndex, Collections.emptyList());
public void verifyMirrorTokenFundFlow(Integer tokenIndex) {
verifyMirrorTokenFundFlow(tokenIndex, Collections.emptyList());
}

@Then("^the mirror node REST API should return status (.*) for token (:?(.*) )?fund flow with assessed custom " +
@Then("^the mirror node REST API should return the transaction for token (:?(.*) )?fund flow with assessed custom" +
" " +
"fees$")
@Retryable(value = {AssertionError.class},
backoff = @Backoff(delayExpression = "#{@restPollingProperties.minBackoff.toMillis()}"),
maxAttemptsExpression = "#{@restPollingProperties.maxAttempts}")
public void verifyMirrorTokenFundFlow(int status, Integer tokenIndex,
List<MirrorAssessedCustomFee> assessedCustomFees) {
public void verifyMirrorTokenFundFlow(Integer tokenIndex, List<MirrorAssessedCustomFee> assessedCustomFees) {
TokenId tokenId = tokenIds.get(getIndexOrDefault(tokenIndex));
verifyTransactions(status, assessedCustomFees);
verifyTransactions(assessedCustomFees);
verifyToken(tokenId);
verifyTokenTransfers(tokenId);
}

@Then("^the mirror node REST API should return status (.*) for token (:?(.*) )?serial number (:?(.*) )?full flow$")
@Then("^the mirror node REST API should return the transaction for token (:?(.*) )?serial number (:?(.*) )?full " +
"flow$")
@Retryable(value = {AssertionError.class},
backoff = @Backoff(delayExpression = "#{@restPollingProperties.minBackoff.toMillis()}"),
maxAttemptsExpression = "#{@restPollingProperties.maxAttempts}")
public void verifyMirrorNftFundFlow(int status, Integer tokenIndex, Integer serialNumberIndex) {
public void verifyMirrorNftFundFlow(Integer tokenIndex, Integer serialNumberIndex) {
TokenId tokenId = tokenIds.get(getIndexOrDefault(tokenIndex));
Long serialNumber = tokenSerialNumbers.get(tokenId).get(getIndexOrDefault(serialNumberIndex));
verifyTransactions(status);
verifyTransactions();
verifyToken(tokenId);
verifyNft(tokenId, serialNumber);
verifyNftTransfers(tokenId, serialNumber);
Expand All @@ -383,7 +374,7 @@ public void verifyMirrorTokenUpdateFlow() {
verifyTokenUpdate(tokenIds.get(0));
}

@Then("the mirror node REST API should return status {int} for transaction {string}")
@Then("the mirror node REST API should return the transaction for transaction {string}")
@Retryable(value = {AssertionError.class},
backoff = @Backoff(delayExpression = "#{@restPollingProperties.minBackoff.toMillis()}"),
maxAttemptsExpression = "#{@restPollingProperties.maxAttempts}")
Expand All @@ -406,7 +397,7 @@ public void verifyMirrorRestTransactionIsPresent(int status, String transactionI
backoff = @Backoff(delayExpression = "#{@restPollingProperties.minBackoff.toMillis()}"),
maxAttemptsExpression = "#{@restPollingProperties.maxAttempts}")
public void verifyMirrorTokenWithCustomFeesSchedule(Integer tokenIndex) {
MirrorTransaction transaction = verifyTransactions(200);
MirrorTransaction transaction = verifyTransactions();

TokenId tokenId = tokenIds.get(getIndexOrDefault(tokenIndex));
verifyTokenWithCustomFeesSchedule(tokenId, transaction.getConsensusTimestamp());
Expand Down Expand Up @@ -560,11 +551,11 @@ private void transferNfts(TokenId tokenId, long serialNumber, ExpandedAccountId
assertThat(tokenClient.getTokenBalance(receiver, tokenId)).isEqualTo(startingBalance + 1);
}

private MirrorTransaction verifyTransactions(int status) {
return verifyTransactions(status, Collections.emptyList());
private MirrorTransaction verifyTransactions() {
return verifyTransactions(Collections.emptyList());
}

private MirrorTransaction verifyTransactions(int status, List<MirrorAssessedCustomFee> assessedCustomFees) {
private MirrorTransaction verifyTransactions(List<MirrorAssessedCustomFee> assessedCustomFees) {
String transactionId = networkTransactionResponse.getTransactionIdStringNoCheckSum();
MirrorTransactionsResponse mirrorTransactionsResponse = mirrorClient.getTransactions(transactionId);

Expand All @@ -577,10 +568,7 @@ private MirrorTransaction verifyTransactions(int status, List<MirrorAssessedCust
.isEqualTo(networkTransactionResponse.getValidStartString());
assertThat(mirrorTransaction.getAssessedCustomFees())
.containsExactlyInAnyOrderElementsOf(assessedCustomFees);

if (status == HttpStatus.OK.value()) {
assertThat(mirrorTransaction.getResult()).isEqualTo("SUCCESS");
}
assertThat(mirrorTransaction.getResult()).isEqualTo("SUCCESS");

return mirrorTransaction;
}
Expand Down
3 changes: 0 additions & 3 deletions hedera-mirror-test/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ hedera:
mirror:
test:
acceptance:
emitBackgroundMessages: false
messageTimeout: 20s
# grpc endpoint
mirrorNodeAddress: hcs.testnet.mirrornode.hedera.com:5600
network: testnet
# Do not use use 0.0.2 or 0.0.50 for operator to ensure crypto transfers are not waived
operatorId:
operatorKey:
rest:
# REST endpoint
baseUrl: http://testnet.mirrornode.hedera.com/api/v1
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
@accounts @fullsuite
Feature: Account Coverage Feature

@critical @release @acceptance @balancecheck
Scenario Outline: Validate account balance check scenario
When I request balance info for this account
Then the crypto balance should be greater than or equal to <threshold>
Examples:
| threshold |
| 4000000000 |

@createcryptoaccount
Scenario Outline: Create crypto account
When I create a new account with balance <amount> tℏ
Expand Down

This file was deleted.

Loading

0 comments on commit cd5d33e

Please sign in to comment.