-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #395 from scorpioborn/test/e2e-house
Test / E2E house
- Loading branch information
Showing
8 changed files
with
1,261 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
}) | ||
} | ||
} |
Oops, something went wrong.