siatest

package
v1.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 31 Imported by: 0

README

Siatest

The siatest package is designed to handle the integration tests for the Sia codebase.

Methodology

When writing siatests, the developer should structure the tests to mimic production use. All interactions with Sia should be performed through the API and client methods.

Test group creation is a time and resource intensive operation. Whenever possible tests should be grouped together and share the same test group.

Submodules

There is a submodule of the siatest package for each module of Sia (ie Host, Renter, Wallet, etc). There submodules contain all the test code for the corresponding Sia module.

In addition to these testing submodules there is a dependencies submodule. The dependencies submodule is for dependency injection for tests that need to exploit a specific test scenario that cannot be reliably tested through normal means.

Subsystems

The following subsystems help the SiaDir module execute its responsibilities:

Local Dir Subsystem

Key Files

The Local Dir subsystem is responsible for representing a local directory on disk that could be uploaded to the Sia network.

Exports TestNode Methods

  • NewLocalDir creates a new LocalDir in the TestNodes renter directory

LocalDir Methods

  • CreateDircreates a new LocalDir
  • Files returns a slice of files that are in the LocalDir
  • Name returns the name of the LocalDir
  • NewFile creates a new LocalFile in the LocalDir
  • NewFileWithName creates a new LocalFile with a specified name in the LocalDir
  • NewFileWithMode creates a new LocalFile with a specified mode in the LocalDir
  • Path returns the path of the LocalDir
  • PopulateDir populates a LocalDir with files and sub-directories

Outbound Complexities

  • NewLocalDir calls out to the testhelper subsystem's RenterDir method
Local File Subsystem

Key Files

The Local File subsystem is responsible for representing a file on disk that has been uploaded to the Sia network.

Exports

  • Data returns the byte slice data of a file
  • Delete deletes the local file from disk
  • Equal compares a byte slice to the data stored on disk
  • FileName returns the file name
  • Move moves the file to a new random location
  • Path returns the on disk path to the file
  • Size returns the size of the file
  • Stat is a wrapper for os.Stat
Remote Dir Subsystem

Key Files

The Remote Dir subsystem is responsible for representing a directory on the Sia network.

Exports

  • SiaPath returns the siapath of the remote directory
Remote File Subsystem

Key Files

The Remote File subsystem is responsible for representing a SiaFile on the Sia network.

Exports

  • Checksum returns the checksum of the remote file
  • SiaPath returns the siapath of the remote file
Test Group Subsystem

Key Files

The Test Group subsystem to responsible for creating a group of TestNodes to form a mini Sia network.

There is a testGroupBuffer that is used to control the creation of the TestGroups in order to reduce too many open file errors.

Exports

  • NewGroup creates a new TestGroup with fully synced, funded, and connected TestNodes based on node params
  • NewGroupBuffer creates a buffer channel and fills it
  • NewGroupFromTemplate creates a new TestGroup with fully synced, funded, and connected TestNodes based on group params
  • AddNodeN adds a number of nodes of a given template to a TestGroup
  • AddNodes adds a list of nodes to a TestGroup
  • Close closes the group
  • Hosts converts the map of host nodes to a slice and returns it
  • Nodes converts the map of nodes to a slice and returns it
  • Miners converts the map of miners nodes to a slice and returns it - RemoveNode removes a node from the group
  • Renters converts the map of renters nodes to a slice and returns it
  • RestartNode restarts a node from the group
  • SetRenterAllowance sets the allowance of a renter node in the group
  • StartNode starts a group's previously stopped node
  • StartNodeCleanDeps starts a group's previously stopped node with nil dependencies
  • StopNode stops a group's node
  • Sync makes sure that the group's nodes are synchronized

Inbound Complexities

Outbound Complexities

Test Node Subsystem

Key Files

The Test Node subsystem is responsible for representing a node on the Sia network.

