From 3d0df0d068b94e8ad4d433487e5b82ce63ac396d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 12 Nov 2021 14:19:16 +0300 Subject: [PATCH] [#54] tests: unify test generator names Signed-off-by: Evgenii Stratonikov --- accounting/decimal_test.go | 4 ++-- accounting/test/decimal.go | 4 ++-- audit/result_test.go | 4 ++-- audit/test/generate.go | 6 +++--- checksum/test/generate.go | 2 +- container/announcement_test.go | 2 +- container/container_test.go | 4 ++-- container/id/id_test.go | 12 ++++++------ container/id/test/id.go | 10 +++++----- container/test/generate.go | 4 ++-- eacl/record_test.go | 4 ++-- eacl/table_test.go | 6 +++--- eacl/test/generate.go | 6 +++--- netmap/test/generate.go | 2 +- object/address_test.go | 6 +++--- object/raw_test.go | 8 ++++---- object/test/generate.go | 10 +++++----- owner/id_test.go | 18 +++++++++--------- owner/test/id.go | 10 +++++----- reputation/peer_test.go | 6 +++--- reputation/test/generate.go | 22 +++++++++++----------- reputation/trust_test.go | 22 +++++++++++----------- session/container_test.go | 2 +- session/session_test.go | 8 ++++---- session/test/container.go | 2 +- session/test/token.go | 10 +++++----- signature/test/generate.go | 2 +- storagegroup/storagegroup_test.go | 2 +- storagegroup/test/generate.go | 4 ++-- subnet/id/id_test.go | 2 +- subnet/id/test/id.go | 4 ++-- subnet/subnet_test.go | 2 +- token/bearer_test.go | 2 +- token/test/generate.go | 12 ++++++------ version/test/generate.go | 2 +- 35 files changed, 113 insertions(+), 113 deletions(-) diff --git a/accounting/decimal_test.go b/accounting/decimal_test.go index e240d519..264c186d 100644 --- a/accounting/decimal_test.go +++ b/accounting/decimal_test.go @@ -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() diff --git a/accounting/test/decimal.go b/accounting/test/decimal.go index dd2e5d44..65978b9c 100644 --- a/accounting/test/decimal.go +++ b/accounting/test/decimal.go @@ -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()) diff --git a/audit/result_test.go b/audit/result_test.go index a5d13d58..28db3559 100644 --- a/audit/result_test.go +++ b/audit/result_test.go @@ -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() diff --git a/audit/test/generate.go b/audit/test/generate.go index ac14cfbc..212d07ac 100644 --- a/audit/test/generate.go +++ b/audit/test/generate.go @@ -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) diff --git a/checksum/test/generate.go b/checksum/test/generate.go index 0df988d0..1f8fa97b 100644 --- a/checksum/test/generate.go +++ b/checksum/test/generate.go @@ -1,4 +1,4 @@ -package test +package checksumtest import ( "crypto/sha256" diff --git a/container/announcement_test.go b/container/announcement_test.go index 00b62b4b..dcc40981 100644 --- a/container/announcement_test.go +++ b/container/announcement_test.go @@ -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) diff --git a/container/container_test.go b/container/container_test.go index 784a284a..2598cff6 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -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() diff --git a/container/id/id_test.go b/container/id/id_test.go index 972a2f8c..02d1d75f 100644 --- a/container/id/id_test.go +++ b/container/id/id_test.go @@ -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() diff --git a/container/id/test/id.go b/container/id/test/id.go index 94696b65..cf26feaf 100644 --- a/container/id/test/id.go +++ b/container/id/test/id.go @@ -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) diff --git a/container/test/generate.go b/container/test/generate.go index 4ad99100..cf2aed21 100644 --- a/container/test/generate.go +++ b/container/test/generate.go @@ -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) diff --git a/eacl/record_test.go b/eacl/record_test.go index 3a26c0d8..904d33b2 100644 --- a/eacl/record_test.go +++ b/eacl/record_test.go @@ -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) ) diff --git a/eacl/table_test.go b/eacl/table_test.go index 3412da1e..410eada2 100644 --- a/eacl/table_test.go +++ b/eacl/table_test.go @@ -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) diff --git a/eacl/test/generate.go b/eacl/test/generate.go index 8da310cd..e5e0c37c 100644 --- a/eacl/test/generate.go +++ b/eacl/test/generate.go @@ -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()) diff --git a/netmap/test/generate.go b/netmap/test/generate.go index 86edb25d..ae9759e2 100644 --- a/netmap/test/generate.go +++ b/netmap/test/generate.go @@ -1,4 +1,4 @@ -package test +package netmaptest import "github.com/nspcc-dev/neofs-sdk-go/netmap" diff --git a/object/address_test.go b/object/address_test.go index 5dd374d4..3df0bc9b 100644 --- a/object/address_test.go +++ b/object/address_test.go @@ -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() diff --git a/object/raw_test.go b/object/raw_test.go index 13cdd7e4..e03fa30b 100644 --- a/object/raw_test.go +++ b/object/raw_test.go @@ -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) diff --git a/object/test/generate.go b/object/test/generate.go index 23eef70d..5e09a06c 100644 --- a/object/test/generate.go +++ b/object/test/generate.go @@ -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 } diff --git a/owner/id_test.go b/owner/id_test.go index 6493d7aa..820fa2e0 100644 --- a/owner/id_test.go +++ b/owner/id_test.go @@ -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), )) } diff --git a/owner/test/id.go b/owner/test/id.go index 059c517c..3a62023c 100644 --- a/owner/test/id.go +++ b/owner/test/id.go @@ -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) diff --git a/reputation/peer_test.go b/reputation/peer_test.go index 7ef37635..3bed03d4 100644 --- a/reputation/peer_test.go +++ b/reputation/peer_test.go @@ -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() diff --git a/reputation/test/generate.go b/reputation/test/generate.go index 16204647..be216aa9 100644 --- a/reputation/test/generate.go +++ b/reputation/test/generate.go @@ -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) diff --git a/reputation/trust_test.go b/reputation/trust_test.go index e7e2b571..74616708 100644 --- a/reputation/trust_test.go +++ b/reputation/trust_test.go @@ -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) diff --git a/session/container_test.go b/session/container_test.go index 16fdb21c..bcd809fb 100644 --- a/session/container_test.go +++ b/session/container_test.go @@ -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) diff --git a/session/session_test.go b/session/session_test.go index 3d9490c5..af820cdb 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -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()) }) diff --git a/session/test/container.go b/session/test/container.go index 9c3f67fb..2a0e2024 100644 --- a/session/test/container.go +++ b/session/test/container.go @@ -20,7 +20,7 @@ func ContainerContext() *session.ContainerContext { setters[rand.Uint32()%uint32(len(setters))]() - c.ApplyTo(cidtest.GenerateID()) + c.ApplyTo(cidtest.ID()) return c } diff --git a/session/test/token.go b/session/test/token.go index 56a5f11a..84bf3e11 100644 --- a/session/test/token.go +++ b/session/test/token.go @@ -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 { diff --git a/signature/test/generate.go b/signature/test/generate.go index 90e56cb1..80edc589 100644 --- a/signature/test/generate.go +++ b/signature/test/generate.go @@ -1,4 +1,4 @@ -package test +package sigtest import ( "github.com/nspcc-dev/neofs-sdk-go/signature" diff --git a/storagegroup/storagegroup_test.go b/storagegroup/storagegroup_test.go index b49621c3..5121a979 100644 --- a/storagegroup/storagegroup_test.go +++ b/storagegroup/storagegroup_test.go @@ -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() diff --git a/storagegroup/test/generate.go b/storagegroup/test/generate.go index ad572d83..13f5e88b 100644 --- a/storagegroup/test/generate.go +++ b/storagegroup/test/generate.go @@ -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) diff --git a/subnet/id/id_test.go b/subnet/id/id_test.go index f15e7f84..ddd926bf 100644 --- a/subnet/id/id_test.go +++ b/subnet/id/id_test.go @@ -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() diff --git a/subnet/id/test/id.go b/subnet/id/test/id.go index 2d92f1cf..7a8ba466 100644 --- a/subnet/id/test/id.go +++ b/subnet/id/test/id.go @@ -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()) diff --git a/subnet/subnet_test.go b/subnet/subnet_test.go index 438bfb40..763319e9 100644 --- a/subnet/subnet_test.go +++ b/subnet/subnet_test.go @@ -40,7 +40,7 @@ func TestInfo_SetOwner(t *testing.T) { info Info ) - id = *ownertest.GenerateID() + id = *ownertest.ID() require.False(t, IsOwner(info, id)) diff --git a/token/bearer_test.go b/token/bearer_test.go index ce6bb707..13985b0b 100644 --- a/token/bearer_test.go +++ b/token/bearer_test.go @@ -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() diff --git a/token/test/generate.go b/token/test/generate.go index 65977737..4e5926c3 100644 --- a/token/test/generate.go +++ b/token/test/generate.go @@ -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 { diff --git a/version/test/generate.go b/version/test/generate.go index 1afecaa9..39b1b11f 100644 --- a/version/test/generate.go +++ b/version/test/generate.go @@ -1,4 +1,4 @@ -package test +package versiontest import ( "math/rand"