Search in sources :

Example 26 with AccountCreateTransaction

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);
}
Also used : AccountInfoQuery(com.hedera.hashgraph.sdk.AccountInfoQuery) Hbar(com.hedera.hashgraph.sdk.Hbar) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 27 with AccountCreateTransaction

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);
}
Also used : AccountInfoQuery(com.hedera.hashgraph.sdk.AccountInfoQuery) Hbar(com.hedera.hashgraph.sdk.Hbar) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 28 with AccountCreateTransaction

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);
}
Also used : AccountDeleteTransaction(com.hedera.hashgraph.sdk.AccountDeleteTransaction) Hbar(com.hedera.hashgraph.sdk.Hbar) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 29 with AccountCreateTransaction

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);
}
Also used : LiveHashDeleteTransaction(com.hedera.hashgraph.sdk.LiveHashDeleteTransaction) Hbar(com.hedera.hashgraph.sdk.Hbar) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 30 with AccountCreateTransaction

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);
}
Also used : TransactionRecordQuery(com.hedera.hashgraph.sdk.TransactionRecordQuery) TransactionReceiptQuery(com.hedera.hashgraph.sdk.TransactionReceiptQuery) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)73 Hbar (com.hedera.hashgraph.sdk.Hbar)62 Test (org.junit.jupiter.api.Test)59 DisplayName (org.junit.jupiter.api.DisplayName)57 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)29 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)26 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)23 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)16 AccountId (com.hedera.hashgraph.sdk.AccountId)15 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)15 Var (com.google.errorprone.annotations.Var)12 Client (com.hedera.hashgraph.sdk.Client)12 TokenGrantKycTransaction (com.hedera.hashgraph.sdk.TokenGrantKycTransaction)12 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)11 ScheduleInfoQuery (com.hedera.hashgraph.sdk.ScheduleInfoQuery)10 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)9 KeyList (com.hedera.hashgraph.sdk.KeyList)9 TokenWipeTransaction (com.hedera.hashgraph.sdk.TokenWipeTransaction)8 AccountInfoQuery (com.hedera.hashgraph.sdk.AccountInfoQuery)7 PublicKey (com.hedera.hashgraph.sdk.PublicKey)7