Align name state nullness with reference
This commit is contained in:
parent
64b3f6bf05
commit
4ef0ece61c
2 changed files with 11 additions and 5 deletions
|
|
@ -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 &&
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue