Skip to content

Commit

Permalink
feat: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
skynet2 committed Oct 1, 2024
1 parent c7939dd commit 1c71b21
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions wrapper/localsuite/creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"

"github.com/stretchr/testify/require"

mockkms "github.com/trustbloc/kms-go/mock/kms"
kmsapi "github.com/trustbloc/kms-go/spi/kms"
)
Expand Down Expand Up @@ -40,6 +41,23 @@ func TestKeyCreator(t *testing.T) {
require.IsType(t, ed25519.PublicKey{}, pubRaw)
})

t.Run("success export", func(t *testing.T) {
keyBytes, _, err := ed25519.GenerateKey(rand.Reader)
require.NoError(t, err)

keyID := "foo"

creator := newKeyCreator(&mockkms.KeyManager{
ExportPubKeyTypeValue: kmsapi.ED25519Type,
ExportPubKeyBytesValue: keyBytes,
})

pubJWK, keyType, err := creator.ExportPubKeyBytes(keyID)
require.NoError(t, err)
require.EqualValues(t, kmsapi.ED25519Type, keyType)
require.NotNil(t, pubJWK)
})

t.Run("kms create err", func(t *testing.T) {
errExpected := errors.New("expected error")

Expand Down

0 comments on commit 1c71b21

Please sign in to comment.