testutils

package
v0.0.0-...-a2061c1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserXPriv         = "xprv9s21ZrQH143K3fqNnUmXmgfT9ToMtiq5cuKsVBG4E5UqVh4psHDY2XKsEfZKuV4FSZcPS9CYgEQiLUpW2xmHqHFyp23SvTkTCE153cCdwaj"
	UserXPub          = "xpub661MyMwAqRbcG9uqtWJY8pcBhVdrJBYvz8FUHZffnR1pNVPyQpXnaKeM5w2FyH5Wwhf5Cf15mFDVRZnuK9sEHDqqd39qWz36UDoobrzLyFM"
	UserPrivAccessKey = "03a446ede05f04fd92d2707599a80b67ad76f63b3958706819c76308bfc7c1143d"
	UserPubAccessKey  = "0239a60e37d62b0217ac86881caba194ab943e18099c080de70c173daf75d917b2"
	PubKey            = "034252e5359a1de3b8ec08e6c29b80594e88fb47e6ae9ce65ee5a94f0d371d2cde"

	AliceXPriv = "xprv9s21ZrQH143K4JFXqGhBzdrthyNFNuHPaMUwvuo8xvpHwWXprNK7T4JPj1w53S1gojQncyj8JhSh8qouYPZpbocsq934cH5G1t1DRBfgbod"
	AliceXPub  = "xpub661MyMwAqRbcGnKzwJECMmodG1CjnN1EwaQYjJCkXGMGpJryPudMzrcsaK6frwUxXqFxRJwPkKvJh6myJEpQPJS9N67jhZWr24biGe277DH"
	BobXPriv   = "xprv9s21ZrQH143K4VneY3UWCF1o5Kk2tmgGrGtMtsrThCTsHsszEZ6H1iP37ZTwuUBvMwudG68SRkcfTjeu8h3rkayfyqkjKAStFBkuNsBnAkS"
	BobXPub    = "xpub661MyMwAqRbcGys7e51WZNxXdMaXJEQ8DVoxhGG5FXzrAgD8n6QXZWhWxrm2yMzH8e9fxV8TYxmkL9sivVEEoPfDpg4u5mrp2VTqvfGT1Us"
)
View Source
const TestAPIAddr = "http://localhost:3003"

Variables

This section is empty.

Functions

func FullAPIURL

func FullAPIURL(t *testing.T, endpoint string, pathParams ...string) string

FullAPIURL constructs a full URL by combining the base address and an endpoint path. It uses the testing context to fail gracefully if invalid input is provided.

func GivenSPVAdminAPI

func GivenSPVAdminAPI(t *testing.T) (*spvwallet.AdminAPI, *httpmock.MockTransport)

func GivenSPVUserAPI

func GivenSPVUserAPI(t *testing.T) (*spvwallet.UserAPI, *httpmock.MockTransport)

func MockPKI

func MockPKI(t *testing.T, xpub string) string

func NewBadRequestSPVError

func NewBadRequestSPVError() models.SPVError

NewBadRequestSPVError creates a new SPVError for bad request

func NewBadRequestSPVErrorResponder

func NewBadRequestSPVErrorResponder() httpmock.Responder

NewBadRequestSPVErrorResponder returns a new SPVError object with status code 400

func NewConflictRequestSPVError

func NewConflictRequestSPVError() models.SPVError

NewConflictRequestSPVError returns an example SPV error returned by SPV Wallet API to indicate a request conflict with the current state of the target resource.

func NewConflictRequestSPVErrorResponder

func NewConflictRequestSPVErrorResponder() httpmock.Responder

NewConflictRequestSPVErrorResponder returns a new SPVError object with status code 409.

func NewInternalServerSPVError

func NewInternalServerSPVError() models.SPVError

NewInternalServerSPVError creates a new SPVError for internal server error

func NewInternalServerSPVErrorResponder

func NewInternalServerSPVErrorResponder() httpmock.Responder

