-
Notifications
You must be signed in to change notification settings - Fork 725
/
Copy pathconfig_test.go
67 lines (61 loc) · 1.44 KB
/
config_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package subnets
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/consensus/snowball"
"github.com/ava-labs/avalanchego/utils/set"
)
var validParameters = snowball.Parameters{
K: 1,
Alpha: 1,
BetaVirtuous: 1,
BetaRogue: 1,
ConcurrentRepolls: 1,
OptimalProcessing: 1,
MaxOutstandingItems: 1,
MaxItemProcessingTime: 1,
}
func TestValid(t *testing.T) {
tests := []struct {
name string
s Config
expectedErr error
}{
{
name: "invalid consensus parameters",
s: Config{
ConsensusParameters: snowball.Parameters{
K: 2,
Alpha: 1,
},
},
expectedErr: snowball.ErrParametersInvalid,
},
{
name: "invalid allowed node IDs",
s: Config{
AllowedNodes: set.Set[ids.NodeID]{ids.GenerateTestNodeID(): struct{}{}},
ValidatorOnly: false,
ConsensusParameters: validParameters,
},
expectedErr: errAllowedNodesWhenNotValidatorOnly,
},
{
name: "valid",
s: Config{
ConsensusParameters: validParameters,
ValidatorOnly: false,
},
expectedErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.s.Valid()
require.ErrorIs(t, err, tt.expectedErr)
})
}
}