github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/token_delete_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 TestIntegrationTokenDeleteTransactionCanExecute(t *testing.T) { 36 t.Parallel() 37 env := NewIntegrationTestEnv(t) 38 39 tokenID, err := createFungibleToken(&env) 40 require.NoError(t, err) 41 42 err = CloseIntegrationTestEnv(env, &tokenID) 43 require.NoError(t, err) 44 } 45 46 func TestIntegrationTokenDeleteTransactionNoKeys(t *testing.T) { 47 t.Parallel() 48 env := NewIntegrationTestEnv(t) 49 50 newKey, err := PrivateKeyGenerateEd25519() 51 require.NoError(t, err) 52 53 tokenCreate, err := NewTokenCreateTransaction(). 54 SetNodeAccountIDs(env.NodeAccountIDs). 55 SetTokenName("ffff"). 56 SetTokenSymbol("F"). 57 SetDecimals(3). 58 SetInitialSupply(1000000). 59 SetTreasuryAccountID(env.Client.GetOperatorAccountID()). 60 SetAdminKey(env.OperatorKey.PublicKey()). 61 SetFreezeDefault(false). 62 FreezeWith(env.Client) 63 require.NoError(t, err) 64 65 tokenCreate, err = tokenCreate. 66 SignWithOperator(env.Client) 67 require.NoError(t, err) 68 69 resp, err := tokenCreate. 70 Sign(newKey). 71 Execute(env.Client) 72 require.NoError(t, err) 73 74 receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client) 75 require.NoError(t, err) 76 77 err = CloseIntegrationTestEnv(env, receipt.TokenID) 78 require.NoError(t, err) 79 } 80 81 func TestIntegrationTokenDeleteTransactionNoTokenID(t *testing.T) { 82 t.Parallel() 83 env := NewIntegrationTestEnv(t) 84 85 resp, err := NewTokenDeleteTransaction(). 86 SetNodeAccountIDs(env.NodeAccountIDs). 87 Execute(env.Client) 88 assert.Error(t, err) 89 if err != nil { 90 assert.Equal(t, fmt.Sprintf("exceptional precheck status INVALID_TOKEN_ID received for transaction %s", resp.TransactionID), err.Error()) 91 } 92 93 err = CloseIntegrationTestEnv(env, nil) 94 require.NoError(t, err) 95 }