NewInternalServerSPVErrorResponder returns a new SPVError object with status code 500

func NewInternalServerSPVErrorStringResponder

func NewInternalServerSPVErrorStringResponder(errMessage string) httpmock.Responder

NewInternalServerSPVErrorStringResponder returns a new SPVError object with status code 500

func NewInvalidRequestError

func NewInvalidRequestError() models.SPVError

NewInvalidRequestError creates a new SPVError for invalid request

func NewJSONBodyResponderWithStatusOK

func NewJSONBodyResponderWithStatusOK(body any) httpmock.Responder

NewBadRequestSPVError returns a new SPVError object with status code 400

func NewJSONFileResponderWithStatusOK

func NewJSONFileResponderWithStatusOK(filePath string) httpmock.Responder

NewBadRequestSPVError returns a new SPVError object with status code 400

func NewPaginatedJSONResponder

func NewPaginatedJSONResponder(t *testing.T, files ...string) httpmock.Responder

NewPaginatedJSONResponder creates a responder that simulates paginated responses

func NewResourceNotFoundSPVError

func NewResourceNotFoundSPVError() models.SPVError

NewResourceNotFoundSPVError returns an example SPV error returned by SPV Wallet API to indicate that the server cannot find the requested resource.

func NewResourceNotFoundSPVErrorResponder

func NewResourceNotFoundSPVErrorResponder() httpmock.Responder

NewResourceNotFoundSPVErrorResponder returns a new SPVError object with status code 404.

func NewStringResponderStatusOK

func NewStringResponderStatusOK(body string) httpmock.Responder

NewStringResponderStatusOK returns a new responder with status code 200 and a body

func NewUnauthorizedAccessSPVError

func NewUnauthorizedAccessSPVError() models.SPVError

NewUnauthorizedAccessSPVError creates a new SPVError for unauthorized access

func NewUnauthorizedAccessSPVErrorResponder

func NewUnauthorizedAccessSPVErrorResponder() httpmock.Responder

NewUnauthorizedAccessSPVErrorResponder returns a new SPVError object with status code 401

func NewUnrecognizedAPIResponseError

func NewUnrecognizedAPIResponseError() models.SPVError

NewUnrecognizedAPIResponseError creates a new SPVError for unrecognized API response

func ParseTime

func ParseTime(t *testing.T, s string) time.Time

func Ptr

func Ptr[T any](value T) *T

func RegisterMockResponder

func RegisterMockResponder(t *testing.T, client *resty.Client, endpoint string, statusCode int, responseBody interface{})

RegisterMockResponder registers a mock responder for a given endpoint

func SetupEmptyMerkleRootMock

func SetupEmptyMerkleRootMock(mockRepo *MockMerkleRootsRepository)

SetupEmptyMerkleRootMock sets up a mock MerkleRootsRepository with no data

func SetupMerkleRootMockRepo

func SetupMerkleRootMockRepo(mockRepo *MockMerkleRootsRepository, expectedCallCount int)

SetupMerkleRootMockRepo sets up a mock MerkleRootsRepository with common behavior

func SetupStaleKeyMock

func SetupStaleKeyMock(mockRepo *MockMerkleRootsRepository)

SetupStaleKeyMock sets up the mock repository for a stale LastEvaluatedKey scenario

Types

type MockMerkleRootsRepository

type MockMerkleRootsRepository struct {
	mock.Mock
}

Mock repository for testing

func (*MockMerkleRootsRepository) GetLastMerkleRoot

func (m *MockMerkleRootsRepository) GetLastMerkleRoot() string

GetLastMerkleRoot retrieves the last Merkle root from storage.

func (*MockMerkleRootsRepository) SaveMerkleRoots

func (m *MockMerkleRootsRepository) SaveMerkleRoots(roots []models.MerkleRoot) error

SaveMerkleRoots appends synced Merkle roots to the simulated storage.

Jump to

Keyboard shortcuts

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