Skip to content

Commit 30aaa62

Browse files
committed
update tests for starship e2e
1 parent 2b98f0e commit 30aaa62

File tree

10 files changed

+112
-119
lines changed

10 files changed

+112
-119
lines changed

packages/starship/__tests__/v0/gov.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { generateMnemonic } from '@confio/relayer/build/lib/helpers';
22
import { assertIsDeliverTxSuccess } from '@cosmjs/stargate';
3-
import Long from 'long';
43
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
54
import BigNumber from 'bignumber.js';
65

76
import { cosmos, getSigningOsmosisClient } from '../../src/codegen';
8-
import { useChain, waitUntil } from '../../src';
7+
import { useChain } from 'starshipjs';
8+
import { waitUntil } from "../../src";
99
import './setup.test';
1010

1111
describe('Governance tests for osmosis', () => {
@@ -20,7 +20,7 @@ describe('Governance tests for osmosis', () => {
2020
beforeAll(async () => {
2121
({ chainInfo, getCoin, getRpcEndpoint, creditFromFaucet } =
2222
useChain('osmosis'));
23-
denom = getCoin().base;
23+
denom = (await getCoin()).base;
2424

2525
// Initialize wallet
2626
protoSigner = await DirectSecp256k1HdWallet.fromMnemonic(
@@ -33,7 +33,7 @@ describe('Governance tests for osmosis', () => {
3333

3434
// Create custom cosmos interchain client
3535
queryClient = await cosmos.ClientFactory.createRPCQueryClient({
36-
rpcEndpoint: getRpcEndpoint()
36+
rpcEndpoint: await getRpcEndpoint()
3737
});
3838

3939
// Transfer osmosis to address
@@ -70,7 +70,7 @@ describe('Governance tests for osmosis', () => {
7070

7171
it('stake tokens to genesis validator', async () => {
7272
const signingClient = await getSigningOsmosisClient({
73-
rpcEndpoint: getRpcEndpoint(),
73+
rpcEndpoint: await getRpcEndpoint(),
7474
signer: protoSigner
7575
});
7676

@@ -107,7 +107,7 @@ describe('Governance tests for osmosis', () => {
107107

108108
it('submit a txt proposal', async () => {
109109
const signingClient = await getSigningOsmosisClient({
110-
rpcEndpoint: getRpcEndpoint(),
110+
rpcEndpoint: await getRpcEndpoint(),
111111
signer: protoSigner
112112
});
113113

@@ -158,7 +158,7 @@ describe('Governance tests for osmosis', () => {
158158

159159
it('query proposal', async () => {
160160
const result = await queryClient.cosmos.gov.v1beta1.proposal({
161-
proposalId: Long.fromString(proposalId)
161+
proposalId: BigInt(proposalId)
162162
});
163163

164164
expect(result.proposal.proposalId.toString()).toEqual(proposalId);
@@ -167,13 +167,13 @@ describe('Governance tests for osmosis', () => {
167167
it('vote on proposal from genesis address', async () => {
168168
// create genesis address signing client
169169
const signingClient = await getSigningOsmosisClient({
170-
rpcEndpoint: getRpcEndpoint(),
170+
rpcEndpoint: await getRpcEndpoint(),
171171
signer: protoSigner
172172
});
173173

174174
// Vote on proposal from genesis mnemonic address
175175
const msg = cosmos.gov.v1beta1.MessageComposer.withTypeUrl.vote({
176-
proposalId: Long.fromString(proposalId),
176+
proposalId: BigInt(proposalId),
177177
voter: address,
178178
option: cosmos.gov.v1beta1.VoteOption.VOTE_OPTION_YES
179179
});
@@ -194,7 +194,7 @@ describe('Governance tests for osmosis', () => {
194194

195195
it('verify vote', async () => {
196196
const { vote } = await queryClient.cosmos.gov.v1beta1.vote({
197-
proposalId: Long.fromString(proposalId),
197+
proposalId: BigInt(proposalId),
198198
voter: address
199199
});
200200

@@ -205,15 +205,15 @@ describe('Governance tests for osmosis', () => {
205205
it('wait for voting period to end', async () => {
206206
// wait for the voting period to end
207207
const { proposal } = await queryClient.cosmos.gov.v1beta1.proposal({
208-
proposalId: Long.fromString(proposalId)
208+
proposalId: BigInt(proposalId)
209209
});
210210

211211
await expect(waitUntil(proposal.votingEndTime)).resolves.not.toThrow();
212212
}, 200000);
213213

214214
it('verify proposal passed', async () => {
215215
const { proposal } = await queryClient.cosmos.gov.v1beta1.proposal({
216-
proposalId: Long.fromString(proposalId)
216+
proposalId: BigInt(proposalId)
217217
});
218218

219219
expect(proposal.status).toEqual(

packages/starship/__tests__/v0/setup.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
// @ts-nocheck
12
import path from 'path';
2-
3-
import { Config, useChain, useRegistry } from '../../src';
3+
import { ConfigContext, useChain, useRegistry } from 'starshipjs';
4+
import { StargateClient } from '@cosmjs/stargate';
45

56
beforeAll(async () => {
67
const configFile = path.join(__dirname, '../..', 'configs', 'config.yaml');
7-
Config.setConfigFile = configFile;
8-
Config.setRegistry = await useRegistry(configFile);
8+
ConfigContext.setConfigFile(configFile);
9+
ConfigContext.setRegistry(await useRegistry(configFile));
910
}, 200000);
1011

1112
describe('Test clients', () => {
1213
let client;
1314

1415
beforeAll(async () => {
15-
const { getStargateClient } = useChain('osmosis');
16-
client = await getStargateClient();
16+
const { getRpcEndpoint } = useChain('osmosis');
17+
client = await StargateClient.connect(await getRpcEndpoint());
1718
}, 200000);
1819

1920
it('check chain height', async () => {

packages/starship/__tests__/v0/staking.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { generateMnemonic } from '@confio/relayer/build/lib/helpers';
21
import { assertIsDeliverTxSuccess } from '@cosmjs/stargate';
32
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
4-
import BigNumber from 'bignumber.js';
3+
import { BigNumber } from 'bignumber.js';
54

65
import { cosmos, getSigningOsmosisClient } from '../../src/codegen';
7-
import { useChain } from '../../src';
6+
import { useChain, generateMnemonic } from 'starshipjs';
87
import './setup.test';
98

109
describe('Staking tokens testing', () => {
1110
let wallet, denom, address;
12-
let chainInfo, getCoin, getStargateClient, getRpcEndpoint, creditFromFaucet;
11+
let chainInfo, getCoin, getRpcEndpoint, creditFromFaucet;
1312

1413
// Variables used accross testcases
1514
let queryClient;
@@ -18,13 +17,13 @@ describe('Staking tokens testing', () => {
1817

1918
beforeAll(async () => {
2019
({
20+
// @ts-ignore
2121
chainInfo,
2222
getCoin,
23-
getStargateClient,
2423
getRpcEndpoint,
2524
creditFromFaucet
2625
} = useChain('osmosis'));
27-
denom = getCoin().base;
26+
denom = (await getCoin()).base;
2827

2928
// Initialize wallet
3029
wallet = await DirectSecp256k1HdWallet.fromMnemonic(generateMnemonic(), {
@@ -34,7 +33,7 @@ describe('Staking tokens testing', () => {
3433

3534
// Create custom cosmos interchain client
3635
queryClient = await cosmos.ClientFactory.createRPCQueryClient({
37-
rpcEndpoint: getRpcEndpoint()
36+
rpcEndpoint: await getRpcEndpoint()
3837
});
3938

4039
// Transfer osmosis and ibc tokens to address, send only osmo to address
@@ -71,7 +70,7 @@ describe('Staking tokens testing', () => {
7170

7271
it('stake tokens to genesis validator', async () => {
7372
const signingClient = await getSigningOsmosisClient({
74-
rpcEndpoint: getRpcEndpoint(),
73+
rpcEndpoint: await getRpcEndpoint(),
7574
signer: wallet
7675
});
7776

packages/starship/__tests__/v0/token.test.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import { generateMnemonic } from '@confio/relayer/build/lib/helpers';
22
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
3-
import { assertIsDeliverTxSuccess } from '@cosmjs/stargate';
3+
import {assertIsDeliverTxSuccess, StargateClient} from '@cosmjs/stargate';
44

55
import { ibc, getSigningOsmosisClient } from '../../src/codegen';
6-
import { useChain } from '../../src';
6+
import { useChain } from 'starshipjs';
77
import './setup.test';
88

99
describe('Token transfers', () => {
1010
let wallet, denom, address;
11-
let chainInfo, getCoin, getStargateClient, getRpcEndpoint, creditFromFaucet;
11+
let chainInfo, getCoin, getRpcEndpoint, creditFromFaucet;
1212

1313
beforeAll(async () => {
1414
({
1515
chainInfo,
1616
getCoin,
17-
getStargateClient,
1817
getRpcEndpoint,
1918
creditFromFaucet
2019
} = useChain('osmosis'));
21-
denom = getCoin().base;
20+
denom = (await getCoin()).base;
2221

2322
// Initialize wallet
2423
wallet = await DirectSecp256k1HdWallet.fromMnemonic(generateMnemonic(), {
@@ -38,7 +37,7 @@ describe('Token transfers', () => {
3837
const address2 = (await wallet2.getAccounts())[0].address;
3938

4039
const signingClient = await getSigningOsmosisClient({
41-
rpcEndpoint: getRpcEndpoint(),
40+
rpcEndpoint: await getRpcEndpoint(),
4241
signer: wallet
4342
});
4443

@@ -74,13 +73,12 @@ describe('Token transfers', () => {
7473

7574
it('send ibc osmo tokens to address on cosmos chain', async () => {
7675
const signingClient = await getSigningOsmosisClient({
77-
rpcEndpoint: getRpcEndpoint(),
76+
rpcEndpoint: await getRpcEndpoint(),
7877
signer: wallet
7978
});
8079

8180
const {
8281
chainInfo: cosmosChainInfo,
83-
getStargateClient: cosmosGetStargateClient,
8482
getRpcEndpoint: cosmosRpcEndpoint
8583
} = useChain('cosmoshub');
8684

@@ -139,23 +137,23 @@ describe('Token transfers', () => {
139137
assertIsDeliverTxSuccess(resp);
140138

141139
// Check osmos in address on cosmos chain
142-
const cosmosClient = await cosmosGetStargateClient();
140+
const cosmosClient = await StargateClient.connect(await cosmosRpcEndpoint());
143141
const balances = await cosmosClient.getAllBalances(cosmosAddress);
144142

145143
// check balances
146144
expect(balances.length).toEqual(1);
147145
const ibcBalance = balances.find((balance) => {
148146
return balance.denom.startsWith('ibc/');
149147
});
150-
expect(ibcBalance!.amount).toEqual(token.amount);
151-
expect(ibcBalance!.denom).toContain('ibc/');
148+
expect(ibcBalance.amount).toEqual(token.amount);
149+
expect(ibcBalance.denom).toContain('ibc/');
152150

153151
// check ibc denom trace of the same
154152
const queryClient = await ibc.ClientFactory.createRPCQueryClient({
155-
rpcEndpoint: cosmosRpcEndpoint()
153+
rpcEndpoint: await cosmosRpcEndpoint()
156154
});
157155
const trace = await queryClient.ibc.applications.transfer.v1.denomTrace({
158-
hash: ibcBalance!.denom.replace('ibc/', '')
156+
hash: ibcBalance.denom.replace('ibc/', '')
159157
});
160158
expect(trace?.denomTrace?.baseDenom).toEqual(denom);
161159
}, 200000);

0 commit comments

Comments
 (0)