use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class AccountCreateIntegrationTest method canCreateAccountWithOnlyInitialBalanceAndKey.
@Test
@DisplayName("Can create account with only initial balance and key")
void canCreateAccountWithOnlyInitialBalanceAndKey() 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);
var info = new AccountInfoQuery().setAccountId(accountId).execute(testEnv.client);
assertThat(info.accountId).isEqualTo(accountId);
assertThat(info.isDeleted).isFalse();
assertThat(info.key.toString()).isEqualTo(key.getPublicKey().toString());
assertThat(info.balance).isEqualTo(new Hbar(1));
assertThat(info.autoRenewPeriod).isEqualTo(Duration.ofDays(90));
assertThat(info.proxyAccountId).isNull();
assertThat(info.proxyReceived).isEqualTo(Hbar.ZERO);
testEnv.close(accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class AccountDeleteIntegrationTest method canDeleteAccount.
@Test
@DisplayName("Can delete account")
void canDeleteAccount() 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);
var info = new AccountInfoQuery().setAccountId(accountId).execute(testEnv.client);
assertThat(info.accountId).isEqualTo(accountId);
assertThat(info.isDeleted).isFalse();
assertThat(info.key.toString()).isEqualTo(key.getPublicKey().toString());
assertThat(info.balance).isEqualTo(new Hbar(1));
assertThat(info.autoRenewPeriod).isEqualTo(Duration.ofDays(90));
assertThat(info.proxyAccountId).isNull();
assertThat(info.proxyReceived).isEqualTo(Hbar.ZERO);
testEnv.close(accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class AccountDeleteIntegrationTest method cannotDeleteAccountThatHasNotSignedTransaction.
@Test
@DisplayName("Cannot delete account that has not signed transaction")
void cannotDeleteAccountThatHasNotSignedTransaction() 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(ReceiptStatusException.class).isThrownBy(() -> {
new AccountDeleteTransaction().setAccountId(accountId).setTransferAccountId(testEnv.operatorId).execute(testEnv.client).getReceipt(testEnv.client);
}).withMessageContaining(Status.INVALID_SIGNATURE.toString());
testEnv.close(accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class LiveHashDeleteIntegrationTest method cannotDeleteLiveHashBecauseItsNotSupported.
@Test
@DisplayName("Cannot delete live hash because it's not supported")
void cannotDeleteLiveHashBecauseItsNotSupported() 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 LiveHashDeleteTransaction().setAccountId(accountId).setHash(HASH).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 ReceiptQueryIntegrationTest method getCostTransactionRecord.
@Test
@DisplayName("Can get Record cost")
@SuppressWarnings("UnusedVariable")
void getCostTransactionRecord() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var key = PrivateKey.generateED25519();
var response = new AccountCreateTransaction().setKey(key).execute(testEnv.client);
new TransactionReceiptQuery().setTransactionId(response.transactionId).execute(testEnv.client);
var recordQuery = new TransactionRecordQuery().setTransactionId(response.transactionId);
var cost = recordQuery.getCost(testEnv.client);
var record = recordQuery.execute(testEnv.client);
testEnv.close(record.receipt.accountId, key);
}
Aggregations