frostfs-api-go/tombstone/test/generate.go
Aleksey Savchuk 9c5e32a183
[#106] test: Generate correct data for tests
Some tests are using invalid data that do not meet the requirements of the
FrostFS protocol, e.g.
- Container/Object IDs aren't 32 bytes long
- Signature key and sign have invalid length
- Split IDs aren't valid UUIDv4
and etc.

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
2024-08-30 13:37:29 +03:00

23 lines
446 B
Go

package tombstonetest
import (
"crypto/rand"
refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/tombstone"
)
func GenerateTombstone(empty bool) *tombstone.Tombstone {
m := new(tombstone.Tombstone)
if !empty {
id := make([]byte, 16)
_, _ = rand.Read(id)
m.SetExpirationEpoch(89)
m.SetSplitID(id)
m.SetMembers(refstest.GenerateObjectIDs(false))
}
return m
}