forked from hashgraph/hedera-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
file_info_query_test.go
59 lines (44 loc) · 1.91 KB
/
file_info_query_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
package hedera
import (
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestNewFileInfoQuery(t *testing.T) {
mockTransaction, err := newMockTransaction()
assert.NoError(t, err)
query := NewFileInfoQuery().
SetFileID(FileID{File: 3}).
SetQueryPaymentTransaction(mockTransaction)
assert.Equal(t, `fileGetInfo:<header:<payment:<bodyBytes:"\n\016\n\010\010\334\311\007\020\333\237\t\022\002\030\003\022\002\030\003\030\200\302\327/\"\002\010xr\024\n\022\n\007\n\002\030\002\020\307\001\n\007\n\002\030\003\020\310\001" 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:"\022&5\226\373\264\034]P\273%\354P\233k\315\231\013\337\274\254)\246+\322<\227+\273\214\212f\313\332i\027T4{\367\363UYn\n\217\253ep\004\366\203\017\272FUP\243\321/\035\235\032\013" > > > > fileID:<fileNum:3 > > `, query.QueryBuilder.pb.String())
}
func TestFileInfoQueryTransaction_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)
info, err := NewFileInfoQuery().
SetFileID(*fileID).
Execute(client)
assert.NoError(t, err)
assert.Equal(t, *fileID, info.FileID)
txID, err = NewFileDeleteTransaction().
SetFileID(*fileID).
Execute(client)
assert.NoError(t, err)
_, err = txID.GetReceipt(client)
assert.NoError(t, err)
}