Exports

  • NewNode returns a new TestNode that has a funded wallet
  • NewCleanNew returns a new TestNode that has an unfunded wallet
  • NewCleanNewAsync returns a new TestNode that has an unfunded wallet and uses the NewAsync function of the server package
  • IsAlertRegistered checks if an alert is registered with a TestNode
  • IsAlertUnregistered checks if an alert has been unregistered with a TestNode
  • PrintDebugInfo logs out some helpful debug information about a TestNode
  • RestartNode stops and then restarts a TestNode
  • SiaPath returns a siapath of a LocalDir or LocalFile that could be used for uploading
  • StartNode starts a TestNode
  • StartNodeCleanDeps starts a TestNode but first sets any dependencies to nil
  • StopNode stops a TestNode
Test Helpers Subsystem

Key Files

The Test Helper subsystem contains helper methods and functions for executing tests.

Exports

  • ChunkSize calculates the size of a chunk based on the pieces
  • DownloadDir returns the LocalDir of the TestNode that represents the downloads directory
  • FilesDir returns the LocalDir of the TestNode that represents the upload directory
  • Fuzz returns -1, 0, or 1
  • RenterDir returns the path of the TestNode's renter directory
  • RenterFilesDir returns the path of the TestNode's files directory
  • Retry calls a function a number of times with a sleep duration in between each call
  • TestDir creates a tmp directory on disk for the test

Inbound Complexities

  • The LocaDir subsystem's NewLocalDir method uses the RenterDir method
Modules Subsystem

Key Files

The modules subsystem contains useful methods that are common across a module's test suite. For example, uploading a file is necessary for almost every renter test so there are a number of Upload methods in renter.go that can be used to deduplicate code.

See each corresponding module file for more details and examples.

Documentation

Index

Constants

View Source
const (
	// NumberOfParallelGroups is the number of testgroups that can be created in
	// parallel to prevent `too many open files` errors
	//
	// The value of 1 is based on running the siatest package with 8 threads, so
	// 8 tests can be run in parallel and the testgroup creation is throttled to
	// 1 at a time
	NumberOfParallelGroups = 1
)

Variables

View Source
var (
	// DefaultAllowance is the allowance used for the group's renters.
	//
	// Note: the default allowance needs to be close enough in practice to what
	// the host default settings are that price gouging protection does not kick
	// in.
	DefaultAllowance = modules.Allowance{
		Funds:       types.SiacoinPrecision.Mul64(1e3),
		Hosts:       5,
		Period:      50,
		RenewWindow: 24,

		ExpectedStorage:    modules.SectorSize * 5e3,
		ExpectedUpload:     modules.SectorSize * 500,
		ExpectedDownload:   modules.SectorSize * 500,
		ExpectedRedundancy: 5.0,
		MaxPeriodChurn:     modules.SectorSize * 500,
	}
)
View Source
var (
	// ErrFileNotTracked is an error returned by the TestNode in case a file
	// wasn't accessible due to being unknown to the renter.
	ErrFileNotTracked = errors.New("file is not tracked by renter")
)
View Source
var (
	// SiaTestingDir is the directory that contains all of the files and
	// folders created during testing.
	SiaTestingDir = filepath.Join(os.TempDir(), "SiaTesting")
)

Functions

func CheckBalanceVsSpending added in v1.4.13

func CheckBalanceVsSpending(r *TestNode, initialBalance types.Currency) error

CheckBalanceVsSpending checks the renters confirmed siacoin balance in their wallet against their reported spending

func CheckContractVsReportedSpending added in v1.4.13

func CheckContractVsReportedSpending(r *TestNode, WindowSize types.BlockHeight, oldContracts, renewedContracts []api.RenterContract) error

CheckContractVsReportedSpending confirms that the spending recorded in the renter's contracts matches the reported spending for the renter. Renewed contracts should be the renter's active contracts and oldContracts should be the renter's inactive and expired contracts

func CheckExpectedNumberOfContracts added in v1.4.13

