50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package discovery
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeRailOperations(t *testing.T) {
|
|
got := NormalizeRailOperations([]string{
|
|
"send",
|
|
"payout.crypto",
|
|
"observe.confirm",
|
|
"unknown",
|
|
"EXTERNAL_CREDIT",
|
|
})
|
|
|
|
want := []string{
|
|
RailOperationSend,
|
|
RailOperationExternalCredit,
|
|
RailOperationObserveConfirm,
|
|
}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("unexpected operations count: got=%d want=%d", len(got), len(want))
|
|
}
|
|
for i := range want {
|
|
if got[i] != want[i] {
|
|
t.Fatalf("unexpected operation[%d]: got=%q want=%q", i, got[i], want[i])
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestExpandRailOperationLegacyAliases(t *testing.T) {
|
|
got := ExpandRailOperation("payout.fiat")
|
|
if len(got) != 2 {
|
|
t.Fatalf("unexpected operations count: got=%d want=2", len(got))
|
|
}
|
|
if got[0] != RailOperationExternalCredit {
|
|
t.Fatalf("unexpected first operation: got=%q want=%q", got[0], RailOperationExternalCredit)
|
|
}
|
|
if got[1] != RailOperationSend {
|
|
t.Fatalf("unexpected second operation: got=%q want=%q", got[1], RailOperationSend)
|
|
}
|
|
}
|
|
|
|
func TestIsKnownRail(t *testing.T) {
|
|
if !IsKnownRail("crypto") {
|
|
t.Fatalf("expected crypto rail to be known")
|
|
}
|
|
if IsKnownRail("telegram") {
|
|
t.Fatalf("did not expect telegram rail to be known")
|
|
}
|
|
}
|