testabilities

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type ARCFixture

type ARCFixture interface {
	// WillRespondForBroadcast returns a http response for a broadcast request.
	WillRespondForBroadcast(httpCode int, info *chainmodels.TXInfo)

	// WillRespondForBroadcastWithSeenOnNetwork is a default ARC behavior for broadcasting (happy path).
	WillRespondForBroadcastWithSeenOnNetwork(txID string)
}

type BalanceAssertions

type BalanceAssertions interface {
	IsEqualTo(expected bsv.Satoshis)
	IsGreaterThanOrEqualTo(expected bsv.Satoshis)
	IsZero()
}

type BlockHeadersServiceFixture

type BlockHeadersServiceFixture interface {
	// WillRespondForMerkleRoots returns a http response for get merkleroots endpoint with
	// provided httpCode and response
	WillRespondForMerkleRoots(httpCode int, response string)

	// WillRespondForMerkleRootsVerify returns a MerkleRootsConfirmations response for get merkleroot/verify endpoint with
	// provided httpCode
	WillRespondForMerkleRootsVerify(httpCode int, response *chainmodels.MerkleRootsConfirmations)
}

type JsonValueGetter

type JsonValueGetter interface {
	GetString(xpath string) string
	GetAsType(xpath string, target any)
	GetField(xpath string) any
	GetInt(xpath string) int
}

type LastOperationAssertions

type LastOperationAssertions interface {
	WithTxID(txID string) LastOperationAssertions
	WithValue(value int64) LastOperationAssertions
	WithType(operationType string) LastOperationAssertions
	WithCounterparty(counterparty string) LastOperationAssertions
	WithNoCounterparty() LastOperationAssertions
	WithTxStatus(txStatus string) LastOperationAssertions
	WithBlockHeight(blockHeight int64) LastOperationAssertions
	WithBlockHash(blockHash string) LastOperationAssertions
}

type OperationsAssertions

type OperationsAssertions interface {
	Last() LastOperationAssertions
}

type SPVWalletAppUserAssertions

type SPVWalletAppUserAssertions interface {
	Balance() BalanceAssertions
	Operations() OperationsAssertions
}

type SPVWalletApplicationFixture

type SPVWalletApplicationFixture interface {
	StartedSPVWallet() (cleanup func())
	StartedSPVWalletWithConfiguration(opts ...testengine.ConfigOpts) (cleanup func())

	// HttpClient returns a new http client that can be used to make requests to the spv-wallet server.
	// It is also failing tests if there are network or invalid request configuration errors,
	// so the tests can focus on the server response.
	HttpClient() SPVWalletHttpClientFixture

	// NewTest creates a new test fixture based on the current one and the provided testing.TB
	// This is useful if you want to start spv-wallet once and then run multiple t.Run with some calls against this one instance.
	NewTest(t testing.TB) SPVWalletApplicationFixture

	// BHS creates a new test fixture for Block Header Service (BHS)
	BHS() BlockHeadersServiceFixture

	// ARC creates a new test fixture for ARC
	ARC() ARCFixture

	Paymail() testpaymail.PaymailClientFixture

	Faucet(user fixtures.User) testengine.FaucetFixture

	User(user fixtures.User) testengine.UserFixture

	EngineFixture() testengine.EngineFixture

	// Tx creates a new mocked transaction builder
	Tx() txtestability.TransactionSpec

	Config() *config.AppConfig
}

type SPVWalletHttpClientFixture

type SPVWalletHttpClientFixture interface {
	// ForAnonymous returns a new http client that is configured without any authentication.
	ForAnonymous() *resty.Client
	// ForAdmin returns a new http client that is configured with the authentication with default admin xpub.
	ForAdmin() *resty.Client
	// ForUser returns a new http client that is configured with the authentication with the xpub of the sender user.
	ForUser() *resty.Client
	// ForGivenUser returns a new http client that is configured with the authentication with the xpub of the given user.
	ForGivenUser(user fixtures.User) *resty.Client
}

type SPVWalletResponseAssertions

type SPVWalletResponseAssertions interface {
	IsOK() SPVWalletResponseAssertions
	IsCreated() SPVWalletResponseAssertions
	HasStatus(status int) SPVWalletResponseAssertions
	WithJSONf(expectedFormat string, args ...any)
	WithJSONMatching(expectedTemplateFormat string, params map[string]any)
	WithProblemDetails(status int, errType string, containDetails ...string)
	JSONValue() JsonValueGetter
	// IsUnauthorized asserts that the response status code is 401 and the error is about lack of authorization.
	IsUnauthorized()
	// IsUnauthorizedForAdmin asserts that the response status code is 401 and the error is that admin is not authorized to use the endpoint.
	IsUnauthorizedForAdmin()
	// IsUnauthorizedForUser asserts that the response status code is 401 and the error is that only admin is authorized to use this endpoint.
	IsUnauthorizedForUser()
	IsBadRequest() SPVWalletResponseAssertions
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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