func CheckExpectedNumberOfContracts(r *TestNode, numActive, numPassive, numRefreshed, numDisabled, numExpired, numExpiredRefreshed int) error

CheckExpectedNumberOfContracts confirms that the renter has the expected number of each type of contract

func CheckRenewedContractIDs added in v1.4.13

func CheckRenewedContractIDs(oldContracts, renewedContracts []api.RenterContract) error

CheckRenewedContractIDs confirms that contracts are renewed as expected with hosts and no duplicate IDs

func CheckRenewedContractsSpending added in v1.4.13

func CheckRenewedContractsSpending(renewedContracts []api.RenterContract) error

CheckRenewedContractsSpending confirms that renewed contracts have zero upload and download spending. Renewed contracts should be the renter's active contracts

func ChunkSize added in v1.3.3

func ChunkSize(minPieces uint64, ct crypto.CipherType) uint64

ChunkSize is a helper method to calculate the size of a chunk depending on the minimum number of pieces required to restore the chunk.

func DrainContractsByUploading added in v1.4.13

func DrainContractsByUploading(renter *TestNode, tg *TestGroup) (startingUploadSpend types.Currency, err error)

DrainContractsByUploading uploads files until the contracts renew due to running out of funds

NOTE: in order to use this helper method the renter must use the dependency DependencyDisableUploadGougingCheck so that the uploads succeed

func FundNodes added in v1.4.13

func FundNodes(miner *TestNode, nodes map[*TestNode]struct{}) error

FundNodes uses the funds of a miner node to fund all the nodes of the group

func Fuzz

func Fuzz() int

Fuzz returns 0, 1 or -1. This can be used to test for random off-by-one errors in the code. For example fuzz can be used to create a File that is either sector aligned or off-by-one.

func NewGroupBuffer added in v1.4.0

func NewGroupBuffer(size int) chan struct{}

NewGroupBuffer creates a new buffer channel and fills it

func PrintJSON added in v1.4.13

func PrintJSON(a interface{})

PrintJSON is a helper function that wraps the jsonMarshalIndent function

func RenewContractsByRenewWindow added in v1.4.13

func RenewContractsByRenewWindow(renter *TestNode, tg *TestGroup) error

RenewContractsByRenewWindow mines blocks to force contract renewal

func Retry

func Retry(tries int, durationBetweenAttempts time.Duration, fn func() error) (err error)

Retry will call 'fn' 'tries' times, waiting 'durationBetweenAttempts' between each attempt, returning 'nil' the first time that 'fn' returns nil. If 'nil' is never returned, then the final error returned by 'fn' is returned.

func RunSubTests added in v1.4.13

func RunSubTests(t *testing.T, params GroupParams, directory string, tests []SubTest) error

RunSubTests is a helper function to run the subtests when tests can use the same test group

func TestDir

func TestDir(dirs ...string) string

TestDir joins the provided directories and prefixes them with the Sia testing directory, removing any files or directories that previously existed at that location.

Types

type GroupParams

type GroupParams struct {
	Hosts   int // number of hosts to create
	Renters int // number of renters to create
	Miners  int // number of miners to create
}

GroupParams is a helper struct to make creating TestGroups easier.

type LocalDir added in v1.4.0

type LocalDir struct {
	// contains filtered or unexported fields
}

LocalDir is a helper struct that represents a directory on disk that is to be uploaded to the sia network

func (*LocalDir) CreateDir added in v1.4.0

func (ld *LocalDir) CreateDir(name string) (*LocalDir, error)

CreateDir creates a new LocalDir in the current LocalDir with the provided name.

func (*LocalDir) Files added in v1.4.0

func (ld *LocalDir) Files() ([]*LocalFile, error)

Files returns a slice of the files in the LocalDir

func (*LocalDir) Name added in v1.4.0

func (ld *LocalDir) Name() string

Name returns the directory name of the directory on disk

func (*LocalDir) NewFile added in v1.4.0

