github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/live_hash_add_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 "encoding/hex" 28 "fmt" 29 "testing" 30 "time" 31 32 "github.com/stretchr/testify/assert" 33 34 "github.com/stretchr/testify/require" 35 ) 36 37 func TestIntegrationLiveHashAddTransactionCanExecute(t *testing.T) { 38 t.Parallel() 39 env := NewIntegrationTestEnv(t) 40 41 _hash, _ := hex.DecodeString("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002") 42 43 newKey, err := PrivateKeyGenerateEd25519() 44 require.NoError(t, err) 45 46 resp, err := NewAccountCreateTransaction(). 47 SetKey(newKey.PublicKey()). 48 SetNodeAccountIDs(env.NodeAccountIDs). 49 SetInitialBalance(NewHbar(1)). 50 Execute(env.Client) 51 require.NoError(t, err) 52 53 receipt, err := resp.SetValidateStatus(true).GetReceipt(env.Client) 54 require.NoError(t, err) 55 56 accountID := *receipt.AccountID 57 58 resp2, err := NewLiveHashAddTransaction(). 59 SetAccountID(accountID). 60 SetDuration(24 * 30 * time.Hour). 61 SetNodeAccountIDs([]AccountID{resp.NodeID}). 62 SetHash(_hash). 63 SetKeys(newKey.PublicKey()). 64 Execute(env.Client) 65 assert.Error(t, err) 66 if err != nil { 67 assert.Equal(t, fmt.Sprintf("exceptional precheck status NOT_SUPPORTED received for transaction %s", resp2.TransactionID), err.Error()) 68 } 69 70 resp2, err = NewLiveHashDeleteTransaction(). 71 SetAccountID(accountID). 72 SetNodeAccountIDs([]AccountID{resp.NodeID}). 73 SetHash(_hash). 74 Execute(env.Client) 75 assert.Error(t, err) 76 if err != nil { 77 assert.Equal(t, fmt.Sprintf("exceptional precheck status NOT_SUPPORTED received for transaction %s", resp2.TransactionID), err.Error()) 78 } 79 80 tx, err := NewAccountDeleteTransaction(). 81 SetAccountID(accountID). 82 SetNodeAccountIDs([]AccountID{resp.NodeID}). 83 SetTransferAccountID(env.Client.GetOperatorAccountID()). 84 FreezeWith(env.Client) 85 require.NoError(t, err) 86 87 resp, err = tx.Sign(newKey). 88 Execute(env.Client) 89 require.NoError(t, err) 90 91 _, err = resp.SetValidateStatus(true).GetReceipt(env.Client) 92 require.NoError(t, err) 93 94 err = CloseIntegrationTestEnv(env, nil) 95 require.NoError(t, err) 96 }