Skip to content

Commit

Permalink
fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Sep 27, 2022
1 parent afa2820 commit 464c46f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
3 changes: 1 addition & 2 deletions tests/e2e/bank/client/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/rest"
sdk "github.com/cosmos/cosmos-sdk/types"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/types/query"
Expand Down Expand Up @@ -277,7 +276,7 @@ func (s *EndToEndTestSuite) TestBalancesGRPCHandler() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType))
Expand Down
16 changes: 8 additions & 8 deletions tests/e2e/nft/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package nft
import (
"fmt"

"github.com/cosmos/cosmos-sdk/testutil/rest"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/x/nft"
)

Expand Down Expand Up @@ -61,7 +61,7 @@ func (s *IntegrationTestSuite) TestQueryBalanceGRPC() {
for _, tc := range testCases {
uri := fmt.Sprintf(balanceURL, tc.args.Owner, tc.args.ClassID)
s.Run(tc.name, func() {
resp, _ := rest.GetRequest(uri)
resp, _ := testutil.GetRequest(uri)
if tc.expectErr {
s.Require().Contains(string(resp), tc.errMsg)
} else {
Expand Down Expand Up @@ -153,7 +153,7 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() {
for _, tc := range testCases {
uri := fmt.Sprintf(ownerURL, tc.args.ClassID, tc.args.ID)
s.Run(tc.name, func() {
resp, err := rest.GetRequest(uri)
resp, err := testutil.GetRequest(uri)
if tc.expectErr {
s.Require().Contains(string(resp), tc.errMsg)
} else {
Expand Down Expand Up @@ -215,7 +215,7 @@ func (s *IntegrationTestSuite) TestQuerySupplyGRPC() {
for _, tc := range testCases {
uri := fmt.Sprintf(supplyURL, tc.args.ClassID)
s.Run(tc.name, func() {
resp, err := rest.GetRequest(uri)
resp, err := testutil.GetRequest(uri)
if tc.expectErr {
s.Require().Contains(string(resp), tc.errMsg)
} else {
Expand Down Expand Up @@ -312,7 +312,7 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() {
for _, tc := range testCases {
uri := fmt.Sprintf(nftsOfClassURL, tc.args.ClassID, tc.args.Owner)
s.Run(tc.name, func() {
resp, err := rest.GetRequest(uri)
resp, err := testutil.GetRequest(uri)
if tc.expectErr {
s.Require().Contains(string(resp), tc.errorMsg)
} else {
Expand Down Expand Up @@ -401,7 +401,7 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() {
for _, tc := range testCases {
uri := fmt.Sprintf(nftURL, tc.args.ClassID, tc.args.ID)
s.Run(tc.name, func() {
resp, err := rest.GetRequest(uri)
resp, err := testutil.GetRequest(uri)
if tc.expectErr {
s.Require().Contains(string(resp), tc.errorMsg)
} else {
Expand Down Expand Up @@ -449,7 +449,7 @@ func (s *IntegrationTestSuite) TestQueryClassGRPC() {
for _, tc := range testCases {
uri := fmt.Sprintf(classURL, tc.args.ClassID)
s.Run(tc.name, func() {
resp, err := rest.GetRequest(uri)
resp, err := testutil.GetRequest(uri)
if tc.expectErr {
s.Require().Contains(string(resp), tc.errorMsg)
} else {
Expand All @@ -466,7 +466,7 @@ func (s *IntegrationTestSuite) TestQueryClassGRPC() {
func (s *IntegrationTestSuite) TestQueryClassesGRPC() {
val := s.network.Validators[0]
classURL := val.APIAddress + "/cosmos/nft/v1beta1/classes"
resp, err := rest.GetRequest(classURL)
resp, err := testutil.GetRequest(classURL)
s.Require().NoError(err)
var result nft.QueryClassesResponse
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &result)
Expand Down
23 changes: 11 additions & 12 deletions tests/e2e/staking/client/testutil/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/rest"
sdk "github.com/cosmos/cosmos-sdk/types"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/types/query"
Expand Down Expand Up @@ -46,7 +45,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryValidatorsHandler() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var valRes types.QueryValidatorsResponse
Expand Down Expand Up @@ -94,7 +93,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryValidator() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var validator types.QueryValidatorResponse
Expand Down Expand Up @@ -203,7 +202,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryValidatorUnbondingDelegations() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var ubds types.QueryValidatorUnbondingDelegationsResponse
Expand Down Expand Up @@ -282,7 +281,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegation() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)
s.T().Logf("%s", resp)
err = val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType)
Expand Down Expand Up @@ -336,7 +335,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryUnbondingDelegation() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var ubd types.QueryUnbondingDelegationResponse
Expand Down Expand Up @@ -470,7 +469,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegatorUnbondingDelegations() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var ubds types.QueryDelegatorUnbondingDelegationsResponse
Expand Down Expand Up @@ -532,7 +531,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRedelegations() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)
var redelegations types.QueryRedelegationsResponse

Expand Down Expand Up @@ -581,7 +580,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegatorValidators() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var validators types.QueryDelegatorValidatorsResponse
Expand Down Expand Up @@ -638,7 +637,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegatorValidator() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var validator types.QueryDelegatorValidatorResponse
Expand Down Expand Up @@ -684,7 +683,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryHistoricalInfo() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)

var historicalInfo types.QueryHistoricalInfoResponse
Expand Down Expand Up @@ -723,7 +722,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {

for _, tc := range testCases {
tc := tc
resp, err := rest.GetRequest(tc.url)
resp, err := testutil.GetRequest(tc.url)
s.Run(tc.name, func() {
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType))
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/staking/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/testutil/rest"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
Expand Down Expand Up @@ -1406,7 +1406,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
if !tc.expectErr && tc.expectedCode != sdkerrors.ErrNotFound.ABCICode() {
getCreationHeight := func() int64 {
// fethichg the unbonding delegations
resp, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/staking/v1beta1/delegators/%s/unbonding_delegations", val.APIAddress, val.Address.String()))
resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/staking/v1beta1/delegators/%s/unbonding_delegations", val.APIAddress, val.Address.String()))
s.Require().NoError(err)

var ubds types.QueryDelegatorUnbondingDelegationsResponse
Expand Down
11 changes: 5 additions & 6 deletions tests/e2e/tx/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/testutil/rest"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -259,7 +258,7 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() {
s.Run(tc.name, func() {
req, err := val.ClientCtx.Codec.MarshalJSON(tc.req)
s.Require().NoError(err)
res, err := rest.PostRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/simulate", val.APIAddress), "application/json", req)
res, err := testutil.PostRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/simulate", val.APIAddress), "application/json", req)
s.Require().NoError(err)
if tc.expErr {
s.Require().Contains(string(res), tc.expErrMsg)
Expand Down Expand Up @@ -413,7 +412,7 @@ func (s IntegrationTestSuite) TestGetTxEvents_GRPCGateway() {
}
for _, tc := range testCases {
s.Run(tc.name, func() {
res, err := rest.GetRequest(tc.url)
res, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)
if tc.expErr {
s.Require().Contains(string(res), tc.expErrMsg)
Expand Down Expand Up @@ -483,7 +482,7 @@ func (s IntegrationTestSuite) TestGetTx_GRPCGateway() {
}
for _, tc := range testCases {
s.Run(tc.name, func() {
res, err := rest.GetRequest(tc.url)
res, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)
if tc.expErr {
s.Require().Contains(string(res), tc.expErrMsg)
Expand Down Expand Up @@ -566,7 +565,7 @@ func (s IntegrationTestSuite) TestBroadcastTx_GRPCGateway() {
s.Run(tc.name, func() {
req, err := val.ClientCtx.Codec.MarshalJSON(tc.req)
s.Require().NoError(err)
res, err := rest.PostRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/txs", val.APIAddress), "application/json", req)
res, err := testutil.PostRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/txs", val.APIAddress), "application/json", req)
s.Require().NoError(err)
if tc.expErr {
s.Require().Contains(string(res), tc.expErrMsg)
Expand Down Expand Up @@ -751,7 +750,7 @@ func (s IntegrationTestSuite) TestGetBlockWithTxs_GRPCGateway() {
}
for _, tc := range testCases {
s.Run(tc.name, func() {
res, err := rest.GetRequest(tc.url)
res, err := testutil.GetRequest(tc.url)
s.Require().NoError(err)
if tc.expErr {
s.Require().Contains(string(res), tc.expErrMsg)
Expand Down

0 comments on commit 464c46f

Please sign in to comment.