func (ld *LocalDir) NewFile(size int) (*LocalFile, error)

NewFile creates a new LocalFile in the current LocalDir

func (*LocalDir) NewFileWithMode added in v1.4.13

func (ld *LocalDir) NewFileWithMode(size int, mode os.FileMode) (*LocalFile, error)

NewFileWithMode creates a new LocalFile in the current LocalDir with the given mode and size.

func (*LocalDir) NewFileWithName added in v1.4.13

func (ld *LocalDir) NewFileWithName(name string, size int) (*LocalFile, error)

NewFileWithName creates a new LocalFile in the current LocalDir with the given name and size.

func (*LocalDir) Path added in v1.4.0

func (ld *LocalDir) Path() string

Path creates a new LocalFile in the current LocalDir

func (*LocalDir) PopulateDir added in v1.4.0

func (ld *LocalDir) PopulateDir(files, dirs, levels uint) error

PopulateDir populates a LocalDir levels deep with the number of files and directories provided at each level. The same number of files and directories will be at each level

type LocalFile

type LocalFile struct {
	// contains filtered or unexported fields
}

LocalFile is a helper struct that represents a file on disk that was uploaded to the Sia network.

func (*LocalFile) Data added in v1.4.13

func (lf *LocalFile) Data() ([]byte, error)

Data will return the data of the file, so that it can be compared against output such as download output after it has been deleted locally.

func (*LocalFile) Delete added in v1.3.3

func (lf *LocalFile) Delete() error

Delete removes the LocalFile from disk.

func (*LocalFile) Equal added in v1.4.0

func (lf *LocalFile) Equal(data []byte) error

Equal will compare the input to the bytes of the local file, returning an error if the bytes are not a perfect match, or if there is an error reading the local file data.

func (*LocalFile) FileName added in v1.4.0

func (lf *LocalFile) FileName() string

FileName returns the file name of the file on disk

func (*LocalFile) Move added in v1.3.5

func (lf *LocalFile) Move() error

Move moves the file to a new random location.

func (*LocalFile) Path added in v1.4.0

func (lf *LocalFile) Path() string

Path returns the on-disk path of the local file.

func (*LocalFile) Size added in v1.4.13

func (lf *LocalFile) Size() int

Size returns the size of the local file.

func (*LocalFile) Stat added in v1.4.13

func (lf *LocalFile) Stat() (os.FileInfo, error)

Stat is a wrapper for os.Stat.

type RemoteDir added in v1.4.0

type RemoteDir struct {
	// contains filtered or unexported fields
}

RemoteDir is a helper struct that represents a directory on the Sia network.

func (*RemoteDir) SiaPath added in v1.4.0

func (rd *RemoteDir) SiaPath() modules.SiaPath

SiaPath returns the siapath of a remote directory.

type RemoteFile

type RemoteFile struct {
	// contains filtered or unexported fields
}

RemoteFile is a helper struct that represents a file uploaded to the Sia network.

func (*RemoteFile) Checksum added in v1.4.0

func (rf *RemoteFile) Checksum() crypto.Hash

Checksum returns the checksum of a remote file.

func (*RemoteFile) Root added in v1.4.13

func (rf *RemoteFile) Root() bool

Root returns whether the siapath needs to be treated as an absolute path.

func (*RemoteFile) SiaPath added in v1.3.4

func (rf *RemoteFile) SiaPath() modules.SiaPath

SiaPath returns the siaPath of a remote file.

type SubTest added in v1.4.13

type SubTest struct {
	Name string
	Test func(*testing.T, *TestGroup)
}

SubTest is a helper struct for running subtests when tests can use the same test group

type TestGroup

type TestGroup struct {
	// contains filtered or unexported fields
}

TestGroup is a group of of TestNodes that are funded, synced and ready for upload, download and mining depending on their configuration

func NewGroup

func NewGroup(groupDir string, nodeParams ...node.NodeParams) (*TestGroup, error)

