Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe authored and conorpp committed Feb 1, 2023
1 parent c74b43d commit 5aa0843
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion x/wasm/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func ProposalUnpinCodesCmd() *cobra.Command {
return cmd
}

func parseAccessConfig(raw string) (types.AccessConfig, error) {
func parseAccessConfig(raw string) (c types.AccessConfig, err error) {
switch raw {
case "nobody":
return types.AllowNobody, nil
Expand All @@ -613,6 +613,11 @@ func parseAccessConfig(raw string) (types.AccessConfig, error) {
}
addrs[i] = addr
}
defer func() { // convert panic in ".With" to error for better output
if r := recover(); r != nil {
err = r.(error)
}
}()
cfg := types.AccessTypeAnyOfAddresses.With(addrs...)
return cfg, cfg.ValidateBasic()
}
Expand Down
12 changes: 12 additions & 0 deletions x/wasm/client/cli/gov_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ func TestParseAccessConfigUpdates(t *testing.T) {
},
},
},
"any of addresses - empty list": {
src: []string{"1:"},
expErr: true,
},
"any of addresses - invalid address": {
src: []string{"1:foo"},
expErr: true,
},
"any of addresses - duplicate address": {
src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"},
expErr: true,
},
}
for name, spec := range specs {
t.Run(name, func(t *testing.T) {
Expand Down

0 comments on commit 5aa0843

Please sign in to comment.