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