forked from TrueCloudLab/frostfs-node
[#1255] node/session: Add persistent tests
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
455b9fb325
commit
a884ad56d9
2 changed files with 252 additions and 0 deletions
26
pkg/services/session/storage/persistent/util_test.go
Normal file
26
pkg/services/session/storage/persistent/util_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
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()))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue