mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-17 07:26:52 +01:00
handshake/fragment: Remember answered messages, so repair fragments trailing a completed msg1 do not eat the source quota
This commit is contained in:
1 parent
a508a4e22c
commit
3b850c6ecf
5 files changed
+217
-10
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package nebula
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"math/rand/v2"
|
||||
"net/netip"
|
||||
"sync"
|
||||
@@ -126,11 +127,11 @@ func TestPQAnswered(t *testing.T) {
|
||||
a := newPQAnswered(5 * time.Second)
|
||||
hi := &HostInfo{}
|
||||
|
||||
assert.Nil(t, a.lookup([]byte("msg1"), now))
|
||||
assert.Nil(t, a.lookup(sha256.Sum256([]byte("msg1")), now))
|
||||
a.add([]byte("msg1"), hi, now)
|
||||
assert.Same(t, hi, a.lookup([]byte("msg1"), now.Add(time.Second)))
|
||||
assert.Nil(t, a.lookup([]byte("other"), now))
|
||||
assert.Nil(t, a.lookup([]byte("msg1"), now.Add(6*time.Second)), "stale entries are not answered")
|
||||
assert.Same(t, hi, a.lookup(sha256.Sum256([]byte("msg1")), now.Add(time.Second)))
|
||||
assert.Nil(t, a.lookup(sha256.Sum256([]byte("other")), now))
|
||||
assert.Nil(t, a.lookup(sha256.Sum256([]byte("msg1")), now.Add(6*time.Second)), "stale entries are not answered")
|
||||
|
||||
a.expire(now.Add(6 * time.Second))
|
||||
assert.Empty(t, a.entries)
|
||||
|
||||
Reference in new issue
Block a user