From 6f002f422094964227d9e8edf4b9d8423089c507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Mon, 31 Jul 2023 09:42:45 +0200 Subject: [PATCH] satellite/overlay: NR placement should exclude nodes without geofencing information https://github.com/storj/storj-private/issues/378 Change-Id: If2af02083496e5a8eefe27beabb406388ee50644 --- satellite/overlay/placement.go | 2 +- satellite/overlay/placement_test.go | 31 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/satellite/overlay/placement.go b/satellite/overlay/placement.go index f0bc3f188..514171cd5 100644 --- a/satellite/overlay/placement.go +++ b/satellite/overlay/placement.go @@ -68,7 +68,7 @@ func (d *ConfigurablePlacementRule) AddLegacyStaticRules() { d.placements[storj.EU] = nodeselection.NodeFilters{nodeselection.NewCountryFilter(nodeselection.EuCountries)} d.placements[storj.US] = nodeselection.NodeFilters{nodeselection.NewCountryFilter(location.NewSet(location.UnitedStates))} d.placements[storj.DE] = nodeselection.NodeFilters{nodeselection.NewCountryFilter(location.NewSet(location.Germany))} - d.placements[storj.NR] = nodeselection.NodeFilters{nodeselection.NewCountryFilter(location.NewFullSet().Without(location.Russia, location.Belarus))} + d.placements[storj.NR] = nodeselection.NodeFilters{nodeselection.NewCountryFilter(location.NewFullSet().Without(location.Russia, location.Belarus, location.None))} } // AddPlacementRule registers a new placement. diff --git a/satellite/overlay/placement_test.go b/satellite/overlay/placement_test.go index edf5b5d26..7f459ed1e 100644 --- a/satellite/overlay/placement_test.go +++ b/satellite/overlay/placement_test.go @@ -113,4 +113,35 @@ func TestPlacementFromString(t *testing.T) { }) + t.Run("legacy geofencing rules", func(t *testing.T) { + p := NewPlacementRules() + p.AddLegacyStaticRules() + + t.Run("nr", func(t *testing.T) { + nr := p.placements[storj.NR] + require.True(t, nr.MatchInclude(&nodeselection.SelectedNode{ + CountryCode: location.UnitedKingdom, + })) + require.False(t, nr.MatchInclude(&nodeselection.SelectedNode{ + CountryCode: location.Russia, + })) + require.False(t, nr.MatchInclude(&nodeselection.SelectedNode{ + CountryCode: 0, + })) + }) + t.Run("us", func(t *testing.T) { + us := p.placements[storj.US] + require.True(t, us.MatchInclude(&nodeselection.SelectedNode{ + CountryCode: location.UnitedStates, + })) + require.False(t, us.MatchInclude(&nodeselection.SelectedNode{ + CountryCode: location.Germany, + })) + require.False(t, us.MatchInclude(&nodeselection.SelectedNode{ + CountryCode: 0, + })) + }) + + }) + }