Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: fix error message #2372

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,11 +933,13 @@ func writeLockToAPI(ctx context.Context, publishAddr string, lock cluster.Lock)
// validateAddresses checks if we have sufficient addresses. It also fills addresses slices if only one is provided.
func validateAddresses(numVals int, feeRecipientAddrs []string, withdrawalAddrs []string) ([]string, []string, error) {
if len(feeRecipientAddrs) != numVals && len(feeRecipientAddrs) != 1 {
return nil, nil, errors.New("insufficient fee recipient addresses")
return nil, nil, errors.New("mismatching --num-validators and --fee-recipient-addresses",
z.Int("num_validators", numVals), z.Int("addresses", len(feeRecipientAddrs)))
}

if len(withdrawalAddrs) != numVals && len(withdrawalAddrs) != 1 {
return nil, nil, errors.New("insufficient withdrawal addresses")
return nil, nil, errors.New("mismatching --num-validators and --withdrawal-addresses",
z.Int("num_validators", numVals), z.Int("addresses", len(withdrawalAddrs)))
}

if len(feeRecipientAddrs) == 1 {
Expand Down
13 changes: 11 additions & 2 deletions cmd/createcluster_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,22 @@ func TestSplitKeys(t *testing.T) {
}

func TestMultipleAddresses(t *testing.T) {
t.Run("insufficient addresses in config", func(t *testing.T) {
t.Run("insufficient fee recipient addresses", func(t *testing.T) {
err := runCreateCluster(context.Background(), io.Discard, clusterConfig{
NumDVs: 4,
FeeRecipientAddrs: []string{},
WithdrawalAddrs: []string{},
})
require.ErrorContains(t, err, "insufficient fee recipient addresses")
require.ErrorContains(t, err, "mismatching --num-validators and --fee-recipient-addresses")
})

t.Run("insufficient withdrawal addresses", func(t *testing.T) {
err := runCreateCluster(context.Background(), io.Discard, clusterConfig{
NumDVs: 1,
FeeRecipientAddrs: []string{feeRecipientAddr},
WithdrawalAddrs: []string{},
})
require.ErrorContains(t, err, "mismatching --num-validators and --withdrawal-addresses")
})

t.Run("insufficient addresses from remote URL", func(t *testing.T) {
Expand Down