[#570] *: Use generator of test container IDs from API Go lib
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3dd10b6795
commit
3e1463cc76
26 changed files with 64 additions and 155 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
"strconv"
|
||||
"testing"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||
|
@ -28,13 +28,6 @@ func testSHA(t *testing.T) [sha256.Size]byte {
|
|||
return cs
|
||||
}
|
||||
|
||||
func testContainerID(t *testing.T) *cid.ID {
|
||||
id := cid.New()
|
||||
id.SetSHA256(testSHA(t))
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func testObjectID(t *testing.T) *object.ID {
|
||||
id := object.NewID()
|
||||
id.SetSHA256(testSHA(t))
|
||||
|
@ -50,7 +43,7 @@ func blankValidObject(t *testing.T, key *ecdsa.PrivateKey) *RawObject {
|
|||
ownerID.SetNeo3Wallet(wallet)
|
||||
|
||||
obj := NewRaw()
|
||||
obj.SetContainerID(testContainerID(t))
|
||||
obj.SetContainerID(cidtest.Generate())
|
||||
obj.SetOwnerID(ownerID)
|
||||
|
||||
return obj
|
||||
|
@ -94,7 +87,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
|
||||
t.Run("unsigned object", func(t *testing.T) {
|
||||
obj := NewRaw()
|
||||
obj.SetContainerID(testContainerID(t))
|
||||
obj.SetContainerID(cidtest.Generate())
|
||||
obj.SetID(testObjectID(t))
|
||||
|
||||
require.Error(t, v.Validate(obj.Object()))
|
||||
|
@ -105,7 +98,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
tok.SetSessionKey(crypto.MarshalPublicKey(&ownerKey.PublicKey))
|
||||
|
||||
obj := NewRaw()
|
||||
obj.SetContainerID(testContainerID(t))
|
||||
obj.SetContainerID(cidtest.Generate())
|
||||
obj.SetSessionToken(tok)
|
||||
|
||||
require.NoError(t, object.SetIDWithSignature(ownerKey, obj.SDK()))
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package audit_test
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"testing"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -77,16 +76,10 @@ func TestSelect(t *testing.T) {
|
|||
}
|
||||
|
||||
func generateContainers(n int) []*cid.ID {
|
||||
var buf [sha256.Size]byte
|
||||
result := make([]*cid.ID, 0, n)
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
_, _ = rand.Read(buf[:])
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(buf)
|
||||
|
||||
result = append(result, id)
|
||||
result = append(result, cidtest.Generate())
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
|
||||
|
@ -21,15 +21,12 @@ func testSHA256() (h [sha256.Size]byte) {
|
|||
}
|
||||
|
||||
func testAddress() *objectSDK.Address {
|
||||
id := cid.New()
|
||||
id.SetSHA256(testSHA256())
|
||||
|
||||
oid := objectSDK.NewID()
|
||||
oid.SetSHA256(testSHA256())
|
||||
|
||||
addr := objectSDK.NewAddress()
|
||||
addr.SetObjectID(oid)
|
||||
addr.SetContainerID(id)
|
||||
addr.SetContainerID(cidtest.Generate())
|
||||
|
||||
return addr
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
|
||||
|
@ -21,15 +21,12 @@ func testSHA256() (h [sha256.Size]byte) {
|
|||
}
|
||||
|
||||
func testAddress() *objectSDK.Address {
|
||||
id := cid.New()
|
||||
id.SetSHA256(testSHA256())
|
||||
|
||||
oid := objectSDK.NewID()
|
||||
oid.SetSHA256(testSHA256())
|
||||
|
||||
addr := objectSDK.NewAddress()
|
||||
addr.SetObjectID(oid)
|
||||
addr.SetContainerID(id)
|
||||
addr.SetContainerID(cidtest.Generate())
|
||||
|
||||
return addr
|
||||
}
|
||||
|
|
|
@ -8,21 +8,11 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func testCID() *cid.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(cs)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func testOID() *objectSDK.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
@ -36,7 +26,7 @@ func testOID() *objectSDK.ID {
|
|||
func testAddress() *objectSDK.Address {
|
||||
a := objectSDK.NewAddress()
|
||||
a.SetObjectID(testOID())
|
||||
a.SetContainerID(testCID())
|
||||
a.SetContainerID(cidtest.Generate())
|
||||
|
||||
return a
|
||||
}
|
||||
|
|
|
@ -61,16 +61,6 @@ func testNewShard(t *testing.T, id int) *shard.Shard {
|
|||
return s
|
||||
}
|
||||
|
||||
func testCID() *cid.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(cs)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func testOID() *objectSDK.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -12,7 +13,7 @@ import (
|
|||
func TestHeadRaw(t *testing.T) {
|
||||
defer os.RemoveAll(t.Name())
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -12,7 +13,7 @@ import (
|
|||
func TestStorageEngine_Inhume(t *testing.T) {
|
||||
defer os.RemoveAll(t.Name())
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
fs := objectSDK.SearchFilters{}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -84,7 +85,7 @@ func TestDB_ContainerSize(t *testing.T) {
|
|||
objs := make(map[*cid.ID][]*object.RawObject, C*N)
|
||||
|
||||
for i := 0; i < C; i++ {
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
cids[cid] = 0
|
||||
|
||||
for j := 0; j < N; j++ {
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
|
@ -32,16 +33,6 @@ func testSelect(t *testing.T, db *meta.DB, cid *cid.ID, fs objectSDK.SearchFilte
|
|||
}
|
||||
}
|
||||
|
||||
func testCID() *cid.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(cs)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func testOID() *objectSDK.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
@ -68,7 +59,7 @@ func releaseDB(db *meta.DB) {
|
|||
}
|
||||
|
||||
func generateRawObject(t *testing.T) *object.RawObject {
|
||||
return generateRawObjectWithCID(t, testCID())
|
||||
return generateRawObjectWithCID(t, cidtest.Generate())
|
||||
}
|
||||
|
||||
func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
|
||||
|
@ -102,7 +93,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
|
|||
|
||||
func generateAddress() *objectSDK.Address {
|
||||
addr := objectSDK.NewAddress()
|
||||
addr.SetContainerID(testCID())
|
||||
addr.SetContainerID(cidtest.Generate())
|
||||
addr.SetObjectID(testOID())
|
||||
|
||||
return addr
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -13,7 +14,7 @@ func TestDB_Delete(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
addAttribute(parent, "foo", "bar")
|
||||
|
||||
|
@ -70,7 +71,7 @@ func TestDeleteAllChildren(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
// generate parent object
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -55,7 +56,7 @@ func TestDB_Exists(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("virtual object", func(t *testing.T) {
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
|
||||
child := generateRawObjectWithCID(t, cid)
|
||||
|
@ -72,7 +73,7 @@ func TestDB_Exists(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("merge split info", func(t *testing.T) {
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
|
@ -59,7 +60,7 @@ func TestDB_Get(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("put virtual object", func(t *testing.T) {
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
|
@ -15,7 +16,7 @@ func TestDB_SelectUserAttributes(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
raw1 := generateRawObjectWithCID(t, cid)
|
||||
addAttribute(raw1, "foo", "bar")
|
||||
|
@ -88,7 +89,7 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
// prepare
|
||||
|
||||
|
@ -256,7 +257,7 @@ func TestDB_SelectInhume(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
raw1 := generateRawObjectWithCID(t, cid)
|
||||
err := putBig(db, raw1.Object())
|
||||
|
@ -289,7 +290,7 @@ func TestDB_SelectPayloadHash(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
raw1 := generateRawObjectWithCID(t, cid)
|
||||
err := putBig(db, raw1.Object())
|
||||
|
@ -325,7 +326,7 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
v20 := new(pkg.Version)
|
||||
v20.SetMajor(2)
|
||||
|
@ -424,7 +425,7 @@ func TestDB_SelectObjectID(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
// prepare
|
||||
|
||||
|
@ -533,7 +534,7 @@ func TestDB_SelectSplitID(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
child1 := generateRawObjectWithCID(t, cid)
|
||||
child2 := generateRawObjectWithCID(t, cid)
|
||||
|
@ -588,7 +589,7 @@ func TestDB_SelectContainerID(t *testing.T) {
|
|||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
||||
cid := testCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
obj1 := generateRawObjectWithCID(t, cid)
|
||||
err := putBig(db, obj1.Object())
|
||||
|
@ -622,7 +623,7 @@ func TestDB_SelectContainerID(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("not same cid", func(t *testing.T) {
|
||||
newCID := testCID()
|
||||
newCID := cidtest.Generate()
|
||||
|
||||
fs := objectSDK.SearchFilters{}
|
||||
fs.AddObjectContainerIDFilter(objectSDK.MatchStringEqual, newCID)
|
||||
|
|
|
@ -3,6 +3,7 @@ package shard_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -22,7 +23,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
|
|||
sh := newShard(t, hasWriteCache)
|
||||
defer releaseShard(sh, t)
|
||||
|
||||
cid := generateCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
obj := generateRawObjectWithCID(t, cid)
|
||||
addAttribute(obj, "foo", "bar")
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
|
@ -67,7 +68,7 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
|
|||
t.Run("parent object", func(t *testing.T) {
|
||||
obj := generateRawObject(t)
|
||||
addAttribute(obj, "foo", "bar")
|
||||
cid := generateCID()
|
||||
cid := cidtest.Generate()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
|
@ -45,7 +46,7 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
|
|||
})
|
||||
|
||||
t.Run("virtual object", func(t *testing.T) {
|
||||
cid := generateCID()
|
||||
cid := cidtest.Generate()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
parent := generateRawObjectWithCID(t, cid)
|
||||
|
|
|
@ -3,6 +3,7 @@ package shard_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -22,7 +23,7 @@ func testShardInhume(t *testing.T, hasWriteCache bool) {
|
|||
sh := newShard(t, hasWriteCache)
|
||||
defer releaseShard(sh, t)
|
||||
|
||||
cid := generateCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
obj := generateRawObjectWithCID(t, cid)
|
||||
addAttribute(obj, "foo", "bar")
|
||||
|
|
|
@ -3,6 +3,7 @@ package shard_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -33,7 +34,7 @@ func testShardList(t *testing.T, sh *shard.Shard) {
|
|||
putPrm := new(shard.PutPrm)
|
||||
|
||||
for i := 0; i < C; i++ {
|
||||
cid := generateCID()
|
||||
cid := cidtest.Generate()
|
||||
|
||||
for j := 0; j < N; j++ {
|
||||
obj := generateRawObjectWithCID(t, cid)
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
|
@ -61,7 +62,7 @@ func releaseShard(s *shard.Shard, t testing.TB) {
|
|||
}
|
||||
|
||||
func generateRawObject(t *testing.T) *object.RawObject {
|
||||
return generateRawObjectWithCID(t, generateCID())
|
||||
return generateRawObjectWithCID(t, cidtest.Generate())
|
||||
}
|
||||
|
||||
func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
|
||||
|
@ -110,16 +111,6 @@ func addPayload(obj *object.RawObject, size int) {
|
|||
obj.SetPayloadSize(uint64(size))
|
||||
}
|
||||
|
||||
func generateCID() *cid.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(cs)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func generateOID() *objectSDK.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
_, _ = rand.Read(cs[:])
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package audit_test
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
auditWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
||||
|
@ -36,8 +35,7 @@ func TestAuditResults(t *testing.T) {
|
|||
auditClientWrapper, err := auditWrapper.NewFromMorph(morphClient, auditHash, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256([sha256.Size]byte{1, 2, 3})
|
||||
id := cidtest.Generate()
|
||||
|
||||
auditRes := auditAPI.NewResult()
|
||||
auditRes.SetAuditEpoch(epoch)
|
||||
|
|
|
@ -2,13 +2,12 @@ package loadcontroller_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
loadcontroller "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/controller"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -74,20 +73,9 @@ func (s *testAnnouncementStorage) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func randCID() *cid.ID {
|
||||
h := [sha256.Size]byte{}
|
||||
|
||||
rand.Read(h[:])
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(h)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func randAnnouncement() container.UsedSpaceAnnouncement {
|
||||
a := container.NewAnnouncement()
|
||||
a.SetContainerID(randCID())
|
||||
a.SetContainerID(cidtest.Generate())
|
||||
a.SetUsedSpace(rand.Uint64())
|
||||
|
||||
return *a
|
||||
|
|
|
@ -1,31 +1,19 @@
|
|||
package loadstorage
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func randCID() *cid.ID {
|
||||
h := [sha256.Size]byte{}
|
||||
|
||||
rand.Read(h[:])
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(h)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func TestStorage(t *testing.T) {
|
||||
const epoch uint64 = 13
|
||||
|
||||
a := container.NewAnnouncement()
|
||||
a.SetContainerID(randCID())
|
||||
a.SetContainerID(cidtest.Generate())
|
||||
a.SetEpoch(epoch)
|
||||
|
||||
const opinionsNum = 100
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||
|
@ -57,22 +58,10 @@ func testID(t *testing.T) *objectSDK.ID {
|
|||
return id
|
||||
}
|
||||
|
||||
func testCID(t *testing.T) *cid.ID {
|
||||
cs := [sha256.Size]byte{}
|
||||
|
||||
_, err := rand.Read(cs[:])
|
||||
require.NoError(t, err)
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(cs)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func testAddress(t *testing.T) *objectSDK.Address {
|
||||
addr := objectSDK.NewAddress()
|
||||
addr.SetObjectID(testID(t))
|
||||
addr.SetContainerID(testCID(t))
|
||||
addr.SetContainerID(cidtest.Generate())
|
||||
|
||||
return addr
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
|
@ -192,10 +193,7 @@ func generateAddress() *objectSDK.Address {
|
|||
addr := objectSDK.NewAddress()
|
||||
addr.SetObjectID(generateID())
|
||||
|
||||
id := cid.New()
|
||||
id.SetSHA256(testSHA256())
|
||||
|
||||
addr.SetContainerID(id)
|
||||
addr.SetContainerID(cidtest.Generate())
|
||||
|
||||
return addr
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
|
@ -127,13 +128,6 @@ func testSHA256() (cs [sha256.Size]byte) {
|
|||
return cs
|
||||
}
|
||||
|
||||
func generateCID() *cid.ID {
|
||||
id := cid.New()
|
||||
id.SetSHA256(testSHA256())
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
func generateIDs(num int) []*objectSDK.ID {
|
||||
res := make([]*objectSDK.ID, num)
|
||||
|
||||
|
@ -169,7 +163,7 @@ func TestGetLocalOnly(t *testing.T) {
|
|||
storage := newTestStorage()
|
||||
svc := newSvc(storage)
|
||||
|
||||
cid := generateCID()
|
||||
cid := cidtest.Generate()
|
||||
ids := generateIDs(10)
|
||||
storage.addResult(cid, ids, nil)
|
||||
|
||||
|
@ -185,7 +179,7 @@ func TestGetLocalOnly(t *testing.T) {
|
|||
storage := newTestStorage()
|
||||
svc := newSvc(storage)
|
||||
|
||||
cid := generateCID()
|
||||
cid := cidtest.Generate()
|
||||
testErr := errors.New("any error")
|
||||
storage.addResult(cid, nil, testErr)
|
||||
|
||||
|
|
Loading…
Reference in a new issue