NewGroup creates a group of TestNodes from node params. All the nodes will be connected, synced and funded. Hosts nodes are also announced.

func NewGroupFromTemplate

func NewGroupFromTemplate(groupDir string, groupParams GroupParams) (*TestGroup, error)

NewGroupFromTemplate will create hosts, renters and miners according to the settings in groupParams.

func (*TestGroup) AddNodeN added in v1.3.3

func (tg *TestGroup) AddNodeN(np node.NodeParams, n int) ([]*TestNode, error)

AddNodeN adds n nodes of a given template to the group.

func (*TestGroup) AddNodes added in v1.3.3

func (tg *TestGroup) AddNodes(nps ...node.NodeParams) ([]*TestNode, error)

AddNodes creates a node and adds it to the group.

func (*TestGroup) Close

func (tg *TestGroup) Close() error

Close closes the group and all its nodes. Closing a node is usually a slow process, but we can speed it up a lot by closing each node in a separate goroutine.

func (*TestGroup) Hosts

func (tg *TestGroup) Hosts() []*TestNode

Hosts returns all the hosts of the group. Note that the ordering of nodes in the slice returned is not the same across multiple calls this function.

func (*TestGroup) Miners

func (tg *TestGroup) Miners() []*TestNode

Miners returns all the miners of the group. Note that the ordering of nodes in the slice returned is not the same across multiple calls this function.

func (*TestGroup) Nodes

func (tg *TestGroup) Nodes() []*TestNode

Nodes returns all the nodes of the group. Note that the ordering of nodes in the slice returned is not the same across multiple calls this function.

func (*TestGroup) RemoveNode added in v1.3.3

func (tg *TestGroup) RemoveNode(tn *TestNode) error

RemoveNode removes a node from the group and shuts it down.

func (*TestGroup) Renters

func (tg *TestGroup) Renters() []*TestNode

Renters returns all the renters of the group. Note that the ordering of nodes in the slice returned is not the same across multiple calls this function.

func (*TestGroup) RestartNode added in v1.4.0

func (tg *TestGroup) RestartNode(tn *TestNode) error

RestartNode stops a node and then starts it again while conducting a few checks and guaranteeing that the node is connected to the group afterwards.

func (*TestGroup) SetRenterAllowance added in v1.3.3

func (tg *TestGroup) SetRenterAllowance(renter *TestNode, allowance modules.Allowance) error

SetRenterAllowance finished the setup for the renter test node

func (*TestGroup) StartNode added in v1.3.3

func (tg *TestGroup) StartNode(tn *TestNode) error

StartNode starts a node from the group that has previously been stopped.

func (*TestGroup) StartNodeCleanDeps added in v1.4.13

func (tg *TestGroup) StartNodeCleanDeps(tn *TestNode) error

StartNodeCleanDeps starts a node from the group that has previously been stopped without its previously assigned dependencies.

func (*TestGroup) StopNode added in v1.3.3

func (tg *TestGroup) StopNode(tn *TestNode) error

StopNode stops a node of a group.

func (*TestGroup) Sync added in v1.3.3

func (tg *TestGroup) Sync() error

Sync makes sure that the test group's nodes are synchronized

type TestNode

type TestNode struct {
	*server.Server
	client.Client
	// contains filtered or unexported fields
}

TestNode is a helper struct for testing that contains a server and a client as embedded fields.

func NewCleanNode

func NewCleanNode(nodeParams node.NodeParams) (*TestNode, error)

NewCleanNode creates a new TestNode that's not yet funded

func NewCleanNodeAsync added in v1.4.13

func NewCleanNodeAsync(nodeParams node.NodeParams) (*TestNode, error)

NewCleanNodeAsync creates a new TestNode that's not yet funded

func NewNode

func NewNode(nodeParams node.NodeParams) (*TestNode, error)

NewNode creates a new funded TestNode

func (*TestNode) BlockHeight added in v1.4.0

