github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/core/discovery/reducer/mocks_test.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package reducer
    19  
    20  import (
    21  	"github.com/mysteriumnetwork/node/market"
    22  )
    23  
    24  var (
    25  	provider1            = "0x1"
    26  	provider2            = "0x2"
    27  	serviceTypeStreaming = "streaming"
    28  	serviceTypeNoop      = "noop"
    29  	accessRuleWhitelist  = market.AccessPolicy{
    30  		ID:     "whitelist",
    31  		Source: "whitelist.txt",
    32  	}
    33  	accessRuleBlacklist = market.AccessPolicy{
    34  		ID:     "blacklist",
    35  		Source: "blacklist.txt",
    36  	}
    37  	locationDatacenter  = market.Location{ASN: 1000, Country: "DE", City: "Berlin", IPType: "datacenter"}
    38  	locationResidential = market.Location{ASN: 124, Country: "LT", City: "Vilnius", IPType: "residential"}
    39  
    40  	proposalEmpty              = market.NewProposal("", serviceTypeNoop, market.NewProposalOpts{})
    41  	proposalProvider1Streaming = market.NewProposal(provider1, serviceTypeStreaming, market.NewProposalOpts{
    42  		Location:       &locationDatacenter,
    43  		AccessPolicies: []market.AccessPolicy{accessRuleWhitelist},
    44  	})
    45  	proposalProvider1Noop      = market.NewProposal(provider1, serviceTypeNoop, market.NewProposalOpts{})
    46  	proposalProvider2Streaming = market.NewProposal(provider2, serviceTypeStreaming, market.NewProposalOpts{
    47  		Location:       &locationResidential,
    48  		AccessPolicies: []market.AccessPolicy{accessRuleWhitelist, accessRuleBlacklist},
    49  	})
    50  )
    51  
    52  func conditionAlwaysMatch(_ market.ServiceProposal) bool {
    53  	return true
    54  }
    55  
    56  func conditionNeverMatch(_ market.ServiceProposal) bool {
    57  	return false
    58  }
    59  
    60  func conditionIsProvider1(provider market.ServiceProposal) bool {
    61  	return provider.ProviderID == provider1
    62  }
    63  
    64  func conditionIsStreaming(provider market.ServiceProposal) bool {
    65  	return provider.ServiceType == "streaming"
    66  }
    67  
    68  func fieldCompatibility(proposal market.ServiceProposal) interface{} {
    69  	return proposal.Compatibility
    70  }
    71  
    72  func fieldProviderID(proposal market.ServiceProposal) interface{} {
    73  	return proposal.ProviderID
    74  }