fixed tests and compilation
This commit is contained in:
@@ -200,7 +200,7 @@ type repositoryStub struct {
|
|||||||
|
|
||||||
func (r *repositoryStub) Ping(context.Context) error { return nil }
|
func (r *repositoryStub) Ping(context.Context) error { return nil }
|
||||||
func (r *repositoryStub) Rates() storage.RatesStore { return r.rates }
|
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) Pairs() storage.PairStore { return nil }
|
||||||
func (r *repositoryStub) Currencies() storage.CurrencyStore { return nil }
|
func (r *repositoryStub) Currencies() storage.CurrencyStore { return nil }
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
type repositoryStub struct {
|
type repositoryStub struct {
|
||||||
rates storage.RatesStore
|
rates storage.RatesStore
|
||||||
quotes quotestorage.QuotesStore
|
quotes storage.QuotesStore
|
||||||
pairs storage.PairStore
|
pairs storage.PairStore
|
||||||
currencies storage.CurrencyStore
|
currencies storage.CurrencyStore
|
||||||
pingErr error
|
pingErr error
|
||||||
@@ -27,7 +27,7 @@ type repositoryStub struct {
|
|||||||
|
|
||||||
func (r *repositoryStub) Ping(ctx context.Context) error { return r.pingErr }
|
func (r *repositoryStub) Ping(ctx context.Context) error { return r.pingErr }
|
||||||
func (r *repositoryStub) Rates() storage.RatesStore { return r.rates }
|
func (r *repositoryStub) Rates() storage.RatesStore { return r.rates }
|
||||||
func (r *repositoryStub) Quotes() quotestorage.QuotesStore { return r.quotes }
|
func (r *repositoryStub) Quotes() storage.QuotesStore { return r.quotes }
|
||||||
func (r *repositoryStub) Pairs() storage.PairStore { return r.pairs }
|
func (r *repositoryStub) Pairs() storage.PairStore { return r.pairs }
|
||||||
func (r *repositoryStub) Currencies() storage.CurrencyStore {
|
func (r *repositoryStub) Currencies() storage.CurrencyStore {
|
||||||
return r.currencies
|
return r.currencies
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type Store struct {
|
|||||||
txFactory transaction.Factory
|
txFactory transaction.Factory
|
||||||
|
|
||||||
rates storage.RatesStore
|
rates storage.RatesStore
|
||||||
quotes quotestorage.QuotesStore
|
quotes storage.QuotesStore
|
||||||
pairs storage.PairStore
|
pairs storage.PairStore
|
||||||
currencies storage.CurrencyStore
|
currencies storage.CurrencyStore
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ func (s *Store) Rates() storage.RatesStore {
|
|||||||
return s.rates
|
return s.rates
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) Quotes() quotestorage.QuotesStore {
|
func (s *Store) Quotes() storage.QuotesStore {
|
||||||
return s.quotes
|
return s.quotes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type quotesStore struct {
|
|||||||
txFactory transaction.Factory
|
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)
|
repo := repository.CreateMongoRepository(db, model.QuotesCollection)
|
||||||
indexes := []*ri.Definition{
|
indexes := []*ri.Definition{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type repoStub struct {
|
|||||||
findOneFn func(ctx context.Context, query builder.Query, result storable.Storable) error
|
findOneFn func(ctx context.Context, query builder.Query, result storable.Storable) error
|
||||||
findManyFn func(ctx context.Context, query builder.Query, decoder rd.DecodingFunc) error
|
findManyFn func(ctx context.Context, query builder.Query, decoder rd.DecodingFunc) error
|
||||||
updateFn func(ctx context.Context, obj storable.Storable) 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)
|
patchManyFn func(ctx context.Context, filter builder.Query, patch builder.Patch) (int, error)
|
||||||
createIdxFn func(def *ri.Definition) error
|
createIdxFn func(def *ri.Definition) error
|
||||||
}
|
}
|
||||||
@@ -69,6 +70,13 @@ func (r *repoStub) Update(ctx context.Context, obj storable.Storable) error {
|
|||||||
return nil
|
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 {
|
func (r *repoStub) Patch(ctx context.Context, id bson.ObjectID, patch builder.Patch) error {
|
||||||
return merrors.NotImplemented("Patch not used")
|
return merrors.NotImplemented("Patch not used")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type repositoryStub struct {
|
|||||||
InsertFunc func(ctx context.Context, object storable.Storable, filter builder.Query) error
|
InsertFunc func(ctx context.Context, object storable.Storable, filter builder.Query) error
|
||||||
InsertManyFunc func(ctx context.Context, objects []storable.Storable) error
|
InsertManyFunc func(ctx context.Context, objects []storable.Storable) error
|
||||||
UpdateFunc func(ctx context.Context, object 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
|
DeleteFunc func(ctx context.Context, id bson.ObjectID) error
|
||||||
FindOneByFilterFunc func(ctx context.Context, filter builder.Query, result storable.Storable) 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
|
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
|
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 {
|
func (r *repositoryStub) Delete(ctx context.Context, id bson.ObjectID) error {
|
||||||
if r.DeleteFunc != nil {
|
if r.DeleteFunc != nil {
|
||||||
return r.DeleteFunc(ctx, id)
|
return r.DeleteFunc(ctx, id)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/tech/sendico/pkg/mlogger"
|
"github.com/tech/sendico/pkg/mlogger"
|
||||||
"github.com/tech/sendico/pkg/model"
|
"github.com/tech/sendico/pkg/model"
|
||||||
"github.com/tech/sendico/pkg/mservice"
|
"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"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ func encodePaymentMethod(pm *model.PaymentMethod) ([]byte, error) {
|
|||||||
return payload, nil
|
return payload, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toModelCursor(cursor *methodsv1.ViewCursor) *model.ViewCursor {
|
func toModelCursor(cursor *paginationv2.ViewCursor) *model.ViewCursor {
|
||||||
if cursor == nil {
|
if cursor == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package orchestrator
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
mntxclient "github.com/tech/sendico/gateway/mntx/client"
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user