forked from hiero-ledger/hiero-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
file_delete_transaction_test.go
62 lines (46 loc) · 2.12 KB
/
file_delete_transaction_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package hedera
import (
"github.com/stretchr/testify/assert"
"os"
"strings"
"testing"
)
func TestSerializeFileDeleteTransaction(t *testing.T) {
mockClient, err := newMockClient()
assert.NoError(t, err)
privateKey, err := Ed25519PrivateKeyFromString(mockPrivateKey)
assert.NoError(t, err)
tx, err := NewFileDeleteTransaction().
SetFileID(FileID{File: 5}).
SetMaxTransactionFee(HbarFromTinybar(1e6)).
SetTransactionID(testTransactionID).
Build(mockClient)
assert.NoError(t, err)
tx.Sign(privateKey)
assert.Equal(t, `bodyBytes:"\n\016\n\010\010\334\311\007\020\333\237\t\022\002\030\003\022\002\030\003\030\300\204=\"\002\010x\222\001\004\022\002\030\005"sigMap:<sigPair:<pubKeyPrefix:"\344\361\300\353L}\315\303\347\353\021p\263\010\212=\022\242\227\364\243\353\342\362\205\003\375g5F\355\216"ed25519:"cX\335@\024\365\365\3065\211NT.\355\245\224\364\230@\301\221\343\\T\343H\374\003\261W\252a\272\3401-)\251?N\204\305C\034\301\375\306\327K7a`+"`"+`r\262]\247\231I\332*:\2432\010">>transactionID:<transactionValidStart:<seconds:124124nanos:151515>accountID:<accountNum:3>>nodeAccountID:<accountNum:3>transactionFee:1000000transactionValidDuration:<seconds:120>fileDelete:<fileID:<fileNum:5>>`, strings.ReplaceAll(strings.ReplaceAll(tx.String(), " ", ""), "\n", ""))
}
func TestFileDeleteTransaction_Execute(t *testing.T) {
operatorAccountID, err := AccountIDFromString(os.Getenv("OPERATOR_ID"))
assert.NoError(t, err)
operatorPrivateKey, err := Ed25519PrivateKeyFromString(os.Getenv("OPERATOR_KEY"))
assert.NoError(t, err)
client := ClientForTestnet().
SetOperator(operatorAccountID, operatorPrivateKey).
SetMaxTransactionFee(NewHbar(2))
txID, err := NewFileCreateTransaction().
AddKey(operatorPrivateKey.PublicKey()).
SetContents([]byte("Hello, World")).
SetTransactionMemo("go sdk e2e tests").
Execute(client)
assert.NoError(t, err)
receipt, err := txID.GetReceipt(client)
assert.NoError(t, err)
fileID := receipt.fileID
assert.NotNil(t, fileID)
txID, err = NewFileDeleteTransaction().
SetFileID(*fileID).
Execute(client)
assert.NoError(t, err)
_, err = txID.GetReceipt(client)
assert.NoError(t, err)
}