github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/account_create_transaction_e2e_test.go (about)

     1  //go:build all || e2e
     2  // +build all e2e
     3  
     4  package hedera
     5  
     6  /*-
     7   *
     8   * Hedera Go SDK
     9   *
    10   * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
    11   *
    12   * Licensed under the Apache License, Version 2.0 (the "License");
    13   * you may not use this file except in compliance with the License.
    14   * You may obtain a copy of the License at
    15   *
    16   *      http://www.apache.org/licenses/LICENSE-2.0
    17   *
    18   * Unless required by applicable law or agreed to in writing, software
    19   * distributed under the License is distributed on an "AS IS" BASIS,
    20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    21   * See the License for the specific language governing permissions and
    22   * limitations under the License.
    23   *
    24   */
    25  
    26  import (
    27  	"fmt"
    28  	"testing"
    29  
    30  	"github.com/stretchr/testify/assert"
    31  
    32  	"github.com/stretchr/testify/require"
    33  )
    34  
    35  func TestIntegrationAccountCreateTransactionCanExecute(t *testing.T) {
    36  	t.Parallel()
    37  	env := NewIntegrationTestEnv(t)
    38  	newKey, err := PrivateKeyGenerateEd25519()
    39  	require.NoError(t, err)
    40  
    41  	newBalance := NewHbar(2)
    42  
    43  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
    44  
    45  	resp, err := NewAccountCreateTransaction().
    46  		SetKey(newKey).
    47  		SetNodeAccountIDs(env.NodeAccountIDs).
    48  		SetInitialBalance(newBalance).
    49  		SetMaxAutomaticTokenAssociations(100).
    50  		Execute(env.Client)
    51  
    52  	require.NoError(t, err)
    53  
    54  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
    55  	require.NoError(t, err)
    56  
    57  	accountID := *receipt.AccountID
    58  
    59  	tx, err := NewAccountDeleteTransaction().
    60  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
    61  		SetAccountID(accountID).
    62  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
    63  		SetTransactionID(TransactionIDGenerate(accountID)).
    64  		FreezeWith(env.Client)
    65  	require.NoError(t, err)
    66  
    67  	resp, err = tx.
    68  		Sign(newKey).
    69  		Execute(env.Client)
    70  	require.NoError(t, err)
    71  
    72  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
    73  	require.NoError(t, err)
    74  
    75  	err = CloseIntegrationTestEnv(env, nil)
    76  	require.NoError(t, err)
    77  }
    78  
    79  func TestIntegrationAccountCreateTransactionCanFreezeModify(t *testing.T) {
    80  	t.Parallel()
    81  	env := NewIntegrationTestEnv(t)
    82  
    83  	newKey, err := PrivateKeyGenerateEd25519()
    84  	require.NoError(t, err)
    85  
    86  	newBalance := NewHbar(1)
    87  
    88  	assert.Equal(t, HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
    89  
    90  	resp, err := NewAccountCreateTransaction().
    91  		SetKey(newKey.PublicKey()).
    92  		SetNodeAccountIDs(env.NodeAccountIDs).
    93  		SetMaxTransactionFee(NewHbar(2)).
    94  		SetInitialBalance(newBalance).
    95  		Execute(env.Client)
    96  
    97  	require.NoError(t, err)
    98  
    99  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   100  	require.NoError(t, err)
   101  
   102  	accountID := *receipt.AccountID
   103  
   104  	tx, err := NewAccountDeleteTransaction().
   105  		SetNodeAccountIDs(env.NodeAccountIDs).
   106  		SetAccountID(accountID).
   107  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   108  		SetMaxTransactionFee(NewHbar(1)).
   109  		SetTransactionID(TransactionIDGenerate(accountID)).
   110  		FreezeWith(env.Client)
   111  	require.NoError(t, err)
   112  
   113  	tx = tx.SetAccountID(accountID)
   114  
   115  	resp, err = tx.
   116  		Sign(newKey).
   117  		Execute(env.Client)
   118  	assert.Error(t, err)
   119  	if err != nil {
   120  		assert.Equal(t, "transaction is immutable; it has at least one signature or has been explicitly frozen", err.Error())
   121  	}
   122  
   123  	err = CloseIntegrationTestEnv(env, nil)
   124  	require.NoError(t, err)
   125  }
   126  
   127  func TestIntegrationAccountCreateTransactionNoKey(t *testing.T) {
   128  	t.Parallel()
   129  	env := NewIntegrationTestEnv(t)
   130  
   131  	resp, err := NewAccountCreateTransaction().
   132  		SetNodeAccountIDs(env.NodeAccountIDs).
   133  		Execute(env.Client)
   134  	assert.Error(t, err)
   135  	if err != nil {
   136  		assert.Equal(t, fmt.Sprintf("exceptional precheck status KEY_REQUIRED received for transaction %s", resp.TransactionID), err.Error())
   137  	}
   138  
   139  	err = CloseIntegrationTestEnv(env, nil)
   140  	require.NoError(t, err)
   141  }
   142  
   143  func TestIntegrationAccountCreateTransactionAddSignature(t *testing.T) {
   144  	t.Parallel()
   145  	env := NewIntegrationTestEnv(t)
   146  
   147  	newKey, err := PrivateKeyGenerateEd25519()
   148  	require.NoError(t, err)
   149  
   150  	resp, err := NewAccountCreateTransaction().
   151  		SetKey(newKey.PublicKey()).
   152  		SetNodeAccountIDs(env.NodeAccountIDs).
   153  		Execute(env.Client)
   154  	require.NoError(t, err)
   155  
   156  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   157  	require.NoError(t, err)
   158  
   159  	tx, err := NewAccountDeleteTransaction().
   160  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   161  		SetAccountID(*receipt.AccountID).
   162  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   163  		FreezeWith(env.Client)
   164  	require.NoError(t, err)
   165  	updateBytes, err := tx.ToBytes()
   166  	require.NoError(t, err)
   167  
   168  	sig1, err := newKey.SignTransaction(&tx.Transaction)
   169  	require.NoError(t, err)
   170  
   171  	tx2, err := TransactionFromBytes(updateBytes)
   172  	require.NoError(t, err)
   173  
   174  	if newTx, ok := tx2.(AccountDeleteTransaction); ok {
   175  		resp, err = newTx.AddSignature(newKey.PublicKey(), sig1).Execute(env.Client)
   176  		require.NoError(t, err)
   177  	}
   178  
   179  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   180  	require.NoError(t, err)
   181  
   182  	err = CloseIntegrationTestEnv(env, nil)
   183  	require.NoError(t, err)
   184  }
   185  
   186  func DisabledTestIntegrationAccountCreateTransactionSetProxyAccountID(t *testing.T) {
   187  	t.Parallel()
   188  	env := NewIntegrationTestEnv(t)
   189  
   190  	newKey, err := PrivateKeyGenerateEd25519()
   191  	require.NoError(t, err)
   192  
   193  	newBalance := NewHbar(2)
   194  
   195  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   196  
   197  	resp, err := NewAccountCreateTransaction().
   198  		SetKey(newKey).
   199  		SetNodeAccountIDs(env.NodeAccountIDs).
   200  		SetInitialBalance(newBalance).
   201  		Execute(env.Client)
   202  
   203  	require.NoError(t, err)
   204  
   205  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   206  	require.NoError(t, err)
   207  
   208  	accountID := *receipt.AccountID
   209  
   210  	resp, err = NewAccountCreateTransaction().
   211  		SetKey(newKey).
   212  		SetNodeAccountIDs(env.NodeAccountIDs).
   213  		SetInitialBalance(newBalance).
   214  		SetProxyAccountID(accountID).
   215  		Execute(env.Client)
   216  
   217  	require.NoError(t, err)
   218  
   219  	receipt, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   220  	require.NoError(t, err)
   221  
   222  	accountID2 := *receipt.AccountID
   223  
   224  	info, err := NewAccountInfoQuery().
   225  		SetAccountID(accountID2).
   226  		SetNodeAccountIDs(env.NodeAccountIDs).
   227  		Execute(env.Client)
   228  	require.NoError(t, err)
   229  
   230  	assert.Equal(t, accountID.String(), info.ProxyAccountID.String())
   231  
   232  	tx, err := NewAccountDeleteTransaction().
   233  		SetNodeAccountIDs(env.NodeAccountIDs).
   234  		SetAccountID(accountID).
   235  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   236  		SetTransactionID(TransactionIDGenerate(accountID)).
   237  		FreezeWith(env.Client)
   238  	require.NoError(t, err)
   239  
   240  	resp, err = tx.
   241  		Sign(newKey).
   242  		Execute(env.Client)
   243  	require.NoError(t, err)
   244  
   245  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   246  	require.NoError(t, err)
   247  
   248  	err = CloseIntegrationTestEnv(env, nil)
   249  	require.NoError(t, err)
   250  }
   251  
   252  func TestIntegrationAccountCreateTransactionNetwork(t *testing.T) {
   253  	t.Parallel()
   254  	env := NewIntegrationTestEnv(t)
   255  
   256  	newKey, err := PrivateKeyGenerateEd25519()
   257  	require.NoError(t, err)
   258  
   259  	newBalance := NewHbar(2)
   260  
   261  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   262  
   263  	resp, err := NewAccountCreateTransaction().
   264  		SetKey(newKey).
   265  		SetNodeAccountIDs(env.NodeAccountIDs).
   266  		SetInitialBalance(newBalance).
   267  		Execute(env.Client)
   268  
   269  	require.NoError(t, err)
   270  
   271  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   272  	require.NoError(t, err)
   273  
   274  	accountID := *receipt.AccountID
   275  	env.Client.SetAutoValidateChecksums(true)
   276  
   277  	accountIDString, err := accountID.ToStringWithChecksum(ClientForMainnet())
   278  	require.NoError(t, err)
   279  	accountID, err = AccountIDFromString(accountIDString)
   280  	require.NoError(t, err)
   281  
   282  	_, err = NewAccountDeleteTransaction().
   283  		SetNodeAccountIDs(env.NodeAccountIDs).
   284  		SetAccountID(accountID).
   285  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   286  		SetTransactionID(TransactionIDGenerate(accountID)).
   287  		FreezeWith(env.Client)
   288  	assert.Error(t, err)
   289  
   290  	env.Client.SetAutoValidateChecksums(false)
   291  
   292  	err = CloseIntegrationTestEnv(env, nil)
   293  	require.NoError(t, err)
   294  }
   295  
   296  func TestIntegrationAccountCreateTransactionWithAliasFromAdminKey(t *testing.T) {
   297  	// Tests the third row of this table
   298  	// https://github.com/hashgraph/hedera-improvement-proposal/blob/d39f740021d7da592524cffeaf1d749803798e9a/HIP/hip-583.md#signatures
   299  	t.Parallel()
   300  	env := NewIntegrationTestEnv(t)
   301  
   302  	adminKey, err := PrivateKeyGenerateEcdsa()
   303  	require.NoError(t, err)
   304  
   305  	evmAddress := adminKey.PublicKey().ToEvmAddress()
   306  
   307  	// Create the admin account
   308  	_, err = NewAccountCreateTransaction().
   309  		SetKey(adminKey).
   310  		Execute(env.Client)
   311  	require.NoError(t, err)
   312  
   313  	resp, err := NewAccountCreateTransaction().
   314  		SetKey(adminKey).
   315  		SetAlias(evmAddress).
   316  		Execute(env.Client)
   317  	require.NoError(t, err)
   318  
   319  	receipt, err := resp.GetReceipt(env.Client)
   320  	require.NoError(t, err)
   321  
   322  	accountID := *receipt.AccountID
   323  
   324  	info, err := NewAccountInfoQuery().
   325  		SetAccountID(accountID).
   326  		Execute(env.Client)
   327  	require.NoError(t, err)
   328  
   329  	assert.NotEmpty(t, info.AccountID)
   330  	assert.Equal(t, evmAddress, info.ContractAccountID)
   331  	assert.Equal(t, adminKey.PublicKey(), info.Key)
   332  
   333  	err = CloseIntegrationTestEnv(env, nil)
   334  	require.NoError(t, err)
   335  }
   336  
   337  func TestIntegrationAccountCreateTransactionWithAliasFromAdminKeyWithReceiverSigRequired(t *testing.T) {
   338  	// Tests the fourth row of this table
   339  	// https://github.com/hashgraph/hedera-improvement-proposal/blob/d39f740021d7da592524cffeaf1d749803798e9a/HIP/hip-583.md#signatures
   340  	t.Parallel()
   341  	env := NewIntegrationTestEnv(t)
   342  
   343  	adminKey, err := PrivateKeyGenerateEcdsa()
   344  	require.NoError(t, err)
   345  
   346  	evmAddress := adminKey.PublicKey().ToEvmAddress()
   347  
   348  	// Create the admin account
   349  	_, err = NewAccountCreateTransaction().
   350  		SetKey(adminKey).
   351  		Execute(env.Client)
   352  	require.NoError(t, err)
   353  
   354  	frozenTxn, err := NewAccountCreateTransaction().
   355  		SetReceiverSignatureRequired(true).
   356  		SetKey(adminKey).
   357  		SetAlias(evmAddress).
   358  		FreezeWith(env.Client)
   359  	require.NoError(t, err)
   360  
   361  	resp, err := frozenTxn.Sign(adminKey).Execute(env.Client)
   362  	require.NoError(t, err)
   363  
   364  	receipt, err := resp.GetReceipt(env.Client)
   365  	require.NoError(t, err)
   366  
   367  	accountID := *receipt.AccountID
   368  
   369  	info, err := NewAccountInfoQuery().
   370  		SetAccountID(accountID).
   371  		Execute(env.Client)
   372  	require.NoError(t, err)
   373  
   374  	assert.NotEmpty(t, info.AccountID)
   375  	assert.Equal(t, evmAddress, info.ContractAccountID)
   376  	assert.Equal(t, adminKey.PublicKey(), info.Key)
   377  
   378  	err = CloseIntegrationTestEnv(env, nil)
   379  	require.NoError(t, err)
   380  }
   381  
   382  func TestIntegrationAccountCreateTransactionWithAliasFromAdminKeyWithReceiverSigRequiredWithoutSignature(t *testing.T) {
   383  	// Tests the fourth row of this table
   384  	// https://github.com/hashgraph/hedera-improvement-proposal/blob/d39f740021d7da592524cffeaf1d749803798e9a/HIP/hip-583.md#signatures
   385  	t.Parallel()
   386  	env := NewIntegrationTestEnv(t)
   387  
   388  	adminKey, err := PrivateKeyGenerateEcdsa()
   389  	require.NoError(t, err)
   390  
   391  	evmAddress := adminKey.PublicKey().ToEvmAddress()
   392  
   393  	// Create the admin account
   394  	_, err = NewAccountCreateTransaction().
   395  		SetKey(adminKey).
   396  		Execute(env.Client)
   397  	require.NoError(t, err)
   398  
   399  	resp, err := NewAccountCreateTransaction().
   400  		SetReceiverSignatureRequired(true).
   401  		SetKey(adminKey).
   402  		SetAlias(evmAddress).
   403  		Execute(env.Client)
   404  	require.NoError(t, err)
   405  
   406  	_, err = resp.GetReceipt(env.Client)
   407  	assert.Error(t, err)
   408  	if err != nil {
   409  		assert.Equal(t, "exceptional receipt status: INVALID_SIGNATURE", err.Error())
   410  	}
   411  
   412  	err = CloseIntegrationTestEnv(env, nil)
   413  	require.NoError(t, err)
   414  }
   415  
   416  func TestIntegrationAccountCreateTransactionWithAlias(t *testing.T) {
   417  	// Tests the fifth row of this table
   418  	// https://github.com/hashgraph/hedera-improvement-proposal/blob/d39f740021d7da592524cffeaf1d749803798e9a/HIP/hip-583.md#signatures
   419  	t.Parallel()
   420  	env := NewIntegrationTestEnv(t)
   421  
   422  	adminKey, err := PrivateKeyGenerateEd25519()
   423  	require.NoError(t, err)
   424  
   425  	// Create the admin account
   426  	_, err = NewAccountCreateTransaction().
   427  		SetKey(adminKey).
   428  		Execute(env.Client)
   429  	require.NoError(t, err)
   430  
   431  	key, err := PrivateKeyGenerateEcdsa()
   432  	evmAddress := key.PublicKey().ToEvmAddress()
   433  
   434  	tx, err := NewAccountCreateTransaction().
   435  		SetKey(adminKey).
   436  		SetAlias(evmAddress).
   437  		FreezeWith(env.Client)
   438  	require.NoError(t, err)
   439  
   440  	resp, err := tx.
   441  		Sign(key).
   442  		Execute(env.Client)
   443  	require.NoError(t, err)
   444  
   445  	receipt, err := resp.GetReceipt(env.Client)
   446  	require.NoError(t, err)
   447  
   448  	accountID := *receipt.AccountID
   449  
   450  	info, err := NewAccountInfoQuery().
   451  		SetAccountID(accountID).
   452  		Execute(env.Client)
   453  	require.NoError(t, err)
   454  
   455  	assert.NotEmpty(t, info.AccountID)
   456  	assert.Equal(t, evmAddress, info.ContractAccountID)
   457  	assert.Equal(t, adminKey.PublicKey(), info.Key)
   458  
   459  	err = CloseIntegrationTestEnv(env, nil)
   460  	require.NoError(t, err)
   461  }
   462  
   463  func TestIntegrationAccountCreateTransactionWithAliasWithoutSignature(t *testing.T) {
   464  	t.Parallel()
   465  	env := NewIntegrationTestEnv(t)
   466  
   467  	adminKey, err := PrivateKeyGenerateEd25519()
   468  	require.NoError(t, err)
   469  
   470  	// Create the admin account
   471  	_, err = NewAccountCreateTransaction().
   472  		SetKey(adminKey).
   473  		Execute(env.Client)
   474  	require.NoError(t, err)
   475  
   476  	key, err := PrivateKeyGenerateEcdsa()
   477  	evmAddress := key.PublicKey().ToEvmAddress()
   478  
   479  	resp, err := NewAccountCreateTransaction().
   480  		SetKey(adminKey).
   481  		SetAlias(evmAddress).
   482  		Execute(env.Client)
   483  	require.NoError(t, err)
   484  
   485  	_, err = resp.GetReceipt(env.Client)
   486  	assert.Error(t, err)
   487  	if err != nil {
   488  		assert.Equal(t, "exceptional receipt status: INVALID_SIGNATURE", err.Error())
   489  	}
   490  
   491  	err = CloseIntegrationTestEnv(env, nil)
   492  	require.NoError(t, err)
   493  }
   494  
   495  func TestIntegrationAccountCreateTransactionWithAliasWithReceiverSigRequired(t *testing.T) {
   496  	// Tests the sixth row of this table
   497  	// https://github.com/hashgraph/hedera-improvement-proposal/blob/d39f740021d7da592524cffeaf1d749803798e9a/HIP/hip-583.md#signatures
   498  	t.Parallel()
   499  	env := NewIntegrationTestEnv(t)
   500  
   501  	adminKey, err := PrivateKeyGenerateEd25519()
   502  	require.NoError(t, err)
   503  
   504  	// Create the admin account
   505  	_, err = NewAccountCreateTransaction().
   506  		SetKey(adminKey).
   507  		Execute(env.Client)
   508  	require.NoError(t, err)
   509  
   510  	key, err := PrivateKeyGenerateEcdsa()
   511  	evmAddress := key.PublicKey().ToEvmAddress()
   512  
   513  	frozenTxn, err := NewAccountCreateTransaction().
   514  		SetReceiverSignatureRequired(true).
   515  		SetKey(adminKey).
   516  		SetAlias(evmAddress).
   517  		FreezeWith(env.Client)
   518  	require.NoError(t, err)
   519  
   520  	resp, err := frozenTxn.
   521  		Sign(key).
   522  		Sign(adminKey).
   523  		Execute(env.Client)
   524  	require.NoError(t, err)
   525  
   526  	receipt, err := resp.GetReceipt(env.Client)
   527  	require.NoError(t, err)
   528  
   529  	accountID := *receipt.AccountID
   530  
   531  	info, err := NewAccountInfoQuery().
   532  		SetAccountID(accountID).
   533  		Execute(env.Client)
   534  	require.NoError(t, err)
   535  
   536  	assert.NotEmpty(t, info.AccountID)
   537  	assert.Equal(t, evmAddress, info.ContractAccountID)
   538  	assert.Equal(t, adminKey.PublicKey(), info.Key)
   539  
   540  	err = CloseIntegrationTestEnv(env, nil)
   541  	require.NoError(t, err)
   542  }
   543  
   544  func TestIntegrationAccountCreateTransactionWithAliasWithReceiverSigRequiredWithoutSignature(t *testing.T) {
   545  	t.Parallel()
   546  	env := NewIntegrationTestEnv(t)
   547  
   548  	adminKey, err := PrivateKeyGenerateEd25519()
   549  	require.NoError(t, err)
   550  
   551  	// Create the admin account
   552  	_, err = NewAccountCreateTransaction().
   553  		SetKey(adminKey).
   554  		Execute(env.Client)
   555  	require.NoError(t, err)
   556  
   557  	key, err := PrivateKeyGenerateEcdsa()
   558  	evmAddress := key.PublicKey().ToEvmAddress()
   559  
   560  	frozenTxn, err := NewAccountCreateTransaction().
   561  		SetReceiverSignatureRequired(true).
   562  		SetKey(adminKey).
   563  		SetAlias(evmAddress).
   564  		FreezeWith(env.Client)
   565  	require.NoError(t, err)
   566  
   567  	resp, err := frozenTxn.
   568  		Sign(key).
   569  		Execute(env.Client)
   570  	require.NoError(t, err)
   571  
   572  	_, err = resp.GetReceipt(env.Client)
   573  	assert.Error(t, err)
   574  	if err != nil {
   575  		assert.Equal(t, "exceptional receipt status: INVALID_SIGNATURE", err.Error())
   576  	}
   577  
   578  	err = CloseIntegrationTestEnv(env, nil)
   579  	require.NoError(t, err)
   580  }
   581  
   582  func TestIntegrationSerializeTransactionWithoutNodeAccountIdDeserialiseAndExecute(t *testing.T) {
   583  	t.Parallel()
   584  	env := NewIntegrationTestEnv(t)
   585  
   586  	newKey, err := PrivateKeyGenerateEd25519()
   587  	require.NoError(t, err)
   588  
   589  	newBalance := NewHbar(2)
   590  
   591  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   592  
   593  	transactionOriginal := NewAccountCreateTransaction().
   594  		SetKey(newKey.PublicKey()).
   595  		SetInitialBalance(newBalance)
   596  
   597  	require.NoError(t, err)
   598  	resp, _ := transactionOriginal.ToBytes()
   599  
   600  	txFromBytes, err := TransactionFromBytes(resp)
   601  	require.NoError(t, err)
   602  
   603  	transaction := txFromBytes.(AccountCreateTransaction)
   604  	_, err = transaction.
   605  		SetNodeAccountIDs(env.NodeAccountIDs).
   606  		Execute(env.Client)
   607  
   608  	require.NoError(t, err)
   609  }
   610  
   611  func TestIntegrationAccountCreateTransactionSetStakingNodeID(t *testing.T) {
   612  	t.Parallel()
   613  	env := NewIntegrationTestEnv(t)
   614  	defer CloseIntegrationTestEnv(env, nil)
   615  
   616  	newKey, err := PrivateKeyGenerateEd25519()
   617  	require.NoError(t, err)
   618  
   619  	newBalance := NewHbar(2)
   620  
   621  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   622  
   623  	resp, err := NewAccountCreateTransaction().
   624  		SetKey(newKey).
   625  		SetNodeAccountIDs(env.NodeAccountIDs).
   626  		SetInitialBalance(newBalance).
   627  		SetStakedAccountID(env.OperatorID).
   628  		SetStakedNodeID(0).
   629  		SetMaxAutomaticTokenAssociations(100).
   630  		Execute(env.Client)
   631  
   632  	require.NoError(t, err)
   633  
   634  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   635  	require.NoError(t, err)
   636  }