frostfs-node/pkg/services/session/storage/persistent/util_test.go
Pavel Karpy a884ad56d9 [#1255] node/session: Add persistent tests
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-03-29 09:35:10 +03:00

26 lines
538 B
Go

package persistent
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/stretchr/testify/require"
)
func TestPack(t *testing.T) {
key, err := keys.NewPrivateKey()
require.NoError(t, err)
const exp = 12345
raw, err := packToken(exp, &key.PrivateKey)
require.NoError(t, err)
require.Equal(t, uint64(exp), epochFromToken(raw))
unpacked, err := unpackToken(raw)
require.NoError(t, err)
require.Equal(t, uint64(exp), unpacked.ExpiredAt())
require.Equal(t, true, key.Equal(unpacked.SessionKey()))
}