stack

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package smeltery provides a simple API for spinning up the complete Storacha network in Go tests using testcontainers-go.

Example usage:

func TestUploadFlow(t *testing.T) {
    stack := smeltery.MustNewStack(t,
        smeltery.WithPiriImage("my-piri:test"),
    )

    resp, _ := http.Get(stack.PiriEndpoint() + "/readyz")
    assert.Equal(t, 200, resp.StatusCode)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config)

Option configures a Stack.

func WithBlockchainImage

func WithBlockchainImage(image string) Option

WithBlockchainImage sets the blockchain (Anvil) container image.

func WithDelegatorImage

func WithDelegatorImage(image string) Option

WithDelegatorImage sets the delegator container image.

func WithGuppyImage

func WithGuppyImage(image string) Option

WithGuppyImage sets the guppy container image.

func WithIPNIImage

func WithIPNIImage(image string) Option

WithIPNIImage sets the IPNI container image.

func WithIndexerImage

func WithIndexerImage(image string) Option

WithIndexerImage sets the indexer container image.

func WithKeepOnFailure

func WithKeepOnFailure() Option

WithKeepOnFailure prevents cleanup when a test fails, useful for debugging.

func WithPiriBinary

func WithPiriBinary(path string) Option

WithPiriBinary mounts a local piri binary into the container, replacing the image's binary. This enables rapid iteration without rebuilding the container image. The binary must be compiled for Linux (use BuildPiriBinary helper).

Example:

piriBin := stack.BuildPiriBinary(t, "/path/to/piri/repo")
s := stack.MustNewStack(t, stack.WithPiriBinary(piriBin))

func WithPiriImage

func WithPiriImage(image string) Option

WithPiriImage sets the piri container image.

func WithSignerImage

func WithSignerImage(image string) Option

WithSignerImage sets the signing service container image.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the maximum time to wait for the stack to start.

func WithUploadImage

func WithUploadImage(image string) Option

WithUploadImage sets the upload service container image.

type Stack

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

Stack represents a running Storacha network.

func MustNewStack

func MustNewStack(t *testing.T, opts ...Option) *Stack

MustNewStack creates and starts a network, calling t.Fatal on error.

func NewStack

func NewStack(ctx context.Context, t *testing.T, opts ...Option) (*Stack, error)

NewStack creates and starts a complete Storacha network. Returns error if startup fails. Cleanup is automatically registered via t.Cleanup().

func (*Stack) Close

func (s *Stack) Close(ctx context.Context) error

Close shuts down the stack and cleans up resources. This is called automatically via t.Cleanup(), but can be called manually.

func (*Stack) Exec

func (s *Stack) Exec(ctx context.Context, service string, args ...string) (stdout, stderr string, err error)

Exec executes a command inside a service container and returns stdout and stderr separately.

func (*Stack) Logs

func (s *Stack) Logs(ctx context.Context, service string) (string, error)

Logs returns the logs for a service.

Jump to

Keyboard shortcuts

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