MCPcopy
hub / github.com/safing/portmaster / TestFindNearest

Function TestFindNearest

spn/navigator/findnearest_test.go:7–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestFindNearest(t *testing.T) {
8 t.Parallel()
9
10 // Create map and lock faking in order to guarantee reproducability of faked data.
11 m := getDefaultTestMap()
12 fakeLock.Lock()
13 defer fakeLock.Unlock()
14
15 for range 100 {
16 // Create a random destination address
17 ip4, loc4 := createGoodIP(true)
18
19 nbPins, err := m.findNearestPins(loc4, nil, m.DefaultOptions(), DestinationHub, false)
20 if err != nil {
21 t.Error(err)
22 } else {
23 t.Logf("Pins near %s: %s", ip4, nbPins)
24 }
25 }
26
27 for range 100 {
28 // Create a random destination address
29 ip6, loc6 := createGoodIP(true)
30
31 nbPins, err := m.findNearestPins(nil, loc6, m.DefaultOptions(), DestinationHub, false)
32 if err != nil {
33 t.Error(err)
34 } else {
35 t.Logf("Pins near %s: %s", ip6, nbPins)
36 }
37 }
38}
39
40/*
41TODO: Find a way to quickly generate good geoip data on the fly, as we don't want to measure IP address generation, but only finding the nearest pins.

Callers

nothing calls this directly

Calls 7

getDefaultTestMapFunction · 0.85
createGoodIPFunction · 0.85
findNearestPinsMethod · 0.80
DefaultOptionsMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected