Skip to content

Commit

Permalink
Add power shaping params to query test
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed May 7, 2024
1 parent 8cebfa8 commit 07067b9
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion x/ccv/provider/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,57 @@ func TestGetAllConsumerChains(t *testing.T) {
50, // everyone is in the top 100%
}

validatorSetCaps := []uint32{0, 5, 10, 20}
validatorPowerCaps := []uint32{0, 5, 10, 33}
allowlists := [][]types.ProviderConsAddress{
{},
{types.NewProviderConsAddress([]byte("providerAddr1")), types.NewProviderConsAddress([]byte("providerAddr2"))},
{types.NewProviderConsAddress([]byte("providerAddr3"))},
{},
}

denylists := [][]types.ProviderConsAddress{
{types.NewProviderConsAddress([]byte("providerAddr4")), types.NewProviderConsAddress([]byte("providerAddr5"))},
{},
{types.NewProviderConsAddress([]byte("providerAddr6"))},
{},
}

expectedGetAllOrder := []types.Chain{}
for i, chainID := range chainIDs {
clientID := fmt.Sprintf("client-%d", len(chainIDs)-i)
topN := topNs[i]
pk.SetConsumerClientId(ctx, chainID, clientID)
pk.SetTopN(ctx, chainID, topN)
expectedGetAllOrder = append(expectedGetAllOrder, types.Chain{ChainId: chainID, ClientId: clientID, Top_N: topN, MinPowerInTop_N: expectedMinPowerInTopNs[i]})
pk.SetValidatorSetCap(ctx, chainID, validatorSetCaps[i])
pk.SetValidatorsPowerCap(ctx, chainID, validatorPowerCaps[i])
for _, addr := range allowlists[i] {
pk.SetAllowlist(ctx, chainID, addr)
}
for _, addr := range denylists[i] {
pk.SetDenylist(ctx, chainID, addr)
}
strAllowlist := make([]string, len(allowlists[i]))
for j, addr := range allowlists[i] {
strAllowlist[j] = addr.String()
}

strDenylist := make([]string, len(denylists[i]))
for j, addr := range denylists[i] {
strDenylist[j] = addr.String()
}

expectedGetAllOrder = append(expectedGetAllOrder,
types.Chain{
ChainId: chainID,
ClientId: clientID,
Top_N: topN,
MinPowerInTop_N: expectedMinPowerInTopNs[i],
ValidatorSetCap: validatorSetCaps[i],
ValidatorsPowerCap: validatorPowerCaps[i],
Allowlist: strAllowlist,
Denylist: strDenylist,
})
}
// sorting by chainID
sort.Slice(expectedGetAllOrder, func(i, j int) bool {
Expand Down

0 comments on commit 07067b9

Please sign in to comment.