(t *testing.T)
| 1044 | } |
| 1045 | |
| 1046 | func TestDeltaDERPMap(t *testing.T) { |
| 1047 | regions1 := map[int]*tailcfg.DERPRegion{ |
| 1048 | 1: { |
| 1049 | RegionID: 1, |
| 1050 | Nodes: []*tailcfg.DERPNode{{ |
| 1051 | Name: "derp1a", |
| 1052 | RegionID: 1, |
| 1053 | HostName: "derp1a" + tailcfg.DotInvalid, |
| 1054 | IPv4: "169.254.169.254", |
| 1055 | IPv6: "none", |
| 1056 | }}, |
| 1057 | }, |
| 1058 | } |
| 1059 | |
| 1060 | // As above, but with a changed IPv4 addr |
| 1061 | regions2 := map[int]*tailcfg.DERPRegion{1: regions1[1].Clone()} |
| 1062 | regions2[1].Nodes[0].IPv4 = "127.0.0.1" |
| 1063 | |
| 1064 | type step struct { |
| 1065 | got *tailcfg.DERPMap |
| 1066 | want *tailcfg.DERPMap |
| 1067 | } |
| 1068 | tests := []struct { |
| 1069 | name string |
| 1070 | steps []step |
| 1071 | }{ |
| 1072 | { |
| 1073 | name: "nothing-to-nothing", |
| 1074 | steps: []step{ |
| 1075 | {nil, nil}, |
| 1076 | {nil, nil}, |
| 1077 | }, |
| 1078 | }, |
| 1079 | { |
| 1080 | name: "regions-sticky", |
| 1081 | steps: []step{ |
| 1082 | {&tailcfg.DERPMap{Regions: regions1}, &tailcfg.DERPMap{Regions: regions1}}, |
| 1083 | {&tailcfg.DERPMap{}, &tailcfg.DERPMap{Regions: regions1}}, |
| 1084 | }, |
| 1085 | }, |
| 1086 | { |
| 1087 | name: "regions-change", |
| 1088 | steps: []step{ |
| 1089 | {&tailcfg.DERPMap{Regions: regions1}, &tailcfg.DERPMap{Regions: regions1}}, |
| 1090 | {&tailcfg.DERPMap{Regions: regions2}, &tailcfg.DERPMap{Regions: regions2}}, |
| 1091 | }, |
| 1092 | }, |
| 1093 | { |
| 1094 | name: "home-params", |
| 1095 | steps: []step{ |
| 1096 | // Send a DERP map |
| 1097 | {&tailcfg.DERPMap{Regions: regions1}, &tailcfg.DERPMap{Regions: regions1}}, |
| 1098 | // Send home params, want to still have the same regions |
| 1099 | { |
| 1100 | &tailcfg.DERPMap{HomeParams: &tailcfg.DERPHomeParams{ |
| 1101 | RegionScore: map[int]float64{1: 0.5}, |
| 1102 | }}, |
| 1103 | &tailcfg.DERPMap{Regions: regions1, HomeParams: &tailcfg.DERPHomeParams{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…