integrationtest

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 8 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 (
	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. Integration clients default to allowing private / local network downloads so local proxy environments can exercise retrieval flows. The SDK's public default remains private-network rejection.

The client is automatically closed via t.Cleanup; a failed dial is reported with t.Fatalf so callers can treat the returned value as non-nil.

func NewDefaultClient

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

NewDefaultClient resolves INTEGRATION_PRIVATE_KEY (skipping when absent) and returns a ready client.

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