Documentation
¶
Index ¶
- Constants
- func FullAPIURL(t *testing.T, endpoint string, pathParams ...string) string
- func GivenSPVAdminAPI(t *testing.T) (*spvwallet.AdminAPI, *httpmock.MockTransport)
- func GivenSPVUserAPI(t *testing.T) (*spvwallet.UserAPI, *httpmock.MockTransport)
- func MockPKI(t *testing.T, xpub string) string
- func NewBadRequestSPVError() models.SPVError
- func NewBadRequestSPVErrorResponder() httpmock.Responder
- func NewConflictRequestSPVError() models.SPVError
- func NewConflictRequestSPVErrorResponder() httpmock.Responder
- func NewInternalServerSPVError() models.SPVError
- func NewInternalServerSPVErrorResponder() httpmock.Responder
- func NewInternalServerSPVErrorStringResponder(errMessage string) httpmock.Responder
- func NewInvalidRequestError() models.SPVError
- func NewJSONBodyResponderWithStatusOK(body any) httpmock.Responder
- func NewJSONFileResponderWithStatusOK(filePath string) httpmock.Responder
- func NewPaginatedJSONResponder(t *testing.T, files ...string) httpmock.Responder
- func NewResourceNotFoundSPVError() models.SPVError
- func NewResourceNotFoundSPVErrorResponder() httpmock.Responder
- func NewStringResponderStatusOK(body string) httpmock.Responder
- func NewUnauthorizedAccessSPVError() models.SPVError
- func NewUnauthorizedAccessSPVErrorResponder() httpmock.Responder
- func NewUnrecognizedAPIResponseError() models.SPVError
- func ParseTime(t *testing.T, s string) time.Time
- func Ptr[T any](value T) *T
- func RegisterMockResponder(t *testing.T, client *resty.Client, endpoint string, statusCode int, ...)
- func SetupEmptyMerkleRootMock(mockRepo *MockMerkleRootsRepository)
- func SetupMerkleRootMockRepo(mockRepo *MockMerkleRootsRepository, expectedCallCount int)
- func SetupStaleKeyMock(mockRepo *MockMerkleRootsRepository)
- type MockMerkleRootsRepository
Constants ¶
const ( UserXPriv = "xprv9s21ZrQH143K3fqNnUmXmgfT9ToMtiq5cuKsVBG4E5UqVh4psHDY2XKsEfZKuV4FSZcPS9CYgEQiLUpW2xmHqHFyp23SvTkTCE153cCdwaj" UserXPub = "xpub661MyMwAqRbcG9uqtWJY8pcBhVdrJBYvz8FUHZffnR1pNVPyQpXnaKeM5w2FyH5Wwhf5Cf15mFDVRZnuK9sEHDqqd39qWz36UDoobrzLyFM" UserPrivAccessKey = "03a446ede05f04fd92d2707599a80b67ad76f63b3958706819c76308bfc7c1143d" UserPubAccessKey = "0239a60e37d62b0217ac86881caba194ab943e18099c080de70c173daf75d917b2" PubKey = "034252e5359a1de3b8ec08e6c29b80594e88fb47e6ae9ce65ee5a94f0d371d2cde" AliceXPriv = "xprv9s21ZrQH143K4JFXqGhBzdrthyNFNuHPaMUwvuo8xvpHwWXprNK7T4JPj1w53S1gojQncyj8JhSh8qouYPZpbocsq934cH5G1t1DRBfgbod" AliceXPub = "xpub661MyMwAqRbcGnKzwJECMmodG1CjnN1EwaQYjJCkXGMGpJryPudMzrcsaK6frwUxXqFxRJwPkKvJh6myJEpQPJS9N67jhZWr24biGe277DH" BobXPriv = "xprv9s21ZrQH143K4VneY3UWCF1o5Kk2tmgGrGtMtsrThCTsHsszEZ6H1iP37ZTwuUBvMwudG68SRkcfTjeu8h3rkayfyqkjKAStFBkuNsBnAkS" BobXPub = "xpub661MyMwAqRbcGys7e51WZNxXdMaXJEQ8DVoxhGG5FXzrAgD8n6QXZWhWxrm2yMzH8e9fxV8TYxmkL9sivVEEoPfDpg4u5mrp2VTqvfGT1Us" )
const TestAPIAddr = "http://localhost:3003"
Variables ¶
This section is empty.
Functions ¶
func FullAPIURL ¶
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 GivenSPVUserAPI ¶
func NewBadRequestSPVError ¶
NewBadRequestSPVError creates a new SPVError for bad request
func NewBadRequestSPVErrorResponder ¶
NewBadRequestSPVErrorResponder returns a new SPVError object with status code 400
func NewConflictRequestSPVError ¶
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 ¶
NewConflictRequestSPVErrorResponder returns a new SPVError object with status code 409.
func NewInternalServerSPVError ¶
NewInternalServerSPVError creates a new SPVError for internal server error
func NewInternalServerSPVErrorResponder ¶
NewInternalServerSPVErrorResponder returns a new SPVError object with status code 500
func NewInternalServerSPVErrorStringResponder ¶
NewInternalServerSPVErrorStringResponder returns a new SPVError object with status code 500
func NewInvalidRequestError ¶
NewInvalidRequestError creates a new SPVError for invalid request
func NewJSONBodyResponderWithStatusOK ¶
NewBadRequestSPVError returns a new SPVError object with status code 400
func NewJSONFileResponderWithStatusOK ¶
NewBadRequestSPVError returns a new SPVError object with status code 400
func NewPaginatedJSONResponder ¶
NewPaginatedJSONResponder creates a responder that simulates paginated responses
func NewResourceNotFoundSPVError ¶
NewResourceNotFoundSPVError returns an example SPV error returned by SPV Wallet API to indicate that the server cannot find the requested resource.
func NewResourceNotFoundSPVErrorResponder ¶
NewResourceNotFoundSPVErrorResponder returns a new SPVError object with status code 404.
func NewStringResponderStatusOK ¶
NewStringResponderStatusOK returns a new responder with status code 200 and a body
func NewUnauthorizedAccessSPVError ¶
NewUnauthorizedAccessSPVError creates a new SPVError for unauthorized access
func NewUnauthorizedAccessSPVErrorResponder ¶
NewUnauthorizedAccessSPVErrorResponder returns a new SPVError object with status code 401
func NewUnrecognizedAPIResponseError ¶
NewUnrecognizedAPIResponseError creates a new SPVError for unrecognized API response
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 ¶
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.