[#54] tests: unify test generator names

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-11-12 14:19:16 +03:00 committed by Alex Vanin
parent fa7c01bd0b
commit 3d0df0d068
35 changed files with 113 additions and 113 deletions

View file

@ -4,7 +4,7 @@ import (
"testing"
"github.com/nspcc-dev/neofs-sdk-go/accounting"
test "github.com/nspcc-dev/neofs-sdk-go/accounting/test"
accountingtest "github.com/nspcc-dev/neofs-sdk-go/accounting/test"
"github.com/stretchr/testify/require"
)
@ -20,7 +20,7 @@ func TestDecimal(t *testing.T) {
}
func TestDecimalEncoding(t *testing.T) {
d := test.GenerateDecimal()
d := accountingtest.Decimal()
t.Run("binary", func(t *testing.T) {
data, err := d.Marshal()

View file

@ -6,8 +6,8 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/accounting"
)
// GenerateDecimal returns random accounting.Decimal.
func GenerateDecimal() *accounting.Decimal {
// Decimal returns random accounting.Decimal.
func Decimal() *accounting.Decimal {
d := accounting.NewDecimal()
d.SetValue(rand.Int63())
d.SetPrecision(rand.Uint32())

View file

@ -21,7 +21,7 @@ func TestResult(t *testing.T) {
r.SetAuditEpoch(epoch)
require.Equal(t, epoch, r.AuditEpoch())
cid := cidtest.GenerateID()
cid := cidtest.ID()
r.SetContainerID(cid)
require.Equal(t, cid, r.ContainerID())
@ -70,7 +70,7 @@ func TestResult(t *testing.T) {
}
func TestStorageGroupEncoding(t *testing.T) {
r := audittest.Generate()
r := audittest.Result()
t.Run("binary", func(t *testing.T) {
data, err := r.Marshal()

View file

@ -8,12 +8,12 @@ import (
versiontest "github.com/nspcc-dev/neofs-sdk-go/version/test"
)
// Generate returns random audit.Result.
func Generate() *audit.Result {
// Result returns random audit.Result.
func Result() *audit.Result {
x := audit.NewResult()
x.SetVersion(versiontest.Version())
x.SetContainerID(cidtest.GenerateID())
x.SetContainerID(cidtest.ID())
x.SetPublicKey([]byte("key"))
x.SetComplete(true)
x.SetAuditEpoch(44)

View file

@ -1,4 +1,4 @@
package test
package checksumtest
import (
"crypto/sha256"

View file

@ -17,7 +17,7 @@ func TestAnnouncement(t *testing.T) {
const epoch, usedSpace uint64 = 10, 100
cidValue := [sha256.Size]byte{1, 2, 3}
id := cidtest.GenerateIDWithChecksum(cidValue)
id := cidtest.IDWithChecksum(cidValue)
a := container.NewAnnouncement()
a.SetEpoch(epoch)

View file

@ -20,7 +20,7 @@ func TestNewContainer(t *testing.T) {
nonce := uuid.New()
ownerID := ownertest.GenerateID()
ownerID := ownertest.ID()
policy := netmaptest.PlacementPolicy()
c.SetBasicACL(acl.PublicBasicRule)
@ -75,7 +75,7 @@ func TestContainerEncoding(t *testing.T) {
}
func TestContainer_SessionToken(t *testing.T) {
tok := sessiontest.Generate()
tok := sessiontest.Token()
cnr := container.New()

View file

@ -20,7 +20,7 @@ func TestID_ToV2(t *testing.T) {
t.Run("non-nil", func(t *testing.T) {
checksum := randSHA256Checksum()
id := cidtest.GenerateIDWithChecksum(checksum)
id := cidtest.IDWithChecksum(checksum)
idV2 := id.ToV2()
@ -46,19 +46,19 @@ func TestID_ToV2(t *testing.T) {
func TestID_Equal(t *testing.T) {
cs := randSHA256Checksum()
id1 := cidtest.GenerateIDWithChecksum(cs)
id2 := cidtest.GenerateIDWithChecksum(cs)
id1 := cidtest.IDWithChecksum(cs)
id2 := cidtest.IDWithChecksum(cs)
require.True(t, id1.Equal(id2))
id3 := cidtest.GenerateID()
id3 := cidtest.ID()
require.False(t, id1.Equal(id3))
}
func TestID_String(t *testing.T) {
t.Run("Parse/String", func(t *testing.T) {
id := cidtest.GenerateID()
id := cidtest.ID()
id2 := cid.New()
require.NoError(t, id2.Parse(id.String()))
@ -73,7 +73,7 @@ func TestID_String(t *testing.T) {
}
func TestContainerIDEncoding(t *testing.T) {
id := cidtest.GenerateID()
id := cidtest.ID()
t.Run("binary", func(t *testing.T) {
data, err := id.Marshal()

View file

@ -7,18 +7,18 @@ import (
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
)
// GenerateID returns random cid.ID.
func GenerateID() *cid.ID {
// ID returns random cid.ID.
func ID() *cid.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
return GenerateIDWithChecksum(checksum)
return IDWithChecksum(checksum)
}
// GenerateIDWithChecksum returns cid.ID initialized
// IDWithChecksum returns cid.ID initialized
// with specified checksum.
func GenerateIDWithChecksum(cs [sha256.Size]byte) *cid.ID {
func IDWithChecksum(cs [sha256.Size]byte) *cid.ID {
id := cid.New()
id.SetSHA256(cs)

View file

@ -29,7 +29,7 @@ func Container() *container.Container {
x.SetVersion(versiontest.Version())
x.SetAttributes(Attributes())
x.SetOwnerID(ownertest.GenerateID())
x.SetOwnerID(ownertest.ID())
x.SetBasicACL(123)
x.SetPlacementPolicy(netmaptest.PlacementPolicy())
@ -40,7 +40,7 @@ func Container() *container.Container {
func UsedSpaceAnnouncement() *container.UsedSpaceAnnouncement {
x := container.NewAnnouncement()
x.SetContainerID(cidtest.GenerateID())
x.SetContainerID(cidtest.ID())
x.SetEpoch(55)
x.SetUsedSpace(999)

View file

@ -158,8 +158,8 @@ func TestReservedRecords(t *testing.T) {
var (
v = versiontest.Version()
oid = objecttest.ID()
cid = cidtest.GenerateID()
ownerid = ownertest.GenerateID()
cid = cidtest.ID()
ownerid = ownertest.ID()
h = checksumtest.Checksum()
typ = new(object.Type)
)

View file

@ -17,7 +17,7 @@ func TestTable(t *testing.T) {
var v version.Version
sha := sha256.Sum256([]byte("container id"))
id := cidtest.GenerateIDWithChecksum(sha)
id := cidtest.IDWithChecksum(sha)
v.SetMajor(3)
v.SetMinor(2)
@ -42,7 +42,7 @@ func TestTable(t *testing.T) {
})
t.Run("create table", func(t *testing.T) {
id := cidtest.GenerateID()
id := cidtest.ID()
table := eacl.CreateTable(*id)
require.Equal(t, id, table.CID())
@ -91,7 +91,7 @@ func TestTableEncoding(t *testing.T) {
}
func TestTable_SessionToken(t *testing.T) {
tok := sessiontest.Generate()
tok := sessiontest.Token()
table := eacl.NewTable()
table.SetSessionToken(tok)

View file

@ -27,8 +27,8 @@ func Record() *eacl.Record {
x.SetAction(eacl.ActionAllow)
x.SetOperation(eacl.OperationRangeHash)
x.SetTargets(Target(), Target())
x.AddObjectContainerIDFilter(eacl.MatchStringEqual, cidtest.GenerateID())
x.AddObjectOwnerIDFilter(eacl.MatchStringNotEqual, ownertest.GenerateID())
x.AddObjectContainerIDFilter(eacl.MatchStringEqual, cidtest.ID())
x.AddObjectOwnerIDFilter(eacl.MatchStringNotEqual, ownertest.ID())
return x
}
@ -36,7 +36,7 @@ func Record() *eacl.Record {
func Table() *eacl.Table {
x := eacl.NewTable()
x.SetCID(cidtest.GenerateID())
x.SetCID(cidtest.ID())
x.AddRecord(Record())
x.AddRecord(Record())
x.SetVersion(*versiontest.Version())

View file

@ -1,4 +1,4 @@
package test
package netmaptest
import "github.com/nspcc-dev/neofs-sdk-go/netmap"

View file

@ -12,7 +12,7 @@ import (
func TestAddress_SetContainerID(t *testing.T) {
a := NewAddress()
id := cidtest.GenerateID()
id := cidtest.ID()
a.SetContainerID(id)
@ -30,7 +30,7 @@ func TestAddress_SetObjectID(t *testing.T) {
}
func TestAddress_Parse(t *testing.T) {
cid := cidtest.GenerateID()
cid := cidtest.ID()
oid := NewID()
oid.SetSHA256(randSHA256Checksum(t))
@ -63,7 +63,7 @@ func TestAddress_Parse(t *testing.T) {
func TestAddressEncoding(t *testing.T) {
a := NewAddress()
a.SetObjectID(randID(t))
a.SetContainerID(cidtest.GenerateID())
a.SetContainerID(cidtest.ID())
t.Run("binary", func(t *testing.T) {
data, err := a.Marshal()

View file

@ -93,7 +93,7 @@ func TestRawObject_SetPayloadSize(t *testing.T) {
func TestRawObject_SetContainerID(t *testing.T) {
obj := NewRaw()
cid := cidtest.GenerateID()
cid := cidtest.ID()
obj.SetContainerID(cid)
@ -103,7 +103,7 @@ func TestRawObject_SetContainerID(t *testing.T) {
func TestRawObject_SetOwnerID(t *testing.T) {
obj := NewRaw()
ownerID := ownertest.GenerateID()
ownerID := ownertest.ID()
obj.SetOwnerID(ownerID)
@ -196,7 +196,7 @@ func TestRawObject_SetParent(t *testing.T) {
par := NewRaw()
par.SetID(randID(t))
par.SetContainerID(cidtest.GenerateID())
par.SetContainerID(cidtest.ID())
par.SetSignature(signature.New())
parObj := par.Object()
@ -218,7 +218,7 @@ func TestRawObject_ToV2(t *testing.T) {
func TestRawObject_SetSessionToken(t *testing.T) {
obj := NewRaw()
tok := sessiontest.Generate()
tok := sessiontest.Token()
obj.SetSessionToken(tok)

View file

@ -36,7 +36,7 @@ func IDWithChecksum(cs [sha256.Size]byte) *object.ID {
func Address() *object.Address {
x := object.NewAddress()
x.SetContainerID(cidtest.GenerateID())
x.SetContainerID(cidtest.ID())
x.SetObjectID(ID())
return x
@ -75,10 +75,10 @@ func generateRaw(withParent bool) *object.RawObject {
x := object.NewRaw()
x.SetID(ID())
x.SetSessionToken(sessiontest.Generate())
x.SetSessionToken(sessiontest.Token())
x.SetPayload([]byte{1, 2, 3})
x.SetOwnerID(ownertest.GenerateID())
x.SetContainerID(cidtest.GenerateID())
x.SetOwnerID(ownertest.ID())
x.SetContainerID(cidtest.ID())
x.SetType(object.TypeTombstone)
x.SetVersion(version.Current())
x.SetPayloadSize(111)
@ -136,7 +136,7 @@ func SearchFilters() object.SearchFilters {
x := object.NewSearchFilters()
x.AddObjectIDFilter(object.MatchStringEqual, ID())
x.AddObjectContainerIDFilter(object.MatchStringNotEqual, cidtest.GenerateID())
x.AddObjectContainerIDFilter(object.MatchStringNotEqual, cidtest.ID())
return x
}

View file

@ -14,7 +14,7 @@ import (
)
func TestIDV2(t *testing.T) {
id := ownertest.GenerateID()
id := ownertest.ID()
idV2 := id.ToV2()
@ -22,7 +22,7 @@ func TestIDV2(t *testing.T) {
}
func TestID_Valid(t *testing.T) {
id := ownertest.GenerateID()
id := ownertest.ID()
require.True(t, id.Valid())
val := id.ToV2().GetValue()
@ -32,13 +32,13 @@ func TestID_Valid(t *testing.T) {
copy(v, val)
v[0] ^= 0xFF
id := ownertest.GenerateIDFromBytes(v)
id := ownertest.IDFromBytes(v)
require.False(t, id.Valid())
})
t.Run("invalid size", func(t *testing.T) {
val := val[:NEO3WalletSize-1]
id := ownertest.GenerateIDFromBytes(val)
id := ownertest.IDFromBytes(val)
require.False(t, id.Valid())
})
t.Run("invalid checksum", func(t *testing.T) {
@ -46,7 +46,7 @@ func TestID_Valid(t *testing.T) {
copy(v, val)
v[NEO3WalletSize-1] ^= 0xFF
id := ownertest.GenerateIDFromBytes(v)
id := ownertest.IDFromBytes(v)
require.False(t, id.Valid())
})
}
@ -87,7 +87,7 @@ func TestID_Parse(t *testing.T) {
}
func TestIDEncoding(t *testing.T) {
id := ownertest.GenerateID()
id := ownertest.ID()
t.Run("binary", func(t *testing.T) {
data, err := id.Marshal()
@ -117,14 +117,14 @@ func TestID_Equal(t *testing.T) {
data3 = append(data1, 255)
)
id1 := ownertest.GenerateIDFromBytes(data1)
id1 := ownertest.IDFromBytes(data1)
require.True(t, id1.Equal(
ownertest.GenerateIDFromBytes(data2),
ownertest.IDFromBytes(data2),
))
require.False(t, id1.Equal(
ownertest.GenerateIDFromBytes(data3),
ownertest.IDFromBytes(data3),
))
}

View file

@ -8,21 +8,21 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/owner"
)
// GenerateID returns owner.ID calculated
// ID returns owner.ID calculated
// from a random owner.NEO3Wallet.
func GenerateID() *owner.ID {
func ID() *owner.ID {
u := make([]byte, owner.NEO3WalletSize)
u[0] = 0x35
rand.Read(u[1:21])
h1 := sha256.Sum256(u[:21])
h2 := sha256.Sum256(h1[:])
copy(u[21:], h2[:4])
return GenerateIDFromBytes(u)
return IDFromBytes(u)
}
// GenerateIDFromBytes returns owner.ID generated
// IDFromBytes returns owner.ID generated
// from a passed byte slice.
func GenerateIDFromBytes(val []byte) *owner.ID {
func IDFromBytes(val []byte) *owner.ID {
idV2 := new(refs.OwnerID)
idV2.SetValue(val)

View file

@ -17,7 +17,7 @@ func TestPeerID_ToV2(t *testing.T) {
})
t.Run("nil", func(t *testing.T) {
peerID := reputationtest.GeneratePeerID()
peerID := reputationtest.PeerID()
require.Equal(t, peerID, reputation.PeerIDFromV2(peerID.ToV2()))
})
@ -25,7 +25,7 @@ func TestPeerID_ToV2(t *testing.T) {
func TestPeerID_String(t *testing.T) {
t.Run("Parse/String", func(t *testing.T) {
id := reputationtest.GeneratePeerID()
id := reputationtest.PeerID()
strID := id.String()
@ -45,7 +45,7 @@ func TestPeerID_String(t *testing.T) {
}
func TestPeerIDEncoding(t *testing.T) {
id := reputationtest.GeneratePeerID()
id := reputationtest.PeerID()
t.Run("binary", func(t *testing.T) {
data, err := id.Marshal()

View file

@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
)
func GeneratePeerID() *reputation.PeerID {
func PeerID() *reputation.PeerID {
v := reputation.NewPeerID()
p, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
@ -26,32 +26,32 @@ func GeneratePeerID() *reputation.PeerID {
return v
}
func GenerateTrust() *reputation.Trust {
func Trust() *reputation.Trust {
v := reputation.NewTrust()
v.SetPeer(GeneratePeerID())
v.SetPeer(PeerID())
v.SetValue(1.5)
return v
}
func GeneratePeerToPeerTrust() *reputation.PeerToPeerTrust {
func PeerToPeerTrust() *reputation.PeerToPeerTrust {
v := reputation.NewPeerToPeerTrust()
v.SetTrustingPeer(GeneratePeerID())
v.SetTrust(GenerateTrust())
v.SetTrustingPeer(PeerID())
v.SetTrust(Trust())
return v
}
func GenerateGlobalTrust() *reputation.GlobalTrust {
func GlobalTrust() *reputation.GlobalTrust {
v := reputation.NewGlobalTrust()
v.SetManager(GeneratePeerID())
v.SetTrust(GenerateTrust())
v.SetManager(PeerID())
v.SetTrust(Trust())
return v
}
func GenerateSignedGlobalTrust(t testing.TB) *reputation.GlobalTrust {
gt := GenerateGlobalTrust()
func SignedGlobalTrust(t testing.TB) *reputation.GlobalTrust {
gt := GlobalTrust()
p, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
require.NoError(t, err)

View file

@ -14,7 +14,7 @@ import (
func TestTrust(t *testing.T) {
trust := reputation.NewTrust()
id := reputationtest.GeneratePeerID()
id := reputationtest.PeerID()
trust.SetPeer(id)
require.Equal(t, id, trust.Peer())
@ -23,7 +23,7 @@ func TestTrust(t *testing.T) {
require.Equal(t, val, trust.Value())
t.Run("binary encoding", func(t *testing.T) {
trust := reputationtest.GenerateTrust()
trust := reputationtest.Trust()
data, err := trust.Marshal()
require.NoError(t, err)
@ -33,7 +33,7 @@ func TestTrust(t *testing.T) {
})
t.Run("JSON encoding", func(t *testing.T) {
trust := reputationtest.GenerateTrust()
trust := reputationtest.Trust()
data, err := trust.MarshalJSON()
require.NoError(t, err)
@ -58,17 +58,17 @@ func TestPeerToPeerTrust(t *testing.T) {
require.Nil(t, p2pt.TrustingPeer())
require.Nil(t, p2pt.Trust())
trusting := reputationtest.GeneratePeerID()
trusting := reputationtest.PeerID()
p2pt.SetTrustingPeer(trusting)
require.Equal(t, trusting, p2pt.TrustingPeer())
trust := reputationtest.GenerateTrust()
trust := reputationtest.Trust()
p2pt.SetTrust(trust)
require.Equal(t, trust, p2pt.Trust())
})
t.Run("encoding", func(t *testing.T) {
p2pt := reputationtest.GeneratePeerToPeerTrust()
p2pt := reputationtest.PeerToPeerTrust()
t.Run("binary", func(t *testing.T) {
data, err := p2pt.Marshal()
@ -112,17 +112,17 @@ func TestGlobalTrust(t *testing.T) {
gt.SetVersion(version)
require.Equal(t, version, gt.Version())
mngr := reputationtest.GeneratePeerID()
mngr := reputationtest.PeerID()
gt.SetManager(mngr)
require.Equal(t, mngr, gt.Manager())
trust := reputationtest.GenerateTrust()
trust := reputationtest.Trust()
gt.SetTrust(trust)
require.Equal(t, trust, gt.Trust())
})
t.Run("sign+verify", func(t *testing.T) {
gt := reputationtest.GenerateSignedGlobalTrust(t)
gt := reputationtest.SignedGlobalTrust(t)
err := gt.VerifySignature()
require.NoError(t, err)
@ -130,7 +130,7 @@ func TestGlobalTrust(t *testing.T) {
t.Run("encoding", func(t *testing.T) {
t.Run("binary", func(t *testing.T) {
gt := reputationtest.GenerateSignedGlobalTrust(t)
gt := reputationtest.SignedGlobalTrust(t)
data, err := gt.Marshal()
require.NoError(t, err)
@ -141,7 +141,7 @@ func TestGlobalTrust(t *testing.T) {
})
t.Run("JSON", func(t *testing.T) {
gt := reputationtest.GenerateSignedGlobalTrust(t)
gt := reputationtest.SignedGlobalTrust(t)
data, err := gt.MarshalJSON()
require.NoError(t, err)

View file

@ -36,7 +36,7 @@ func TestContainerContextVerbs(t *testing.T) {
func TestContainerContext_ApplyTo(t *testing.T) {
c := session.NewContainerContext()
id := cidtest.GenerateID()
id := cidtest.ID()
t.Run("method", func(t *testing.T) {
c.ApplyTo(id)

View file

@ -22,7 +22,7 @@ func TestSessionToken_SetID(t *testing.T) {
func TestSessionToken_SetOwnerID(t *testing.T) {
token := session.NewToken()
ownerID := ownertest.GenerateID()
ownerID := ownertest.ID()
token.SetOwnerID(ownerID)
@ -39,7 +39,7 @@ func TestSessionToken_SetSessionKey(t *testing.T) {
}
func TestSessionTokenEncoding(t *testing.T) {
tok := sessiontest.Generate()
tok := sessiontest.Token()
t.Run("binary", func(t *testing.T) {
data, err := tok.Marshal()
@ -70,13 +70,13 @@ func TestToken_VerifySignature(t *testing.T) {
})
t.Run("unsigned", func(t *testing.T) {
tok := sessiontest.Generate()
tok := sessiontest.Token()
require.False(t, tok.VerifySignature())
})
t.Run("signed", func(t *testing.T) {
tok := sessiontest.GenerateSigned()
tok := sessiontest.SignedToken()
require.True(t, tok.VerifySignature())
})

View file

@ -20,7 +20,7 @@ func ContainerContext() *session.ContainerContext {
setters[rand.Uint32()%uint32(len(setters))]()
c.ApplyTo(cidtest.GenerateID())
c.ApplyTo(cidtest.ID())
return c
}

View file

@ -22,10 +22,10 @@ func init() {
}
}
// Generate returns random session.Token.
// Token returns random session.Token.
//
// Resulting token is unsigned.
func Generate() *session.Token {
func Token() *session.Token {
tok := session.NewToken()
uid, err := uuid.New().MarshalBinary()
@ -51,11 +51,11 @@ func Generate() *session.Token {
return tok
}
// GenerateSigned returns signed random session.Token.
// SignedToken returns signed random session.Token.
//
// Panics if token could not be signed (actually unexpected).
func GenerateSigned() *session.Token {
tok := Generate()
func SignedToken() *session.Token {
tok := Token()
err := tok.Sign(p)
if err != nil {

View file

@ -1,4 +1,4 @@
package test
package sigtest
import (
"github.com/nspcc-dev/neofs-sdk-go/signature"

View file

@ -33,7 +33,7 @@ func TestStorageGroup(t *testing.T) {
}
func TestStorageGroupEncoding(t *testing.T) {
sg := storagegrouptest.Generate()
sg := storagegrouptest.StorageGroup()
t.Run("binary", func(t *testing.T) {
data, err := sg.Marshal()

View file

@ -7,8 +7,8 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/storagegroup"
)
// Generate returns random storagegroup.StorageGroup.
func Generate() *storagegroup.StorageGroup {
// StorageGroup returns random storagegroup.StorageGroup.
func StorageGroup() *storagegroup.StorageGroup {
x := storagegroup.New()
x.SetExpirationEpoch(66)

View file

@ -70,7 +70,7 @@ func TestID_Equals(t *testing.T) {
}
func TestSubnetIDEncoding(t *testing.T) {
id := subnetidtest.GenerateID()
id := subnetidtest.ID()
t.Run("binary", func(t *testing.T) {
data, err := id.Marshal()

View file

@ -6,8 +6,8 @@ import (
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
)
// GenerateID generates and returns random subnetid.ID using math/rand.Uint32.
func GenerateID() *subnetid.ID {
// ID generates and returns random subnetid.ID using math/rand.Uint32.
func ID() *subnetid.ID {
var id subnetid.ID
id.SetNumber(rand.Uint32())

View file

@ -40,7 +40,7 @@ func TestInfo_SetOwner(t *testing.T) {
info Info
)
id = *ownertest.GenerateID()
id = *ownertest.ID()
require.False(t, IsOwner(info, id))

View file

@ -36,7 +36,7 @@ func TestBearerToken_Issuer(t *testing.T) {
}
func TestFilterEncoding(t *testing.T) {
f := tokentest.Generate()
f := tokentest.BearerToken()
t.Run("binary", func(t *testing.T) {
data, err := f.Marshal()

View file

@ -10,24 +10,24 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/token"
)
// Generate returns random token.BearerToken.
// BearerToken returns random token.BearerToken.
//
// Resulting token is unsigned.
func Generate() *token.BearerToken {
func BearerToken() *token.BearerToken {
x := token.NewBearerToken()
x.SetLifetime(3, 2, 1)
x.SetOwner(ownertest.GenerateID())
x.SetOwner(ownertest.ID())
x.SetEACLTable(eacltest.Table())
return x
}
// GenerateSigned returns signed random token.BearerToken.
// SignedBearerToken returns signed random token.BearerToken.
//
// Panics if token could not be signed (actually unexpected).
func GenerateSigned() *token.BearerToken {
tok := Generate()
func SignedBearerToken() *token.BearerToken {
tok := BearerToken()
p, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {

View file

@ -1,4 +1,4 @@
package test
package versiontest
import (
"math/rand"