enginetest

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package enginetest has helpers for tests that need a BitTorrent swarm: a seeder serving generated content on loopback, and client settings that keep anacrolix off the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Offline

func Offline(tc *torrent.ClientConfig)

Offline keeps a client off the network: loopback IPv4 only, no DHT, UPnP, local service discovery, trackers or WebTorrent.

Types

type Seeder

type Seeder struct {
	Client *torrent.Client
	// Metainfo is the .torrent file.
	Metainfo []byte
	// Hash is the infohash, lowercase hex.
	Hash string
	// Name is the torrent's name, the root folder or single file.
	Name string
	// Addr is the seeder's peer address, host:port.
	Addr string
	// Content maps each file's path inside the torrent to its data.
	Content map[string][]byte
}

Seeder is an anacrolix client seeding one generated torrent.

func NewSeeder

func NewSeeder(t testing.TB, name string, files map[string]int) *Seeder

NewSeeder generates files (path to size) under a root folder named name and seeds them on loopback until the test ends.

func StartSeeder

func StartSeeder(dir, name string, files map[string]int, configure func(*torrent.ClientConfig)) (*Seeder, error)

StartSeeder generates files (path to size) under dir/name and seeds them; with no files it seeds what is already there. configure adjusts the client, such as where it listens; Close the client when done.

func (*Seeder) Magnet

func (s *Seeder) Magnet() string

Magnet returns a magnet URI that names the seeder as a peer (x.pe), so metadata and data come from it without trackers or the DHT.

Jump to

Keyboard shortcuts

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