2021-03-12 12:57:23 +00:00
|
|
|
package refstest
|
|
|
|
|
|
|
|
import (
|
2022-02-22 11:25:43 +00:00
|
|
|
"math/rand"
|
|
|
|
|
2023-06-12 22:33:53 +00:00
|
|
|
refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func GenerateVersion(empty bool) *refs.Version {
|
|
|
|
m := new(refs.Version)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetMajor(2)
|
|
|
|
m.SetMinor(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateOwnerID(empty bool) *refs.OwnerID {
|
|
|
|
m := new(refs.OwnerID)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetValue([]byte{1, 2, 3})
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateAddress(empty bool) *refs.Address {
|
|
|
|
m := new(refs.Address)
|
|
|
|
|
2021-06-11 12:41:36 +00:00
|
|
|
if !empty {
|
2023-06-12 22:33:53 +00:00
|
|
|
m.SetObjectId(GenerateObjectID(false))
|
|
|
|
m.SetContainerId(GenerateContainerID(false))
|
2021-06-11 12:41:36 +00:00
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateObjectID(empty bool) *refs.ObjectID {
|
|
|
|
m := new(refs.ObjectID)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetValue([]byte{1, 2, 3})
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2023-06-12 22:33:53 +00:00
|
|
|
func GenerateObjectIDs(empty bool) []*refs.ObjectID {
|
|
|
|
var ids []*refs.ObjectID
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
if !empty {
|
|
|
|
ids = append(ids,
|
2023-06-12 22:33:53 +00:00
|
|
|
GenerateObjectID(false),
|
|
|
|
GenerateObjectID(false),
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateContainerID(empty bool) *refs.ContainerID {
|
|
|
|
m := new(refs.ContainerID)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetValue([]byte{1, 2, 3})
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2023-06-12 22:33:53 +00:00
|
|
|
func GenerateContainerIDs(empty bool) []*refs.ContainerID {
|
|
|
|
var res []*refs.ContainerID
|
2021-06-11 12:41:36 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if !empty {
|
|
|
|
res = append(res,
|
2023-06-12 22:33:53 +00:00
|
|
|
GenerateContainerID(false),
|
|
|
|
GenerateContainerID(false),
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:41:36 +00:00
|
|
|
return res
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSignature(empty bool) *refs.Signature {
|
|
|
|
m := new(refs.Signature)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetKey([]byte{1})
|
|
|
|
m.SetSign([]byte{2})
|
2022-02-22 11:25:43 +00:00
|
|
|
m.SetScheme(refs.SignatureScheme(rand.Int31() % 3))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2023-06-12 22:33:53 +00:00
|
|
|
func GenerateSignatureRFC6979(empty bool) *refs.SignatureRFC6979 {
|
|
|
|
m := new(refs.SignatureRFC6979)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetKey([]byte{1})
|
|
|
|
m.SetSign([]byte{2})
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func GenerateChecksum(empty bool) *refs.Checksum {
|
|
|
|
m := new(refs.Checksum)
|
|
|
|
|
|
|
|
if !empty {
|
2023-06-12 22:33:53 +00:00
|
|
|
m.SetChecksumType(1)
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetSum([]byte{1, 2, 3})
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|