integration

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StandaloneNetworkPassphrase = "Standalone Network ; February 2017"
)

Variables

View Source
var (
	RunWithCaptiveCore = os.Getenv("HORIZON_INTEGRATION_ENABLE_CAPTIVE_CORE") != ""
)

Functions

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps returns a new map which contains the keys and values of *all* input maps, overwriting earlier values with later values on duplicate keys.

Types

type CaptiveConfig

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

type Config

type Config struct {
	PostgresURL           string
	ProtocolVersion       int32
	SkipContainerCreation bool
	CoreDockerImage       string

	// Weird naming here because bools default to false, but we want to start
	// Horizon by default.
	SkipHorizonStart bool

	// If you want to override the default parameters passed to Horizon, you can
	// set this map accordingly. All of them are passed along as --k=v, but if
	// you pass an empty value, the parameter will be dropped. (Note that you
	// should exclude the prepending `--` from keys; this is for compatibility
	// with the constant names in flags.go)
	//
	// You can also control the environmental variables in a similar way, but
	// note that CLI args take precedence over envvars, so set the corresponding
	// CLI arg empty.
	HorizonParameters  map[string]string
	HorizonEnvironment map[string]string
}

type EnvironmentManager

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

func NewEnvironmentManager

func NewEnvironmentManager() *EnvironmentManager

func (*EnvironmentManager) Add

func (envmgr *EnvironmentManager) Add(key, value string) error

Add sets a new environment variable, saving the original value (if any).

func (*EnvironmentManager) Restore

func (envmgr *EnvironmentManager) Restore()

Restore restores the environment prior to any modifications.

You should probably use this alongside `defer` to ensure the global environment isn't modified for longer than you intend.

type Test

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

func NewTest

func NewTest(t *testing.T, config Config) *Test

NewTest starts a new environment for integration test at a given protocol version and blocks until Horizon starts ingesting.

Skips the test if HORIZON_INTEGRATION_TESTS env variable is not set.

WARNING: This requires Docker Compose installed.

func NewTestForRemoteHorizon

func NewTestForRemoteHorizon(t *testing.T, horizonURL string, passPhrase string, masterKey *keypair.Full) *Test

func (*Test) AdminPort

func (i *Test) AdminPort() int

AdminPort returns Horizon admin port.

func (*Test) Client

func (i *Test) Client() *sdk.Client

Client returns horizon.Client connected to started Horizon instance.

func (*Test) CreateAccounts

func (i *Test) CreateAccounts(count int, initialBalance string) ([]*keypair.Full, []txnbuild.Account)

Creates new accounts via the master account.

It funds each account with the given balance and then queries the API to find the randomized sequence number for future operations.

Returns: The slice of created keypairs and account objects.

Note: panics on any errors, since we assume that tests cannot proceed without this method succeeding.

func (*Test) CreateSignedTransaction

func (i *Test) CreateSignedTransaction(
	source txnbuild.Account, signers []*keypair.Full, ops ...txnbuild.Operation,
) (*txnbuild.Transaction, error)

func (*Test) CurrentTest

func (i *Test) CurrentTest() *testing.T

func (*Test) EstablishTrustline

func (i *Test) EstablishTrustline(
	truster *keypair.Full, account txnbuild.Account, asset txnbuild.Asset,
) (proto.Transaction, error)

EstablishTrustline works on a given asset for a particular account.

func (*Test) GetCurrentCoreLedgerSequence

func (i *Test) GetCurrentCoreLedgerSequence() (int, error)

func (*Test) GetHorizonConfig

func (i *Test) GetHorizonConfig() horizon.Config

func (*Test) GetPassPhrase

func (i *Test) GetPassPhrase() string

func (*Test) Horizon

func (i *Test) Horizon() *horizon.App

Horizon returns the horizon.App instance for the current integration test

func (*Test) LogFailedTx

func (i *Test) LogFailedTx(txResponse proto.Transaction, horizonResult error)

LogFailedTx is a convenience function to provide verbose information about a failing transaction to the test output log, if it's expected to succeed.

func (*Test) Master

func (i *Test) Master() *keypair.Full

Master returns a keypair of the network masterKey account.

func (*Test) MasterAccount

func (i *Test) MasterAccount() txnbuild.Account

func (*Test) MetricsURL

func (i *Test) MetricsURL() string

Metrics URL returns Horizon metrics URL.

func (*Test) MustCreateClaimableBalance

func (i *Test) MustCreateClaimableBalance(
	source *keypair.Full, asset txnbuild.Asset, amount string,
	claimants ...txnbuild.Claimant,
) (claim proto.ClaimableBalance)

MustCreateClaimableBalance panics on any error creating a claimable balance.

func (*Test) MustEstablishTrustline

func (i *Test) MustEstablishTrustline(
	truster *keypair.Full, account txnbuild.Account, asset txnbuild.Asset,
) (resp proto.Transaction)

Panics on any error establishing a trustline.

func (*Test) MustGetAccount

func (i *Test) MustGetAccount(source *keypair.Full) proto.Account

MustGetAccount panics on any error retrieves an account's details from its key. This means it must have previously been funded.

func (*Test) MustSubmitOperations

func (i *Test) MustSubmitOperations(
	source txnbuild.Account, signer *keypair.Full, ops ...txnbuild.Operation,
) proto.Transaction

MustSubmitOperations submits a signed transaction from an account with standard options.

Namely, we set the standard fee, time bounds, etc. to "non-production" defaults that work well for tests.

Most transactions only need one signer, so see the more verbose `MustSubmitOperationsWithSigners` below for multi-sig transactions.

Note: We assume that transaction will be successful here so we panic in case of all errors. To allow failures, use `SubmitOperations`.

func (*Test) RestartHorizon

func (i *Test) RestartHorizon() error

func (*Test) Shutdown

func (i *Test) Shutdown()

Shutdown stops the integration tests and destroys all its associated resources. It will be implicitly called when the calling test (i.e. the `testing.Test` passed to `New()`) is finished if it hasn't been explicitly called before.

func (*Test) StartHorizon

func (i *Test) StartHorizon() error

func (*Test) StopHorizon

func (i *Test) StopHorizon()

StopHorizon shuts down the running Horizon process

func (*Test) SubmitMultiSigOperations

func (i *Test) SubmitMultiSigOperations(
	source txnbuild.Account, signers []*keypair.Full, ops ...txnbuild.Operation,
) (proto.Transaction, error)

func (*Test) SubmitOperations

func (i *Test) SubmitOperations(
	source txnbuild.Account, signer *keypair.Full, ops ...txnbuild.Operation,
) (proto.Transaction, error)

func (*Test) WaitForHorizon

func (i *Test) WaitForHorizon()

Jump to

Keyboard shortcuts

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