storj/internal/testidentity/identity.go

36 lines
839 B
Go
Raw Normal View History

2019-01-24 20:15:10 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package testidentity
import (
"context"
2019-01-30 20:47:21 +00:00
"storj.io/storj/pkg/identity"
)
// NewTestIdentity is a helper function to generate new node identities with
// correct difficulty and concurrency
2019-01-30 20:47:21 +00:00
func NewTestIdentity(ctx context.Context) (*identity.FullIdentity, error) {
ca, err := identity.NewCA(ctx, identity.NewCAOptions{
Difficulty: 4,
Concurrency: 1,
})
if err != nil {
return nil, err
}
identity, err := ca.NewIdentity()
if err != nil {
return nil, err
}
return identity, err
}
// NewTestCA returns a ca with a default difficulty and concurrency for use in tests
2019-01-30 20:47:21 +00:00
func NewTestCA(ctx context.Context) (*identity.FullCertificateAuthority, error) {
return identity.NewCA(ctx, identity.NewCAOptions{
Difficulty: 4,
Concurrency: 1,
})
}