Skip to content

Commit

Permalink
use hdpath instead in e2e tests
Browse files Browse the repository at this point in the history
fix workflows
  • Loading branch information
Zetazzz committed Aug 12, 2024
1 parent 80d82b0 commit 1910449
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 56 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,3 @@ jobs:

- name: Run E2E Tests
run: cd ./networks/cosmos && yarn starship:test

networks-ethermint:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository 📝
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build Project
run: yarn build

- name: Set Up Starship Infrastructure
id: starship-infra
uses: cosmology-tech/[email protected]
with:
config: networks/ethermint/starship/configs/config.workflow.yaml

- name: Run E2E Tests
run: cd ./networks/ethermint && yarn starship:test
39 changes: 39 additions & 0 deletions .github/workflows/ethermint-e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Run Ethermint E2E Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
networks-ethermint:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository 📝
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build Project
run: yarn build

- name: Set Up Starship Infrastructure
id: starship-infra
uses: cosmology-tech/[email protected]
with:
config: networks/ethermint/starship/configs/config.workflow.yaml

- name: Run E2E Tests
run: cd ./networks/ethermint && yarn starship:test
31 changes: 14 additions & 17 deletions libs/interchainjs/starship/__tests__/token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import { assertIsDeliverTxSuccess } from '@cosmjs/stargate';
import { OfflineDirectSigner } from '@interchainjs/cosmos/types/wallet';
import { Secp256k1HDWallet } from '@interchainjs/cosmos/wallets/secp256k1hd';
import { MsgTransfer } from '@interchainjs/cosmos-types/ibc/applications/transfer/v1/tx';
import { HDPath } from '@interchainjs/types';
import { RpcQuery } from 'interchainjs/query/rpc';
import { StargateSigningClient } from 'interchainjs/stargate';
import { useChain } from 'starshipjs';

const cosmosHdPath = "m/44'/118'/0'/0/0";

describe('Token transfers', () => {
let protoSigner: OfflineDirectSigner, denom: string, address: string;
let protoSigner: OfflineDirectSigner,
denom: string,
address,
address2: string;
let commonPrefix: string,
chainInfo: ChainInfo,
getCoin: () => Promise<Asset>,
Expand All @@ -31,14 +35,17 @@ describe('Token transfers', () => {

const mnemonic = generateMnemonic();
// Initialize wallet
const wallet = Secp256k1HDWallet.fromMnemonic(mnemonic, [
{
const wallet = Secp256k1HDWallet.fromMnemonic(
mnemonic,
[0, 1].map((i) => ({
prefix: commonPrefix,
hdPath: cosmosHdPath,
},
]);
hdPath: HDPath.cosmos(0, 0, i).toString(),
}))
);
protoSigner = wallet.toOfflineDirectSigner();
address = (await protoSigner.getAccounts())[0].address;
const accounts = await protoSigner.getAccounts();
address = accounts[0].address;
address2 = accounts[1].address;

// Create custom cosmos interchain client
queryClient = new RpcQuery(await getRpcEndpoint());
Expand All @@ -47,16 +54,6 @@ describe('Token transfers', () => {
});

it('send osmosis token to address', async () => {
const mnemonic = generateMnemonic();
// Initialize wallet
const wallet2 = Secp256k1HDWallet.fromMnemonic(mnemonic, [
{
prefix: commonPrefix,
hdPath: cosmosHdPath,
},
]);
const address2 = (await wallet2.getAccounts())[0].address;

const signingClient = await StargateSigningClient.connectWithSigner(
await getRpcEndpoint(),
protoSigner
Expand Down
6 changes: 5 additions & 1 deletion networks/cosmos/starship/__tests__/gov.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
bondStatusToJSON,
} from '@interchainjs/cosmos-types/cosmos/staking/v1beta1/staking';
import { MsgDelegate } from '@interchainjs/cosmos-types/cosmos/staking/v1beta1/tx';
import {
HDPath
} from '@interchainjs/types';
import { fromBase64, toUtf8 } from '@interchainjs/utils';
import { BigNumber } from 'bignumber.js';
import { RpcQuery } from 'interchainjs/query/rpc';
Expand Down Expand Up @@ -55,7 +58,8 @@ describe('Governance tests for osmosis', () => {
cosmosHdPath,
]);
const [aminoAuth] = Secp256k1Auth.fromMnemonic(generateMnemonic(), [
cosmosHdPath,
// use cosmos hdpath built by HDPath
HDPath.cosmos().toString(),
]);
directSigner = new DirectSigner(
directAuth,
Expand Down
21 changes: 11 additions & 10 deletions networks/cosmos/starship/__tests__/token.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './setup.test';

import { ChainInfo } from '@chain-registry/client';
import {Asset} from '@chain-registry/types';
import { Asset } from '@chain-registry/types';
import { Secp256k1Auth } from '@interchainjs/auth/secp256k1';
import { defaultSignerOptions } from '@interchainjs/cosmos/defaults';
import { DirectSigner } from '@interchainjs/cosmos/direct';
Expand All @@ -11,6 +11,7 @@ import {
} from '@interchainjs/cosmos/utils';
import { MsgSend } from '@interchainjs/cosmos-types/cosmos/bank/v1beta1/tx';
import { MsgTransfer } from '@interchainjs/cosmos-types/ibc/applications/transfer/v1/tx';
import { HDPath } from '@interchainjs/types';
import { RpcQuery } from 'interchainjs/query/rpc';
import { useChain } from 'starshipjs';

Expand All @@ -19,7 +20,7 @@ import { generateMnemonic } from '../src';
const cosmosHdPath = "m/44'/118'/0'/0/0";

describe('Token transfers', () => {
let directSigner: DirectSigner, denom: string, address: string;
let directSigner: DirectSigner, denom: string, address, address2: string;
let chainInfo: ChainInfo,
getCoin: () => Promise<Asset>,
getRpcEndpoint: () => Promise<string>,
Expand All @@ -33,11 +34,18 @@ describe('Token transfers', () => {

const mnemonic = generateMnemonic();
// Initialize auth
const [auth] = Secp256k1Auth.fromMnemonic(mnemonic, [cosmosHdPath]);
const [auth, auth2] = Secp256k1Auth.fromMnemonic(
mnemonic,
[0, 1].map((i) => HDPath.cosmos(0, 0, i).toString())
);
directSigner = new DirectSigner(auth, [], await getRpcEndpoint(), {
prefix: chainInfo.chain.bech32_prefix,
});
const directSigner2 = new DirectSigner(auth2, [], await getRpcEndpoint(), {
prefix: chainInfo.chain.bech32_prefix,
});
address = await directSigner.getAddress();
address2 = await directSigner2.getAddress();

// Create custom cosmos interchain client
queryClient = new RpcQuery(await getRpcEndpoint());
Expand All @@ -46,13 +54,6 @@ describe('Token transfers', () => {
});

it('send osmosis token to address', async () => {
const mnemonic = generateMnemonic();
// Initialize wallet
const [auth2] = Secp256k1Auth.fromMnemonic(mnemonic, [cosmosHdPath]);
const address2 = defaultSignerOptions.publicKey
.hash(auth2.getPublicKey(defaultSignerOptions.publicKey.isCompressed))
.toBech32(chainInfo.chain.bech32_prefix);

const fee = {
amount: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './account';
export * from './auth';
export * from './doc';
export * from './hdpath';
export * from './signer';
export * from './telescope';
export * from './wallet';

0 comments on commit 1910449

Please sign in to comment.