github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/token_transfer_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  	"github.com/stretchr/testify/require"
    32  )
    33  
    34  func TestIntegrationTokenTransferTransactionCanExecute(t *testing.T) {
    35  	t.Parallel()
    36  	env := NewIntegrationTestEnv(t)
    37  
    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  		SetNodeAccountIDs(env.NodeAccountIDs).
    47  		SetKey(newKey.PublicKey()).
    48  		SetInitialBalance(newBalance).
    49  		Execute(env.Client)
    50  	require.NoError(t, err)
    51  
    52  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
    53  	require.NoError(t, err)
    54  
    55  	accountID := *receipt.AccountID
    56  
    57  	tokenID, err := createFungibleToken(&env, func(transaction *TokenCreateTransaction) {
    58  		transaction.SetKycKey(env.Client.GetOperatorPublicKey())
    59  	})
    60  	require.NoError(t, err)
    61  
    62  	transaction, err := NewTokenAssociateTransaction().
    63  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
    64  		SetAccountID(accountID).
    65  		SetTokenIDs(tokenID).
    66  		FreezeWith(env.Client)
    67  	require.NoError(t, err)
    68  
    69  	resp, err = transaction.
    70  		Sign(newKey).
    71  		Execute(env.Client)
    72  	require.NoError(t, err)
    73  
    74  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
    75  	require.NoError(t, err)
    76  
    77  	resp, err = NewTokenGrantKycTransaction().
    78  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
    79  		SetAccountID(accountID).
    80  		SetTokenID(tokenID).
    81  		Execute(env.Client)
    82  	require.NoError(t, err)
    83  
    84  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
    85  	require.NoError(t, err)
    86  
    87  	resp, err = NewTransferTransaction().
    88  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
    89  		AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10).
    90  		AddTokenTransfer(tokenID, accountID, 10).
    91  		Execute(env.Client)
    92  	require.NoError(t, err)
    93  
    94  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
    95  	require.NoError(t, err)
    96  
    97  	_, err = NewAccountBalanceQuery().
    98  		SetAccountID(env.Client.GetOperatorAccountID()).
    99  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   100  		Execute(env.Client)
   101  	require.NoError(t, err)
   102  
   103  	// TODO assert.Contains(t, balance.Tokens.balances, tokenID.String())
   104  	// TODO amount := balance.Tokens.balances[tokenID.String()]
   105  	// TODO assert.Equal(t, uint64(999990), amount, "token transfer transaction failed")
   106  	resp, err = NewTokenWipeTransaction().
   107  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   108  		SetTokenID(tokenID).
   109  		SetAccountID(accountID).
   110  		SetAmount(10).
   111  		Execute(env.Client)
   112  	require.NoError(t, err)
   113  
   114  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   115  	require.NoError(t, err)
   116  
   117  	tx, err := NewAccountDeleteTransaction().
   118  		SetAccountID(accountID).
   119  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   120  		FreezeWith(env.Client)
   121  	require.NoError(t, err)
   122  
   123  	resp, err = tx.
   124  		Sign(newKey).
   125  		Execute(env.Client)
   126  	require.NoError(t, err)
   127  
   128  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   129  	require.NoError(t, err)
   130  
   131  	err = CloseIntegrationTestEnv(env, &tokenID)
   132  	require.NoError(t, err)
   133  }
   134  
   135  func TestIntegrationTokenTransferTransactionNotZeroSum(t *testing.T) {
   136  	t.Parallel()
   137  	env := NewIntegrationTestEnv(t)
   138  
   139  	newKey, err := PrivateKeyGenerateEd25519()
   140  	require.NoError(t, err)
   141  
   142  	newBalance := NewHbar(2)
   143  
   144  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   145  
   146  	resp, err := NewAccountCreateTransaction().
   147  		SetNodeAccountIDs(env.NodeAccountIDs).
   148  		SetKey(newKey.PublicKey()).
   149  		SetInitialBalance(newBalance).
   150  		Execute(env.Client)
   151  	require.NoError(t, err)
   152  
   153  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   154  	require.NoError(t, err)
   155  
   156  	accountID := *receipt.AccountID
   157  
   158  	tokenID, err := createFungibleToken(&env, func(transaction *TokenCreateTransaction) {
   159  		transaction.SetKycKey(env.Client.GetOperatorPublicKey())
   160  	})
   161  	require.NoError(t, err)
   162  
   163  	nodeID := resp.NodeID
   164  
   165  	transaction, err := NewTokenAssociateTransaction().
   166  		SetNodeAccountIDs([]AccountID{nodeID}).
   167  		SetAccountID(accountID).
   168  		SetTokenIDs(tokenID).
   169  		FreezeWith(env.Client)
   170  	require.NoError(t, err)
   171  
   172  	resp, err = transaction.
   173  		Sign(newKey).
   174  		Execute(env.Client)
   175  	require.NoError(t, err)
   176  
   177  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   178  	require.NoError(t, err)
   179  
   180  	resp, err = NewTokenGrantKycTransaction().
   181  		SetNodeAccountIDs([]AccountID{nodeID}).
   182  		SetAccountID(accountID).
   183  		SetTokenID(tokenID).
   184  		Execute(env.Client)
   185  	require.NoError(t, err)
   186  
   187  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   188  	require.NoError(t, err)
   189  
   190  	resp2, err := NewTransferTransaction().
   191  		SetNodeAccountIDs([]AccountID{nodeID}).
   192  		AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10).
   193  		Execute(env.Client)
   194  	assert.Error(t, err)
   195  	if err != nil {
   196  		assert.Equal(t, fmt.Sprintf("exceptional precheck status TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN received for transaction %s", resp2.TransactionID), err.Error())
   197  	}
   198  
   199  	resp, err = NewTokenWipeTransaction().
   200  		SetNodeAccountIDs([]AccountID{nodeID}).
   201  		SetTokenID(tokenID).
   202  		SetAccountID(accountID).
   203  		SetAmount(10).
   204  		Execute(env.Client)
   205  	require.NoError(t, err)
   206  
   207  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   208  	assert.Error(t, err)
   209  
   210  	tx, err := NewAccountDeleteTransaction().
   211  		SetAccountID(accountID).
   212  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   213  		FreezeWith(env.Client)
   214  	require.NoError(t, err)
   215  
   216  	resp, err = tx.
   217  		Sign(newKey).
   218  		Execute(env.Client)
   219  	require.NoError(t, err)
   220  
   221  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   222  	require.NoError(t, err)
   223  
   224  	err = CloseIntegrationTestEnv(env, &tokenID)
   225  	require.NoError(t, err)
   226  }
   227  
   228  func DisabledTestIntegrationNftTransferTransaction(t *testing.T) { // nolint
   229  	t.Parallel()
   230  	env := NewIntegrationTestEnv(t)
   231  
   232  	newKey, err := PrivateKeyGenerateEd25519()
   233  	require.NoError(t, err)
   234  
   235  	newBalance := NewHbar(2)
   236  
   237  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   238  
   239  	resp, err := NewAccountCreateTransaction().
   240  		SetNodeAccountIDs(env.NodeAccountIDs).
   241  		SetKey(newKey.PublicKey()).
   242  		SetInitialBalance(newBalance).
   243  		Execute(env.Client)
   244  	require.NoError(t, err)
   245  
   246  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   247  	require.NoError(t, err)
   248  
   249  	accountID := *receipt.AccountID
   250  
   251  	tokenID, err := createNft(&env)
   252  	require.NoError(t, err)
   253  
   254  	metaData := [][]byte{{50}, {50}}
   255  
   256  	mint, err := NewTokenMintTransaction().
   257  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   258  		SetTokenID(tokenID).
   259  		SetMetadatas(metaData).
   260  		Execute(env.Client)
   261  	require.NoError(t, err)
   262  
   263  	mintReceipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client)
   264  	require.NoError(t, err)
   265  
   266  	transaction, err := NewTokenAssociateTransaction().
   267  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   268  		SetAccountID(accountID).
   269  		SetTokenIDs(tokenID).
   270  		FreezeWith(env.Client)
   271  	require.NoError(t, err)
   272  
   273  	resp, err = transaction.
   274  		Sign(newKey).
   275  		Execute(env.Client)
   276  	require.NoError(t, err)
   277  
   278  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   279  	require.NoError(t, err)
   280  
   281  	resp, err = NewTokenGrantKycTransaction().
   282  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   283  		SetAccountID(accountID).
   284  		SetTokenID(tokenID).
   285  		Execute(env.Client)
   286  	require.NoError(t, err)
   287  
   288  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   289  	require.NoError(t, err)
   290  
   291  	resp, err = NewTransferTransaction().
   292  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   293  		AddNftTransfer(tokenID.Nft(mintReceipt.SerialNumbers[0]), env.OperatorID, accountID).
   294  		AddNftTransfer(tokenID.Nft(mintReceipt.SerialNumbers[1]), env.OperatorID, accountID).
   295  		Execute(env.Client)
   296  	require.NoError(t, err)
   297  
   298  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   299  	require.NoError(t, err)
   300  
   301  	info, err := NewTokenNftInfoQuery().
   302  		SetNftID(tokenID.Nft(mintReceipt.SerialNumbers[0])).
   303  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   304  		Execute(env.Client)
   305  	require.NoError(t, err)
   306  
   307  	assert.Equal(t, accountID.String(), info[0].AccountID.String())
   308  
   309  	info, err = NewTokenNftInfoQuery().
   310  		SetNftID(tokenID.Nft(mintReceipt.SerialNumbers[1])).
   311  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   312  		Execute(env.Client)
   313  	require.NoError(t, err)
   314  
   315  	assert.Equal(t, accountID.String(), info[0].AccountID.String())
   316  
   317  	resp, err = NewTokenWipeTransaction().
   318  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   319  		SetTokenID(tokenID).
   320  		SetAccountID(accountID).
   321  		SetSerialNumbers(mintReceipt.SerialNumbers).
   322  		Execute(env.Client)
   323  	require.NoError(t, err)
   324  
   325  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   326  	require.NoError(t, err)
   327  
   328  	tx, err := NewAccountDeleteTransaction().
   329  		SetAccountID(accountID).
   330  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   331  		FreezeWith(env.Client)
   332  	require.NoError(t, err)
   333  
   334  	resp, err = tx.
   335  		Sign(newKey).
   336  		Execute(env.Client)
   337  	require.NoError(t, err)
   338  
   339  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   340  	require.NoError(t, err)
   341  }
   342  
   343  func DisabledTestIntegrationTokenFeeScheduleUpdateRecursionDepthTransaction(t *testing.T) { // nolint
   344  	t.Parallel()
   345  	env := NewIntegrationTestEnv(t)
   346  
   347  	newKey, err := PrivateKeyGenerateEd25519()
   348  	require.NoError(t, err)
   349  
   350  	newBalance := NewHbar(10)
   351  
   352  	resp, err := NewAccountCreateTransaction().
   353  		SetNodeAccountIDs(env.NodeAccountIDs).
   354  		SetKey(newKey.PublicKey()).
   355  		SetInitialBalance(newBalance).
   356  		Execute(env.Client)
   357  	require.NoError(t, err)
   358  
   359  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   360  	require.NoError(t, err)
   361  
   362  	accountID := *receipt.AccountID
   363  
   364  	tokenID, err := createFungibleToken(&env)
   365  	require.NoError(t, err)
   366  
   367  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   368  	require.NoError(t, err)
   369  
   370  	customFee := CustomFixedFee{
   371  		CustomFee: CustomFee{
   372  			FeeCollectorAccountID: &env.OperatorID,
   373  		},
   374  		Amount:              100000000,
   375  		DenominationTokenID: nil,
   376  	}
   377  
   378  	resp, err = NewTokenFeeScheduleUpdateTransaction().
   379  		SetTokenID(tokenID).
   380  		SetCustomFees([]Fee{customFee}).
   381  		Execute(env.Client)
   382  	require.NoError(t, err)
   383  
   384  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   385  	require.NoError(t, err)
   386  
   387  	transaction, err := NewTokenAssociateTransaction().
   388  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   389  		SetAccountID(accountID).
   390  		SetTokenIDs(tokenID).
   391  		FreezeWith(env.Client)
   392  	require.NoError(t, err)
   393  
   394  	resp, err = transaction.
   395  		Sign(newKey).
   396  		Execute(env.Client)
   397  	require.NoError(t, err)
   398  
   399  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   400  	require.NoError(t, err)
   401  
   402  	resp, err = NewTokenGrantKycTransaction().
   403  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   404  		SetAccountID(accountID).
   405  		SetTokenID(tokenID).
   406  		Execute(env.Client)
   407  	require.NoError(t, err)
   408  
   409  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   410  	require.NoError(t, err)
   411  
   412  	transferTx, err := NewTransferTransaction().
   413  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   414  		AddTokenTransfer(tokenID, accountID, -1).
   415  		AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), 1).
   416  		FreezeWith(env.Client)
   417  	require.NoError(t, err)
   418  
   419  	transferTx.Sign(newKey)
   420  
   421  	resp, err = transferTx.Execute(env.Client)
   422  	require.NoError(t, err)
   423  
   424  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   425  	assert.Error(t, err)
   426  	if err != nil {
   427  		assert.Equal(t, "exceptional receipt status: CUSTOM_FEE_CHARGING_EXCEEDED_MAX_RECURSION_DEPTH", err.Error())
   428  	}
   429  }
   430  
   431  func TestIntegrationTokenFeeScheduleUpdateHugeAmountTransaction(t *testing.T) {
   432  	t.Parallel()
   433  	env := NewIntegrationTestEnv(t)
   434  
   435  	newKey, err := PrivateKeyGenerateEd25519()
   436  	require.NoError(t, err)
   437  
   438  	newBalance := NewHbar(2)
   439  
   440  	resp, err := NewAccountCreateTransaction().
   441  		SetNodeAccountIDs(env.NodeAccountIDs).
   442  		SetKey(newKey.PublicKey()).
   443  		SetInitialBalance(newBalance).
   444  		Execute(env.Client)
   445  	require.NoError(t, err)
   446  
   447  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   448  	require.NoError(t, err)
   449  
   450  	accountID := *receipt.AccountID
   451  
   452  	tokenID, err := createFungibleToken(&env, func(transaction *TokenCreateTransaction) {
   453  		transaction.SetKycKey(env.Client.GetOperatorPublicKey())
   454  	})
   455  	require.NoError(t, err)
   456  
   457  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   458  	require.NoError(t, err)
   459  
   460  	customFee := CustomFixedFee{
   461  		CustomFee: CustomFee{
   462  			FeeCollectorAccountID: &env.OperatorID,
   463  		},
   464  		Amount:              1000,
   465  		DenominationTokenID: nil,
   466  	}
   467  
   468  	resp, err = NewTokenFeeScheduleUpdateTransaction().
   469  		SetTokenID(tokenID).
   470  		SetCustomFees([]Fee{customFee}).
   471  		Execute(env.Client)
   472  	require.NoError(t, err)
   473  
   474  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   475  	require.NoError(t, err)
   476  
   477  	transaction, err := NewTokenAssociateTransaction().
   478  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   479  		SetAccountID(accountID).
   480  		SetTokenIDs(tokenID).
   481  		FreezeWith(env.Client)
   482  	require.NoError(t, err)
   483  
   484  	resp, err = transaction.
   485  		Sign(newKey).
   486  		Execute(env.Client)
   487  	require.NoError(t, err)
   488  
   489  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   490  	require.NoError(t, err)
   491  
   492  	resp, err = NewTokenGrantKycTransaction().
   493  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   494  		SetAccountID(accountID).
   495  		SetTokenID(tokenID).
   496  		Execute(env.Client)
   497  	require.NoError(t, err)
   498  
   499  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   500  	require.NoError(t, err)
   501  
   502  	transferTx, err := NewTransferTransaction().
   503  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   504  		AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -5).
   505  		AddTokenTransfer(tokenID, accountID, 5).
   506  		FreezeWith(env.Client)
   507  	require.NoError(t, err)
   508  
   509  	resp, err = transferTx.Execute(env.Client)
   510  	require.NoError(t, err)
   511  
   512  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   513  	require.NoError(t, err)
   514  }
   515  
   516  func DisabledTestIntegrationTokenFeeScheduleUpdateHugeAmountOneTransaction(t *testing.T) {
   517  	t.Parallel()
   518  	env := NewIntegrationTestEnv(t)
   519  
   520  	newKey, err := PrivateKeyGenerateEd25519()
   521  	require.NoError(t, err)
   522  
   523  	newBalance := NewHbar(2)
   524  
   525  	resp, err := NewAccountCreateTransaction().
   526  		SetNodeAccountIDs(env.NodeAccountIDs).
   527  		SetKey(newKey.PublicKey()).
   528  		SetInitialBalance(newBalance).
   529  		Execute(env.Client)
   530  	require.NoError(t, err)
   531  
   532  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   533  	require.NoError(t, err)
   534  
   535  	accountID := *receipt.AccountID
   536  
   537  	resp, err = NewAccountCreateTransaction().
   538  		SetNodeAccountIDs(env.NodeAccountIDs).
   539  		SetKey(newKey.PublicKey()).
   540  		SetInitialBalance(newBalance).
   541  		Execute(env.Client)
   542  	require.NoError(t, err)
   543  
   544  	receipt, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   545  	require.NoError(t, err)
   546  
   547  	accountID2 := *receipt.AccountID
   548  
   549  	tokenID, err := createFungibleToken(&env)
   550  	require.NoError(t, err)
   551  
   552  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   553  	require.NoError(t, err)
   554  
   555  	customFee := CustomFixedFee{
   556  		CustomFee: CustomFee{
   557  			FeeCollectorAccountID: &accountID2,
   558  		},
   559  		Amount:              1000,
   560  		DenominationTokenID: nil,
   561  	}
   562  
   563  	resp, err = NewTokenFeeScheduleUpdateTransaction().
   564  		SetTokenID(tokenID).
   565  		SetCustomFees([]Fee{customFee}).
   566  		Execute(env.Client)
   567  	require.NoError(t, err)
   568  
   569  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   570  	require.NoError(t, err)
   571  
   572  	transaction, err := NewTokenAssociateTransaction().
   573  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   574  		SetAccountID(accountID).
   575  		SetTokenIDs(tokenID).
   576  		FreezeWith(env.Client)
   577  	require.NoError(t, err)
   578  
   579  	resp, err = transaction.
   580  		Sign(newKey).
   581  		Execute(env.Client)
   582  	require.NoError(t, err)
   583  
   584  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   585  	require.NoError(t, err)
   586  
   587  	resp, err = NewTokenGrantKycTransaction().
   588  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   589  		SetAccountID(accountID).
   590  		SetTokenID(tokenID).
   591  		Execute(env.Client)
   592  	require.NoError(t, err)
   593  
   594  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   595  	require.NoError(t, err)
   596  
   597  	transferTx, err := NewTransferTransaction().
   598  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   599  		AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -5).
   600  		AddTokenTransfer(tokenID, accountID, 5).
   601  		FreezeWith(env.Client)
   602  	require.NoError(t, err)
   603  
   604  	resp, err = transferTx.Execute(env.Client)
   605  	require.NoError(t, err)
   606  
   607  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   608  	require.NoError(t, err)
   609  }
   610  
   611  func TestIntegrationNftTransferTransactionAccountAmountTransfersOnlyForFungibleCommon(t *testing.T) {
   612  	t.Parallel()
   613  	env := NewIntegrationTestEnv(t)
   614  
   615  	newKey, err := PrivateKeyGenerateEd25519()
   616  	require.NoError(t, err)
   617  
   618  	newBalance := NewHbar(2)
   619  
   620  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   621  
   622  	resp, err := NewAccountCreateTransaction().
   623  		SetNodeAccountIDs(env.NodeAccountIDs).
   624  		SetKey(newKey.PublicKey()).
   625  		SetInitialBalance(newBalance).
   626  		Execute(env.Client)
   627  	require.NoError(t, err)
   628  
   629  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   630  	require.NoError(t, err)
   631  
   632  	accountID := *receipt.AccountID
   633  
   634  	tokenID, err := createNft(&env, func(transaction *TokenCreateTransaction) {
   635  		transaction.SetKycKey(env.Client.GetOperatorPublicKey())
   636  	})
   637  	require.NoError(t, err)
   638  
   639  	transaction, err := NewTokenAssociateTransaction().
   640  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   641  		SetAccountID(accountID).
   642  		SetTokenIDs(tokenID).
   643  		FreezeWith(env.Client)
   644  	require.NoError(t, err)
   645  
   646  	resp, err = transaction.
   647  		Sign(newKey).
   648  		Execute(env.Client)
   649  	require.NoError(t, err)
   650  
   651  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   652  	require.NoError(t, err)
   653  
   654  	resp, err = NewTokenGrantKycTransaction().
   655  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   656  		SetAccountID(accountID).
   657  		SetTokenID(tokenID).
   658  		Execute(env.Client)
   659  	require.NoError(t, err)
   660  
   661  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   662  	require.NoError(t, err)
   663  
   664  	resp, err = NewTransferTransaction().
   665  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   666  		AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10).
   667  		AddTokenTransfer(tokenID, accountID, 10).
   668  		Execute(env.Client)
   669  	require.NoError(t, err)
   670  
   671  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   672  	assert.Error(t, err)
   673  	if err != nil {
   674  		assert.Equal(t, "exceptional receipt status: ACCOUNT_AMOUNT_TRANSFERS_ONLY_ALLOWED_FOR_FUNGIBLE_COMMON", err.Error())
   675  	}
   676  
   677  	resp, err = NewTokenWipeTransaction().
   678  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   679  		SetTokenID(tokenID).
   680  		SetAccountID(accountID).
   681  		SetAmount(10).
   682  		Execute(env.Client)
   683  	require.NoError(t, err)
   684  
   685  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   686  	assert.Error(t, err)
   687  	if err != nil {
   688  		assert.Equal(t, "exceptional receipt status: INVALID_WIPING_AMOUNT", err.Error())
   689  	}
   690  
   691  	tx, err := NewAccountDeleteTransaction().
   692  		SetAccountID(accountID).
   693  		SetTransferAccountID(env.Client.GetOperatorAccountID()).
   694  		FreezeWith(env.Client)
   695  	require.NoError(t, err)
   696  
   697  	resp, err = tx.
   698  		Sign(newKey).
   699  		Execute(env.Client)
   700  	require.NoError(t, err)
   701  
   702  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   703  	require.NoError(t, err)
   704  
   705  	err = CloseIntegrationTestEnv(env, &tokenID)
   706  	require.NoError(t, err)
   707  }
   708  
   709  func DisabledTestIntegrationNftAccountStillOwnsNfts(t *testing.T) { // nolint
   710  	t.Parallel()
   711  	env := NewIntegrationTestEnv(t)
   712  
   713  	newKey, err := PrivateKeyGenerateEd25519()
   714  	require.NoError(t, err)
   715  
   716  	newBalance := NewHbar(2)
   717  
   718  	assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
   719  
   720  	resp, err := NewAccountCreateTransaction().
   721  		SetNodeAccountIDs(env.NodeAccountIDs).
   722  		SetKey(newKey.PublicKey()).
   723  		SetInitialBalance(newBalance).
   724  		Execute(env.Client)
   725  	require.NoError(t, err)
   726  
   727  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   728  	require.NoError(t, err)
   729  
   730  	accountID := *receipt.AccountID
   731  
   732  	tokenID, err := createNft(&env)
   733  	require.NoError(t, err)
   734  
   735  	metaData := [][]byte{{50}, {50}}
   736  
   737  	transaction, err := NewTokenAssociateTransaction().
   738  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   739  		SetAccountID(accountID).
   740  		SetTokenIDs(tokenID).
   741  		FreezeWith(env.Client)
   742  	require.NoError(t, err)
   743  
   744  	resp, err = transaction.
   745  		Sign(newKey).
   746  		Execute(env.Client)
   747  	require.NoError(t, err)
   748  
   749  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   750  	require.NoError(t, err)
   751  
   752  	mint, err := NewTokenMintTransaction().
   753  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   754  		SetTokenID(tokenID).
   755  		SetMetadatas(metaData).
   756  		Execute(env.Client)
   757  	require.NoError(t, err)
   758  
   759  	mintReceipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client)
   760  	require.NoError(t, err)
   761  
   762  	resp, err = NewTokenGrantKycTransaction().
   763  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   764  		SetAccountID(accountID).
   765  		SetTokenID(tokenID).
   766  		Execute(env.Client)
   767  	require.NoError(t, err)
   768  
   769  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   770  	require.NoError(t, err)
   771  
   772  	resp, err = NewTransferTransaction().
   773  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   774  		AddNftTransfer(tokenID.Nft(mintReceipt.SerialNumbers[0]), env.OperatorID, accountID).
   775  		AddNftTransfer(tokenID.Nft(mintReceipt.SerialNumbers[1]), env.OperatorID, accountID).
   776  		Execute(env.Client)
   777  	require.NoError(t, err)
   778  
   779  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   780  	require.NoError(t, err)
   781  
   782  	info, err := NewTokenNftInfoQuery().
   783  		ByNftID(tokenID.Nft(mintReceipt.SerialNumbers[0])).
   784  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   785  		Execute(env.Client)
   786  	require.NoError(t, err)
   787  
   788  	assert.Equal(t, accountID.String(), info[0].AccountID.String())
   789  
   790  	info, err = NewTokenNftInfoQuery().
   791  		ByNftID(tokenID.Nft(mintReceipt.SerialNumbers[1])).
   792  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   793  		Execute(env.Client)
   794  	require.NoError(t, err)
   795  
   796  	assert.Equal(t, accountID.String(), info[0].AccountID.String())
   797  
   798  	tx, err := NewAccountDeleteTransaction().
   799  		SetAccountID(accountID).
   800  		FreezeWith(env.Client)
   801  	require.NoError(t, err)
   802  
   803  	resp, err = tx.
   804  		Sign(newKey).
   805  		Execute(env.Client)
   806  	require.NoError(t, err)
   807  
   808  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   809  	require.NoError(t, err)
   810  }
   811  
   812  func TestIntegrationTokenFeeScheduleUpdateTokenNotAssociatedToFeeCollector(t *testing.T) {
   813  	t.Parallel()
   814  	env := NewIntegrationTestEnv(t)
   815  
   816  	newKey, err := PrivateKeyGenerateEd25519()
   817  	require.NoError(t, err)
   818  
   819  	newBalance := NewHbar(2)
   820  
   821  	resp, err := NewAccountCreateTransaction().
   822  		SetNodeAccountIDs(env.NodeAccountIDs).
   823  		SetKey(newKey.PublicKey()).
   824  		SetInitialBalance(newBalance).
   825  		Execute(env.Client)
   826  	require.NoError(t, err)
   827  
   828  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   829  	require.NoError(t, err)
   830  
   831  	accountID := *receipt.AccountID
   832  
   833  	tokenID, err := createFungibleToken(&env, func(transaction *TokenCreateTransaction) {
   834  		transaction.SetKycKey(env.Client.GetOperatorPublicKey()).
   835  			SetFeeScheduleKey(env.Client.GetOperatorPublicKey())
   836  	})
   837  	require.NoError(t, err)
   838  
   839  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   840  	require.NoError(t, err)
   841  
   842  	resp, err = NewTokenFeeScheduleUpdateTransaction().
   843  		SetTokenID(tokenID).
   844  		SetCustomFees([]Fee{NewCustomFixedFee().
   845  			SetFeeCollectorAccountID(accountID).
   846  			SetAmount(1).
   847  			SetDenominatingTokenToSameToken()}).
   848  		Execute(env.Client)
   849  	require.NoError(t, err)
   850  
   851  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   852  	assert.Error(t, err)
   853  	if err != nil {
   854  		assert.Equal(t, "exceptional receipt status: INVALID_TOKEN_ID_IN_CUSTOM_FEES", err.Error())
   855  	}
   856  }
   857  
   858  func DisabledTestIntegrationTokenFeeScheduleUpdateCustomFeeChargingExceededMax(t *testing.T) { // nolint
   859  	t.Parallel()
   860  	env := NewIntegrationTestEnv(t)
   861  
   862  	newKey, err := PrivateKeyGenerateEd25519()
   863  	require.NoError(t, err)
   864  
   865  	newBalance := NewHbar(2)
   866  
   867  	resp, err := NewAccountCreateTransaction().
   868  		SetNodeAccountIDs(env.NodeAccountIDs).
   869  		SetKey(newKey.PublicKey()).
   870  		SetInitialBalance(newBalance).
   871  		Execute(env.Client)
   872  	require.NoError(t, err)
   873  
   874  	receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client)
   875  	require.NoError(t, err)
   876  
   877  	accountID := *receipt.AccountID
   878  
   879  	resp, err = NewAccountCreateTransaction().
   880  		SetNodeAccountIDs(env.NodeAccountIDs).
   881  		SetKey(newKey.PublicKey()).
   882  		SetInitialBalance(newBalance).
   883  		Execute(env.Client)
   884  	require.NoError(t, err)
   885  
   886  	receipt, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   887  	require.NoError(t, err)
   888  
   889  	accountID2 := *receipt.AccountID
   890  
   891  	resp, err = NewAccountCreateTransaction().
   892  		SetNodeAccountIDs(env.NodeAccountIDs).
   893  		SetKey(newKey.PublicKey()).
   894  		SetInitialBalance(newBalance).
   895  		Execute(env.Client)
   896  	require.NoError(t, err)
   897  
   898  	receipt, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   899  	require.NoError(t, err)
   900  
   901  	accountID3 := *receipt.AccountID
   902  
   903  	tokenID, err := createFungibleToken(&env)
   904  	require.NoError(t, err)
   905  
   906  	tokenID2, err := createFungibleToken(&env)
   907  	require.NoError(t, err)
   908  
   909  	tokenID3, err := createFungibleToken(&env)
   910  	require.NoError(t, err)
   911  
   912  	transaction, err := NewTokenAssociateTransaction().
   913  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   914  		SetAccountID(accountID).
   915  		SetTokenIDs(tokenID).
   916  		FreezeWith(env.Client)
   917  	require.NoError(t, err)
   918  
   919  	resp, err = transaction.
   920  		Sign(newKey).
   921  		Execute(env.Client)
   922  	require.NoError(t, err)
   923  
   924  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   925  	require.NoError(t, err)
   926  
   927  	transaction, err = NewTokenAssociateTransaction().
   928  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   929  		SetAccountID(accountID2).
   930  		SetTokenIDs(tokenID2).
   931  		FreezeWith(env.Client)
   932  	require.NoError(t, err)
   933  
   934  	resp, err = transaction.
   935  		Sign(newKey).
   936  		Execute(env.Client)
   937  	require.NoError(t, err)
   938  
   939  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   940  	require.NoError(t, err)
   941  
   942  	transaction, err = NewTokenAssociateTransaction().
   943  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
   944  		SetAccountID(accountID3).
   945  		SetTokenIDs(tokenID3).
   946  		FreezeWith(env.Client)
   947  	require.NoError(t, err)
   948  
   949  	resp, err = transaction.
   950  		Sign(newKey).
   951  		Execute(env.Client)
   952  	require.NoError(t, err)
   953  
   954  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   955  	require.NoError(t, err)
   956  
   957  	customFee := NewCustomFixedFee().SetDenominatingTokenToSameToken().SetAmount(1).SetFeeCollectorAccountID(accountID)
   958  
   959  	feeArray := make([]Fee, 0)
   960  
   961  	for i := 0; i < 10; i++ {
   962  		feeArray = append(feeArray, customFee)
   963  	}
   964  
   965  	resp, err = NewTokenFeeScheduleUpdateTransaction().
   966  		SetTokenID(tokenID).
   967  		SetCustomFees(feeArray).
   968  		Execute(env.Client)
   969  	require.NoError(t, err)
   970  
   971  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   972  	require.NoError(t, err)
   973  
   974  	customFee2 := NewCustomFixedFee().SetDenominatingTokenToSameToken().SetAmount(1).SetFeeCollectorAccountID(accountID2)
   975  
   976  	feeArray2 := make([]Fee, 0)
   977  
   978  	for i := 0; i < 10; i++ {
   979  		feeArray2 = append(feeArray2, customFee2)
   980  	}
   981  
   982  	resp, err = NewTokenFeeScheduleUpdateTransaction().
   983  		SetTokenID(tokenID2).
   984  		SetCustomFees(feeArray2).
   985  		Execute(env.Client)
   986  	require.NoError(t, err)
   987  
   988  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
   989  	require.NoError(t, err)
   990  
   991  	customFee3 := NewCustomFixedFee().SetDenominatingTokenToSameToken().SetAmount(1).SetFeeCollectorAccountID(accountID3)
   992  
   993  	feeArray3 := make([]Fee, 0)
   994  
   995  	for i := 0; i < 10; i++ {
   996  		feeArray3 = append(feeArray3, customFee3)
   997  	}
   998  
   999  	resp, err = NewTokenFeeScheduleUpdateTransaction().
  1000  		SetTokenID(tokenID3).
  1001  		SetCustomFees(feeArray3).
  1002  		Execute(env.Client)
  1003  	require.NoError(t, err)
  1004  
  1005  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
  1006  	require.NoError(t, err)
  1007  
  1008  	resp, err = NewTokenGrantKycTransaction().
  1009  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
  1010  		SetAccountID(accountID).
  1011  		SetTokenID(tokenID).
  1012  		Execute(env.Client)
  1013  	require.NoError(t, err)
  1014  
  1015  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
  1016  	require.NoError(t, err)
  1017  
  1018  	resp, err = NewTokenGrantKycTransaction().
  1019  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
  1020  		SetAccountID(accountID2).
  1021  		SetTokenID(tokenID2).
  1022  		Execute(env.Client)
  1023  	require.NoError(t, err)
  1024  
  1025  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
  1026  	require.NoError(t, err)
  1027  
  1028  	resp, err = NewTokenGrantKycTransaction().
  1029  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
  1030  		SetAccountID(accountID3).
  1031  		SetTokenID(tokenID3).
  1032  		Execute(env.Client)
  1033  	require.NoError(t, err)
  1034  
  1035  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
  1036  	require.NoError(t, err)
  1037  
  1038  	transferTx, err := NewTransferTransaction().
  1039  		SetNodeAccountIDs([]AccountID{resp.NodeID}).
  1040  		AddTokenTransfer(tokenID3, env.Client.GetOperatorAccountID(), -1).
  1041  		AddTokenTransfer(tokenID, accountID, 1).
  1042  		AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -1).
  1043  		AddTokenTransfer(tokenID2, accountID2, 1).
  1044  		AddTokenTransfer(tokenID2, env.Client.GetOperatorAccountID(), -1).
  1045  		AddTokenTransfer(tokenID3, accountID3, 1).
  1046  		FreezeWith(env.Client)
  1047  	require.NoError(t, err)
  1048  
  1049  	resp, err = transferTx.Execute(env.Client)
  1050  	require.NoError(t, err)
  1051  
  1052  	_, err = resp.SetValidateStatus(true).GetReceipt(env.Client)
  1053  	require.NoError(t, err)
  1054  }