[#295] pkg: Remove usage of deprecated elements

Remove usage of deprecated of `container.ID` and `token.SessionToken` code
elements. Replace using of custom message generators with the ones provided
by packages. Replace string comparison with `Equal` method call.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-31 15:09:04 +03:00 committed by Leonard Lyubich
parent 89be8d3f5a
commit 65080c8b69
22 changed files with 97 additions and 209 deletions

View file

@ -6,9 +6,9 @@ import (
"testing"
"github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-api-go/pkg/token"
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test"
sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test"
"github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/stretchr/testify/require"
)
@ -20,13 +20,6 @@ func randID(t *testing.T) *ID {
return id
}
func randCID(t *testing.T) *container.ID {
id := container.NewID()
id.SetSHA256(randSHA256Checksum(t))
return id
}
func randSHA256Checksum(t *testing.T) (cs [sha256.Size]byte) {
_, err := rand.Read(cs[:])
require.NoError(t, err)
@ -98,10 +91,7 @@ func TestRawObject_SetPayloadSize(t *testing.T) {
func TestRawObject_SetContainerID(t *testing.T) {
obj := NewRaw()
checksum := randSHA256Checksum(t)
cid := container.NewID()
cid.SetSHA256(checksum)
cid := cidtest.Generate()
obj.SetContainerID(cid)
@ -111,11 +101,7 @@ func TestRawObject_SetContainerID(t *testing.T) {
func TestRawObject_SetOwnerID(t *testing.T) {
obj := NewRaw()
w := new(owner.NEO3Wallet)
_, _ = rand.Read(w.Bytes())
ownerID := owner.NewID()
ownerID.SetNeo3Wallet(w)
ownerID := ownertest.Generate()
obj.SetOwnerID(ownerID)
@ -208,7 +194,7 @@ func TestRawObject_SetParent(t *testing.T) {
par := NewRaw()
par.SetID(randID(t))
par.SetContainerID(container.NewID())
par.SetContainerID(cidtest.Generate())
par.SetSignature(pkg.NewSignature())
parObj := par.Object()
@ -230,8 +216,7 @@ func TestRawObject_ToV2(t *testing.T) {
func TestRawObject_SetSessionToken(t *testing.T) {
obj := NewRaw()
tok := token.NewSessionToken()
tok.SetID([]byte{1, 2, 3})
tok := sessiontest.Generate()
obj.SetSessionToken(tok)