summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-06-03 18:22:50 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-06-03 18:22:50 +0200
commitd0cf96114fa60b8f7e7a671a7749538edec9d877 (patch)
tree3df4f738fb9f1d88077eaea69a14ce7939fa7893
parent841756e328c743fec624e9259921ea6d815911d5 (diff)
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>
-rw-r--r--device/allowedips_rand_test.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/device/allowedips_rand_test.go b/device/allowedips_rand_test.go
index 8d1e633..16de170 100644
--- a/device/allowedips_rand_test.go
+++ b/device/allowedips_rand_test.go
@@ -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")