Skip to content

Commit

Permalink
update tests for same
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 committed Jan 2, 2024
1 parent cc02ac3 commit 1cadb8e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
4 changes: 1 addition & 3 deletions registry/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ func (a *AppServer) ListIBC(ctx context.Context, _ *emptypb.Empty) (*pb.Response
return nil, err
}

for _, info := range infos {
resData = append(resData, info.ToProto())
}
resData = append(resData, infos.ToProto()...)
}

return &pb.ResponseListIBC{Data: resData}, nil
Expand Down
4 changes: 2 additions & 2 deletions registry/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func (info *ChainIBCInfo) ToProto() *pb.IBCData {

// GetCounterpartyChainInfo returns ChainIBCInfo struct for given counterparty
// chain id.
func (c ChainIBCInfos) GetCounterpartyChainInfo(chainId string) *ChainIBCInfo {
for _, cii := range c {
func (infos ChainIBCInfos) GetCounterpartyChainInfo(chainId string) *ChainIBCInfo {
for _, cii := range infos {
if cii.Counterparty.ChainId == chainId {
return cii
}
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/configs/two-chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ relayers:
global:
log_level: "error"
rest:
enabled: false
enabled: true
telemetry:
enabled: false
event_source:
mode: pull
ports:
rest: 3000
exposer: 3002

explorer:
enabled: true
Expand All @@ -52,4 +55,4 @@ registry:
grpc: 9091

exposer:
image: ghcr.io/cosmology-tech/starship/exposer:20231215-7c22b86
image: anmol1696/exposer:20240102-cc02ac3
8 changes: 7 additions & 1 deletion tests/e2e/exposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ func (s *TestSuite) TestExposer_CreateChannel() {
}

// get number of channels before creating channel
ibcDataBefore := s.getIBCData(relayer.Chains[0], relayer.Chains[1])
s.Require().GreaterOrEqual(len(ibcDataBefore.Channels), 1, ibcDataBefore)

body := map[string]string{
"a_chain": relayer.Chains[0],
Expand All @@ -179,6 +181,10 @@ func (s *TestSuite) TestExposer_CreateChannel() {
err = json.NewDecoder(resp).Decode(&res)
s.Require().NoError(err)

s.Require().Contains("SUCCESS Channel", res["status"].(string), "response from exposer creaste_channel", res)
s.Require().Contains(res["status"].(string), "SUCCESS Channel", "response from exposer creaste_channel", res)

// get number of channels after creating channel
ibcDataAfter := s.getIBCData(relayer.Chains[0], relayer.Chains[1])
s.Require().Len(ibcDataAfter.Channels, len(ibcDataBefore.Channels)+1, "number of channels should be 1 more then before", ibcDataAfter)
}
}
10 changes: 10 additions & 0 deletions tests/e2e/faucet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ func (s *TestSuite) getChainDenoms(chain *Chain) string {
return respChain.Fees.FeeTokens[0].Denom
}

func (s *TestSuite) getIBCData(aChain, bChain string) *pb.IBCData {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("/ibc/%s/%s", aChain, bChain), nil)
s.Require().NoError(err)

ibcData := &pb.IBCData{}
s.MakeRegistryRequest(req, ibcData)

return ibcData
}

func (s *TestSuite) getAccountBalance(chain *Chain, address string, denom string) float64 {
data := map[string]interface{}{}
s.MakeChainGetRequest(chain, fmt.Sprintf("/cosmos/bank/v1beta1/balances/%s", address), &data)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (s *TestSuite) TestRegistry_ListIBC() {
s.MakeRegistryRequest(req, respIBC)

// assert results to expected values
s.Require().Len(respIBC.Data, len(s.config.Relayers)*2, "number of ibc information should be double the number of relayers")
s.Require().GreaterOrEqual(len(respIBC.Data), len(s.config.Relayers)*2, "number of ibc information should be double the number of relayers")
}

func (s *TestSuite) TestRegistry_GetChainKeys() {
Expand Down

0 comments on commit 1cadb8e

Please sign in to comment.