frostfs-node/pkg/services/control/common_test.go
Leonard Lyubich 1c30414a6c [] Upgrade NeoFS SDK Go module with new IDs
Core changes:
 * avoid package-colliding variable naming
 * avoid using pointers to IDs where unnecessary
 * avoid using `idSDK` import alias pattern
 * use `EncodeToString` for protocol string calculation and `String` for
  printing

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-06-01 17:41:45 +03:00

33 lines
592 B
Go

package control_test
import (
"crypto/rand"
"testing"
"github.com/mr-tron/base58"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)
type protoMessage interface {
StableMarshal([]byte) []byte
proto.Message
}
func testStableMarshal(t *testing.T, m1, m2 protoMessage, cmp func(m1, m2 protoMessage) bool) {
require.NoError(t, proto.Unmarshal(m1.StableMarshal(nil), m2))
require.True(t, cmp(m1, m2))
}
func testData(sz int) []byte {
d := make([]byte, sz)
_, _ = rand.Read(d)
return d
}
func testString() string {
return base58.Encode(testData(10))
}