use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class TokenFreezeIntegrationTest method cannotFreezeAccountOnTokenWhenTokenIDIsNotSet.
@Test
@DisplayName("Cannot freeze account on token when token ID is not set")
void cannotFreezeAccountOnTokenWhenTokenIDIsNotSet() 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);
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new TokenFreezeTransaction().setAccountId(accountId).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
}).withMessageContaining(Status.INVALID_TOKEN_ID.toString());
testEnv.close(accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class TokenFreezeIntegrationTest method cannotFreezeAccountOnTokenWhenAccountWasNotAssociatedWith.
@Test
@DisplayName("Cannot freeze account on token when account was not associated with")
void cannotFreezeAccountOnTokenWhenAccountWasNotAssociatedWith() 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 TokenFreezeTransaction().setAccountId(accountId).setTokenId(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);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class TokenGrantKycIntegrationTest method canGrantKycAccountWithToken.
@Test
@DisplayName("Can grant kyc to account with token")
void canGrantKycAccountWithToken() 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);
new TokenAssociateTransaction().setAccountId(accountId).setTokenIds(Collections.singletonList(tokenId)).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
new TokenGrantKycTransaction().setAccountId(accountId).setTokenId(tokenId).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
testEnv.close(tokenId, accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class TokenGrantKycIntegrationTest method cannotGrantKycToAccountOnTokenWhenTokenIDIsNotSet.
@Test
@DisplayName("Cannot grant kyc to account on token when token ID is not set")
void cannotGrantKycToAccountOnTokenWhenTokenIDIsNotSet() throws Exception {
var testEnv = new IntegrationTestEnv(1);
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);
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new TokenGrantKycTransaction().setAccountId(accountId).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
}).withMessageContaining(Status.INVALID_TOKEN_ID.toString());
testEnv.close(accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class TokenGrantKycIntegrationTest method cannotGrantKycToAccountOnTokenWhenAccountWasNotAssociatedWith.
@Test
@DisplayName("Cannot grant kyc to account on token when account was not associated with")
void cannotGrantKycToAccountOnTokenWhenAccountWasNotAssociatedWith() 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 TokenGrantKycTransaction().setAccountId(accountId).setTokenId(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);
}
Aggregations