Skip to content

Commit

Permalink
inital correctness of registry service (#240)
Browse files Browse the repository at this point in the history
* inital correctness of registry service

* add assets into the default defination of the chains

* update default to add assets for all defaultChains

* use local image of registry for tests, add empty test

* fix tests, use require instead of asserts

* set registry image as debug test image, change after merge
  • Loading branch information
Anmol1696 authored Sep 15, 2023
1 parent a7877b7 commit 6b2102d
Show file tree
Hide file tree
Showing 22 changed files with 568 additions and 56 deletions.
373 changes: 373 additions & 0 deletions charts/devnet/defaults.yaml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions charts/devnet/templates/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ data:
{
"$schema": "../assetlist.schema.json",
"chain_name": "{{ $chain.type }}",
{{- if hasKey $chain "assets" }}
"assets": {{ toJson $chain.assets }}
{{- else }}
"assets": [
{
"description": "The denom for token {{ $chain.denom }}",
Expand All @@ -138,6 +141,7 @@ data:
"coingecko_id": "{{ $chain.type }}"
}
]
{{- end }}
}
chain.json: |-
{
Expand All @@ -146,6 +150,7 @@ data:
"status": "live",
"network_type": "mainnet",
"chain_id": "{{ $chain.name }}",
"pretty_name": "{{ $chain.prettyName }}",
"bech32_prefix": "{{ $chain.prefix }}",
"daemon_name": "{{ $chain.binary }}",
"node_home": "{{ $chain.home }}",
Expand Down
3 changes: 3 additions & 0 deletions charts/devnet/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
"denom": {
"type": "string"
},
"prettyName": {
"type": "string"
},
"coins": {
"type": "string"
},
Expand Down
16 changes: 8 additions & 8 deletions examples/upgrade-test/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func (s *TestSuite) TestChainsStatus() {

for _, chainClient := range s.chainClients {
status, err := chainClient.GetStatus()
s.Assert().NoError(err)
s.Require().NoError(err)

s.Assert().Equal(chainClient.GetChainID(), status.NodeInfo.Network)
s.Require().Equal(chainClient.GetChainID(), status.NodeInfo.Network)
}
}

Expand All @@ -41,9 +41,9 @@ func (s *TestSuite) TestChainTokenTransfer() {
s.Require().NoError(err)

// Assert correct transfers
s.Assert().Len(balance, 1)
s.Assert().Equal(balance.Denoms(), []string{denom})
s.Assert().Equal(balance[0].Amount, sdk.NewInt(2345000))
s.Require().Len(balance, 1)
s.Require().Equal(balance.Denoms(), []string{denom})
s.Require().Equal(balance[0].Amount, sdk.NewInt(2345000))
}

func (s *TestSuite) TestChainIBCTransfer() {
Expand All @@ -69,7 +69,7 @@ func (s *TestSuite) TestChainIBCTransfer() {
s.Require().NoError(err)

// Assert correct transfers
s.Assert().Len(balance, 1)
s.Assert().Equal(balance.Denoms(), []string{chain2Denom})
s.Assert().Equal(balance[0].Amount, sdk.NewInt(12345000))
s.Require().Len(balance, 1)
s.Require().Equal(balance.Denoms(), []string{chain2Denom})
s.Require().Equal(balance[0].Amount, sdk.NewInt(12345000))
}
4 changes: 2 additions & 2 deletions examples/upgrade-test/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ func (s *TestSuite) WaitForTx(chain *starship.ChainClient, txHex string) {
time.Second,
"waited for too long, still txn not successfull",
)
s.Assert().NotNil(tx)
s.Require().NotNil(tx)
}

// WaitForHeight will wait till the chain reaches the block height
func (s *TestSuite) WaitForHeight(chain *starship.ChainClient, height int64) {
s.Require().Eventuallyf(
func() bool {
curHeight, err := chain.GetHeight()
s.Assert().NoError(err)
s.Require().NoError(err)
if curHeight >= height {
return true
}
Expand Down
12 changes: 6 additions & 6 deletions examples/upgrade-test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ func (s *TestSuite) TestChainUpgrade() {
balance, err := chain.Client.QueryBalanceWithDenomTraces(context.Background(), sdk.MustAccAddressFromBech32(address), nil)
s.Require().NoError(err)
// Assert correct transfers
s.Assert().Len(balance, 1)
s.Assert().Equal(balance.Denoms(), []string{denom})
s.Assert().Equal(balance[0].Amount, sdk.NewInt(12312300))
s.Require().Len(balance, 1)
s.Require().Equal(balance.Denoms(), []string{denom})
s.Require().Equal(balance[0].Amount, sdk.NewInt(12312300))
s.T().Logf("post-upgrade: verifed balance of address after upgrade")

// transfer some more tokens to address
Expand All @@ -136,9 +136,9 @@ func (s *TestSuite) TestChainUpgrade() {
balance, err = chain.Client.QueryBalanceWithDenomTraces(context.Background(), sdk.MustAccAddressFromBech32(address), nil)
s.Require().NoError(err)
// Assert correct transfers
s.Assert().Len(balance, 1)
s.Assert().Equal(balance.Denoms(), []string{denom})
s.Assert().Equal(balance[0].Amount, sdk.NewInt(24624600))
s.Require().Len(balance, 1)
s.Require().Equal(balance.Denoms(), []string{denom})
s.Require().Equal(balance[0].Amount, sdk.NewInt(24624600))
s.T().Logf("post-upgrade: verify that the address has double tokens")

s.T().Log("Successful Chain Upgrade")
Expand Down
2 changes: 1 addition & 1 deletion proto/registry/chain.proto
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ message ChainRegistry {

message DenomUnit {
string denom = 1 [json_name = "denom"];
int64 exponent = 2 [json_name = "exponent"];
int32 exponent = 2 [json_name = "exponent"];
repeated string aliases = 3 [json_name = "aliases"];
}

Expand Down
10 changes: 9 additions & 1 deletion registry/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ func (c *ChainClient) getChannelsPorts() ([]ChannelsInfo, error) {
return nil, fmt.Errorf("number of connections not 1")
}

ordering := "none"
switch channel.Ordering {
case 1:
ordering = "unordered"
case 2:
ordering = "ordered"
}

ci := ChannelsInfo{
ChannelPort: ChannelPort{
ChannelId: channel.ChannelId,
Expand All @@ -188,7 +196,7 @@ func (c *ChainClient) getChannelsPorts() ([]ChannelsInfo, error) {
PortId: channel.Counterparty.PortId,
},
ConnectionId: channel.ConnectionHops[0],
Ordering: channel.Ordering.String(),
Ordering: ordering,
Version: channel.Version,
}

Expand Down
6 changes: 3 additions & 3 deletions registry/registry/chain.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/e2e/configs/build-chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ relayers:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
1 change: 1 addition & 0 deletions tests/e2e/configs/evmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ relayers:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
1 change: 1 addition & 0 deletions tests/e2e/configs/injective.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ relayers:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
1 change: 1 addition & 0 deletions tests/e2e/configs/multi-validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ chains:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/configs/one-chain-custom-scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ chains:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/configs/one-chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ chains:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/configs/one-custom-chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ chains:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/configs/simapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ chains:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
resources:
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/configs/two-chain-gorelayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ explorer:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
1 change: 1 addition & 0 deletions tests/e2e/configs/two-chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ explorer:

registry:
enabled: true
image: anmol1696/registry:20230914-a6ee678
ports:
rest: 8081
grpc: 9091
4 changes: 2 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func (s *TestSuite) TestChains_Status() {
body := s.MakeRequest(req, 200)
resp := &pb.Status{}
err = jsonpb.Unmarshal(body, resp)
s.Assert().NoError(err)
s.Require().NoError(err)

// assert chain id
s.Assert().Equal(chain.Name, resp.Result.NodeInfo.Network)
s.Require().Equal(chain.Name, resp.Result.NodeInfo.Network)
}
}

Expand Down
28 changes: 14 additions & 14 deletions tests/e2e/exposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *TestSuite) TestExposer_GetNodeID() {
s.MakeExposerRequest(chain, req, resp)

// assert results to expected values
s.Assert().NotEmpty(resp.NodeId)
s.Require().NotEmpty(resp.NodeId)
}

func (s *TestSuite) TestExposer_GetGenesisFile() {
Expand All @@ -53,8 +53,8 @@ func (s *TestSuite) TestExposer_GetGenesisFile() {
s.MakeExposerRequest(chain, req, resp)

// assert results to expected values
s.Assert().NotNil(resp)
s.Assert().Equal(chain.Name, resp.AsMap()["chain_id"])
s.Require().NotNil(resp)
s.Require().Equal(chain.Name, resp.AsMap()["chain_id"])
}

func (s *TestSuite) TestExposer_GetPubKey() {
Expand All @@ -69,9 +69,9 @@ func (s *TestSuite) TestExposer_GetPubKey() {
s.MakeExposerRequest(chain, req, resp)

// assert results to expected values
s.Assert().NotNil(resp)
s.Assert().NotEmpty(resp.Key)
s.Assert().Equal("/cosmos.crypto.ed25519.PubKey", resp.Type)
s.Require().NotNil(resp)
s.Require().NotEmpty(resp.Key)
s.Require().Equal("/cosmos.crypto.ed25519.PubKey", resp.Type)
}

func (s *TestSuite) TestExposer_GetPrivKey() {
Expand All @@ -87,9 +87,9 @@ func (s *TestSuite) TestExposer_GetPrivKey() {
s.MakeExposerRequest(chain, req, resp)

// assert results to expected values
s.Assert().NotNil(resp)
s.Assert().NotEmpty(resp.PrivKey)
s.Assert().NotEmpty(resp.PubKey)
s.Require().NotNil(resp)
s.Require().NotEmpty(resp.PrivKey)
s.Require().NotEmpty(resp.PubKey)
}

func (s *TestSuite) TestExposer_GetKeys() {
Expand All @@ -104,9 +104,9 @@ func (s *TestSuite) TestExposer_GetKeys() {
s.MakeExposerRequest(chain, req, resp)

// assert results to expected values
s.Assert().NotNil(resp)
s.Assert().Len(resp.Genesis, 1)
s.Assert().Len(resp.Validators, 4)
s.Assert().Len(resp.Keys, 3)
s.Assert().Len(resp.Relayers, 2)
s.Require().NotNil(resp)
s.Require().Len(resp.Genesis, 1)
s.Require().Len(resp.Validators, 4)
s.Require().Len(resp.Keys, 3)
s.Require().Len(resp.Relayers, 2)
}
Loading

0 comments on commit 6b2102d

Please sign in to comment.