From e2f112b0cde401605bcce31763f3361cf4c22f72 Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 05:44:38 +0000 Subject: [PATCH] feat(covenant): add covenant rules constants --- pkg/covenant/name_test.go | 26 ++++++++++++++++++++++++++ pkg/covenant/rules.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 pkg/covenant/rules.go diff --git a/pkg/covenant/name_test.go b/pkg/covenant/name_test.go index 5cd34b2..13c27e8 100644 --- a/pkg/covenant/name_test.go +++ b/pkg/covenant/name_test.go @@ -15,6 +15,32 @@ func TestNameSizeLimits(t *testing.T) { if MaxResourceSize != 512 { t.Fatalf("MaxResourceSize = %d, want 512", MaxResourceSize) } + + if MaxCovenantSize != 585 { + t.Fatalf("MaxCovenantSize = %d, want 585", MaxCovenantSize) + } + + if CovenantMaxSize != MaxCovenantSize { + t.Fatalf("CovenantMaxSize = %d, want %d", CovenantMaxSize, MaxCovenantSize) + } +} + +func TestNameFlags(t *testing.T) { + if VerifyCovenantsNone != 0 { + t.Fatalf("VerifyCovenantsNone = %d, want 0", VerifyCovenantsNone) + } + + if VerifyCovenantsHardened != 1<<0 { + t.Fatalf("VerifyCovenantsHardened = %d, want %d", VerifyCovenantsHardened, 1<<0) + } + + if VerifyCovenantsLockup != 1<<1 { + t.Fatalf("VerifyCovenantsLockup = %d, want %d", VerifyCovenantsLockup, 1<<1) + } + + if MandatoryVerifyCovenantFlags != VerifyCovenantsNone { + t.Fatalf("MandatoryVerifyCovenantFlags = %d, want %d", MandatoryVerifyCovenantFlags, VerifyCovenantsNone) + } } func TestVerifyString(t *testing.T) { diff --git a/pkg/covenant/rules.go b/pkg/covenant/rules.go new file mode 100644 index 0000000..16a023a --- /dev/null +++ b/pkg/covenant/rules.go @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: EUPL-1.2 + +package covenant + +// NameFlags mirrors the covenant verification flags used by the JS reference +// rules module. +type NameFlags uint8 + +const ( + // VerifyCovenantsNone disables covenant verification flags. + VerifyCovenantsNone NameFlags = 0 + + // VerifyCovenantsHardened is enabled when the covenant hardening soft fork + // activates. + VerifyCovenantsHardened NameFlags = 1 << 0 + + // VerifyCovenantsLockup is enabled when the ICANN lockup soft fork + // activates. + VerifyCovenantsLockup NameFlags = 1 << 1 + + // MandatoryVerifyCovenantFlags is the default covenant verification mask. + MandatoryVerifyCovenantFlags NameFlags = VerifyCovenantsNone + + // MaxCovenantSize is the maximum serialized covenant size mirrored from the + // JS rules reference. + MaxCovenantSize = 1 + 32 + 1 + 4 + 2 + MaxResourceSize + 1 + 32 + + // CovenantMaxSize is an alias for MaxCovenantSize. + CovenantMaxSize = MaxCovenantSize +)