Align name state nullness with reference

This commit is contained in:
Virgil 2026-04-02 02:10:16 +00:00
parent 64b3f6bf05
commit 4ef0ece61c
2 changed files with 11 additions and 5 deletions

View file

@ -15,9 +15,7 @@ func (ns NameState) Clone() NameState {
// IsNull reports whether the name state carries any non-default data.
func (ns NameState) IsNull() bool {
return len(ns.Name) == 0 &&
ns.NameHash == (Hash{}) &&
ns.Height == 0 &&
return ns.Height == 0 &&
ns.Renewal == 0 &&
(ns.Owner == (Outpoint{}) || ns.Owner.IsNull()) &&
ns.Value == 0 &&

View file

@ -11,9 +11,17 @@ func TestNameStateIsNull(t *testing.T) {
t.Fatal("zero name state should be null")
}
ns := NameState{Name: []byte("foo")}
ns := NameState{
Name: []byte("foo"),
NameHash: Hash{1, 2, 3},
}
if got := ns.IsNull(); !got {
t.Fatal("name metadata alone should not make the state non-null")
}
ns.Height = 1
if got := ns.IsNull(); got {
t.Fatal("name state with data should not be null")
t.Fatal("name state with chain data should not be null")
}
}