Search in sources :

Example 6 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class TokenFeature method associateRecipientWithToken.

@Given("^I associate a(?:n)? (?:existing|new) recipient account(?: (.*))? with token(?: (.*))?$")
public void associateRecipientWithToken(Integer recipientIndex, Integer tokenIndex) {
    ExpandedAccountId recipient;
    if (recipientIndex == null) {
        recipient = accountClient.createNewAccount(10_000_000);
        recipients.add(recipient);
    } else {
        recipient = recipients.get(recipientIndex);
    }
    associateWithToken(recipient, tokenIds.get(getIndexOrDefault(tokenIndex)));
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) Given(io.cucumber.java.en.Given)

Example 7 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class TokenFeature method cleanup.

@After
public void cleanup() {
    // dissociate all applicable accounts from token to reduce likelihood of max token association error
    for (TokenId tokenId : tokenIds) {
        // a nonzero balance will result in a TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES error
        // not possible to wipe a treasury account as it results in CANNOT_WIPE_TOKEN_TREASURY_ACCOUNT error
        // as a result to dissociate first delete token
        ExpandedAccountId admin = tokenClient.getSdkClient().getExpandedOperatorAccountId();
        try {
            tokenClient.delete(admin, tokenId);
            dissociateAccounts(tokenId, List.of(admin));
            dissociateAccounts(tokenId, recipients);
            dissociateAccounts(tokenId, senders);
        } catch (Exception ex) {
            log.warn("Error cleaning up token {} and associations error: {}", tokenId, ex);
        }
    }
    recipients.clear();
    senders.clear();
    tokenCustomFees.clear();
    tokenIds.clear();
    tokenSerialNumbers.clear();
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) TokenId(com.hedera.hashgraph.sdk.TokenId) ReceiptStatusException(com.hedera.hashgraph.sdk.ReceiptStatusException) After(io.cucumber.java.After)

Example 8 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class TokenFeature method transferTokensToSender.

@Then("^I transfer (.*) tokens (?:(.*) )?to sender(?: (.*))?$")
public void transferTokensToSender(int amount, Integer tokenIndex, Integer senderIndex) {
    ExpandedAccountId payer = tokenClient.getSdkClient().getExpandedOperatorAccountId();
    transferTokens(tokenIds.get(getIndexOrDefault(tokenIndex)), amount, payer, senders.get(getIndexOrDefault(senderIndex)).getAccountId());
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) Then(io.cucumber.java.en.Then)

Example 9 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class TokenFeature method updateTokenFeeSchedule.

@Given("I update token {int} with new custom fees schedule")
public void updateTokenFeeSchedule(int tokenIndex, List<CustomFee> customFees) {
    ExpandedAccountId admin = tokenClient.getSdkClient().getExpandedOperatorAccountId();
    TokenId tokenId = tokenIds.get(tokenIndex);
    networkTransactionResponse = tokenClient.updateTokenFeeSchedule(tokenId, admin, customFees);
    assertNotNull(networkTransactionResponse.getTransactionId());
    assertNotNull(networkTransactionResponse.getReceipt());
    tokenCustomFees.put(tokenId, customFees);
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) TokenId(com.hedera.hashgraph.sdk.TokenId) Given(io.cucumber.java.en.Given)

Example 10 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class AccountClient method getAccount.

public ExpandedAccountId getAccount(AccountNameEnum accountNameEnum) {
    // retrieve account, setting if it doesn't exist
    ExpandedAccountId accountId = accountMap.computeIfAbsent(accountNameEnum, x -> {
        try {
            return createNewAccount(SMALL_INITIAL_BALANCE, accountNameEnum);
        } catch (Exception e) {
            log.debug("Issue creating additional account: {}, ex: {}", accountNameEnum, e);
            return null;
        }
    });
    if (accountId == null) {
        throw new NetworkException("Null accountId retrieved from receipt");
    }
    long balance = getBalance(accountId);
    if (log.isDebugEnabled()) {
        log.debug("Retrieved Account: {}, {} w balance {}", accountId, accountNameEnum, balance);
    }
    return accountId;
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)

Aggregations

ExpandedAccountId (com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)20 Given (io.cucumber.java.en.Given)9 AccountId (com.hedera.hashgraph.sdk.AccountId)4 TokenId (com.hedera.hashgraph.sdk.TokenId)4 KeyList (com.hedera.hashgraph.sdk.KeyList)3 Then (io.cucumber.java.en.Then)3 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)2 ReceiptStatusException (com.hedera.hashgraph.sdk.ReceiptStatusException)2 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)2 When (io.cucumber.java.en.When)2 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)1 Hbar (com.hedera.hashgraph.sdk.Hbar)1 PublicKey (com.hedera.hashgraph.sdk.PublicKey)1 TokenUpdateTransaction (com.hedera.hashgraph.sdk.TokenUpdateTransaction)1 TopicId (com.hedera.hashgraph.sdk.TopicId)1 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)1 After (io.cucumber.java.After)1