git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/netmap/test/generate.go (about)

     1  package netmaptest
     2  
     3  import (
     4  	"crypto/rand"
     5  
     6  	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
     7  )
     8  
     9  func filter(withInner bool) (x netmap.Filter) {
    10  	x.SetName("name")
    11  	if withInner {
    12  		x.LogicalOR(filter(false), filter(false))
    13  	} else {
    14  		x.NumericGE("epoch", 13)
    15  	}
    16  
    17  	return x
    18  }
    19  
    20  // Filter returns random netmap.Filter.
    21  func Filter() netmap.Filter {
    22  	return filter(true)
    23  }
    24  
    25  // Replica returns random netmap.ReplicaDescriptor.
    26  func Replica() (x netmap.ReplicaDescriptor) {
    27  	x.SetNumberOfObjects(666)
    28  	x.SetSelectorName("selector")
    29  
    30  	return
    31  }
    32  
    33  // Selector returns random netmap.Selector.
    34  func Selector() (x netmap.Selector) {
    35  	x.SetNumberOfNodes(11)
    36  	x.SetName("name")
    37  	x.SetFilterName("filter")
    38  	x.SelectByBucketAttribute("attribute")
    39  	x.SelectDistinct()
    40  
    41  	return
    42  }
    43  
    44  // PlacementPolicy returns random netmap.PlacementPolicy.
    45  func PlacementPolicy() (p netmap.PlacementPolicy) {
    46  	p.SetContainerBackupFactor(9)
    47  	p.AddFilters(Filter(), Filter())
    48  	p.AddReplicas(Replica(), Replica())
    49  	p.AddSelectors(Selector(), Selector())
    50  
    51  	return
    52  }
    53  
    54  // NetworkInfo returns random netmap.NetworkInfo.
    55  func NetworkInfo() (x netmap.NetworkInfo) {
    56  	x.SetCurrentEpoch(21)
    57  	x.SetMagicNumber(32)
    58  	x.SetMsPerBlock(43)
    59  	x.SetAuditFee(1)
    60  	x.SetStoragePrice(2)
    61  	x.SetContainerFee(3)
    62  	x.SetEpochDuration(6)
    63  	x.SetIRCandidateFee(7)
    64  	x.SetMaxObjectSize(8)
    65  	x.SetWithdrawalFee(9)
    66  
    67  	return
    68  }
    69  
    70  // NodeInfo returns random netmap.NodeInfo.
    71  func NodeInfo() (x netmap.NodeInfo) {
    72  	key := make([]byte, 33)
    73  	_, _ = rand.Read(key)
    74  
    75  	x.SetPublicKey(key)
    76  	x.SetNetworkEndpoints("1", "2", "3")
    77  
    78  	return
    79  }