use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class TokenTransferIntegrationTest method tokenTransferTest.
@Test
@DisplayName("Can transfer tokens")
void tokenTransferTest() throws Exception {
var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
var key = PrivateKey.generateED25519();
@Var TransactionResponse response = new AccountCreateTransaction().setKey(key).setInitialBalance(new Hbar(1)).execute(testEnv.client);
var accountId = response.getReceipt(testEnv.client).accountId;
assertThat(accountId).isNotNull();
response = 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);
var tokenId = response.getReceipt(testEnv.client).tokenId;
assertThat(tokenId).isNotNull();
new TokenAssociateTransaction().setAccountId(accountId).setTokenIds(Collections.singletonList(tokenId)).freezeWith(testEnv.client).signWithOperator(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
new TokenGrantKycTransaction().setAccountId(accountId).setTokenId(tokenId).execute(testEnv.client).getReceipt(testEnv.client);
new TransferTransaction().addTokenTransfer(tokenId, testEnv.operatorId, -10).addTokenTransfer(tokenId, accountId, 10).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 TokenUnfreezeIntegrationTest method cannotUnfreezeAccountOnTokenWhenAccountWasNotAssociatedWith.
@Test
@DisplayName("Cannot unfreeze account on token when account was not associated with")
void cannotUnfreezeAccountOnTokenWhenAccountWasNotAssociatedWith() 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 TokenUnfreezeTransaction().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 TokenUnfreezeIntegrationTest method cannotUnfreezeAccountOnTokenWhenTokenIDIsNotSet.
@Test
@DisplayName("Cannot unfreeze account on token when token ID is not set")
void cannotUnfreezeAccountOnTokenWhenTokenIDIsNotSet() 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 TokenUnfreezeTransaction().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 LiveHashAddIntegrationTest method cannotCreateLiveHashBecauseItsNotSupported.
@Test
@DisplayName("Cannot create live hash because it's not supported")
void cannotCreateLiveHashBecauseItsNotSupported() 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 LiveHashAddTransaction().setAccountId(accountId).setDuration(Duration.ofDays(30)).setHash(HASH).setKeys(key).execute(testEnv.client).getReceipt(testEnv.client);
}).withMessageContaining(Status.NOT_SUPPORTED.toString());
testEnv.close(accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class ScheduleCreateIntegrationTest method canCreateSchedule.
@Test
@Disabled
@DisplayName("Can create schedule")
void canCreateSchedule() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var key = PrivateKey.generateED25519();
var transaction = new AccountCreateTransaction().setKey(key).setInitialBalance(new Hbar(10));
var response = new ScheduleCreateTransaction().setScheduledTransaction(transaction).setAdminKey(testEnv.operatorKey).setPayerAccountId(testEnv.operatorId).execute(testEnv.client);
var scheduleId = Objects.requireNonNull(response.getReceipt(testEnv.client).scheduleId);
var info = new ScheduleInfoQuery().setScheduleId(scheduleId).execute(testEnv.client);
assertThat(info.executedAt).isNotNull();
testEnv.close();
}
Aggregations