Skip to content

Commit

Permalink
Merge pull request #395 from scorpioborn/test/e2e-house
Browse files Browse the repository at this point in the history
Test / E2E house
  • Loading branch information
scorpioborn authored May 14, 2024
2 parents bc53357 + 268f404 commit 8139438
Show file tree
Hide file tree
Showing 8 changed files with 1,261 additions and 1 deletion.
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

0 comments on commit 8139438

Please sign in to comment.