-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_test.go
37 lines (28 loc) · 883 Bytes
/
export_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
package filclient
import (
"context"
"fmt"
"os"
"path"
"testing"
"github.com/stretchr/testify/require"
)
func TestExportFile(t *testing.T) {
ctx := context.TODO()
outputFilename := path.Join(t.TempDir() + "export-test")
client, miner, _, fc, closer := initEnsemble(t, ctx)
defer closer()
// Create a dummy deal
importRes := genDummyDeal(ctx, t, client, miner)
// Transfer dummy deal into the client
fmt.Printf("Transferring...\n")
transfer, err := fc.StorageProviderByAddress(miner.ActorAddr).StartRetrievalTransfer(ctx, importRes.Root)
require.NoError(t, err)
<-transfer.Done()
fmt.Printf("Finished transferring\n")
// Export to file and check that it exists
require.NoError(t, fc.ExportToFile(ctx, importRes.Root, outputFilename, false))
outFile, err := os.Stat(outputFilename)
require.NoError(t, err)
require.Greater(t, outFile.Size(), int64(0))
}