Skip to content

Commit

Permalink
fix test err
Browse files Browse the repository at this point in the history
  • Loading branch information
trestinlsd committed Nov 6, 2024
1 parent 9cb9684 commit 3a670c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
6 changes: 4 additions & 2 deletions x/avs/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 26 additions & 4 deletions x/feedistribution/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3a670c9

Please sign in to comment.