[#283] pkg/owner: Implement generators of ID's for testing
Create `ownertest` package with functions which generate random `owner.ID` instances. These functions is going to be used for testing. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
48837bd5da
commit
4f286f5175
1 changed files with 27 additions and 0 deletions
27
pkg/owner/test/id.go
Normal file
27
pkg/owner/test/id.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package ownertest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate returns owner.ID calculated
|
||||||
|
// from a random owner.NEO3Wallet.
|
||||||
|
func Generate() *owner.ID {
|
||||||
|
data := make([]byte, owner.NEO3WalletSize)
|
||||||
|
|
||||||
|
rand.Read(data)
|
||||||
|
|
||||||
|
return GenerateFromBytes(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenerateFromBytes returns owner.ID generated
|
||||||
|
// from a passed byte slice.
|
||||||
|
func GenerateFromBytes(val []byte) *owner.ID {
|
||||||
|
idV2 := new(refs.OwnerID)
|
||||||
|
idV2.SetValue(val)
|
||||||
|
|
||||||
|
return owner.NewIDFromV2(idV2)
|
||||||
|
}
|
Loading…
Reference in a new issue