Search in sources :

Example 6 with TokenDissociateTransaction

use of com.hedera.hashgraph.sdk.TokenDissociateTransaction in project hedera-mirror-node by hashgraph.

the class TokenDissociateTransactionSupplierTest method createWithCustomData.

@Test
void createWithCustomData() {
    TokenDissociateTransactionSupplier tokenDissociateTransactionSupplier = new TokenDissociateTransactionSupplier();
    tokenDissociateTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
    tokenDissociateTransactionSupplier.setMaxTransactionFee(1);
    tokenDissociateTransactionSupplier.setTokenId(TOKEN_ID.toString());
    TokenDissociateTransaction actual = tokenDissociateTransactionSupplier.get();
    assertThat(actual).returns(ACCOUNT_ID, TokenDissociateTransaction::getAccountId).returns(ONE_TINYBAR, TokenDissociateTransaction::getMaxTransactionFee).returns(List.of(TOKEN_ID), TokenDissociateTransaction::getTokenIds);
}
Also used : TokenDissociateTransaction(com.hedera.hashgraph.sdk.TokenDissociateTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 7 with TokenDissociateTransaction

use of com.hedera.hashgraph.sdk.TokenDissociateTransaction in project hedera-mirror-node by hashgraph.

the class TokenDissociateTransactionSupplierTest method createWithMinimumData.

@Test
void createWithMinimumData() {
    TokenDissociateTransactionSupplier tokenDissociateTransactionSupplier = new TokenDissociateTransactionSupplier();
    tokenDissociateTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
    tokenDissociateTransactionSupplier.setTokenId(TOKEN_ID.toString());
    TokenDissociateTransaction actual = tokenDissociateTransactionSupplier.get();
    assertThat(actual).returns(ACCOUNT_ID, TokenDissociateTransaction::getAccountId).returns(MAX_TRANSACTION_FEE_HBAR, TokenDissociateTransaction::getMaxTransactionFee).returns(List.of(TOKEN_ID), TokenDissociateTransaction::getTokenIds);
}
Also used : TokenDissociateTransaction(com.hedera.hashgraph.sdk.TokenDissociateTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 8 with TokenDissociateTransaction

use of com.hedera.hashgraph.sdk.TokenDissociateTransaction in project hedera-sdk-java by hashgraph.

the class TokenDissociateIntegrationTest method cannotDissociateAccountFromTokenWhenAccountWasNotAssociatedWith.

@Test
@DisplayName("Cannot dissociate account from token when account was not associated with")
void cannotDissociateAccountFromTokenWhenAccountWasNotAssociatedWith() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var key = PrivateKey.generateED25519();
    var response = new AccountCreateTransaction().setKey(key).setInitialBalance(new Hbar(1)).execute(testEnv.client);
    var accountId = Objects.requireNonNull(response.getReceipt(testEnv.client).accountId);
    var tokenId = Objects.requireNonNull(new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setDecimals(3).setInitialSupply(1000000).setTreasuryAccountId(testEnv.operatorId).setAdminKey(testEnv.operatorKey).setFreezeKey(testEnv.operatorKey).setWipeKey(testEnv.operatorKey).setKycKey(testEnv.operatorKey).setSupplyKey(testEnv.operatorKey).setFreezeDefault(false).execute(testEnv.client).getReceipt(testEnv.client).tokenId);
    assertThatExceptionOfType(ReceiptStatusException.class).isThrownBy(() -> {
        new TokenDissociateTransaction().setAccountId(accountId).setTokenIds(Collections.singletonList(tokenId)).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
    }).withMessageContaining(Status.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT.toString());
    testEnv.close(tokenId, accountId, key);
}
Also used : TokenDissociateTransaction(com.hedera.hashgraph.sdk.TokenDissociateTransaction) Hbar(com.hedera.hashgraph.sdk.Hbar) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TokenDissociateTransaction (com.hedera.hashgraph.sdk.TokenDissociateTransaction)8 Test (org.junit.jupiter.api.Test)7 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)5 Hbar (com.hedera.hashgraph.sdk.Hbar)5 DisplayName (org.junit.jupiter.api.DisplayName)5 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)3 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)2 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)1 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)1