2021-10-26 13:19:11 +00:00
|
|
|
package cidtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"math/rand"
|
|
|
|
|
2023-03-07 11:20:03 +00:00
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
2021-10-26 13:19:11 +00:00
|
|
|
)
|
|
|
|
|
2021-11-12 11:19:16 +00:00
|
|
|
// ID returns random cid.ID.
|
2022-04-11 16:25:14 +00:00
|
|
|
func ID() cid.ID {
|
2021-10-26 13:19:11 +00:00
|
|
|
checksum := [sha256.Size]byte{}
|
|
|
|
|
|
|
|
rand.Read(checksum[:])
|
|
|
|
|
2021-11-12 11:19:16 +00:00
|
|
|
return IDWithChecksum(checksum)
|
2021-10-26 13:19:11 +00:00
|
|
|
}
|
|
|
|
|
2021-11-12 11:19:16 +00:00
|
|
|
// IDWithChecksum returns cid.ID initialized
|
2021-10-26 13:19:11 +00:00
|
|
|
// with specified checksum.
|
2022-04-11 16:25:14 +00:00
|
|
|
func IDWithChecksum(cs [sha256.Size]byte) cid.ID {
|
|
|
|
var id cid.ID
|
2021-10-26 13:19:11 +00:00
|
|
|
id.SetSHA256(cs)
|
|
|
|
|
|
|
|
return id
|
|
|
|
}
|