func (tn *TestNode) BlockHeight() (types.BlockHeight, error)

BlockHeight returns the node's consensus modules's synced block height.

func (*TestNode) ConfirmedBalance added in v1.4.0

func (tn *TestNode) ConfirmedBalance() (types.Currency, error)

ConfirmedBalance returns the confirmed siacoin balance of the node's wallet.

func (*TestNode) ConfirmedTransactions added in v1.4.0

func (tn *TestNode) ConfirmedTransactions() ([]modules.ProcessedTransaction, error)

ConfirmedTransactions returns all of the wallet's tracked confirmed transactions.

func (*TestNode) Dirs added in v1.4.0

func (tn *TestNode) Dirs() ([]modules.SiaPath, error)

Dirs returns the siapaths of all dirs of the TestNode's renter in no deterministic order.

func (*TestNode) DownloadByStream

func (tn *TestNode) DownloadByStream(rf *RemoteFile) (uid modules.DownloadID, data []byte, err error)

DownloadByStream downloads a file and returns its contents as a slice of bytes.

func (*TestNode) DownloadByStreamWithDiskFetch added in v1.4.13

func (tn *TestNode) DownloadByStreamWithDiskFetch(rf *RemoteFile, disableLocalFetch bool) (uid modules.DownloadID, data []byte, err error)

DownloadByStreamWithDiskFetch downloads a file and returns its contents as a slice of bytes.

func (*TestNode) DownloadDir added in v1.4.0

func (tn *TestNode) DownloadDir() *LocalDir

DownloadDir returns the LocalDir that is the testnodes download directory

func (*TestNode) DownloadInfo

func (tn *TestNode) DownloadInfo(lf *LocalFile, rf *RemoteFile) (*api.DownloadInfo, error)

DownloadInfo returns the DownloadInfo struct of a file. If it returns nil, the download has either finished, or was never started in the first place. If the corresponding download info was found, DownloadInfo also performs a few sanity checks on its fields.

func (*TestNode) DownloadToDisk

func (tn *TestNode) DownloadToDisk(rf *RemoteFile, async bool) (modules.DownloadID, *LocalFile, error)

DownloadToDisk downloads a previously uploaded file. The file will be downloaded to a random location and returned as a LocalFile object.

func (*TestNode) DownloadToDiskPartial added in v1.3.5

func (tn *TestNode) DownloadToDiskPartial(rf *RemoteFile, lf *LocalFile, async bool, offset, length uint64) (modules.DownloadID, *LocalFile, error)

DownloadToDiskPartial downloads a part of a previously uploaded file. The file will be downloaded to a random location and returned as a LocalFile object.

func (*TestNode) DownloadToDiskWithDiskFetch added in v1.4.13

func (tn *TestNode) DownloadToDiskWithDiskFetch(rf *RemoteFile, async bool, disableLocalFetch bool) (modules.DownloadID, *LocalFile, error)

DownloadToDiskWithDiskFetch downloads a previously uploaded file. The file will be downloaded to a random location and returned as a LocalFile object.

func (*TestNode) File added in v1.3.3

func (tn *TestNode) File(rf *RemoteFile) (fi modules.FileInfo, err error)

File returns the file queried by the user

func (*TestNode) Files

func (tn *TestNode) Files(cached bool) ([]modules.FileInfo, error)

Files lists the files tracked by the renter

func (*TestNode) FilesDir added in v1.4.0

func (tn *TestNode) FilesDir() *LocalDir

FilesDir returns the LocalDir that is the testnodes upload directory

func (*TestNode) IsAlertRegistered added in v1.4.13

func (tn *TestNode) IsAlertRegistered(a modules.Alert) error

IsAlertRegistered returns an error if the given alert is not found

func (*TestNode) IsAlertUnregistered added in v1.4.13

func (tn *TestNode) IsAlertUnregistered(a modules.Alert) error

IsAlertUnregistered returns an error if the given alert is still found

func (*TestNode) KnowsHost added in v1.3.3

