Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilkumarpilli committed Oct 4, 2024
1 parent 1cf1862 commit 9c261aa
Showing 1 changed file with 1 addition and 51 deletions.
52 changes: 1 addition & 51 deletions tests/systemtests/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestWithdrawAllRewardsCmd(t *testing.T) {
}

func TestDistrValidatorGRPCQueries(t *testing.T) {
// scenario: test distribution validator gsrpc gateway queries
// scenario: test distribution validator grpc gateway queries
// given a running chain

sut.ResetChain(t)
Expand Down Expand Up @@ -138,16 +138,9 @@ func TestDistrValidatorGRPCQueries(t *testing.T) {

// test validator distribution info grpc endpoint
validatorsURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s`
decodingFailedOutput := `{"code":2, "message":"decoding bech32 failed: invalid separator index -1", "details":[]}`
validatorsOutput := fmt.Sprintf(`{"operator_address":"%s","self_bond_rewards":[],"commission":[%s]}`, valAddr, expectedAmountOutput)

validatorsTestCases := []RestTestCase{
{
"invalid validator gRPC request with wrong validator address",
fmt.Sprintf(validatorsURL, "wrongaddress"),
http.StatusInternalServerError,
decodingFailedOutput,
},
{
"gRPC request validator with valid validator address",
fmt.Sprintf(validatorsURL, valOperAddr),
Expand All @@ -161,12 +154,6 @@ func TestDistrValidatorGRPCQueries(t *testing.T) {
outstandingRewardsURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s/outstanding_rewards`

rewardsTestCases := []RestTestCase{
{
"invalid outstanding rewards gRPC request with wrong validator address",
fmt.Sprintf(outstandingRewardsURL, "wrongaddress"),
http.StatusInternalServerError,
decodingFailedOutput,
},
{
"gRPC request outstanding rewards with valid validator address",
fmt.Sprintf(outstandingRewardsURL, valOperAddr),
Expand All @@ -180,12 +167,6 @@ func TestDistrValidatorGRPCQueries(t *testing.T) {
commissionURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s/commission`

commissionTestCases := []RestTestCase{
{
"invalid commission gRPC request with wrong validator address",
fmt.Sprintf(commissionURL, "wrongaddress"),
http.StatusInternalServerError,
decodingFailedOutput,
},
{
"gRPC request commission with valid validator address",
fmt.Sprintf(commissionURL, valOperAddr),
Expand All @@ -200,12 +181,6 @@ func TestDistrValidatorGRPCQueries(t *testing.T) {
invalidHeightOutput := `{"code":3, "message":"strconv.ParseUint: parsing \"-3\": invalid syntax", "details":[]}`

slashTestCases := []RestTestCase{
{
"invalid slashes gRPC request with wrong validator address",
fmt.Sprintf(slashURL, "wrongaddress"),
http.StatusBadRequest,
`{"code":3, "message":"invalid validator address", "details":[]}`,
},
{
"invalid start height",
fmt.Sprintf(slashURL+`?starting_height=%s&ending_height=%s`, valOperAddr, "-3", "3"),
Expand Down Expand Up @@ -278,32 +253,19 @@ func TestDistrDelegatorGRPCQueries(t *testing.T) {
sut.AwaitNBlocks(t, 5)

baseurl := sut.APIAddress()
decodingFailedOutput := `{"code":2, "message":"decoding bech32 failed: invalid separator index -1", "details":[]}`

// test delegator rewards grpc endpoint
delegatorRewardsURL := baseurl + `/cosmos/distribution/v1beta1/delegators/%s/rewards`
expectedAmountOutput := `{"denom":"stake","amount":"0.121275000000000000"}`
rewardsOutput := fmt.Sprintf(`{"rewards":[{"validator_address":"%s","reward":[%s]}],"total":[%s]}`, valOperAddr, expectedAmountOutput, expectedAmountOutput)

delegatorRewardsTestCases := []RestTestCase{
{
"wrong delegator address",
fmt.Sprintf(delegatorRewardsURL, "wrongdeladdress"),
http.StatusInternalServerError,
decodingFailedOutput,
},
{
"valid rewards request with valid delegator address",
fmt.Sprintf(delegatorRewardsURL, delAddr),
http.StatusOK,
rewardsOutput,
},
{
"wrong validator address (specific validator rewards)",
fmt.Sprintf(delegatorRewardsURL+`/%s`, delAddr, "wrongvaladdress"),
http.StatusInternalServerError,
decodingFailedOutput,
},
{
"valid request(specific validator rewards)",
fmt.Sprintf(delegatorRewardsURL+`/%s`, delAddr, valOperAddr),
Expand All @@ -316,12 +278,6 @@ func TestDistrDelegatorGRPCQueries(t *testing.T) {
// test delegator validators grpc endpoint
delegatorValsURL := baseurl + `/cosmos/distribution/v1beta1/delegators/%s/validators`
valsTestCases := []RestTestCase{
{
"invalid delegator validators gRPC request with wrong delegator address",
fmt.Sprintf(delegatorValsURL, "wrongaddress"),
http.StatusInternalServerError,
decodingFailedOutput,
},
{
"gRPC request delegator validators with valid delegator address",
fmt.Sprintf(delegatorValsURL, delAddr),
Expand All @@ -334,12 +290,6 @@ func TestDistrDelegatorGRPCQueries(t *testing.T) {
// test withdraw address grpc endpoint
withdrawAddrURL := baseurl + `/cosmos/distribution/v1beta1/delegators/%s/withdraw_address`
withdrawAddrTestCases := []RestTestCase{
{
"invalid withdraw address gRPC request with wrong delegator address",
fmt.Sprintf(withdrawAddrURL, "wrongaddress"),
http.StatusInternalServerError,
decodingFailedOutput,
},
{
"gRPC request withdraw address with valid delegator address",
fmt.Sprintf(withdrawAddrURL, delAddr),
Expand Down

0 comments on commit 9c261aa

Please sign in to comment.