testing

package
v7.0.0-...-5d54eda Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package testing provides utilities for testing applications written against the DAML SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DamlSDK

type DamlSDK struct {
	Home           string
	DefaultVersion *semver.Version
}

func Default

func Default() (sdk DamlSDK, err error)

Default returns parameters for DamlSDK as discovered by looking for the `daml` executable on the user's current `PATH`.

func (DamlSDK) InstalledVersions

func (sdk DamlSDK) InstalledVersions() (versions semver.Versions)

InstalledVersions lists the locally available versions of the DAML SDK.

func (DamlSDK) NewSandbox

func (sdk DamlSDK) NewSandbox(options SandboxOptions) (s SandboxProcess, err error)

NewSandbox creates a new Sandbox instance with default parameters from the specified DAML SDK.

func (*DamlSDK) ReadDefaultVersion

func (sdk *DamlSDK) ReadDefaultVersion() error

ReadDefaultVersion() fills in the DefaultVersion field for a DamlSDK.

type SandboxOptions

type SandboxOptions struct {
	// Context optionally launches the Sandbox, managed by the given context.
	// If this context is terminated, the process is terminated.
	Context context.Context

	// ListenAddress is the address that the Sandbox will bind to. If
	// unspecified, 127.0.0.1 is used.
	ListenAddress net.IP

	// Port is the port that the Sandbox will bind to. If unspecified, the
	// default Ledger API port (6865) is used; if set to 0, a port will
	// automatically be assigned.
	Port *int

	// LedgerId is the ID of the created ledger. If unspecified, the
	// implementation may provide its own Ledger Id.
	LedgerId dazlclient.LedgerId

	// JDBCURL is the JDBC URL to connect to. If unspecified, an in-memory
	// database is used instead.
	JDBCURL string

	// SDKVersion is the version of the DAML SDK to use to launch the Sandbox.
	// Only Sandbox versions 1.0.0 or later are supported. The default version
	// is the most recent one available.
	SDKVersion *semver.Version

	// DamlHome is the path to a DAML SDK installation. If unspecified, it is
	// detected by looking for the `daml` command in the path.
	DamlHome string

	// LogPath is the place to pipe stdout/stderr to.
	LogPath string
}

SandboxOptions are launch options for starting a Sandbox.

type SandboxProcess

type SandboxProcess interface {
	Context() context.Context

	ListenAddress() net.IP

	// Port is the actual port that the Sandbox is using. If a sandbox was
	// created with SandboxOptions.Port as `0` or `nil`, Port() returns the
	// actual port that the process is listening on.
	Port() int

	// LedgerId returns the ledger id of the running Sandbox.
	LedgerId() dazlclient.LedgerId

	JDBCURL() string

	// DAML SDK version of the running Sandbox
	SDKVersion() semver.Version

	// PID of the Sandbox process
	ProcessId() int

	// Stop shuts down the Sandbox process. This method does _not_ block.
	Stop()
}

SandboxProcess represents a running instance of a Sandbox.

func NewSandbox

func NewSandbox(options SandboxOptions) (SandboxProcess, error)

NewSandbox creates a new Sandbox instance. The function blocks until the Sandbox has successfully been started, the port is open, and accepting connections, OR returns an error if this is not possible.

See the documentation for SandboxOptions for information on default values that will be used if none are specified.

Jump to

Keyboard shortcuts

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