feat(dns): parse chain alias action maps

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 00:08:28 +00:00
parent f0a6c12443
commit 08e0d201e1
2 changed files with 29 additions and 0 deletions

View file

@ -475,6 +475,19 @@ func parseActionAliasList(value any) ([]string, error) {
if name != "" {
return []string{name}, nil
}
if len(aliases) > 0 {
parsed := make([]string, 0, len(aliases))
for _, rawAlias := range aliases {
alias, err := parseActionAliasValue(rawAlias)
if err != nil {
continue
}
if alias != "" {
parsed = append(parsed, alias)
}
}
return normalizeAliasList(parsed), nil
}
}
return nil, fmt.Errorf("blockchain.chain.aliases action returned unsupported result type %T", value)

View file

@ -3399,6 +3399,22 @@ func TestParseActionAliasListAcceptsStringMapSlice(t *testing.T) {
}
}
func TestParseActionAliasListAcceptsAliasMap(t *testing.T) {
aliases, err := parseActionAliasList(map[string]any{
"gateway": "gateway.charon.lthn",
"node": "node.charon.lthn",
})
if err != nil {
t.Fatalf("unexpected alias map parse error: %v", err)
}
if len(aliases) != 2 {
t.Fatalf("expected two aliases, got %#v", aliases)
}
if aliases[0] != "gateway.charon.lthn" || aliases[1] != "node.charon.lthn" {
t.Fatalf("unexpected alias map parsing result: %#v", aliases)
}
}
func TestNormalizeNameAndNormalizeIPArePublicWrappers(t *testing.T) {
normalizedName := NormalizeName(" Gateway.Charon.lthn. ")
if normalizedName != "gateway.charon.lthn" {