forked from TrueCloudLab/frostfs-api-go
sdk: Define container identifier type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7f4544ede0
commit
8df69c4042
2 changed files with 78 additions and 0 deletions
27
pkg/container/id_test.go
Normal file
27
pkg/container/id_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIDV2_0(t *testing.T) {
|
||||
cid := new(ID)
|
||||
|
||||
checksum := [sha256.Size]byte{}
|
||||
|
||||
_, err := rand.Read(checksum[:])
|
||||
require.NoError(t, err)
|
||||
|
||||
cid.SetSHA256(checksum)
|
||||
|
||||
cidV2 := cid.ToV2()
|
||||
|
||||
cid2, err := IDFromV2(cidV2)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, cid, cid2)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue