device: limit allowedip fuzzer a to 4 times through

Trying this for every peer winds up being very slow and precludes it
from acceptable runtime in the CI, so reduce this to 4.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-06-03 18:22:50 +02:00
parent 841756e328
commit d0cf96114f

View file

@ -13,9 +13,10 @@ import (
)
const (
NumberOfPeers = 100
NumberOfAddresses = 250
NumberOfTests = 10000
NumberOfPeers = 100
NumberOfPeerRemovals = 4
NumberOfAddresses = 250
NumberOfTests = 10000
)
type SlowNode struct {
@ -103,7 +104,8 @@ func TestTrieRandom(t *testing.T) {
slow6 = slow6.Insert(addr6[:], cidr, peers[index])
}
for p := 0; ; p++ {
var p int
for p = 0; ; p++ {
for n := 0; n < NumberOfTests; n++ {
var addr4 [4]byte
rand.Read(addr4[:])
@ -121,13 +123,16 @@ func TestTrieRandom(t *testing.T) {
t.Errorf("Trie did not match naive implementation, for %v: want %p, got %p", net.IP(addr6[:]), peer1, peer2)
}
}
if p >= len(peers) {
if p >= len(peers) || p >= NumberOfPeerRemovals {
break
}
allowedIPs.RemoveByPeer(peers[p])
slow4 = slow4.RemoveByPeer(peers[p])
slow6 = slow6.RemoveByPeer(peers[p])
}
for ; p < len(peers); p++ {
allowedIPs.RemoveByPeer(peers[p])
}
if allowedIPs.IPv4 != nil || allowedIPs.IPv6 != nil {
t.Error("Failed to remove all nodes from trie by peer")