Documentation ¶
Index ¶
- Constants
- Variables
- func CheckBalanceVsSpending(r *TestNode, initialBalance types.Currency) error
- func CheckContractVsReportedSpending(r *TestNode, WindowSize types.BlockHeight, ...) error
- func CheckExpectedNumberOfContracts(r *TestNode, ...) error
- func CheckRenewedContractIDs(oldContracts, renewedContracts []api.RenterContract) error
- func CheckRenewedContractsSpending(renewedContracts []api.RenterContract) error
- func ChunkSize(minPieces uint64, ct crypto.CipherType) uint64
- func DrainContractsByUploading(renter *TestNode, tg *TestGroup) (startingUploadSpend types.Currency, err error)
- func FundNodes(miner *TestNode, nodes map[*TestNode]struct{}) error
- func Fuzz() int
- func NewGroupBuffer(size int) chan struct{}
- func RenewContractsByRenewWindow(renter *TestNode, tg *TestGroup) error
- func Retry(tries int, durationBetweenAttempts time.Duration, fn func() error) (err error)
- func TestDir(dirs ...string) string
- type GroupParams
- type LocalDir
- func (ld *LocalDir) CreateDir(name string) (*LocalDir, error)
- func (ld *LocalDir) Files() ([]*LocalFile, error)
- func (ld *LocalDir) Name() string
- func (ld *LocalDir) NewFile(size int) (*LocalFile, error)
- func (ld *LocalDir) NewFileWithMode(size int, mode os.FileMode) (*LocalFile, error)
- func (ld *LocalDir) NewFileWithName(name string, size int) (*LocalFile, error)
- func (ld *LocalDir) Path() string
- func (ld *LocalDir) PopulateDir(files, dirs, levels uint) error
- type LocalFile
- func (lf *LocalFile) Data() ([]byte, error)
- func (lf *LocalFile) Delete() error
- func (lf *LocalFile) Equal(data []byte) error
- func (lf *LocalFile) FileName() string
- func (lf *LocalFile) Move() error
- func (lf *LocalFile) Path() string
- func (lf *LocalFile) Size() int
- func (lf *LocalFile) Stat() (os.FileInfo, error)
- type RemoteDir
- type RemoteFile
- type TestGroup
- func (tg *TestGroup) AddNodeN(np node.NodeParams, n int) ([]*TestNode, error)
- func (tg *TestGroup) AddNodes(nps ...node.NodeParams) ([]*TestNode, error)
- func (tg *TestGroup) Close() error
- func (tg *TestGroup) Hosts() []*TestNode
- func (tg *TestGroup) Miners() []*TestNode
- func (tg *TestGroup) Nodes() []*TestNode
- func (tg *TestGroup) RemoveNode(tn *TestNode) error
- func (tg *TestGroup) Renters() []*TestNode
- func (tg *TestGroup) RestartNode(tn *TestNode) error
- func (tg *TestGroup) SetRenterAllowance(renter *TestNode, allowance modules.Allowance) error
- func (tg *TestGroup) StartNode(tn *TestNode) error
- func (tg *TestGroup) StartNodeCleanDeps(tn *TestNode) error
- func (tg *TestGroup) StopNode(tn *TestNode) error
- func (tg *TestGroup) Sync() error
- type TestNode
- func (tn *TestNode) BlockHeight() (types.BlockHeight, error)
- func (tn *TestNode) ConfirmedBalance() (types.Currency, error)
- func (tn *TestNode) ConfirmedTransactions() ([]modules.ProcessedTransaction, error)
- func (tn *TestNode) Dirs() ([]modules.I3vPath, error)
- func (tn *TestNode) DownloadByStream(rf *RemoteFile) (uid modules.DownloadID, data []byte, err error)
- func (tn *TestNode) DownloadByStreamWithDiskFetch(rf *RemoteFile, disableLocalFetch bool) (uid modules.DownloadID, data []byte, err error)
- func (tn *TestNode) DownloadDir() *LocalDir
- func (tn *TestNode) DownloadInfo(lf *LocalFile, rf *RemoteFile) (*api.DownloadInfo, error)
- func (tn *TestNode) DownloadToDisk(rf *RemoteFile, async bool) (modules.DownloadID, *LocalFile, error)
- func (tn *TestNode) DownloadToDiskPartial(rf *RemoteFile, lf *LocalFile, async bool, offset, length uint64) (modules.DownloadID, *LocalFile, error)
- func (tn *TestNode) DownloadToDiskWithDiskFetch(rf *RemoteFile, async bool, disableLocalFetch bool) (modules.DownloadID, *LocalFile, error)
- func (tn *TestNode) File(rf *RemoteFile) (modules.FileInfo, error)
- func (tn *TestNode) Files(cached bool) ([]modules.FileInfo, error)
- func (tn *TestNode) FilesDir() *LocalDir
- func (tn *TestNode) I3vPath(path string) modules.I3vPath
- func (tn *TestNode) IsAlertRegistered(a modules.Alert) error
- func (tn *TestNode) IsAlertUnregistered(a modules.Alert) error
- func (tn *TestNode) KnowsHost(host *TestNode) error
- func (tn *TestNode) MineBlock() error
- func (tn *TestNode) MineEmptyBlock() error
- func (tn *TestNode) NewLocalDir() (*LocalDir, error)
- func (tn *TestNode) PrintDebugInfo(t *testing.T, contractInfo, hostInfo, renterInfo bool)
- func (tn *TestNode) Rename(rf *RemoteFile, newPath modules.I3vPath) (*RemoteFile, error)
- func (tn *TestNode) RenterDir() string
- func (tn *TestNode) RenterFilesDir() string
- func (tn *TestNode) RestartNode() error
- func (tn *TestNode) SetFileRepairPath(rf *RemoteFile, lf *LocalFile) error
- func (tn *TestNode) StartNode() error
- func (tn *TestNode) StartNodeCleanDeps() error
- func (tn *TestNode) StopNode() error
- func (tn *TestNode) Stream(rf *RemoteFile) (data []byte, err error)
- func (tn *TestNode) StreamPartial(rf *RemoteFile, lf *LocalFile, from, to uint64) (data []byte, err error)
- func (tn *TestNode) StreamWithDiskFetch(rf *RemoteFile, disableLocalFetch bool) (data []byte, err error)
- func (tn *TestNode) Upload(lf *LocalFile, i3vpath modules.I3vPath, dataPieces, parityPieces uint64, ...) (*RemoteFile, error)
- func (tn *TestNode) UploadBlocking(localFile *LocalFile, dataPieces uint64, parityPieces uint64, force bool) (*RemoteFile, error)
- func (tn *TestNode) UploadDirectory(ld *LocalDir) (*RemoteDir, error)
- func (tn *TestNode) UploadNewDirectory() (*RemoteDir, error)
- func (tn *TestNode) UploadNewFile(filesize int, dataPieces uint64, parityPieces uint64, force bool) (*LocalFile, *RemoteFile, error)
- func (tn *TestNode) UploadNewFileBlocking(filesize int, dataPieces uint64, parityPieces uint64, force bool) (*LocalFile, *RemoteFile, error)
- func (tn *TestNode) WaitForDecreasingRedundancy(rf *RemoteFile, redundancy float64) error
- func (tn *TestNode) WaitForDownload(lf *LocalFile, rf *RemoteFile) error
- func (tn *TestNode) WaitForFileAvailable(rf *RemoteFile) error
- func (tn *TestNode) WaitForStuckChunksToBubble() error
- func (tn *TestNode) WaitForStuckChunksToRepair() error
- func (tn *TestNode) WaitForUploadHealth(rf *RemoteFile) error
- func (tn *TestNode) WaitForUploadProgress(rf *RemoteFile, progress float64) error
Constants ¶
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 i3vtest 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 ¶
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.I3vcoinPrecision.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, } )
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") )
var ( // I3vTestingDir is the directory that contains all of the files and // folders created during testing. I3vTestingDir = filepath.Join(os.TempDir(), "I3vTesting") )
Functions ¶
func CheckBalanceVsSpending ¶
CheckBalanceVsSpending checks the renters confirmed i3vcoin balance in their wallet against their reported spending
func CheckContractVsReportedSpending ¶
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 ¶
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 ¶
func CheckRenewedContractIDs(oldContracts, renewedContracts []api.RenterContract) error
CheckRenewedContractIDs confirms that contracts are renewed as expected with hosts and no duplicate IDs
func CheckRenewedContractsSpending ¶
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 ¶
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 ¶
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 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 ¶
func NewGroupBuffer(size int) chan struct{}
NewGroupBuffer creates a new buffer channel and fills it
func RenewContractsByRenewWindow ¶
RenewContractsByRenewWindow mines blocks to force contract renewal
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 ¶
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 i3v network
func (*LocalDir) CreateDir ¶
CreateDir creates a new LocalDir in the current LocalDir with the provided name.
func (*LocalDir) NewFileWithMode ¶
NewFileWithMode creates a new LocalFile in the current LocalDir with the given mode and size.
func (*LocalDir) NewFileWithName ¶
NewFileWithName creates a new LocalFile in the current LocalDir with the given name and size.
func (*LocalDir) PopulateDir ¶
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 uploaded to the I3v network.
func (*LocalFile) Data ¶
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) Equal ¶
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.
type RemoteDir ¶
type RemoteDir struct {
// contains filtered or unexported fields
}
RemoteDir is a helper struct that represents a directory on the I3v network.
type RemoteFile ¶
type RemoteFile struct {
// contains filtered or unexported fields
}
RemoteFile is a helper struct that represents a file uploaded to the I3v network.
func (*RemoteFile) Checksum ¶
func (rf *RemoteFile) Checksum() crypto.Hash
Checksum returns the checksum of a remote file.
func (*RemoteFile) I3vPath ¶
func (rf *RemoteFile) I3vPath() modules.I3vPath
I3vPath returns the i3vPath of a remote file.
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) AddNodes ¶
func (tg *TestGroup) AddNodes(nps ...node.NodeParams) ([]*TestNode, error)
AddNodes creates a node and adds it to the group.
func (*TestGroup) Close ¶
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 ¶
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 ¶
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 ¶
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 ¶
RemoveNode removes a node from the group and shuts it down.
func (*TestGroup) Renters ¶
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 ¶
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 ¶
SetRenterAllowance finished the setup for the renter test node
func (*TestGroup) StartNode ¶
StartNode starts a node from the group that has previously been stopped.
func (*TestGroup) StartNodeCleanDeps ¶
StartNodeCleanDeps starts a node from the group that has previously been stopped without its previously assigned dependencies.
type TestNode ¶
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 ¶
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 ¶
func (tn *TestNode) BlockHeight() (types.BlockHeight, error)
BlockHeight returns the node's consensus modules's synced block height.
func (*TestNode) ConfirmedBalance ¶
ConfirmedBalance returns the confirmed i3vcoin balance of the node's wallet.
func (*TestNode) ConfirmedTransactions ¶
func (tn *TestNode) ConfirmedTransactions() ([]modules.ProcessedTransaction, error)
ConfirmedTransactions returns all of the wallet's tracked confirmed transactions.
func (*TestNode) Dirs ¶
Dirs returns the i3vpaths 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (tn *TestNode) File(rf *RemoteFile) (modules.FileInfo, error)
File returns the file queried by the user
func (*TestNode) I3vPath ¶
I3vPath returns the i3vpath of a local file or directory to be used for uploading
func (*TestNode) IsAlertRegistered ¶
IsAlertRegistered returns an error if the given alert is not found
func (*TestNode) IsAlertUnregistered ¶
IsAlertUnregistered returns an error if the given alert is still found
func (*TestNode) KnowsHost ¶
KnowsHost checks if tn has a certain host in its hostdb. This check is performed using the host's public key.
func (*TestNode) MineBlock ¶
MineBlock makes the underlying node mine a single block and broadcast it.
func (*TestNode) MineEmptyBlock ¶
MineEmptyBlock mines an empty block without any transactions and broadcasts it.
func (*TestNode) NewLocalDir ¶
NewLocalDir creates a new LocalDir
func (*TestNode) PrintDebugInfo ¶
PrintDebugInfo prints out helpful debug information when debug tests and ndfs, the boolean arguments dictate what is printed
func (*TestNode) Rename ¶
func (tn *TestNode) Rename(rf *RemoteFile, newPath modules.I3vPath) (*RemoteFile, error)
Rename renames a remoteFile and returns the new file.
func (*TestNode) RenterFilesDir ¶
RenterFilesDir returns the renter's files directory
func (*TestNode) RestartNode ¶
RestartNode restarts a TestNode
func (*TestNode) SetFileRepairPath ¶
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) StartNodeCleanDeps ¶
StartNodeCleanDeps restarts a node from an active group without its previously assigned dependencies.
func (*TestNode) Stream ¶
func (tn *TestNode) Stream(rf *RemoteFile) (data []byte, err error)
Stream uses the streaming endpoint to download a file.
func (*TestNode) StreamPartial ¶
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 ¶
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, i3vpath modules.I3vPath, 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 ¶
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 redundancy.
func (*TestNode) UploadDirectory ¶
UploadDirectory uses the node to upload a directory
func (*TestNode) UploadNewDirectory ¶
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) WaitForDecreasingRedundancy ¶
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 ¶
func (tn *TestNode) WaitForFileAvailable(rf *RemoteFile) error
WaitForFileAvailable waits for a file to become available on the I3v network (redundancy of 1).
func (*TestNode) WaitForStuckChunksToBubble ¶
WaitForStuckChunksToBubble waits until the stuck chunks have been bubbled to the root directory metadata
func (*TestNode) WaitForStuckChunksToRepair ¶
WaitForStuckChunksToRepair waits until the stuck chunks have been repaired and bubbled to the root directory metadata
func (*TestNode) WaitForUploadHealth ¶
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package daemon contains tests related to the /daemon endpoints.
|
Package daemon contains tests related to the /daemon endpoints. |