feat(lns): add missing getter aliases

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 06:31:22 +00:00
parent d96e641d04
commit f2bea3c97b
6 changed files with 63 additions and 0 deletions

View file

@ -39,3 +39,10 @@ func Blind(value uint64, nonce primitives.Hash) (primitives.Hash, error) {
copy(blind[:], sum.Sum(nil))
return blind, nil
}
// GetBlind is an alias for Blind.
//
// bid, err := covenant.GetBlind(1000, nonce)
func GetBlind(value uint64, nonce primitives.Hash) (primitives.Hash, error) {
return Blind(value, nonce)
}

View file

@ -31,3 +31,24 @@ func TestBlind(t *testing.T) {
t.Fatalf("Blind returned %x, want %x", got, want)
}
}
func TestGetBlind(t *testing.T) {
var nonce primitives.Hash
for i := range nonce {
nonce[i] = byte(i)
}
got, err := GetBlind(0x1122334455667788, nonce)
if err != nil {
t.Fatalf("GetBlind returned error: %v", err)
}
want, err := Blind(0x1122334455667788, nonce)
if err != nil {
t.Fatalf("Blind returned error: %v", err)
}
if got != want {
t.Fatalf("GetBlind returned %x, want %x", got, want)
}
}

View file

@ -87,6 +87,13 @@ func TypeName(ct CovenantType) string {
return "UNKNOWN"
}
// GetTypeName is an alias for TypeName.
//
// name := covenant.GetTypeName(covenant.TypeBid)
func GetTypeName(ct CovenantType) string {
return TypeName(ct)
}
// IsName returns true if the covenant type is a name-related operation
// (anything from CLAIM through REVOKE, inclusive).
//

View file

@ -43,6 +43,16 @@ func TestNameFlags(t *testing.T) {
}
}
func TestGetTypeName(t *testing.T) {
if got := GetTypeName(TypeBid); got != "BID" {
t.Fatalf("GetTypeName(TypeBid) = %q, want %q", got, "BID")
}
if got := GetTypeName(CovenantType(99)); got != "UNKNOWN" {
t.Fatalf("GetTypeName(99) = %q, want %q", got, "UNKNOWN")
}
}
func TestVerifyString(t *testing.T) {
cases := []struct {
name string

View file

@ -17,6 +17,9 @@ import (
"dappco.re/go/lns/pkg/primitives"
)
// ServiceName is the registered name for the DNS service group.
const ServiceName = "dns"
// Service handles DNS resolution for .lthn names against the LNS chain state.
//
// svc := dns.NewService()
@ -68,6 +71,13 @@ func (s *Service) GetCore() *core.Core {
return s.Core()
}
// GetServiceName returns the registered name for the DNS service group.
//
// name := svc.GetServiceName()
func (s *Service) GetServiceName() string {
return ServiceName
}
// Resolve normalises a .lthn name and returns its canonical hash.
//
// The resolver accepts either a bare name ("example") or a fully qualified

View file

@ -322,3 +322,11 @@ func TestCoreAccessors(t *testing.T) {
t.Fatal("GetCore should alias Core")
}
}
func TestServiceName(t *testing.T) {
svc := NewService()
if got := svc.GetServiceName(); got != ServiceName {
t.Fatalf("GetServiceName() = %q, want %q", got, ServiceName)
}
}