github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/token_reject_transaction_e2e_test.go (about) 1 //go:build all || e2e 2 // +build all e2e 3 4 package hedera 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 "github.com/stretchr/testify/require" 11 ) 12 13 /*- 14 * 15 * Hedera Go SDK 16 * 17 * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC 18 * 19 * Licensed under the Apache License, Version 2.0 (the "License"); 20 * you may not use this file except in compliance with the License. 21 * You may obtain a copy of the License at 22 * 23 * http://www.apache.org/licenses/LICENSE-2.0 24 * 25 * Unless required by applicable law or agreed to in writing, software 26 * distributed under the License is distributed on an "AS IS" BASIS, 27 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 * See the License for the specific language governing permissions and 29 * limitations under the License. 30 * 31 */ 32 33 func TestIntegrationTokenRejectTransactionCanExecuteForFungibleToken(t *testing.T) { 34 t.Parallel() 35 env := NewIntegrationTestEnv(t) 36 37 // create fungible tokens with treasury 38 tokenID1, err := createFungibleToken(&env) 39 require.NoError(t, err) 40 tokenID2, err := createFungibleToken(&env) 41 require.NoError(t, err) 42 43 // create receiver account with auto associations 44 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 45 tx.SetMaxAutomaticTokenAssociations(100) 46 }) 47 require.NoError(t, err) 48 49 // transfer fts to the receiver 50 tx, err := NewTransferTransaction(). 51 AddTokenTransfer(tokenID1, env.Client.GetOperatorAccountID(), -10). 52 AddTokenTransfer(tokenID1, receiver, 10). 53 AddTokenTransfer(tokenID2, env.Client.GetOperatorAccountID(), -10). 54 AddTokenTransfer(tokenID2, receiver, 10). 55 Execute(env.Client) 56 require.NoError(t, err) 57 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 58 require.NoError(t, err) 59 60 // reject the token 61 frozenTxn, err := NewTokenRejectTransaction(). 62 SetOwnerID(receiver). 63 SetTokenIDs(tokenID1, tokenID2). 64 FreezeWith(env.Client) 65 require.NoError(t, err) 66 resp, err := frozenTxn.Sign(key).Execute(env.Client) 67 require.NoError(t, err) 68 69 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 70 require.NoError(t, err) 71 72 // verify the balance of the receiver is 0 73 tokenBalance, err := NewAccountBalanceQuery().SetAccountID(receiver).Execute(env.Client) 74 require.NoError(t, err) 75 assert.Zero(t, tokenBalance.Tokens.Get(tokenID1)) 76 assert.Zero(t, tokenBalance.Tokens.Get(tokenID2)) 77 78 // verify the tokens are transferred back to the treasury 79 tokenBalance, err = NewAccountBalanceQuery().SetAccountID(env.OperatorID).Execute(env.Client) 80 require.NoError(t, err) 81 assert.Equal(t, uint64(1_000_000), tokenBalance.Tokens.Get(tokenID1)) 82 assert.Equal(t, uint64(1_000_000), tokenBalance.Tokens.Get(tokenID2)) 83 } 84 85 func TestIntegrationTokenRejectTransactionCanExecuteForNFT(t *testing.T) { 86 t.Parallel() 87 env := NewIntegrationTestEnv(t) 88 89 // create nft collections with treasury 90 nftID1, err := createNft(&env) 91 require.NoError(t, err) 92 nftID2, err := createNft(&env) 93 require.NoError(t, err) 94 95 // mint 96 mint, err := NewTokenMintTransaction().SetTokenID(nftID1).SetMetadatas(mintMetadata).Execute(env.Client) 97 require.NoError(t, err) 98 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 99 require.NoError(t, err) 100 mint, err = NewTokenMintTransaction().SetTokenID(nftID2).SetMetadatas(mintMetadata).Execute(env.Client) 101 require.NoError(t, err) 102 receipt, err = mint.SetValidateStatus(true).GetReceipt(env.Client) 103 require.NoError(t, err) 104 105 serials := receipt.SerialNumbers 106 107 // create receiver account with auto associations 108 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 109 tx.SetMaxAutomaticTokenAssociations(100) 110 }) 111 require.NoError(t, err) 112 113 // transfer nfts to the receiver 114 tx, err := NewTransferTransaction(). 115 AddNftTransfer(nftID1.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 116 AddNftTransfer(nftID1.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 117 AddNftTransfer(nftID2.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 118 AddNftTransfer(nftID2.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 119 Execute(env.Client) 120 require.NoError(t, err) 121 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 122 require.NoError(t, err) 123 124 // reject one of the nfts 125 frozenTxn, err := NewTokenRejectTransaction().SetOwnerID(receiver).SetNftIDs(nftID1.Nft(serials[1]), nftID2.Nft(serials[1])).FreezeWith(env.Client) 126 require.NoError(t, err) 127 resp, err := frozenTxn.Sign(key).Execute(env.Client) 128 require.NoError(t, err) 129 130 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 131 require.NoError(t, err) 132 133 // verify the balance is decremented by 1 134 tokenBalance, err := NewAccountBalanceQuery().SetAccountID(receiver).Execute(env.Client) 135 require.NoError(t, err) 136 assert.Equal(t, uint64(1), tokenBalance.Tokens.Get(nftID1)) 137 assert.Equal(t, uint64(1), tokenBalance.Tokens.Get(nftID2)) 138 139 // verify the token is transferred back to the treasury 140 nftBalance, err := NewTokenNftInfoQuery().SetNftID(nftID1.Nft(serials[1])).Execute(env.Client) 141 require.NoError(t, err) 142 assert.Equal(t, env.OperatorID, nftBalance[0].AccountID) 143 144 nftBalance, err = NewTokenNftInfoQuery().SetNftID(nftID2.Nft(serials[1])).Execute(env.Client) 145 require.NoError(t, err) 146 assert.Equal(t, env.OperatorID, nftBalance[0].AccountID) 147 } 148 149 func TestIntegrationTokenRejectTransactionCanExecuteForFTAndNFTAtTheSameTime(t *testing.T) { 150 t.Parallel() 151 env := NewIntegrationTestEnv(t) 152 153 // create fungible tokens with treasury 154 tokenID1, err := createFungibleToken(&env) 155 require.NoError(t, err) 156 tokenID2, err := createFungibleToken(&env) 157 require.NoError(t, err) 158 159 // create nft collections with treasury 160 nftID1, err := createNft(&env) 161 require.NoError(t, err) 162 nftID2, err := createNft(&env) 163 require.NoError(t, err) 164 165 // mint 166 mint, err := NewTokenMintTransaction().SetTokenID(nftID1).SetMetadatas(mintMetadata).Execute(env.Client) 167 require.NoError(t, err) 168 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 169 require.NoError(t, err) 170 mint, err = NewTokenMintTransaction().SetTokenID(nftID2).SetMetadatas(mintMetadata).Execute(env.Client) 171 require.NoError(t, err) 172 receipt, err = mint.SetValidateStatus(true).GetReceipt(env.Client) 173 require.NoError(t, err) 174 175 serials := receipt.SerialNumbers 176 177 // create receiver account with auto associations 178 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 179 tx.SetMaxAutomaticTokenAssociations(100) 180 }) 181 require.NoError(t, err) 182 183 // transfer fts to the receiver 184 tx1, err := NewTransferTransaction(). 185 AddTokenTransfer(tokenID1, env.Client.GetOperatorAccountID(), -10). 186 AddTokenTransfer(tokenID1, receiver, 10). 187 AddTokenTransfer(tokenID2, env.Client.GetOperatorAccountID(), -10). 188 AddTokenTransfer(tokenID2, receiver, 10). 189 Execute(env.Client) 190 require.NoError(t, err) 191 _, err = tx1.SetValidateStatus(true).GetReceipt(env.Client) 192 require.NoError(t, err) 193 194 // transfer nfts to the receiver 195 tx2, err := NewTransferTransaction(). 196 AddNftTransfer(nftID1.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 197 AddNftTransfer(nftID1.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 198 AddNftTransfer(nftID2.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 199 AddNftTransfer(nftID2.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 200 Execute(env.Client) 201 require.NoError(t, err) 202 _, err = tx2.SetValidateStatus(true).GetReceipt(env.Client) 203 require.NoError(t, err) 204 205 // reject the token 206 frozenTxn, err := NewTokenRejectTransaction(). 207 SetOwnerID(receiver). 208 SetTokenIDs(tokenID1, tokenID2). 209 SetNftIDs(nftID1.Nft(serials[1]), nftID2.Nft(serials[1])). 210 FreezeWith(env.Client) 211 require.NoError(t, err) 212 resp, err := frozenTxn.Sign(key).Execute(env.Client) 213 require.NoError(t, err) 214 215 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 216 require.NoError(t, err) 217 218 // verify the balance of the receiver 219 tokenBalance, err := NewAccountBalanceQuery().SetAccountID(receiver).Execute(env.Client) 220 require.NoError(t, err) 221 assert.Zero(t, tokenBalance.Tokens.Get(tokenID1)) 222 assert.Zero(t, tokenBalance.Tokens.Get(tokenID2)) 223 assert.Equal(t, uint64(1), tokenBalance.Tokens.Get(nftID1)) 224 assert.Equal(t, uint64(1), tokenBalance.Tokens.Get(nftID2)) 225 226 // verify the tokens are transferred back to the treasury 227 tokenBalance, err = NewAccountBalanceQuery().SetAccountID(env.OperatorID).Execute(env.Client) 228 require.NoError(t, err) 229 assert.Equal(t, uint64(1_000_000), tokenBalance.Tokens.Get(tokenID1)) 230 assert.Equal(t, uint64(1_000_000), tokenBalance.Tokens.Get(tokenID2)) 231 232 nftBalance, err := NewTokenNftInfoQuery().SetNftID(nftID1.Nft(serials[1])).Execute(env.Client) 233 require.NoError(t, err) 234 assert.Equal(t, env.OperatorID, nftBalance[0].AccountID) 235 236 nftBalance, err = NewTokenNftInfoQuery().SetNftID(nftID2.Nft(serials[1])).Execute(env.Client) 237 require.NoError(t, err) 238 assert.Equal(t, env.OperatorID, nftBalance[0].AccountID) 239 } 240 241 func TestIntegrationTokenRejectTransactionReceiverSigRequired(t *testing.T) { 242 t.Parallel() 243 env := NewIntegrationTestEnv(t) 244 245 // create nft with treasury with receiver sig required 246 treasuryKey, err := PrivateKeyGenerateEd25519() 247 require.NoError(t, err) 248 249 accountCreateFrozen, err := NewAccountCreateTransaction(). 250 SetKey(treasuryKey). 251 SetNodeAccountIDs(env.NodeAccountIDs). 252 SetInitialBalance(NewHbar(0)). 253 SetReceiverSignatureRequired(true). 254 SetMaxAutomaticTokenAssociations(100).FreezeWith(env.Client) 255 require.NoError(t, err) 256 accountCreate, err := accountCreateFrozen.Sign(treasuryKey).Execute(env.Client) 257 receipt, err := accountCreate.SetValidateStatus(true).GetReceipt(env.Client) 258 require.NoError(t, err) 259 treasury := *receipt.AccountID 260 261 nftID, err := createNft(&env, func(transaction *TokenCreateTransaction) { 262 transaction.SetTreasuryAccountID(treasury).FreezeWith(env.Client) 263 transaction.Sign(treasuryKey) 264 }) 265 require.NoError(t, err) 266 267 // mint 268 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 269 require.NoError(t, err) 270 receipt, err = mint.SetValidateStatus(true).GetReceipt(env.Client) 271 require.NoError(t, err) 272 273 serials := receipt.SerialNumbers 274 275 // create receiver account with auto associations 276 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 277 tx.SetMaxAutomaticTokenAssociations(100) 278 }) 279 require.NoError(t, err) 280 281 // transfer nft to the receiver 282 frozenTransfer, err := NewTransferTransaction(). 283 AddNftTransfer(nftID.Nft(serials[0]), treasury, receiver). 284 AddNftTransfer(nftID.Nft(serials[1]), treasury, receiver). 285 FreezeWith(env.Client) 286 require.NoError(t, err) 287 transfer, err := frozenTransfer.Sign(treasuryKey).Execute(env.Client) 288 _, err = transfer.SetValidateStatus(true).GetReceipt(env.Client) 289 require.NoError(t, err) 290 291 // reject the token 292 frozenTxn, err := NewTokenRejectTransaction(). 293 SetOwnerID(receiver). 294 SetNftIDs(nftID.Nft(serials[1])). 295 FreezeWith(env.Client) 296 require.NoError(t, err) 297 resp, err := frozenTxn.Sign(key).Execute(env.Client) 298 require.NoError(t, err) 299 300 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 301 require.NoError(t, err) 302 303 // verify the balance is decremented by 1 304 tokenBalance, err := NewAccountBalanceQuery().SetAccountID(receiver).Execute(env.Client) 305 require.NoError(t, err) 306 assert.Equal(t, uint64(1), tokenBalance.Tokens.Get(nftID)) 307 308 // verify the token is transferred back to the treasury 309 nftBalance, err := NewTokenNftInfoQuery().SetNftID(nftID.Nft(serials[1])).Execute(env.Client) 310 require.NoError(t, err) 311 assert.Equal(t, treasury, nftBalance[0].AccountID) 312 313 // same test for fungible token 314 315 // create fungible token with treasury with receiver sig required 316 tokenID, err := createFungibleToken(&env, func(transaction *TokenCreateTransaction) { 317 transaction.SetTreasuryAccountID(treasury).FreezeWith(env.Client) 318 transaction.Sign(treasuryKey) 319 }) 320 require.NoError(t, err) 321 322 // transfer ft to the receiver 323 frozenTransfer, err = NewTransferTransaction(). 324 AddTokenTransfer(tokenID, treasury, -10). 325 AddTokenTransfer(tokenID, receiver, 10). 326 FreezeWith(env.Client) 327 transfer, err = frozenTransfer.Sign(treasuryKey).Execute(env.Client) 328 require.NoError(t, err) 329 _, err = transfer.SetValidateStatus(true).GetReceipt(env.Client) 330 require.NoError(t, err) 331 332 // reject the token 333 frozenTxn, err = NewTokenRejectTransaction(). 334 SetOwnerID(receiver). 335 SetTokenIDs(tokenID). 336 FreezeWith(env.Client) 337 require.NoError(t, err) 338 resp, err = frozenTxn.Sign(key).Execute(env.Client) 339 require.NoError(t, err) 340 341 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 342 require.NoError(t, err) 343 344 // verify the balance of the receiver is 0 345 tokenBalance, err = NewAccountBalanceQuery().SetAccountID(receiver).Execute(env.Client) 346 require.NoError(t, err) 347 assert.Zero(t, tokenBalance.Tokens.Get(tokenID)) 348 349 // verify the tokens are transferred back to the treasury 350 tokenBalance, err = NewAccountBalanceQuery().SetAccountID(treasury).Execute(env.Client) 351 require.NoError(t, err) 352 assert.Equal(t, uint64(1_000_000), tokenBalance.Tokens.Get(tokenID)) 353 354 } 355 356 func TestIntegrationTokenRejectTransactionTokenFrozen(t *testing.T) { 357 t.Parallel() 358 env := NewIntegrationTestEnv(t) 359 360 // create nft with treasury 361 nftID, err := createNft(&env) 362 require.NoError(t, err) 363 364 // mint 365 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 366 require.NoError(t, err) 367 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 368 require.NoError(t, err) 369 370 serials := receipt.SerialNumbers 371 372 // create receiver account with auto associations 373 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 374 tx.SetMaxAutomaticTokenAssociations(100) 375 }) 376 require.NoError(t, err) 377 378 // transfer nft to the receiver 379 tx, err := NewTransferTransaction(). 380 AddNftTransfer(nftID.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 381 AddNftTransfer(nftID.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 382 Execute(env.Client) 383 require.NoError(t, err) 384 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 385 require.NoError(t, err) 386 387 // freeze the token 388 tokenFreeze, err := NewTokenFreezeTransaction().SetTokenID(nftID).SetAccountID(receiver).Execute(env.Client) 389 require.NoError(t, err) 390 _, err = tokenFreeze.SetValidateStatus(true).GetReceipt(env.Client) 391 require.NoError(t, err) 392 393 // reject the token - should fail with ACCOUNT_FROZEN_FOR_TOKEN 394 frozenTxn, err := NewTokenRejectTransaction(). 395 SetOwnerID(receiver). 396 SetNftIDs(nftID.Nft(serials[1])). 397 FreezeWith(env.Client) 398 require.NoError(t, err) 399 resp, err := frozenTxn.Sign(key).Execute(env.Client) 400 require.NoError(t, err) 401 402 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 403 require.ErrorContains(t, err, "ACCOUNT_FROZEN_FOR_TOKEN") 404 405 // same test with fungible token 406 407 // create fungible token with treasury 408 tokenID, err := createFungibleToken(&env) 409 require.NoError(t, err) 410 411 // transfer ft to the receiver 412 tx, err = NewTransferTransaction(). 413 AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10). 414 AddTokenTransfer(tokenID, receiver, 10). 415 Execute(env.Client) 416 require.NoError(t, err) 417 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 418 require.NoError(t, err) 419 420 // freeze the token 421 tokenFreeze, err = NewTokenFreezeTransaction().SetTokenID(tokenID).SetAccountID(receiver).Execute(env.Client) 422 require.NoError(t, err) 423 _, err = tokenFreeze.SetValidateStatus(true).GetReceipt(env.Client) 424 425 // reject the token - should fail with ACCOUNT_FROZEN_FOR_TOKEN 426 frozenTxn, err = NewTokenRejectTransaction(). 427 SetOwnerID(receiver). 428 AddTokenID(tokenID). 429 FreezeWith(env.Client) 430 require.NoError(t, err) 431 resp, err = frozenTxn.Sign(key).Execute(env.Client) 432 require.NoError(t, err) 433 434 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 435 require.ErrorContains(t, err, "ACCOUNT_FROZEN_FOR_TOKEN") 436 437 } 438 439 func TestIntegrationTokenRejectTransactionTokenPaused(t *testing.T) { 440 t.Parallel() 441 env := NewIntegrationTestEnv(t) 442 443 // create nft with treasury 444 nftID, err := createNft(&env) 445 require.NoError(t, err) 446 447 // mint 448 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 449 require.NoError(t, err) 450 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 451 require.NoError(t, err) 452 453 serials := receipt.SerialNumbers 454 455 // create receiver account with auto associations 456 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 457 tx.SetMaxAutomaticTokenAssociations(100) 458 }) 459 require.NoError(t, err) 460 461 // transfer nft to the receiver 462 tx, err := NewTransferTransaction(). 463 AddNftTransfer(nftID.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 464 AddNftTransfer(nftID.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 465 Execute(env.Client) 466 require.NoError(t, err) 467 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 468 require.NoError(t, err) 469 470 // pause the token 471 tokenPause, err := NewTokenPauseTransaction().SetTokenID(nftID).Execute(env.Client) 472 require.NoError(t, err) 473 _, err = tokenPause.SetValidateStatus(true).GetReceipt(env.Client) 474 require.NoError(t, err) 475 476 // reject the token - should fail with TOKEN_IS_PAUSED 477 frozenTxn, err := NewTokenRejectTransaction(). 478 SetOwnerID(receiver). 479 SetNftIDs(nftID.Nft(serials[1])). 480 FreezeWith(env.Client) 481 require.NoError(t, err) 482 resp, err := frozenTxn.Sign(key).Execute(env.Client) 483 require.NoError(t, err) 484 485 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 486 require.ErrorContains(t, err, "TOKEN_IS_PAUSED") 487 488 // same test with fungible token 489 490 // create fungible token with treasury 491 tokenID, err := createFungibleToken(&env) 492 require.NoError(t, err) 493 494 // transfer ft to the receiver 495 tx, err = NewTransferTransaction(). 496 AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10). 497 AddTokenTransfer(tokenID, receiver, 10). 498 Execute(env.Client) 499 require.NoError(t, err) 500 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 501 require.NoError(t, err) 502 503 // pause the token 504 tokenPause, err = NewTokenPauseTransaction().SetTokenID(tokenID).Execute(env.Client) 505 require.NoError(t, err) 506 _, err = tokenPause.SetValidateStatus(true).GetReceipt(env.Client) 507 508 // reject the token - should fail with TOKEN_IS_PAUSED 509 frozenTxn, err = NewTokenRejectTransaction(). 510 SetOwnerID(receiver). 511 AddTokenID(tokenID). 512 FreezeWith(env.Client) 513 require.NoError(t, err) 514 resp, err = frozenTxn.Sign(key).Execute(env.Client) 515 require.NoError(t, err) 516 517 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 518 require.ErrorContains(t, err, "TOKEN_IS_PAUSED") 519 } 520 521 func TestIntegrationTokenRejectTransactionDoesNotRemoveAllowanceFT(t *testing.T) { 522 t.Skip("Skipping test as this flow is currently not working as expected in services") 523 t.Parallel() 524 env := NewIntegrationTestEnv(t) 525 526 // create fungible token with treasury 527 tokenID, err := createFungibleToken(&env) 528 require.NoError(t, err) 529 // create receiver account with auto associations 530 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 531 tx.SetMaxAutomaticTokenAssociations(100) 532 }) 533 require.NoError(t, err) 534 // create spender account to be approved 535 spender, spenderKey, err := createAccount(&env, func(tx *AccountCreateTransaction) { 536 tx.SetMaxAutomaticTokenAssociations(100) 537 }) 538 require.NoError(t, err) 539 540 // transfer ft to the receiver 541 tx, err := NewTransferTransaction(). 542 AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10). 543 AddTokenTransfer(tokenID, receiver, 10). 544 Execute(env.Client) 545 require.NoError(t, err) 546 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 547 require.NoError(t, err) 548 549 // approve allowance to the spender 550 frozenApprove, err := NewAccountAllowanceApproveTransaction(). 551 ApproveTokenAllowance(tokenID, receiver, spender, 10).FreezeWith(env.Client) 552 require.NoError(t, err) 553 approve, err := frozenApprove.Sign(key).Execute(env.Client) 554 require.NoError(t, err) 555 _, err = approve.SetValidateStatus(true).GetReceipt(env.Client) 556 require.NoError(t, err) 557 558 // verify the spender has allowance 559 env.Client.SetOperator(spender, spenderKey) 560 frozenTx, err := NewTransferTransaction(). 561 AddApprovedTokenTransfer(tokenID, receiver, -5, true). 562 AddTokenTransfer(tokenID, spender, 5). 563 FreezeWith(env.Client) 564 require.NoError(t, err) 565 transfer, err := frozenTx.SignWith(spenderKey.PublicKey(), spenderKey.Sign).Execute(env.Client) 566 require.NoError(t, err) 567 _, err = transfer.SetValidateStatus(true).GetReceipt(env.Client) 568 require.NoError(t, err) 569 570 env.Client.SetOperator(env.OperatorID, env.OperatorKey) 571 572 // reject the token 573 frozenTxn, err := NewTokenRejectTransaction(). 574 SetOwnerID(receiver). 575 AddTokenID(tokenID). 576 FreezeWith(env.Client) 577 require.NoError(t, err) 578 resp, err := frozenTxn.Sign(key).Execute(env.Client) 579 require.NoError(t, err) 580 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 581 require.NoError(t, err) 582 583 // verify the allowance - should be 0 , because the receiver is no longer the owner 584 env.Client.SetOperator(spender, spenderKey) 585 frozenTx, err = NewTransferTransaction(). 586 AddApprovedTokenTransfer(tokenID, receiver, -5, true). 587 AddTokenTransfer(tokenID, spender, 5).FreezeWith(env.Client) 588 tx, err = frozenTx.Sign(spenderKey).Execute(env.Client) 589 require.NoError(t, err) 590 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 591 require.ErrorContains(t, err, "INSUFFICIENT_TOKEN_BALANCE") 592 env.Client.SetOperator(env.OperatorID, env.OperatorKey) 593 594 // transfer ft to the back to the receiver 595 tx, err = NewTransferTransaction(). 596 AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10). 597 AddTokenTransfer(tokenID, receiver, 10). 598 Execute(env.Client) 599 require.NoError(t, err) 600 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 601 require.NoError(t, err) 602 603 // verify the spender has allowance 604 env.Client.SetOperator(spender, spenderKey) 605 frozenTx, err = NewTransferTransaction(). 606 AddApprovedTokenTransfer(tokenID, receiver, -5, true). 607 AddTokenTransfer(tokenID, spender, 5). 608 FreezeWith(env.Client) 609 require.NoError(t, err) 610 transfer, err = frozenTx.SignWith(spenderKey.PublicKey(), spenderKey.Sign).Execute(env.Client) 611 require.NoError(t, err) 612 _, err = transfer.SetValidateStatus(true).GetReceipt(env.Client) 613 require.NoError(t, err) 614 } 615 616 func TestIntegrationTokenRejectTransactionDoesNotRemoveAllowanceNFT(t *testing.T) { 617 t.Skip("Skipping test as this flow is currently not working as expected in services") 618 t.Parallel() 619 env := NewIntegrationTestEnv(t) 620 621 // create receiver account with auto associations 622 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 623 tx.SetMaxAutomaticTokenAssociations(100) 624 }) 625 require.NoError(t, err) 626 // create spender account to be approved 627 spender, spenderKey, err := createAccount(&env, func(tx *AccountCreateTransaction) { 628 tx.SetMaxAutomaticTokenAssociations(100) 629 }) 630 require.NoError(t, err) 631 // create nft with treasury 632 nftID, err := createNft(&env) 633 require.NoError(t, err) 634 635 // mint 636 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 637 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 638 require.NoError(t, err) 639 640 serials := receipt.SerialNumbers 641 642 // transfer nfts to the receiver 643 tx, err := NewTransferTransaction(). 644 AddNftTransfer(nftID.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 645 AddNftTransfer(nftID.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 646 AddNftTransfer(nftID.Nft(serials[2]), env.Client.GetOperatorAccountID(), receiver). 647 AddNftTransfer(nftID.Nft(serials[3]), env.Client.GetOperatorAccountID(), receiver). 648 Execute(env.Client) 649 require.NoError(t, err) 650 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 651 require.NoError(t, err) 652 653 // approve allowance to the spender 654 frozenApprove, err := NewAccountAllowanceApproveTransaction(). 655 ApproveTokenNftAllowance(nftID.Nft(serials[0]), receiver, spender). 656 ApproveTokenNftAllowance(nftID.Nft(serials[1]), receiver, spender). 657 FreezeWith(env.Client) 658 require.NoError(t, err) 659 approve, err := frozenApprove.Sign(key).Execute(env.Client) 660 require.NoError(t, err) 661 _, err = approve.SetValidateStatus(true).GetReceipt(env.Client) 662 require.NoError(t, err) 663 664 // verify the spender has allowance 665 env.Client.SetOperator(spender, spenderKey) 666 frozenTx, err := NewTransferTransaction(). 667 AddApprovedNftTransfer(nftID.Nft(serials[0]), receiver, spender, true). 668 FreezeWith(env.Client) 669 require.NoError(t, err) 670 transfer, err := frozenTx.SignWith(spenderKey.PublicKey(), spenderKey.Sign).Execute(env.Client) 671 require.NoError(t, err) 672 _, err = transfer.SetValidateStatus(true).GetReceipt(env.Client) 673 require.NoError(t, err) 674 env.Client.SetOperator(env.OperatorID, env.OperatorKey) 675 676 // reject the token 677 frozenTxn, err := NewTokenRejectTransaction(). 678 SetOwnerID(receiver). 679 SetNftIDs(nftID.Nft(serials[1]), nftID.Nft(serials[2]), nftID.Nft(serials[3])). 680 FreezeWith(env.Client) 681 require.NoError(t, err) 682 resp, err := frozenTxn.Sign(key).Execute(env.Client) 683 require.NoError(t, err) 684 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 685 require.NoError(t, err) 686 687 // verify the allowance - should be 0 , because the receiver is no longer the owner 688 env.Client.SetOperator(spender, spenderKey) 689 frozenTx, err = NewTransferTransaction(). 690 AddApprovedNftTransfer(nftID.Nft(serials[1]), receiver, spender, true). 691 FreezeWith(env.Client) 692 tx, err = frozenTx.Sign(spenderKey).Execute(env.Client) 693 require.NoError(t, err) 694 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 695 require.ErrorContains(t, err, "SPENDER_DOES_NOT_HAVE_ALLOWANCE") 696 env.Client.SetOperator(env.OperatorID, env.OperatorKey) 697 698 // transfer nfts to the back to the receiver 699 tx, err = NewTransferTransaction(). 700 AddNftTransfer(nftID.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 701 AddNftTransfer(nftID.Nft(serials[2]), env.Client.GetOperatorAccountID(), receiver). 702 AddNftTransfer(nftID.Nft(serials[3]), env.Client.GetOperatorAccountID(), receiver). 703 Execute(env.Client) 704 require.NoError(t, err) 705 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 706 require.NoError(t, err) 707 708 // verify the spender has allowance 709 env.Client.SetOperator(spender, spenderKey) 710 frozenTx, err = NewTransferTransaction(). 711 AddApprovedNftTransfer(nftID.Nft(serials[1]), receiver, spender, true). 712 FreezeWith(env.Client) 713 require.NoError(t, err) 714 transfer, err = frozenTx.SignWith(spenderKey.PublicKey(), spenderKey.Sign).Execute(env.Client) 715 require.NoError(t, err) 716 _, err = transfer.SetValidateStatus(true).GetReceipt(env.Client) 717 require.NoError(t, err) 718 } 719 720 func TestIntegrationTokenRejectTransactionFailsWhenRejectingNFTWithTokenID(t *testing.T) { 721 t.Parallel() 722 env := NewIntegrationTestEnv(t) 723 724 // create nft with treasury 725 nftID, err := createNft(&env) 726 require.NoError(t, err) 727 // mint 728 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 729 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 730 require.NoError(t, err) 731 732 serials := receipt.SerialNumbers 733 734 // create receiver account with auto associations 735 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 736 tx.SetMaxAutomaticTokenAssociations(100) 737 }) 738 require.NoError(t, err) 739 740 // transfer nfts to the receiver 741 tx, err := NewTransferTransaction(). 742 AddNftTransfer(nftID.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 743 AddNftTransfer(nftID.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 744 AddNftTransfer(nftID.Nft(serials[2]), env.Client.GetOperatorAccountID(), receiver). 745 Execute(env.Client) 746 require.NoError(t, err) 747 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 748 require.NoError(t, err) 749 750 // reject the whole collection - should fail 751 frozenTxn, err := NewTokenRejectTransaction().SetOwnerID(receiver).AddTokenID(nftID).FreezeWith(env.Client) 752 require.NoError(t, err) 753 resp, err := frozenTxn.Sign(key).Execute(env.Client) 754 require.NoError(t, err) 755 756 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 757 require.ErrorContains(t, err, "ACCOUNT_AMOUNT_TRANSFERS_ONLY_ALLOWED_FOR_FUNGIBLE_COMMON") 758 } 759 760 func TestIntegrationTokenRejectTransactionFailsWithTokenReferenceRepeated(t *testing.T) { 761 t.Parallel() 762 env := NewIntegrationTestEnv(t) 763 764 // create fungible token with treasury 765 tokenID, err := createFungibleToken(&env) 766 require.NoError(t, err) 767 768 // create receiver account with auto associations 769 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 770 tx.SetMaxAutomaticTokenAssociations(100) 771 }) 772 require.NoError(t, err) 773 774 // transfer ft to the receiver 775 tx, err := NewTransferTransaction(). 776 AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10). 777 AddTokenTransfer(tokenID, receiver, 10). 778 Execute(env.Client) 779 require.NoError(t, err) 780 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 781 require.NoError(t, err) 782 783 // reject the token with duplicate token id - should fail with TOKEN_REFERENCE_REPEATED 784 frozenTxn, err := NewTokenRejectTransaction(). 785 SetOwnerID(receiver). 786 SetTokenIDs(tokenID, tokenID). 787 FreezeWith(env.Client) 788 require.NoError(t, err) 789 _, err = frozenTxn.Sign(key).Execute(env.Client) 790 require.ErrorContains(t, err, "TOKEN_REFERENCE_REPEATED") 791 792 // same test for nft 793 794 // create nft with treasury 795 nftID, err := createNft(&env) 796 require.NoError(t, err) 797 798 // mint 799 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 800 require.NoError(t, err) 801 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 802 require.NoError(t, err) 803 804 serials := receipt.SerialNumbers 805 806 // transfer nft to the receiver 807 tx, err = NewTransferTransaction(). 808 AddNftTransfer(nftID.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 809 Execute(env.Client) 810 require.NoError(t, err) 811 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 812 require.NoError(t, err) 813 814 // reject the nft with duplicate nft id - should fail with TOKEN_REFERENCE_REPEATED 815 frozenTxn, err = NewTokenRejectTransaction().SetOwnerID(receiver).SetNftIDs(nftID.Nft(serials[0]), nftID.Nft(serials[0])).FreezeWith(env.Client) 816 require.NoError(t, err) 817 _, err = frozenTxn.Sign(key).Execute(env.Client) 818 require.ErrorContains(t, err, "TOKEN_REFERENCE_REPEATED") 819 } 820 821 func TestIntegrationTokenRejectTransactionFailsWhenOwnerHasNoBalance(t *testing.T) { 822 t.Parallel() 823 env := NewIntegrationTestEnv(t) 824 825 // create fungible token with treasury 826 tokenID, err := createFungibleToken(&env) 827 require.NoError(t, err) 828 // create receiver account with auto associations 829 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 830 tx.SetMaxAutomaticTokenAssociations(100) 831 }) 832 require.NoError(t, err) 833 834 // skip the transfer 835 // associate the receiver 836 frozenAssociate, err := NewTokenAssociateTransaction(). 837 SetAccountID(receiver). 838 AddTokenID(tokenID).FreezeWith(env.Client) 839 require.NoError(t, err) 840 _, err = frozenAssociate.Sign(key).Execute(env.Client) 841 require.NoError(t, err) 842 843 // reject the token - should fail with INSUFFICIENT_TOKEN_BALANCE 844 frozenTxn, err := NewTokenRejectTransaction(). 845 SetOwnerID(receiver). 846 SetTokenIDs(tokenID). 847 FreezeWith(env.Client) 848 require.NoError(t, err) 849 tx, err := frozenTxn.Sign(key).Execute(env.Client) 850 require.NoError(t, err) 851 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 852 require.ErrorContains(t, err, "INSUFFICIENT_TOKEN_BALANCE") 853 854 // same test for nft 855 856 // create nft with treasury 857 nftID, err := createNft(&env) 858 require.NoError(t, err) 859 860 // mint 861 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 862 require.NoError(t, err) 863 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 864 require.NoError(t, err) 865 866 serials := receipt.SerialNumbers 867 868 // skip the transfer 869 // associate the receiver 870 frozenAssociate, err = NewTokenAssociateTransaction(). 871 SetAccountID(receiver). 872 AddTokenID(nftID).FreezeWith(env.Client) 873 require.NoError(t, err) 874 _, err = frozenAssociate.Sign(key).Execute(env.Client) 875 require.NoError(t, err) 876 877 // reject the nft - should fail with INVALID_OWNER_ID 878 frozenTxn, err = NewTokenRejectTransaction(). 879 SetOwnerID(receiver). 880 SetNftIDs(nftID.Nft(serials[0])). 881 FreezeWith(env.Client) 882 require.NoError(t, err) 883 tx, err = frozenTxn.Sign(key).Execute(env.Client) 884 require.NoError(t, err) 885 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 886 require.ErrorContains(t, err, "INVALID_OWNER_ID") 887 888 } 889 890 func TestIntegrationTokenRejectTransactionFailsTreasuryRejects(t *testing.T) { 891 t.Parallel() 892 env := NewIntegrationTestEnv(t) 893 894 // create fungible token with treasury 895 tokenID, err := createFungibleToken(&env) 896 require.NoError(t, err) 897 898 // skip the transfer 899 // reject the token with the treasury - should fail with ACCOUNT_IS_TREASURY 900 frozenTxn, err := NewTokenRejectTransaction(). 901 SetOwnerID(env.OperatorID). 902 SetTokenIDs(tokenID). 903 FreezeWith(env.Client) 904 require.NoError(t, err) 905 tx, err := frozenTxn.Sign(env.OperatorKey).Execute(env.Client) 906 require.NoError(t, err) 907 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 908 require.ErrorContains(t, err, "ACCOUNT_IS_TREASURY") 909 910 // same test for nft 911 912 // create nft with treasury 913 nftID, err := createNft(&env) 914 require.NoError(t, err) 915 916 // mint 917 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 918 require.NoError(t, err) 919 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 920 require.NoError(t, err) 921 922 serials := receipt.SerialNumbers 923 924 // skip the transfer 925 // reject the nft with the treasury - should fail with ACCOUNT_IS_TREASURY 926 frozenTxn, err = NewTokenRejectTransaction(). 927 SetOwnerID(env.OperatorID). 928 SetNftIDs(nftID.Nft(serials[0])). 929 FreezeWith(env.Client) 930 require.NoError(t, err) 931 tx, err = frozenTxn.Sign(env.OperatorKey).Execute(env.Client) 932 require.NoError(t, err) 933 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 934 require.ErrorContains(t, err, "ACCOUNT_IS_TREASURY") 935 } 936 937 func TestIntegrationTokenRejectTransactionFailsWithInvalidToken(t *testing.T) { 938 t.Parallel() 939 env := NewIntegrationTestEnv(t) 940 941 // reject the token with invalid token - should fail with EMPTY_TOKEN_REFERENCE_LIST 942 frozenTxn, err := NewTokenRejectTransaction(). 943 SetOwnerID(env.OperatorID). 944 FreezeWith(env.Client) 945 require.NoError(t, err) 946 _, err = frozenTxn.Sign(env.OperatorKey).Execute(env.Client) 947 require.ErrorContains(t, err, "EMPTY_TOKEN_REFERENCE_LIST") 948 } 949 950 func TestIntegrationTokenRejectTransactionFailsWithReferenceSizeExceeded(t *testing.T) { 951 t.Parallel() 952 env := NewIntegrationTestEnv(t) 953 954 // create receiver account with auto associations 955 receiver, key, err := createAccount(&env, func(tx *AccountCreateTransaction) { 956 tx.SetMaxAutomaticTokenAssociations(100) 957 }) 958 require.NoError(t, err) 959 960 // create fungible token with treasury 961 tokenID, err := createFungibleToken(&env) 962 require.NoError(t, err) 963 964 // create nft with treasury 965 nftID, err := createNft(&env) 966 require.NoError(t, err) 967 968 // mint 969 mint, err := NewTokenMintTransaction().SetTokenID(nftID).SetMetadatas(mintMetadata).Execute(env.Client) 970 require.NoError(t, err) 971 receipt, err := mint.SetValidateStatus(true).GetReceipt(env.Client) 972 require.NoError(t, err) 973 974 serials := receipt.SerialNumbers 975 976 // transfer the tokens to the receiver 977 tx, err := NewTransferTransaction(). 978 AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10). 979 AddTokenTransfer(tokenID, receiver, 10). 980 AddNftTransfer(nftID.Nft(serials[0]), env.Client.GetOperatorAccountID(), receiver). 981 AddNftTransfer(nftID.Nft(serials[1]), env.Client.GetOperatorAccountID(), receiver). 982 AddNftTransfer(nftID.Nft(serials[2]), env.Client.GetOperatorAccountID(), receiver). 983 AddNftTransfer(nftID.Nft(serials[3]), env.Client.GetOperatorAccountID(), receiver). 984 AddNftTransfer(nftID.Nft(serials[4]), env.Client.GetOperatorAccountID(), receiver). 985 AddNftTransfer(nftID.Nft(serials[5]), env.Client.GetOperatorAccountID(), receiver). 986 AddNftTransfer(nftID.Nft(serials[6]), env.Client.GetOperatorAccountID(), receiver). 987 AddNftTransfer(nftID.Nft(serials[7]), env.Client.GetOperatorAccountID(), receiver). 988 AddNftTransfer(nftID.Nft(serials[8]), env.Client.GetOperatorAccountID(), receiver). 989 AddNftTransfer(nftID.Nft(serials[9]), env.Client.GetOperatorAccountID(), receiver). 990 Execute(env.Client) 991 require.NoError(t, err) 992 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 993 require.NoError(t, err) 994 995 // reject the token with 11 token references - should fail with TOKEN_REFERENCE_LIST_SIZE_LIMIT_EXCEEDED 996 frozenTxn, err := NewTokenRejectTransaction(). 997 SetOwnerID(receiver). 998 SetTokenIDs(tokenID). 999 SetNftIDs(nftID.Nft(serials[0]), nftID.Nft(serials[1]), 1000 nftID.Nft(serials[2]), nftID.Nft(serials[3]), 1001 nftID.Nft(serials[4]), nftID.Nft(serials[5]), 1002 nftID.Nft(serials[6]), nftID.Nft(serials[7]), 1003 nftID.Nft(serials[8]), nftID.Nft(serials[9])). 1004 FreezeWith(env.Client) 1005 require.NoError(t, err) 1006 tx, err = frozenTxn.Sign(key).Execute(env.Client) 1007 require.NoError(t, err) 1008 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 1009 require.ErrorContains(t, err, "TOKEN_REFERENCE_LIST_SIZE_LIMIT_EXCEEDED") 1010 1011 } 1012 1013 func TestIntegrationTokenRejectTransactionFailsWithInvalidSignature(t *testing.T) { 1014 t.Parallel() 1015 env := NewIntegrationTestEnv(t) 1016 1017 // create fungible token with treasury 1018 tokenID, err := createFungibleToken(&env) 1019 require.NoError(t, err) 1020 1021 // create receiver account with auto associations 1022 receiver, _, err := createAccount(&env, func(tx *AccountCreateTransaction) { 1023 tx.SetMaxAutomaticTokenAssociations(100) 1024 }) 1025 require.NoError(t, err) 1026 1027 // craete helper key 1028 otherKey, err := PrivateKeyGenerateEd25519() 1029 require.NoError(t, err) 1030 1031 // transfer ft to the receiver 1032 tx, err := NewTransferTransaction(). 1033 AddTokenTransfer(tokenID, env.Client.GetOperatorAccountID(), -10). 1034 AddTokenTransfer(tokenID, receiver, 10). 1035 Execute(env.Client) 1036 require.NoError(t, err) 1037 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 1038 require.NoError(t, err) 1039 1040 // reject the token with different key - should fail with INVALID_SIGNATURE 1041 frozenTxn, err := NewTokenRejectTransaction(). 1042 SetOwnerID(receiver). 1043 SetTokenIDs(tokenID). 1044 FreezeWith(env.Client) 1045 require.NoError(t, err) 1046 tx, err = frozenTxn.Sign(otherKey).Execute(env.Client) 1047 require.NoError(t, err) 1048 _, err = tx.SetValidateStatus(true).GetReceipt(env.Client) 1049 require.ErrorContains(t, err, "INVALID_SIGNATURE") 1050 }