frostfs-node/pkg/util/salt_test.go
Alex Vanin 20de74a505 Rename package name
Due to source code relocation from GitHub.

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2023-03-07 16:38:26 +03:00

34 lines
532 B
Go

package util_test
import (
"bytes"
"crypto/rand"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
"github.com/stretchr/testify/require"
)
func randData(sz int) []byte {
data := make([]byte, sz)
_, _ = rand.Read(data)
return data
}
func TestSaltWriter_Write(t *testing.T) {
salt := randData(4)
data := randData(15)
buf := bytes.NewBuffer(nil)
w := util.NewSaltingWriter(buf, salt)
_, err := w.Write(data)
require.NoError(t, err)
require.Equal(t,
buf.Bytes(),
util.SaltXOR(data, salt),
)
}