storj/pkg/provider/cert_authority_test.go
Bryan White 0e2fd97029
Identity fixes+: (#270)
* identity fixes+:

+ fix `peertls.NewCert` public key issue
+ fix `peertls.verfiyChain` issue
+ fix identity dial option
+ rename `GenerateCA` to `NewCA` and `generateCAWorker` to `newCAWorker` for better consistency/convention
2018-08-23 16:08:26 +02:00

51 lines
1.1 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package provider
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewCA(t *testing.T) {
expectedDifficulty := uint16(4)
ca, err := NewCA(context.Background(), expectedDifficulty, 5)
assert.NoError(t, err)
assert.NotEmpty(t, ca)
actualDifficulty := ca.ID.Difficulty()
assert.True(t, actualDifficulty >= expectedDifficulty)
}
func BenchmarkNewCA_Difficulty8_Concurrency1(b *testing.B) {
for i := 0; i < b.N; i++ {
expectedDifficulty := uint16(8)
NewCA(nil, expectedDifficulty, 1)
}
}
func BenchmarkNewCA_Difficulty8_Concurrency2(b *testing.B) {
for i := 0; i < b.N; i++ {
expectedDifficulty := uint16(8)
NewCA(nil, expectedDifficulty, 2)
}
}
func BenchmarkNewCA_Difficulty8_Concurrency5(b *testing.B) {
for i := 0; i < b.N; i++ {
expectedDifficulty := uint16(8)
NewCA(nil, expectedDifficulty, 5)
}
}
func BenchmarkNewCA_Difficulty8_Concurrency10(b *testing.B) {
for i := 0; i < b.N; i++ {
expectedDifficulty := uint16(8)
NewCA(nil, expectedDifficulty, 10)
}
}