Skip to content

Commit

Permalink
Merge pull request #615 from hyperweb-io/anmol/simplify-eth
Browse files Browse the repository at this point in the history
feature: simplify eth, add test case for eth-lite, starship client
  • Loading branch information
Anmol1696 authored Feb 9, 2025
2 parents bab1cfc + 6b67078 commit c67b58f
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 196 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- "multi-validator-starship-faucet.yaml"
- "one-chain-cometmock.yaml"
- "one-cosmoshub-starship-faucet.yaml"
- "eth-lite.yaml"
fail-fast: true
max-parallel: 3

Expand Down
29 changes: 25 additions & 4 deletions clients/js/packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Chain, Relayer, StarshipConfig } from './config';
import { Ports } from './config';
import { dependencies as defaultDependencies, Dependency } from './deps';
import { readAndParsePackageJson } from './package';
import {type} from "node:os";

export interface StarshipContext {
name?: string;
Expand Down Expand Up @@ -63,6 +64,10 @@ const defaultPorts: PodPorts = {
rest: 8080
},
chains: {
ethereum: {
rpc: 8551,
rest: 8545,
},
defaultPorts: {
rpc: 26657,
grpc: 9090,
Expand Down Expand Up @@ -714,11 +719,19 @@ export class StarshipClient implements StarshipClientI {
localPort: number,
externalPort: number
): void {
let podName: string;
if (typeof(chain.id) === 'string') {
podName = `${formatChainID(chain.id)}-genesis-0`;
}
else {
podName = `${chain.name}-${chain.id}-0`;
}

if (localPort !== undefined && externalPort !== undefined) {
this.exec([
'kubectl',
'port-forward',
`pods/${formatChainID(chain.id)}-genesis-0`,
`pods/${podName}`,
`${localPort}:${externalPort}`,
...this.getArgs(),
'>',
Expand All @@ -728,7 +741,7 @@ export class StarshipClient implements StarshipClientI {
]);
this.log(
chalk.yellow(
`Forwarded ${formatChainID(chain.id)}: local ${localPort} -> target (host) ${externalPort}`
`Forwarded ${podName}: local ${localPort} -> target (host) ${externalPort}`
)
);
}
Expand All @@ -739,11 +752,19 @@ export class StarshipClient implements StarshipClientI {
localPort: number,
externalPort: number
): void {
let podName: string;
if (typeof(chain.id) === 'string') {
podName = `${formatChainID(chain.id)}-cometmock-0`;
}
else {
podName = `${chain.name}-${chain.id}-0`;
}

if (localPort !== undefined && externalPort !== undefined) {
this.exec([
'kubectl',
'port-forward',
`pods/${formatChainID(chain.id)}-cometmock-0`,
`pods/${podName}`,
`${localPort}:${externalPort}`,
...this.getArgs(),
'>',
Expand All @@ -753,7 +774,7 @@ export class StarshipClient implements StarshipClientI {
]);
this.log(
chalk.yellow(
`Forwarded ${formatChainID(chain.id)}: local ${localPort} -> target (host) ${externalPort}`
`Forwarded ${podName}: local ${localPort} -> target (host) ${externalPort}`
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion clients/js/packages/client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface FaucetConfig {
}

export interface Chain {
id: string;
id: string | number;
name: string;
numValidators: number;
image?: string;
Expand Down
2 changes: 1 addition & 1 deletion clients/js/packages/starshipjs/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export interface ChainConfig {
};
};
chains: Array<{
id: string;
id: string | number;
name: string;
ports: {
rpc: number;
Expand Down
188 changes: 0 additions & 188 deletions starship/charts/devnet/templates/chains/eth/beacon.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions starship/tests/e2e/configs/eth-lite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
chains:
- id: 1337
name: ethereum
numValidators: 1
ports:
rest: 8545
rpc: 8551
resources:
cpu: "200m"
memory: "200Mi"
4 changes: 2 additions & 2 deletions starship/tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *TestSuite) TestChains_Status() {
s.T().Log("running test for /status endpoint for each chain")

for _, chain := range s.config.Chains {
if chain.Name == "neutron" {
if chain.Name == "neutron" || chain.Name == "ethereum" {
s.T().Skip("skip tests for neutron")
}
url := fmt.Sprintf("http://0.0.0.0:%d/status", chain.Ports.Rpc)
Expand All @@ -86,7 +86,7 @@ func (s *TestSuite) TestChains_StakingParams() {
s.T().Skip("skip staking params test for non rest endpoint")
}
s.T().Log("running test for /staking/parameters endpoint for each chain")
if s.config.Chains[0].Name == "neutron" {
if s.config.Chains[0].Name == "neutron" || s.config.Chains[0].Name == "ethereum" {
s.T().Skip("skip tests for neutron")
}

Expand Down
21 changes: 21 additions & 0 deletions starship/tests/e2e/exposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (s *TestSuite) TestExposer_GetNodeID() {
s.T().Log("running test for /node_id endpoint for exposer")

chain := s.config.Chains[0]
if chain.Ports.Exposer == 0 {
s.T().Skip("skipping /node_id test since no exposer")
}

req, err := http.NewRequest(http.MethodGet, "/node_id", nil)
s.Require().NoError(err)
Expand All @@ -45,6 +48,9 @@ func (s *TestSuite) TestExposer_GetGenesisFile() {
s.T().Log("running test for /genesis endpoint for exposer")

chain := s.config.Chains[0]
if chain.Ports.Exposer == 0 {
s.T().Skip("skipping /node_id test since no exposer")
}

req, err := http.NewRequest(http.MethodGet, "/genesis", nil)
s.Require().NoError(err)
Expand All @@ -62,6 +68,9 @@ func (s *TestSuite) TestExposer_GetPubKey() {
s.T().Log("running test for /pub_key endpoint for exposer")

chain := s.config.Chains[0]
if chain.Ports.Exposer == 0 {
s.T().Skip("skipping /node_id test since no exposer")
}
if chain.Cometmock != nil && chain.Cometmock.Enabled {
s.T().Skip("skipping tests for cometmock enabled chain")
}
Expand All @@ -82,6 +91,9 @@ func (s *TestSuite) TestExposer_GetPrivKey() {
s.T().Log("running test for /priv_keys endpoint for exposer")

chain := s.config.Chains[0]
if chain.Ports.Exposer == 0 {
s.T().Skip("skipping /node_id test since no exposer")
}

req, err := http.NewRequest(http.MethodGet, "/priv_keys", nil)
s.Require().NoError(err)
Expand All @@ -99,6 +111,9 @@ func (s *TestSuite) TestExposer_GetPrivValState() {
s.T().Log("running test for /priv_validator_state endpoint for exposer")

chain := s.config.Chains[0]
if chain.Ports.Exposer == 0 {
s.T().Skip("skipping /node_id test since no exposer")
}

req, err := http.NewRequest(http.MethodGet, "/priv_validator_state", nil)
s.Require().NoError(err)
Expand All @@ -115,6 +130,9 @@ func (s *TestSuite) TestExposer_GetNodeKey() {
s.T().Log("running test for /node_key endpoint for exposer")

chain := s.config.Chains[0]
if chain.Ports.Exposer == 0 {
s.T().Skip("skipping /node_id test since no exposer")
}

req, err := http.NewRequest(http.MethodGet, "/node_key", nil)
s.Require().NoError(err)
Expand All @@ -131,6 +149,9 @@ func (s *TestSuite) TestExposer_GetKeys() {
s.T().Log("running test for /keys endpoint for exposer")

chain := s.config.Chains[0]
if chain.Ports.Exposer == 0 {
s.T().Skip("skipping /node_id test since no exposer")
}

req, err := http.NewRequest(http.MethodGet, "/keys", nil)
s.Require().NoError(err)
Expand Down

0 comments on commit c67b58f

Please sign in to comment.