From 6207563b2bc8ffb74a84e57cceca2b6bbc8881e5 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 07:37:33 +0000 Subject: [PATCH] feat(covenant): add catalog get-has aliases Co-Authored-By: Virgil --- pkg/covenant/locked_lookup.go | 14 ++++++++++++++ pkg/covenant/locked_lookup_test.go | 8 ++++++++ pkg/covenant/reserved_lookup.go | 14 ++++++++++++++ pkg/covenant/reserved_lookup_test.go | 8 ++++++++ 4 files changed, 44 insertions(+) diff --git a/pkg/covenant/locked_lookup.go b/pkg/covenant/locked_lookup.go index e2e6f90..c052f5f 100644 --- a/pkg/covenant/locked_lookup.go +++ b/pkg/covenant/locked_lookup.go @@ -298,6 +298,13 @@ func (c *LockedCatalog) HasByHash(hash primitives.Hash) bool { return c.Has(hash) } +// GetHasByHash is an alias for HasByHash. +// +// ok := catalog.GetHasByHash(hash) +func (c *LockedCatalog) GetHasByHash(hash primitives.Hash) bool { + return c.HasByHash(hash) +} + // Get returns the locked-name entry for the hash. // // item, ok := catalog.Get(hash) @@ -325,6 +332,13 @@ func (c *LockedCatalog) HasByName(name string) bool { return ok } +// GetHasByName is an alias for HasByName. +// +// ok := catalog.GetHasByName("example") +func (c *LockedCatalog) GetHasByName(name string) bool { + return c.HasByName(name) +} + // GetByName returns the locked-name entry for the provided label. // // The lookup lower-cases ASCII input, strips canonical `.lthn` suffixes, and diff --git a/pkg/covenant/locked_lookup_test.go b/pkg/covenant/locked_lookup_test.go index aa5ab4a..3ed6fcd 100644 --- a/pkg/covenant/locked_lookup_test.go +++ b/pkg/covenant/locked_lookup_test.go @@ -60,6 +60,10 @@ func TestLockedLookupByHashCatalogAlias(t *testing.T) { t.Fatal("catalog.HasByHash should report the locked hash as present") } + if !catalog.GetHasByHash(hash) { + t.Fatal("catalog.GetHasByHash should alias HasByHash") + } + item, ok := catalog.GetByHash(hash) if !ok { t.Fatal("catalog.GetByHash should find the locked reference entry") @@ -68,6 +72,10 @@ func TestLockedLookupByHashCatalogAlias(t *testing.T) { if item.Hash != hash { t.Fatalf("item.Hash = %x, want %x", item.Hash, hash) } + + if !catalog.GetHasByName("NEC") { + t.Fatal("catalog.GetHasByName should alias HasByName") + } } func TestLockedLookupByHashAlias(t *testing.T) { diff --git a/pkg/covenant/reserved_lookup.go b/pkg/covenant/reserved_lookup.go index 59d7806..cf40e38 100644 --- a/pkg/covenant/reserved_lookup.go +++ b/pkg/covenant/reserved_lookup.go @@ -368,6 +368,13 @@ func (c *ReservedCatalog) HasByHash(hash primitives.Hash) bool { return c.Has(hash) } +// GetHasByHash is an alias for HasByHash. +// +// ok := catalog.GetHasByHash(hash) +func (c *ReservedCatalog) GetHasByHash(hash primitives.Hash) bool { + return c.HasByHash(hash) +} + // Get returns the reserved-name entry for the hash. // // item, ok := catalog.Get(hash) @@ -395,6 +402,13 @@ func (c *ReservedCatalog) HasByName(name string) bool { return ok } +// GetHasByName is an alias for HasByName. +// +// ok := catalog.GetHasByName("example") +func (c *ReservedCatalog) GetHasByName(name string) bool { + return c.HasByName(name) +} + // GetByName returns the reserved-name entry for the provided label. // // The lookup lower-cases ASCII input, strips canonical `.lthn` suffixes, and diff --git a/pkg/covenant/reserved_lookup_test.go b/pkg/covenant/reserved_lookup_test.go index 4736720..a9e7c42 100644 --- a/pkg/covenant/reserved_lookup_test.go +++ b/pkg/covenant/reserved_lookup_test.go @@ -64,6 +64,10 @@ func TestReservedLookupByHashCatalogAlias(t *testing.T) { t.Fatal("catalog.HasByHash should report the reserved hash as present") } + if !catalog.GetHasByHash(hash) { + t.Fatal("catalog.GetHasByHash should alias HasByHash") + } + item, ok := catalog.GetByHash(hash) if !ok { t.Fatal("catalog.GetByHash should find the reserved reference entry") @@ -72,6 +76,10 @@ func TestReservedLookupByHashCatalogAlias(t *testing.T) { if item.Hash != hash { t.Fatalf("item.Hash = %x, want %x", item.Hash, hash) } + + if !catalog.GetHasByName("RESERVED") { + t.Fatal("catalog.GetHasByName should alias HasByName") + } } func TestReservedLookupByHashAlias(t *testing.T) {