fixed rail & operation names

This commit is contained in:
Stephan D
2026-02-27 02:33:40 +01:00
parent 82cf91e703
commit 747153bdbf
73 changed files with 877 additions and 667 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"strings"
"github.com/tech/sendico/pkg/discovery"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/model/account_role"
"github.com/tech/sendico/pkg/payments/rail"
@@ -29,9 +30,9 @@ type chainRailGateway struct {
// NewRailGateway wraps a chain gateway client into a rail gateway adapter.
func NewRailGateway(client Client, cfg RailGatewayConfig) rail.RailGateway {
railName := strings.ToUpper(strings.TrimSpace(cfg.Rail))
railName := discovery.NormalizeRail(cfg.Rail)
if railName == "" {
railName = "CRYPTO"
railName = discovery.RailCrypto
}
return &chainRailGateway{
client: client,

View File

@@ -0,0 +1,21 @@
package client
import (
"testing"
"github.com/tech/sendico/pkg/discovery"
)
func TestNewRailGateway_NormalizesRail(t *testing.T) {
gw := NewRailGateway(nil, RailGatewayConfig{Rail: "card_payout", Network: "tron"})
if got, want := gw.Rail(), discovery.RailCardPayout; got != want {
t.Fatalf("unexpected rail: got=%q want=%q", got, want)
}
}
func TestNewRailGateway_DefaultsToCryptoRail(t *testing.T) {
gw := NewRailGateway(nil, RailGatewayConfig{})
if got, want := gw.Rail(), discovery.RailCrypto; got != want {
t.Fatalf("unexpected rail: got=%q want=%q", got, want)
}
}