2022-04-11 16:25:14 +00:00
|
|
|
package oidtest
|
2022-01-25 16:20:32 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"math/rand"
|
|
|
|
|
2022-12-13 14:36:35 +00:00
|
|
|
cidtest "github.com/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
|
|
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
2022-01-25 16:20:32 +00:00
|
|
|
)
|
|
|
|
|
2022-05-25 09:03:22 +00:00
|
|
|
// ID returns random oid.ID.
|
2022-04-11 16:25:14 +00:00
|
|
|
func ID() oid.ID {
|
2022-01-25 16:20:32 +00:00
|
|
|
checksum := [sha256.Size]byte{}
|
|
|
|
|
|
|
|
rand.Read(checksum[:])
|
|
|
|
|
|
|
|
return idWithChecksum(checksum)
|
|
|
|
}
|
|
|
|
|
2022-05-25 09:03:22 +00:00
|
|
|
// idWithChecksum returns oid.ID initialized
|
2022-01-25 16:20:32 +00:00
|
|
|
// with specified checksum.
|
2022-04-11 16:25:14 +00:00
|
|
|
func idWithChecksum(cs [sha256.Size]byte) oid.ID {
|
|
|
|
var id oid.ID
|
2022-01-25 16:20:32 +00:00
|
|
|
id.SetSHA256(cs)
|
|
|
|
|
|
|
|
return id
|
|
|
|
}
|
2022-05-25 09:03:22 +00:00
|
|
|
|
2022-05-25 17:22:39 +00:00
|
|
|
// Address returns random oid.Address.
|
2022-05-25 09:03:22 +00:00
|
|
|
func Address() oid.Address {
|
|
|
|
var x oid.Address
|
|
|
|
|
|
|
|
x.SetContainer(cidtest.ID())
|
|
|
|
x.SetObject(ID())
|
|
|
|
|
|
|
|
return x
|
|
|
|
}
|