diff --git a/x/avs/types/genesis.go b/x/avs/types/genesis.go index bbf393c27..970ac9e4c 100644 --- a/x/avs/types/genesis.go +++ b/x/avs/types/genesis.go @@ -84,10 +84,12 @@ func (gs GenesisState) Validate() error { if !common.IsHexAddress(info.TaskContractAddress) { return fmt.Errorf("invalid hex address: %s", info.TaskContractAddress) } - if taskInfoMap[info.TaskContractAddress] { + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(info.TaskContractAddress), strconv.FormatUint(info.TaskId, 10)) + + if taskInfoMap[string(infoKey)] { return fmt.Errorf("duplicate task address: %s", info.TaskContractAddress) } - taskInfoMap[info.TaskContractAddress] = true + taskInfoMap[string(infoKey)] = true } // Check for duplicated taskID diff --git a/x/feedistribution/types/genesis_test.go b/x/feedistribution/types/genesis_test.go index ebbdadcfa..a6df7b3c4 100644 --- a/x/feedistribution/types/genesis_test.go +++ b/x/feedistribution/types/genesis_test.go @@ -19,14 +19,36 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField + Params: types.Params{ + EpochIdentifier: "day", + }, }, valid: true, }, - // this line is used by starport scaffolding # types/genesis/testcase + { + desc: "invalid genesis state", + genState: &types.GenesisState{ + Params: types.Params{ + EpochIdentifier: "", + }, + }, + valid: false, + }, + { + desc: "Illegal val address", // Fixed the description to match the valid state + genState: &types.GenesisState{ + Params: types.Params{ + EpochIdentifier: "day", + }, + ValidatorAccumulatedCommissions: []types.ValidatorAccumulatedCommissions{ + {ValAddr: "validator1", Commission: &types.ValidatorAccumulatedCommission{}}, + {ValAddr: "validator2", Commission: &types.ValidatorAccumulatedCommission{}}, + }, + }, + valid: false, + }, } for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) {