feat(covenant): add catalog get-has aliases

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 07:37:33 +00:00
parent 5f2b2832de
commit 6207563b2b
4 changed files with 44 additions and 0 deletions

View file

@ -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

View file

@ -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) {

View file

@ -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

View file

@ -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) {