helpers

package
v1.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0, MIT Imports: 62 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWaitTimeout = xerrors.New("timeout waiting for condition")

Functions

func AddAggregateIndexFromPiece added in v1.27.4

func AddAggregateIndexFromPiece(t *testing.T, ctx context.Context, idx *indexstore.IndexStore, aggregate PieceFixture, subPieces []mk20.DataSource) error

AddAggregateIndexFromPiece indexes an aggregate fixture and stores both its payload block index and aggregate child-piece mappings in the test index store.

func AddIndexFromCAR added in v1.27.4

func AddIndexFromCAR(ctx context.Context, idx *indexstore.IndexStore, pieceCID cid.Cid, carBytes []byte) error

AddIndexFromCAR indexes a CAR fixture into the test index store for the supplied piece CID.

func AddPDPv0IndexFromPiece added in v1.28.3

func AddPDPv0IndexFromPiece(t *testing.T, ctx context.Context, idx *indexstore.IndexStore, piece PieceFixture) error

AddPDPv0IndexFromPiece indexes a PDPv0 parked piece for retrieval tests.

func AssertIPFSCarResponseHeaders added in v1.27.4

func AssertIPFSCarResponseHeaders(t *testing.T, headers http.Header)

func AssertNoFailedSectors added in v1.27.4

func AssertNoFailedSectors(t *testing.T, ctx context.Context, db *harmonydb.DB)

func AssertPieceResponseHeaders added in v1.27.4

func AssertPieceResponseHeaders(t *testing.T, headers http.Header, pieceCID string, expectedBodyLen int)

func AttachCurioHarnessCleanup added in v1.27.4

func AttachCurioHarnessCleanup(t *testing.T, harness CurioHarness, shutdownTimeout time.Duration)

func BootstrapNetwork added in v1.27.4

func BootstrapNetwork(t *testing.T, ctx context.Context, opts ...any) (*kit.TestFullNode, *kit.TestMiner, *kit.Ensemble, string)

func BootstrapNetworkWithNewMiner added in v1.27.4

func BootstrapNetworkWithNewMiner(t *testing.T, ctx context.Context, minerSize string, opts ...any) (*kit.TestFullNode, *kit.TestMiner, *harmonydb.DB, address.Address)

func CreateCliContext

func CreateCliContext(dir string, layers []string) (*cli.Context, error)

func CreateStorageMiner added in v1.27.4

func CreateStorageMiner(
	ctx context.Context,
	full v1api.FullNode,
	owner address.Address,
	sectorSize string,
	confidence uint64,
) (address.Address, error)

func CreateStorageMinerAndConfig added in v1.27.4

func CreateStorageMinerAndConfig(
	ctx context.Context,
	full v1api.FullNode,
	db *harmonydb.DB,
	owner address.Address,
	sectorSize string,
	confidence uint64,
	fapi string,
) (address.Address, error)

func DumpDealPipelineDiagnostics added in v1.27.4

func DumpDealPipelineDiagnostics(t *testing.T, ctx context.Context, db *harmonydb.DB, mk12UUIDs []string, mk20IDs []string, sectors []SectorRef)

func EncodeCurioConfigForDB added in v1.27.4

func EncodeCurioConfigForDB(cfg *config.CurioConfig) (string, error)

func EnvElse

func EnvElse(env, els string) string

func FR32PadFixture added in v1.27.4

func FR32PadFixture(raw []byte, pieceSize abi.PaddedPieceSize) []byte

func FreeListenAddr

func FreeListenAddr(t *testing.T) string

func FullNodeAPIInfo added in v1.27.4

func FullNodeAPIInfo(ctx context.Context, full v1api.FullNode, listenAddr multiaddr.Multiaddr) (string, error)

func HTTPGet added in v1.27.4

func HTTPGet(t *testing.T, baseURL, path string, headers map[string]string) (int, []byte)

func HTTPGetWithHeaders added in v1.27.4

func HTTPGetWithHeaders(t *testing.T, baseURL, path string, headers map[string]string) (int, []byte, http.Header)

func HTTPRequestWithHeaders added in v1.27.4

func HTTPRequestWithHeaders(t *testing.T, method, baseURL, path string, headers map[string]string) (int, []byte, http.Header)

func InsertCompletedParkedPiece added in v1.27.4

func InsertCompletedParkedPiece(tx *harmonydb.Tx, pieceCID string, pieceSize abi.PaddedPieceSize, rawSize int64, longTerm bool) (int64, error)

