From 9645a2af7bef6252d52735b1e4a8b3db5d05f1e6 Mon Sep 17 00:00:00 2001 From: lash Date: Tue, 14 Jan 2025 14:20:51 +0000 Subject: [PATCH] Correct result structs for mock/test api implementations --- remote/http/service.go | 9 +++++++-- testutil/mocks/api_mock.go | 2 +- testutil/mocks/service_mock.go | 9 +++++++-- testutil/testservice/account_service.go | 8 ++++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/remote/http/service.go b/remote/http/service.go index 53b8091..2c1aa85 100644 --- a/remote/http/service.go +++ b/remote/http/service.go @@ -3,6 +3,7 @@ package http import ( "bytes" "context" + "fmt" "encoding/json" "errors" "io" @@ -202,8 +203,8 @@ func (as *HTTPAccountService) TokenTransfer(ctx context.Context, amount, from, t // CheckAliasAddress retrieves the address of an alias from the API endpoint. // Parameters: // - alias: The alias of the user. -func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) { - var r dataserviceapi.AliasAddress +func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) { + var r models.AliasAddress ep, err := url.JoinPath(config.CheckAliasURL, alias) if err != nil { @@ -219,6 +220,10 @@ func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias strin return &r, err } +func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) { + return nil, fmt.Errorf("not yet implemented") +} + // TODO: remove eth-custodial api dependency func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) { var okResponse api.OKResponse diff --git a/testutil/mocks/api_mock.go b/testutil/mocks/api_mock.go index 6794b64..20b9a68 100644 --- a/testutil/mocks/api_mock.go +++ b/testutil/mocks/api_mock.go @@ -50,7 +50,7 @@ func(m MockApi) VoucherData(ctx context.Context, address string) (*models.Vouche return m.VoucherDataContent, nil } -func(m MockApi) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) { +func(m MockApi) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) { return nil, nil } diff --git a/testutil/mocks/service_mock.go b/testutil/mocks/service_mock.go index 3e230a4..d500508 100644 --- a/testutil/mocks/service_mock.go +++ b/testutil/mocks/service_mock.go @@ -48,7 +48,12 @@ func (m *MockAccountService) TokenTransfer(ctx context.Context, amount, from, to return args.Get(0).(*models.TokenTransferResponse), args.Error(1) } -func (m *MockAccountService) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) { +func (m *MockAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) { args := m.Called(alias) - return args.Get(0).(*dataserviceapi.AliasAddress), args.Error(1) + return args.Get(0).(*models.AliasAddress), args.Error(1) +} + +func(m MockAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) { + args := m.Called(publicKey, hint) + return args.Get(0).(*models.RequestAliasResult), args.Error(1) } diff --git a/testutil/testservice/account_service.go b/testutil/testservice/account_service.go index a368102..12b9de4 100644 --- a/testutil/testservice/account_service.go +++ b/testutil/testservice/account_service.go @@ -57,6 +57,10 @@ func (tas *TestAccountService) TokenTransfer(ctx context.Context, amount, from, }, nil } -func (m TestAccountService) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) { - return &dataserviceapi.AliasAddress{}, nil +func (m TestAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) { + return &models.AliasAddress{}, nil +} + +func (m TestAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) { + return &models.RequestAliasResult{}, nil }