2020-11-03 09:03:41 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"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/netmap"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/util/test"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCheckFormat(t *testing.T) {
|
|
|
|
c := container.New()
|
|
|
|
|
|
|
|
require.Error(t, CheckFormat(c))
|
|
|
|
|
2020-11-16 09:43:52 +00:00
|
|
|
policy := netmap.NewPlacementPolicy()
|
|
|
|
c.SetPlacementPolicy(policy)
|
2020-11-03 09:03:41 +00:00
|
|
|
|
|
|
|
require.Error(t, CheckFormat(c))
|
|
|
|
|
2020-11-16 09:43:52 +00:00
|
|
|
c.SetVersion(pkg.SDKVersion())
|
2020-11-03 09:03:41 +00:00
|
|
|
|
|
|
|
require.Error(t, CheckFormat(c))
|
|
|
|
|
|
|
|
wallet, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2020-11-16 09:43:52 +00:00
|
|
|
c.SetOwnerID(owner.NewIDFromNeo3Wallet(wallet))
|
2020-11-03 09:03:41 +00:00
|
|
|
|
2020-12-24 10:20:20 +00:00
|
|
|
// set incorrect nonce
|
|
|
|
cV2 := c.ToV2()
|
|
|
|
cV2.SetNonce([]byte{1, 2, 3})
|
|
|
|
c = container.NewContainerFromV2(cV2)
|
2020-11-03 09:03:41 +00:00
|
|
|
|
|
|
|
require.Error(t, CheckFormat(c))
|
|
|
|
|
2020-12-24 10:20:20 +00:00
|
|
|
c.SetNonceUUID(uuid.New())
|
2020-11-03 09:03:41 +00:00
|
|
|
|
|
|
|
require.NoError(t, CheckFormat(c))
|
|
|
|
}
|