0f5a2f4ef5
* enable more linters * Run gofmt -s * run goimports * run unconvert * fix naked return * fix misspellings * fix ineffectual assigments * fix missing declaration * don't use deprecated grpc.Errof * check errors in tests * run gofmt -w -r "assert.Nil(err) -> assert.NoError(err)" * fix directory permissions * don't use nil Context * simplify boolean expressions * use bytes.Equal instead of bytes.Compare * merge variable declarations, remove redundant returns * fix some golint errors * run goimports * handle more errors * delete empty TestMain * delete empty TestMain * ignore examples for now * fix lint errors * remove unused values * more fixes * run gofmt -w -s . * add more comments * fix naming * more lint fixes * try switching travis to go1.11 * fix unnecessary conversions * fix deprecated methods * use go1.10 and disable gofmt/goimports for now * switch to 1.10 * don't re-enable gofmt and goimports * switch covermode to atomic because of -race * gofmt
52 lines
1.2 KiB
Go
52 lines
1.2 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) {
|
|
context.Background()
|
|
for i := 0; i < b.N; i++ {
|
|
expectedDifficulty := uint16(8)
|
|
NewCA(context.Background(), expectedDifficulty, 1)
|
|
}
|
|
}
|
|
|
|
func BenchmarkNewCA_Difficulty8_Concurrency2(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
expectedDifficulty := uint16(8)
|
|
NewCA(context.Background(), expectedDifficulty, 2)
|
|
}
|
|
}
|
|
|
|
func BenchmarkNewCA_Difficulty8_Concurrency5(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
expectedDifficulty := uint16(8)
|
|
NewCA(context.Background(), expectedDifficulty, 5)
|
|
}
|
|
}
|
|
|
|
func BenchmarkNewCA_Difficulty8_Concurrency10(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
expectedDifficulty := uint16(8)
|
|
NewCA(context.Background(), expectedDifficulty, 10)
|
|
}
|
|
}
|