2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-29 18:39:27 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package testidentity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-01-30 20:47:21 +00:00
|
|
|
"storj.io/storj/pkg/identity"
|
2018-11-29 18:39:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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{
|
2019-01-10 14:23:33 +00:00
|
|
|
Difficulty: 4,
|
|
|
|
Concurrency: 1,
|
2018-11-29 18:39:27 +00:00
|
|
|
})
|
|
|
|
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{
|
2019-01-10 14:23:33 +00:00
|
|
|
Difficulty: 4,
|
|
|
|
Concurrency: 1,
|
2018-11-29 18:39:27 +00:00
|
|
|
})
|
|
|
|
}
|