Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
corverroos committed May 27, 2022
1 parent a9c4566 commit 0071ec2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
29 changes: 25 additions & 4 deletions testutil/compose/compose/smoke_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,41 @@ func TestSmoke(t *testing.T) {
TmplFunc func(compose.TmplData)
}{
{
Name: "create flow alpha",
Name: "default alpha",
ConfigFunc: func(conf *compose.Config) {
conf.KeyGen = compose.KeyGenCreate
conf.FeatureSet = "alpha"
},
},
{
Name: "create flow beta",
Name: "default beta",
ConfigFunc: func(conf *compose.Config) {
conf.KeyGen = compose.KeyGenCreate
conf.FeatureSet = "beta"
},
},
{
Name: "create flow stable",
Name: "default stable",
ConfigFunc: func(conf *compose.Config) {
conf.KeyGen = compose.KeyGenCreate
conf.FeatureSet = "stable"
},
},
{
Name: "dkg flow",
Name: "dkg",
ConfigFunc: func(conf *compose.Config) {
conf.KeyGen = compose.KeyGenDKG
},
},
{
Name: "very large dkg",
ConfigFunc: func(conf *compose.Config) {
conf.NumNodes = 21
conf.Threshold = 14
conf.NumValidators = 1000
conf.KeyGen = compose.KeyGenDKG
},
},
{
Name: "version matrix",
TmplFunc: func(data compose.TmplData) {
Expand All @@ -75,6 +84,18 @@ func TestSmoke(t *testing.T) {
data.Nodes[3].ImageTag = "v0.5.0"
},
},
{
Name: "teku versions", // TODO(corver): Do the same for lighthouse.
ConfigFunc: func(conf *compose.Config) {
conf.VCs = []compose.VCType{compose.VCTeku}
},
TmplFunc: func(data compose.TmplData) {
data.VCs[0].Image = "consensys/teku:latest"
data.VCs[1].Image = "consensys/teku:22.5"
data.VCs[2].Image = "consensys/teku:22.4"
data.VCs[3].Image = "consensys/teku:22.3"
},
},
}

for _, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion testutil/compose/compose_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ func TestParseTemplate(t *testing.T) {
_, err := template.New("").Parse(string(tmpl))
require.NoError(t, err)

_, err = getVC(vcTeku, 0, 1)
_, err = getVC(VCTeku, 0, 1)
require.NoError(t, err)
}
14 changes: 7 additions & 7 deletions testutil/compose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ const (
cmdCreateDKG = "[create,dkg]"
)

// vcType defines a validator client type.
type vcType string
// VCType defines a validator client type.
type VCType string

const (
vcMock vcType = "mock"
vcTeku vcType = "teku"
vcLighthouse vcType = "lighthouse"
VCMock VCType = "mock"
VCTeku VCType = "teku"
VCLighthouse VCType = "lighthouse"
)

// KeyGen defines a key generation process.
Expand Down Expand Up @@ -94,7 +94,7 @@ type Config struct {
BeaconNode string `json:"beacon_node"`

// VCs define the types of validator clients to use.
VCs []vcType `json:"validator_clients"`
VCs []VCType `json:"validator_clients"`

// FeatureSet defines the minimum feature set to enable.
FeatureSet string `json:"feature_set"`
Expand All @@ -117,7 +117,7 @@ func NewDefaultConfig() Config {
Threshold: defaultThreshold,
NumValidators: defaultNumVals,
ImageTag: defaultImageTag,
VCs: []vcType{vcTeku, vcLighthouse, vcMock},
VCs: []VCType{VCTeku, VCLighthouse, VCMock},
KeyGen: defaultKeyGen,
BeaconNode: defaultBeaconNode,
Step: stepNew,
Expand Down
14 changes: 7 additions & 7 deletions testutil/compose/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func Run(ctx context.Context, dir string, conf Config) (TmplData, error) {
}

// getVC returns the validator client template data for the provided type and index.
func getVC(typ vcType, nodeIdx int, numVals int) (vc, error) {
vcByType := map[vcType]vc{
vcLighthouse: {
Label: string(vcLighthouse),
func getVC(typ VCType, nodeIdx int, numVals int) (vc, error) {
vcByType := map[VCType]vc{
VCLighthouse: {
Label: string(VCLighthouse),
Build: "lighthouse",
},
vcTeku: {
Label: string(vcTeku),
VCTeku: {
Label: string(VCTeku),
Image: "consensys/teku:latest",
Command: `|
validator-client
Expand All @@ -90,7 +90,7 @@ func getVC(typ vcType, nodeIdx int, numVals int) (vc, error) {
}

resp := vcByType[typ]
if typ == vcTeku {
if typ == VCTeku {
var keys []string
for i := 0; i < numVals; i++ {
keys = append(keys, fmt.Sprintf("/compose/node%d/keystore-%d.json:/compose/node%d/keystore-%d.txt", nodeIdx, i, nodeIdx, i))
Expand Down

0 comments on commit 0071ec2

Please sign in to comment.