2021-06-11 17:26:25 +00:00
|
|
|
package kit2
|
2021-05-25 23:04:13 +00:00
|
|
|
|
|
|
|
import (
|
2021-06-10 17:25:02 +00:00
|
|
|
"context"
|
2021-05-25 23:04:13 +00:00
|
|
|
"testing"
|
|
|
|
|
2021-06-10 17:25:02 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
2021-05-25 23:04:13 +00:00
|
|
|
"github.com/filecoin-project/lotus/api/v1api"
|
|
|
|
"github.com/filecoin-project/lotus/chain/wallet"
|
|
|
|
"github.com/multiformats/go-multiaddr"
|
2021-06-10 17:25:02 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-05-25 23:04:13 +00:00
|
|
|
)
|
|
|
|
|
2021-06-11 17:26:25 +00:00
|
|
|
// TestFullNode represents a full node enrolled in an Ensemble.
|
2021-05-25 23:04:13 +00:00
|
|
|
type TestFullNode struct {
|
|
|
|
v1api.FullNode
|
|
|
|
|
|
|
|
t *testing.T
|
|
|
|
|
|
|
|
// ListenAddr is the address on which an API server is listening, if an
|
|
|
|
// API server is created for this Node.
|
|
|
|
ListenAddr multiaddr.Multiaddr
|
|
|
|
DefaultKey *wallet.Key
|
|
|
|
|
2021-06-11 17:26:25 +00:00
|
|
|
options nodeOpts
|
2021-05-25 23:04:13 +00:00
|
|
|
}
|
2021-06-10 17:25:02 +00:00
|
|
|
|
2021-06-11 17:26:25 +00:00
|
|
|
// CreateImportFile creates a random file with the specified seed and size, and
|
|
|
|
// imports it into the full node.
|
2021-06-10 17:25:02 +00:00
|
|
|
func (f *TestFullNode) CreateImportFile(ctx context.Context, rseed int, size int) (res *api.ImportRes, path string) {
|
|
|
|
path = CreateRandomFile(f.t, rseed, size)
|
|
|
|
res, err := f.ClientImport(ctx, api.FileRef{Path: path})
|
|
|
|
require.NoError(f.t, err)
|
|
|
|
return res, path
|
|
|
|
}
|