Help us shape the future of Go! Take the 2026 Go Developer Survey

integrationtest

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package integrationtest provides small helpers shared by the SDK's integration tests (files built under `//go:build integration`).

It is intentionally minimal and has no external dependencies beyond stdlib and the SDK itself. Callers wire helpers through t.Skip when a required environment variable is missing, so individual test files do not need to duplicate the same boilerplate across packages.

This package itself does NOT carry the `integration` build tag — only the test files that import it do. That way `go build ./...` continues to compile the helpers as ordinary code.

Running the integration suite

The per-package integration tests and tests/integration/ all operate against the same on-chain wallet (INTEGRATION_PRIVATE_KEY), so their transactions must be serialised to avoid Filecoin mempool nonce collisions. Always invoke `go test` with `-p 1` so packages run one at a time:

go test -tags=integration -p 1 -run '^TestIntegration' -timeout 60m ./...

The repository Makefile encodes this as `make test-integration`. Use `make test-integration-cross` only when you specifically want the cross-package `./tests/integration` flows rather than the full per-package integration coverage.

`-run '^TestIntegration'` restricts the selection to the integration entry points and skips the fast unit tests in the same packages; drop it if you want the full test set in a single invocation. `-tags` is additive to the normal test build — unit tests without the tag always compile and run, which is standard Go behaviour.

Index

Constants

View Source
const (
	FundingExtraRunwayEpochs = chain.EpochsPerDay
	FundingBufferEpochs      = 120
)

Funding margins for Prepare in integration flows. The shared test wallet has many active rails that drain available funds every epoch, and flows can run several epochs between Prepare and their last on-chain operation, so the SDK's default five-epoch buffer is too tight.

View Source
const (
	EnvPrivateKey      = "INTEGRATION_PRIVATE_KEY"
	EnvDestructiveKey  = "INTEGRATION_DESTRUCTIVE_KEY"
	EnvRPCURL          = "INTEGRATION_RPC_URL"
	DefaultRPCURL      = "https://api.calibration.node.glif.io/rpc/v1"
	CalibrationChainID = 314159
)

Env var names and defaults shared by integration tests.

Variables

This section is empty.

Functions

func DestructiveKey

func DestructiveKey(t *testing.T) (bool, string)

DestructiveKey returns (true, key) only when the caller supplied a dedicated destructive-test private key. Callers should t.Skip with a "needs-destructive-account" reason when ok==false.

func EnsureEnv

func EnsureEnv(t *testing.T)

EnsureEnv loads the module-root .env (if present). It anchors the search at the directory containing go.mod so the helper works regardless of which package `go test` is invoked from, without accidentally loading a .env from a parent workspace that belongs to an unrelated project. Safe to call multiple times.

func LoadDotEnv

func LoadDotEnv(path string) error

LoadDotEnv reads a KEY=VALUE file and sets any variables not already present in the environment. Lines beginning with '#' and empty lines are skipped. Values may optionally be wrapped in double-quotes. A missing file is not an error.

func NewClient

func NewClient(t *testing.T, ctx context.Context, privateKeyHex string, opts ...synapse.ClientOption) *synapse.Client

NewClient builds a synapse.Client using the supplied private key hex and the shared RPC URL. Provider HTTP allows private and reserved destinations so calibration tests can reach public providers when local DNS or a transparent proxy maps their hostnames onto intercepted addresses such as 198.18.0.0/15. Pass synapse.WithAllowPrivateNetworks(false) to restore the SDK default denial. Upload batching is disabled unless opts re-enable it. The client is closed via t.Cleanup; a failed dial is a fatal test error so callers can treat the returned value as non-nil.

func NewDefaultClient

func NewDefaultClient(t *testing.T, ctx context.Context, opts ...synapse.ClientOption) *synapse.Client

NewDefaultClient resolves INTEGRATION_PRIVATE_KEY (skipping when absent) and returns a ready client. Upload batching is disabled unless opts re-enable it, keeping existing integration flows immediate and independently timed. Private- network HTTP follows NewClient so later opts can still restore the SDK default.

func RPCURL

func RPCURL() string

RPCURL returns the configured RPC endpoint, falling back to the Calibration default.

func RequirePrivateKey

func RequirePrivateKey(t *testing.T) string

RequirePrivateKey returns the integration signing key, skipping the test when the env var is absent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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