Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test / E2E house #395

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/e2e/house/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package client_test

import (
"testing"

"github.com/stretchr/testify/suite"

client "github.com/sge-network/sge/tests/e2e/house"
"github.com/sge-network/sge/testutil/network"
)

func TestE2ETestSuite(t *testing.T) {
cfg := network.DefaultConfig()
cfg.NumValidators = 1
suite.Run(t, client.NewE2ETestSuite(cfg))
}
105 changes: 105 additions & 0 deletions tests/e2e/house/grpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package client

import (
"fmt"

"github.com/cosmos/gogoproto/proto"

"github.com/cosmos/cosmos-sdk/testutil"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/sge-network/sge/x/house/types"
)

func (s *E2ETestSuite) TestDepositsGRPCHandler() {
val := s.network.Validators[0]
baseURL := val.APIAddress

testCases := []struct {
name string
url string
headers map[string]string
respType proto.Message
expected proto.Message
}{
{
"test GRPC all deposits",
fmt.Sprintf("%s/sge/house/deposits", baseURL),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QueryDepositsResponse{},
&types.QueryDepositsResponse{
Deposits: genesis.DepositList,
Pagination: &query.PageResponse{
Total: 1,
},
},
},
{
"test GRPC deposits of certain creator",
fmt.Sprintf("%s/sge/house/deposits/%s", baseURL, dummyDepositor),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QueryDepositsByAccountResponse{},
&types.QueryDepositsByAccountResponse{
Deposits: genesis.DepositList,
Pagination: &query.PageResponse{
Total: 1,
},
},
},
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)

s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType))
s.Require().Equal(tc.expected.String(), tc.respType.String())
})
}
}

func (s *E2ETestSuite) TestGRPCHandler() {
val := s.network.Validators[0]
baseURL := val.APIAddress

testCases := []struct {
name string
url string
headers map[string]string
respType proto.Message
expected proto.Message
}{
{
"test GRPC all withdraws",
fmt.Sprintf("%s/sge/house/withdrawals/%s", baseURL, dummyDepositor),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QueryWithdrawalsByAccountResponse{},
&types.QueryWithdrawalsByAccountResponse{
Withdrawals: genesis.WithdrawalList,
Pagination: &query.PageResponse{
Total: 1,
},
},
},
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)

s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType))
s.Require().Equal(tc.expected.String(), tc.respType.String())
})
}
}
Loading
Loading