func InsertParkedPieceRef added in v1.27.4

func InsertParkedPieceRef(tx *harmonydb.Tx, pieceID int64, dataURL string, headers []byte, longTerm bool) (int64, error)

func Int64PtrOrNA added in v1.27.4

func Int64PtrOrNA(ptr *int64) string

func LoadBaseConfigFromDB added in v1.27.4

func LoadBaseConfigFromDB(ctx context.Context, db *harmonydb.DB) (*config.CurioConfig, error)

func LogIPNIStatus added in v1.27.4

func LogIPNIStatus(t *testing.T, ctx context.Context, db *harmonydb.DB)

LogIPNIStatus writes the current IPNI rows to the test log for debugging retrieval/indexing test failures.

func NewHashSpaceCluster added in v1.29.1

func NewHashSpaceCluster(t *testing.T, ctx context.Context, db *harmonydb.DB, storageID string) *hashfolder.Cluster

NewHashSpaceCluster joins a single temporary disk to the open-pieces hash space of db. The cluster is closed when the test ends.

func NewIndexStore added in v1.27.4

func NewIndexStore(ctx context.Context, t *testing.T, cfg *config.CurioConfig) *indexstore.IndexStore

func NullInt64OrNA added in v1.27.4

func NullInt64OrNA(v sql.NullInt64) string

func PipelineProgress added in v1.27.4

func PipelineProgress(t *testing.T, ctx context.Context, db *harmonydb.DB, mk12UUIDs []string, mk20IDs []string, poll int, remaining time.Duration) error

func PlaceOpenPiece added in v1.29.1

func PlaceOpenPiece(t *testing.T, ctx context.Context, hs *hashfolder.Cluster, piece PieceFixture)

PlaceOpenPiece writes the fixture's bytes into open-pieces on the disk its hash maps to, named as /piece/ looks it up.

func ProcessPieceDealTx added in v1.27.4

func ProcessPieceDealTx(tx *harmonydb.Tx, p ProcessPieceDealParams) error

func ProviderCollateralBounds added in v1.27.4

func ProviderCollateralBounds(ctx context.Context, full v1api.FullNode, pieceSize abi.PaddedPieceSize) (abi.TokenAmount, error)

func RedeclareAllLocalStorage added in v1.27.4

func RedeclareAllLocalStorage(ctx context.Context, t *testing.T, capi api.Curio)

func RequireNotInOpenPieces added in v1.29.1

func RequireNotInOpenPieces(t *testing.T, ctx context.Context, hs *hashfolder.Cluster, piece PieceFixture)

RequireNotInOpenPieces fails if any disk that may hold the piece has it.

func SectorSizeFromString added in v1.27.4

func SectorSizeFromString(size string) (abi.SectorSize, error)

func SeedMK12F05PendingDeal added in v1.27.4

func SeedMK12F05PendingDeal(tx *harmonydb.Tx, s MK12F05PendingSeed) error

func SeedMK20PendingDeal added in v1.27.4

func SeedMK20PendingDeal(tx *harmonydb.Tx, s MK20PendingSeed) error

func SelectFixtureRawBlockCandidate added in v1.27.4

func SelectFixtureRawBlockCandidate(t *testing.T, fixture PieceFixture) (cid.Cid, []byte)

SelectFixtureRawBlockCandidate returns a deterministic block from the CAR payload, preferring a non-root block when the fixture contains one.

func SetBaseConfigWithDefaults added in v1.27.4

func SetBaseConfigWithDefaults(t *testing.T, ctx context.Context, db *harmonydb.DB) (*config.CurioConfig, error)

func TimePtrOrNA added in v1.27.4

func TimePtrOrNA(v *time.Time) string

func UpdateBaseConfigWithTimestamp added in v1.27.4

func UpdateBaseConfigWithTimestamp(ctx context.Context, db *harmonydb.DB, cfg *config.CurioConfig) error

func UpsertBaseConfig added in v1.27.4

func UpsertBaseConfig(ctx context.Context, db *harmonydb.DB, cfg *config.CurioConfig) error

func WaitForCondition added in v1.27.4

func WaitForCondition(ctx context.Context, timeout time.Duration, pollInterval time.Duration, check func() (bool, error)) error

func WaitForHTTP added in v1.27.4

func WaitForHTTP(t *testing.T, baseURL string)

func WaitForTCP added in v1.27.4

func WaitForTCP(t *testing.T, addr string, timeout time.Duration)

