frostfs-node/pkg/util/salt_test.go
Pavel Karpy 923f84722a Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
2022-12-28 15:04:29 +03:00

34 lines
526 B
Go

package util_test
import (
"bytes"
"crypto/rand"
"testing"
"github.com/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),
)
}