Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
add test validating that createIdentity follows algorithm preference
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott committed Apr 28, 2020
1 parent 4aef0db commit a7317cf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions init_test.go
@@ -0,0 +1,30 @@
package config

import (
"bytes"
"testing"

"github.com/ipfs/interface-go-ipfs-core/options"
crypto_pb "github.com/libp2p/go-libp2p-core/crypto/pb"
)

func TestCreateIdentity(t *testing.T) {
writer := bytes.NewBuffer(nil)
id, err := CreateIdentity(writer, []options.KeyGenerateOption{options.Key.Type(options.Ed25519Key)})
if err != nil {
t.Fatal(err)
}
pk, err := id.DecodePrivateKey("")
if pk.Type() != crypto_pb.KeyType_Ed25519 {
t.Fatal("unexpected type:", pk.Type())
}

id, err = CreateIdentity(writer, []options.KeyGenerateOption{options.Key.Type(options.RSAKey)})
if err != nil {
t.Fatal(err)
}
pk, err = id.DecodePrivateKey("")
if pk.Type() != crypto_pb.KeyType_RSA {
t.Fatal("unexpected type:", pk.Type())
}
}

0 comments on commit a7317cf

Please sign in to comment.