WaitForTCP waits until something accepts TCP connections on addr (e.g. "127.0.0.1:4700"). Use after starting an RPC server in a goroutine so clients do not dial before Listen completes.

func WriteParkedPieceFixture added in v1.27.4

func WriteParkedPieceFixture(dir string, pieceID int64, data []byte) error

func WriteUnsealedSectorFixture added in v1.27.4

func WriteUnsealedSectorFixture(dir string, miner abi.ActorID, sector abi.SectorNumber, sectorSize abi.SectorSize, fixture PieceFixture) error

Types

type CurioHarness added in v1.27.4

type CurioHarness struct {
	API             api.Curio
	Dependencies    *deps.Deps
	EngineTerminate func()
	ClientCloser    jsonrpc.ClientCloser
	FinishCh        <-chan struct{}
}

func StartCurioHarness added in v1.27.4

func StartCurioHarness(
	ctx context.Context,
	t *testing.T,
	dir string,
	db *harmonydb.DB,
	idx *indexstore.IndexStore,
	full v1api.FullNode,
	storageRPCSecret string,
	opts CurioHarnessOptions,
) CurioHarness

func StartCurioHarnessWithCleanup added in v1.27.4

func StartCurioHarnessWithCleanup(
	ctx context.Context,
	t *testing.T,
	dir string,
	db *harmonydb.DB,
	idx *indexstore.IndexStore,
	full v1api.FullNode,
	storageRPCSecret string,
	opts CurioHarnessOptions,
) CurioHarness

type CurioHarnessOptions added in v1.27.4

type CurioHarnessOptions struct {
	Layers    []string
	LogLevels []CurioLogLevel
}

type CurioLogLevel added in v1.27.4

type CurioLogLevel struct {
	Subsystem string
	Level     string
}

type MK12F05PendingSeed added in v1.27.4

type MK12F05PendingSeed struct {
	UUID          string
	SPID          int64
	PieceCID      string
	PieceSize     abi.PaddedPieceSize
	RawSize       int64
	Offline       bool
	URL           string
	Announce      bool
	ClientPeerID  string
	FastRetrieval bool
	Signed        *MK12SignedProposal
}

type MK12SignedProposal added in v1.27.4

type MK12SignedProposal struct {
	Proposal          market9.DealProposal
	SignedProposalCID cid.Cid
	ProposalCID       cid.Cid
	ProposalJSON      []byte
	SignatureBytes    []byte
	LabelCBOR         []byte
}

func BuildSignedMK12Proposal added in v1.27.4

func BuildSignedMK12Proposal(ctx context.Context, full v1api.FullNode, clientAddr address.Address, providerAddr address.Address, root cid.Cid, pieceCID cid.Cid, pieceSize abi.PaddedPieceSize, startEpoch abi.ChainEpoch, endEpoch abi.ChainEpoch, providerCollateral abi.TokenAmount) (*MK12SignedProposal, error)

type MK20PendingSeed added in v1.27.4

type MK20PendingSeed struct {
	DealID     string
	Client     string
	Provider   address.Address
	Contract   string
	PieceCIDV2 cid.Cid
	Offline    bool
	SourceURL  string
	Indexing   bool
	Announce   bool
	Duration   abi.ChainEpoch
}

type PieceFixture added in v1.27.4

type PieceFixture struct {
	RootCID    cid.Cid
	CarBytes   []byte
	PieceCIDV1 cid.Cid
	PieceCIDV2 cid.Cid
	PieceSize  abi.PaddedPieceSize
	RawSize    int64
}

func CreateAggregateFixtureFromSubpieces added in v1.27.4

func CreateAggregateFixtureFromSubpieces(t *testing.T, subpieces []PieceFixture) (PieceFixture, []mk20.DataSource)

func CreatePieceFixture added in v1.27.4

func CreatePieceFixture(t *testing.T, dir string, sourceSize int64) PieceFixture

type ProcessPieceDealParams added in v1.27.4

type ProcessPieceDealParams struct {
	DealID        string
	PieceCID      string
	BoostDeal     bool
	SPID          int64
	SectorNum     int64
	PieceOffset   any
	PieceLength   int64
	RawSize       int64
	FastRetrieval bool
	PieceRefID    any
	LegacyDeal    bool
	LegacyDealID  int64
}

type SectorRef added in v1.27.4

type SectorRef struct {
	SPID   int64
	Number int64
}

Jump to

Keyboard shortcuts

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