forked from TrueCloudLab/frostfs-api-go
initial
This commit is contained in:
commit
1cf33e5ffd
87 changed files with 29835 additions and 0 deletions
57
container/types_test.go
Normal file
57
container/types_test.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/nspcc-dev/neofs-crypto/test"
|
||||
"github.com/nspcc-dev/neofs-proto/refs"
|
||||
"github.com/nspcc-dev/netmap"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCID(t *testing.T) {
|
||||
t.Run("check that marshal/unmarshal works like expected", func(t *testing.T) {
|
||||
var (
|
||||
c2 Container
|
||||
cid2 CID
|
||||
key = test.DecodeKey(0)
|
||||
)
|
||||
|
||||
rules := netmap.PlacementRule{
|
||||
ReplFactor: 2,
|
||||
SFGroups: []netmap.SFGroup{
|
||||
{
|
||||
Selectors: []netmap.Select{
|
||||
{Key: "Country", Count: 1},
|
||||
{Key: netmap.NodesBucket, Count: 2},
|
||||
},
|
||||
Filters: []netmap.Filter{
|
||||
{Key: "Country", F: netmap.FilterIn("USA")},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
owner, err := refs.NewOwnerID(&key.PublicKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
c1, err := New(10, owner, rules)
|
||||
require.NoError(t, err)
|
||||
|
||||
data, err := proto.Marshal(c1)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, c2.Unmarshal(data))
|
||||
require.Equal(t, c1, &c2)
|
||||
|
||||
cid1, err := c1.ID()
|
||||
require.NoError(t, err)
|
||||
|
||||
data, err = proto.Marshal(&cid1)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, cid2.Unmarshal(data))
|
||||
|
||||
require.Equal(t, cid1, cid2)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue