mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
p2p/enr: fix seq invalidation bug
This commit is contained in:
parent
c831778ef2
commit
f746119d96
2 changed files with 13 additions and 1 deletions
|
|
@ -156,7 +156,7 @@ func (r *Record) Set(e Entry) {
|
|||
}
|
||||
|
||||
func (r *Record) invalidate() {
|
||||
if r.signature == nil {
|
||||
if r.signature != nil {
|
||||
r.seq++
|
||||
}
|
||||
r.signature = nil
|
||||
|
|
|
|||
|
|
@ -169,6 +169,18 @@ func TestDirty(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSeq(t *testing.T) {
|
||||
var r Record
|
||||
|
||||
assert.Equal(t, uint64(0), r.Seq())
|
||||
r.Set(UDP(1))
|
||||
assert.Equal(t, uint64(0), r.Seq())
|
||||
signTest([]byte{5}, &r)
|
||||
assert.Equal(t, uint64(0), r.Seq())
|
||||
r.Set(UDP(2))
|
||||
assert.Equal(t, uint64(1), r.Seq())
|
||||
}
|
||||
|
||||
// TestGetSetOverwrite tests value overwrite when setting a new value with an existing key in record.
|
||||
func TestGetSetOverwrite(t *testing.T) {
|
||||
var r Record
|
||||
|
|
|
|||
Loading…
Reference in a new issue