func (tn *TestNode) KnowsHost(host *TestNode) error

KnowsHost checks if tn has a certain host in its hostdb. This check is performed using the host's public key.

func (*TestNode) MineBlock

func (tn *TestNode) MineBlock() error

MineBlock makes the underlying node mine a single block and broadcast it.

func (*TestNode) MineEmptyBlock added in v1.4.13

func (tn *TestNode) MineEmptyBlock() error

MineEmptyBlock mines an empty block without any transactions and broadcasts it.

func (*TestNode) NewLocalDir added in v1.4.0

func (tn *TestNode) NewLocalDir() (*LocalDir, error)

NewLocalDir creates a new LocalDir

func (*TestNode) PrintDebugInfo added in v1.3.5

func (tn *TestNode) PrintDebugInfo(t *testing.T, contractInfo, hostInfo, renterInfo bool)

PrintDebugInfo prints out helpful debug information when debug tests and ndfs, the boolean arguments dictate what is printed

func (*TestNode) Rename added in v1.4.0

func (tn *TestNode) Rename(rf *RemoteFile, newPath modules.SiaPath) (*RemoteFile, error)

Rename renames a remoteFile with the root parameter set to false and returns the new file.

func (*TestNode) RenameRoot added in v1.4.13

func (tn *TestNode) RenameRoot(rf *RemoteFile, newPath modules.SiaPath, root bool) (*RemoteFile, error)

RenameRoot renames a remoteFile with the option of setting the root parameter and returns the new file.

func (*TestNode) RenterDir added in v1.4.0

func (tn *TestNode) RenterDir() string

RenterDir returns the renter directory for the renter

func (*TestNode) RenterFilesDir added in v1.4.0

func (tn *TestNode) RenterFilesDir() string

RenterFilesDir returns the renter's files directory

func (*TestNode) RestartNode added in v1.3.3

func (tn *TestNode) RestartNode() error

RestartNode restarts a TestNode

func (*TestNode) SetFileRepairPath added in v1.3.5

func (tn *TestNode) SetFileRepairPath(rf *RemoteFile, lf *LocalFile) error

SetFileRepairPath changes the repair path of a remote file to the provided local file's path.

func (*TestNode) SiaPath added in v1.4.0

func (tn *TestNode) SiaPath(path string) modules.SiaPath

SiaPath returns the siapath of a local file or directory to be used for uploading

func (*TestNode) StartNode added in v1.3.3

func (tn *TestNode) StartNode() error

StartNode starts a TestNode from an active group

func (*TestNode) StartNodeCleanDeps added in v1.4.13

func (tn *TestNode) StartNodeCleanDeps() error

StartNodeCleanDeps restarts a node from an active group without its previously assigned dependencies.

func (*TestNode) StopNode added in v1.3.3

func (tn *TestNode) StopNode() error

StopNode stops a TestNode

func (*TestNode) Stream added in v1.3.3

func (tn *TestNode) Stream(rf *RemoteFile) (data []byte, err error)

Stream uses the streaming endpoint to download a file.

func (*TestNode) StreamPartial added in v1.3.3

func (tn *TestNode) StreamPartial(rf *RemoteFile, lf *LocalFile, from, to uint64) (data []byte, err error)

StreamPartial uses the streaming endpoint to download a partial file in range [from;to]. A local file can be provided optionally to implicitly check the checksum of the downloaded data.

func (*TestNode) StreamWithDiskFetch added in v1.4.13

func (tn *TestNode) StreamWithDiskFetch(rf *RemoteFile, disableLocalFetch bool) (data []byte, err error)

StreamWithDiskFetch uses the streaming endpoint to download a file.

func (*TestNode) Upload

func (tn *TestNode) Upload(lf *LocalFile, siapath modules.SiaPath, dataPieces, parityPieces uint64, force bool) (*RemoteFile, error)

Upload uses the node to upload the file with the option to overwrite if exists.

func (*TestNode) UploadBlocking added in v1.4.0

func (tn *TestNode) UploadBlocking(localFile *LocalFile, dataPieces uint64, parityPieces uint64, force bool) (*RemoteFile, error)

UploadBlocking attempts to upload an existing file with the option to overwrite if exists and waits for the upload to reach 100% progress and full health.

func (*TestNode) UploadDirectory added in v1.4.0

func (tn *TestNode) UploadDirectory(ld *LocalDir) (*RemoteDir, error)

UploadDirectory uses the node to upload a directory

func (*TestNode) UploadNewDirectory added in v1.4.0

func (tn *TestNode) UploadNewDirectory() (*RemoteDir, error)

UploadNewDirectory uses the node to create and upload a directory with a random name

func (*TestNode) UploadNewFile

func (tn *TestNode) UploadNewFile(filesize int, dataPieces uint64, parityPieces uint64, force bool) (*LocalFile, *RemoteFile, error)

UploadNewFile initiates the upload of a filesize bytes large file with the option to overwrite if exists.

func (*TestNode) UploadNewFileBlocking

func (tn *TestNode) UploadNewFileBlocking(filesize int, dataPieces uint64, parityPieces uint64, force bool) (*LocalFile, *RemoteFile, error)

UploadNewFileBlocking uploads a filesize bytes large file with the option to overwrite if exists and waits for the upload to reach 100% progress and redundancy.

func (*TestNode) UploadNewSkyfileBlocking added in v1.4.13

func (tn *TestNode) UploadNewSkyfileBlocking(filename string, filesize uint64, force bool) (skylink string, sup modules.SkyfileUploadParameters, sshp api.SkynetSkyfileHandlerPOST, err error)

UploadNewSkyfileBlocking attempts to upload a skyfile of given size. After it has successfully performed the upload, it will verify the file can be downloaded using its Skylink. Returns the skylink, the parameters used for the upload and potentially an error.

func (*TestNode) WaitForDecreasingRedundancy added in v1.3.3

func (tn *TestNode) WaitForDecreasingRedundancy(rf *RemoteFile, redundancy float64) error

WaitForDecreasingRedundancy waits until the redundancy decreases to a certain point.

func (*TestNode) WaitForDownload

func (tn *TestNode) WaitForDownload(lf *LocalFile, rf *RemoteFile) error

WaitForDownload waits for the download of a file to finish. If a file wasn't scheduled for download it will return instantly without an error. If parent is provided, it will compare the contents of the downloaded file to the contents of tf2 after the download is finished. WaitForDownload also verifies the checksum of the downloaded file.

func (*TestNode) WaitForFileAvailable added in v1.4.13

func (tn *TestNode) WaitForFileAvailable(rf *RemoteFile) error

WaitForFileAvailable waits for a file to become available on the Sia network (redundancy of 1).

func (*TestNode) WaitForStuckChunksToBubble added in v1.4.0

func (tn *TestNode) WaitForStuckChunksToBubble() error

WaitForStuckChunksToBubble waits until the stuck chunks have been bubbled to the root directory metadata

func (*TestNode) WaitForStuckChunksToRepair added in v1.4.0

func (tn *TestNode) WaitForStuckChunksToRepair() error

WaitForStuckChunksToRepair waits until the stuck chunks have been repaired and bubbled to the root directory metadata

func (*TestNode) WaitForUploadHealth added in v1.4.13

func (tn *TestNode) WaitForUploadHealth(rf *RemoteFile) error

WaitForUploadHealth waits for a file to reach a health better than the RepairThreshold.

func (*TestNode) WaitForUploadProgress

func (tn *TestNode) WaitForUploadProgress(rf *RemoteFile, progress float64) error

WaitForUploadProgress waits for a file to reach a certain upload progress.

Directories

Path Synopsis
Package daemon contains tests related to the /daemon endpoints.
Package daemon contains tests related to the /daemon endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL