From 1b3aa0f9ea5cf04bae9fd9388cea29dc02590031 Mon Sep 17 00:00:00 2001 From: Stephan D Date: Fri, 13 Feb 2026 02:33:22 +0100 Subject: [PATCH] fixed tests and compilation --- .../internal/ingestor/service_test.go | 2 +- .../internal/service/oracle/service_test.go | 10 +-- api/fx/storage/mongo/repository.go | 4 +- api/fx/storage/mongo/store/quotes.go | 2 +- .../mongo/store/testing_helpers_test.go | 8 +++ .../mongo/store/testing_helpers_test.go | 8 +++ .../methods/internal/service/methods/util.go | 4 +- .../payment_plan_executor_test.go | 62 ------------------- 8 files changed, 27 insertions(+), 73 deletions(-) diff --git a/api/fx/ingestor/internal/ingestor/service_test.go b/api/fx/ingestor/internal/ingestor/service_test.go index 7087a467..16f9b2e1 100644 --- a/api/fx/ingestor/internal/ingestor/service_test.go +++ b/api/fx/ingestor/internal/ingestor/service_test.go @@ -200,7 +200,7 @@ type repositoryStub struct { func (r *repositoryStub) Ping(context.Context) error { return nil } func (r *repositoryStub) Rates() storage.RatesStore { return r.rates } -func (r *repositoryStub) Quotes() quotestorage.QuotesStore { return nil } +func (r *repositoryStub) Quotes() storage.QuotesStore { return nil } func (r *repositoryStub) Pairs() storage.PairStore { return nil } func (r *repositoryStub) Currencies() storage.CurrencyStore { return nil } diff --git a/api/fx/oracle/internal/service/oracle/service_test.go b/api/fx/oracle/internal/service/oracle/service_test.go index 7857f608..be573e63 100644 --- a/api/fx/oracle/internal/service/oracle/service_test.go +++ b/api/fx/oracle/internal/service/oracle/service_test.go @@ -19,16 +19,16 @@ import ( type repositoryStub struct { rates storage.RatesStore - quotes quotestorage.QuotesStore + quotes storage.QuotesStore pairs storage.PairStore currencies storage.CurrencyStore pingErr error } -func (r *repositoryStub) Ping(ctx context.Context) error { return r.pingErr } -func (r *repositoryStub) Rates() storage.RatesStore { return r.rates } -func (r *repositoryStub) Quotes() quotestorage.QuotesStore { return r.quotes } -func (r *repositoryStub) Pairs() storage.PairStore { return r.pairs } +func (r *repositoryStub) Ping(ctx context.Context) error { return r.pingErr } +func (r *repositoryStub) Rates() storage.RatesStore { return r.rates } +func (r *repositoryStub) Quotes() storage.QuotesStore { return r.quotes } +func (r *repositoryStub) Pairs() storage.PairStore { return r.pairs } func (r *repositoryStub) Currencies() storage.CurrencyStore { return r.currencies } diff --git a/api/fx/storage/mongo/repository.go b/api/fx/storage/mongo/repository.go index 5d02793f..fd469fde 100644 --- a/api/fx/storage/mongo/repository.go +++ b/api/fx/storage/mongo/repository.go @@ -21,7 +21,7 @@ type Store struct { txFactory transaction.Factory rates storage.RatesStore - quotes quotestorage.QuotesStore + quotes storage.QuotesStore pairs storage.PairStore currencies storage.CurrencyStore } @@ -92,7 +92,7 @@ func (s *Store) Rates() storage.RatesStore { return s.rates } -func (s *Store) Quotes() quotestorage.QuotesStore { +func (s *Store) Quotes() storage.QuotesStore { return s.quotes } diff --git a/api/fx/storage/mongo/store/quotes.go b/api/fx/storage/mongo/store/quotes.go index a97026f4..22201768 100644 --- a/api/fx/storage/mongo/store/quotes.go +++ b/api/fx/storage/mongo/store/quotes.go @@ -23,7 +23,7 @@ type quotesStore struct { txFactory transaction.Factory } -func NewQuotes(logger mlogger.Logger, db *mongo.Database, txFactory transaction.Factory) (quotestorage.QuotesStore, error) { +func NewQuotes(logger mlogger.Logger, db *mongo.Database, txFactory transaction.Factory) (storage.QuotesStore, error) { repo := repository.CreateMongoRepository(db, model.QuotesCollection) indexes := []*ri.Definition{ { diff --git a/api/fx/storage/mongo/store/testing_helpers_test.go b/api/fx/storage/mongo/store/testing_helpers_test.go index 27fdbda6..6d10d7f7 100644 --- a/api/fx/storage/mongo/store/testing_helpers_test.go +++ b/api/fx/storage/mongo/store/testing_helpers_test.go @@ -22,6 +22,7 @@ type repoStub struct { findOneFn func(ctx context.Context, query builder.Query, result storable.Storable) error findManyFn func(ctx context.Context, query builder.Query, decoder rd.DecodingFunc) error updateFn func(ctx context.Context, obj storable.Storable) error + upsertFn func(ctx context.Context, obj storable.Storable) error patchManyFn func(ctx context.Context, filter builder.Query, patch builder.Patch) (int, error) createIdxFn func(def *ri.Definition) error } @@ -69,6 +70,13 @@ func (r *repoStub) Update(ctx context.Context, obj storable.Storable) error { return nil } +func (r *repoStub) Upsert(ctx context.Context, obj storable.Storable) error { + if r.upsertFn != nil { + return r.upsertFn(ctx, obj) + } + return nil +} + func (r *repoStub) Patch(ctx context.Context, id bson.ObjectID, patch builder.Patch) error { return merrors.NotImplemented("Patch not used") } diff --git a/api/ledger/storage/mongo/store/testing_helpers_test.go b/api/ledger/storage/mongo/store/testing_helpers_test.go index 2ba30408..1b0f9ef8 100644 --- a/api/ledger/storage/mongo/store/testing_helpers_test.go +++ b/api/ledger/storage/mongo/store/testing_helpers_test.go @@ -19,6 +19,7 @@ type repositoryStub struct { InsertFunc func(ctx context.Context, object storable.Storable, filter builder.Query) error InsertManyFunc func(ctx context.Context, objects []storable.Storable) error UpdateFunc func(ctx context.Context, object storable.Storable) error + UpsertFunc func(ctx context.Context, object storable.Storable) error DeleteFunc func(ctx context.Context, id bson.ObjectID) error FindOneByFilterFunc func(ctx context.Context, filter builder.Query, result storable.Storable) error FindManyByFilterFunc func(ctx context.Context, filter builder.Query, decoder rd.DecodingFunc) error @@ -64,6 +65,13 @@ func (r *repositoryStub) Update(ctx context.Context, object storable.Storable) e return nil } +func (r *repositoryStub) Upsert(ctx context.Context, object storable.Storable) error { + if r.UpsertFunc != nil { + return r.UpsertFunc(ctx, object) + } + return nil +} + func (r *repositoryStub) Delete(ctx context.Context, id bson.ObjectID) error { if r.DeleteFunc != nil { return r.DeleteFunc(ctx, id) diff --git a/api/payments/methods/internal/service/methods/util.go b/api/payments/methods/internal/service/methods/util.go index a2eaa539..da1d1fac 100644 --- a/api/payments/methods/internal/service/methods/util.go +++ b/api/payments/methods/internal/service/methods/util.go @@ -11,7 +11,7 @@ import ( "github.com/tech/sendico/pkg/mlogger" "github.com/tech/sendico/pkg/model" "github.com/tech/sendico/pkg/mservice" - methodsv1 "github.com/tech/sendico/pkg/proto/payments/methods/v1" + paginationv2 "github.com/tech/sendico/pkg/proto/common/pagination/v2" "go.mongodb.org/mongo-driver/v2/bson" ) @@ -53,7 +53,7 @@ func encodePaymentMethod(pm *model.PaymentMethod) ([]byte, error) { return payload, nil } -func toModelCursor(cursor *methodsv1.ViewCursor) *model.ViewCursor { +func toModelCursor(cursor *paginationv2.ViewCursor) *model.ViewCursor { if cursor == nil { return nil } diff --git a/api/payments/orchestrator/internal/service/orchestrator/payment_plan_executor_test.go b/api/payments/orchestrator/internal/service/orchestrator/payment_plan_executor_test.go index 371919b4..2a45114b 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/payment_plan_executor_test.go +++ b/api/payments/orchestrator/internal/service/orchestrator/payment_plan_executor_test.go @@ -2,7 +2,6 @@ package orchestrator import ( "context" - "strings" "testing" mntxclient "github.com/tech/sendico/gateway/mntx/client" @@ -216,64 +215,3 @@ func TestExecutePaymentPlan_SourceBeforeDestination(t *testing.T) { } } - -func TestExecutePaymentPlan_RejectsLegacyLedgerOperations(t *testing.T) { - ctx := context.Background() - - store := newStubPaymentsStore() - repo := &stubRepository{store: store} - - ledgerFake := &ledgerclient.Fake{} - - svc := &Service{ - logger: zap.NewNop(), - storage: repo, - deps: serviceDependencies{ - ledger: ledgerDependency{ - client: ledgerFake, - internal: ledgerFake, - }, - }, - } - - executor := newPaymentExecutor(&svc.deps, svc.logger, svc) - - payment := &model.Payment{ - PaymentRef: "pay-legacy-1", - IdempotencyKey: "pay-legacy-1", - OrganizationBoundBase: mo.OrganizationBoundBase{ - OrganizationRef: bson.NewObjectID(), - }, - Intent: model.PaymentIntent{ - Ref: "ref-legacy-1", - Kind: model.PaymentKindPayout, - Source: model.PaymentEndpoint{ - Type: model.EndpointTypeManagedWallet, - ManagedWallet: &model.ManagedWalletEndpoint{ - ManagedWalletRef: "wallet-src", - }, - }, - Destination: model.PaymentEndpoint{ - Type: model.EndpointTypeCard, - Card: &model.CardEndpoint{MaskedPan: "4111"}, - }, - }, - PaymentPlan: &model.PaymentPlan{ - ID: "pay-legacy-1", - IdempotencyKey: "pay-legacy-1", - Steps: []*model.PaymentStep{ - {StepID: "ledger_block", Rail: model.RailLedger, Action: model.RailOperationBlock, Amount: &paymenttypes.Money{Currency: "USD", Amount: "100"}}, - }, - }, - } - - store.payments[payment.PaymentRef] = payment - - err := executor.executePaymentPlan(ctx, store, payment, &sharedv1.PaymentQuote{}) - if err == nil { - t.Fatal("expected legacy ledger operation error") - } - if !strings.Contains(err.Error(), "unsupported action") { - t.Fatalf("unexpected error: %v", err) - } -}