50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package model
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
func TestIsGatewayEligible_AllowsMatchingGateway(t *testing.T) {
|
|
gw := &GatewayInstanceDescriptor{
|
|
ID: "gw-1",
|
|
InstanceID: "inst-1",
|
|
Rail: RailCrypto,
|
|
Network: "TRON",
|
|
Currencies: []string{"USDT"},
|
|
Operations: []RailOperation{RailOperationSend, RailOperationExternalCredit},
|
|
IsEnabled: true,
|
|
}
|
|
|
|
err := IsGatewayEligible(gw, RailCrypto, "TRON", "USDT", RailOperationSend, GatewayDirectionOut, decimal.RequireFromString("10"))
|
|
if err != nil {
|
|
t.Fatalf("expected gateway to be eligible, got err=%v", err)
|
|
}
|
|
}
|
|
|
|
func TestIsGatewayEligible_RejectsNetworkMismatch(t *testing.T) {
|
|
gw := &GatewayInstanceDescriptor{
|
|
ID: "gw-1",
|
|
InstanceID: "inst-1",
|
|
Rail: RailCrypto,
|
|
Network: "ETH",
|
|
Currencies: []string{"USDT"},
|
|
Operations: []RailOperation{RailOperationSend},
|
|
IsEnabled: true,
|
|
}
|
|
|
|
err := IsGatewayEligible(gw, RailCrypto, "TRON", "USDT", RailOperationSend, GatewayDirectionOut, decimal.RequireFromString("10"))
|
|
if err == nil {
|
|
t.Fatalf("expected network mismatch error")
|
|
}
|
|
}
|
|
|
|
func TestNoEligibleGatewayMessage(t *testing.T) {
|
|
got := NoEligibleGatewayMessage("tron", "usdt", RailOperationSend, GatewayDirectionOut)
|
|
want := "plan builder: no eligible gateway found for TRON USDT SEND for direction out"
|
|
if got != want {
|
|
t.Fatalf("unexpected message: got=%q want=%q", got, want)
|
|
}
|
|
}
|