Skip to content

Commit

Permalink
fix integration tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo committed Sep 5, 2024
1 parent a372a9b commit b05af9d
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 40 deletions.
2 changes: 1 addition & 1 deletion integration-tests/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ IMPORTANT: `@cosmjs/*` dependencies must match the versions used by stridejs. To
### test new protobufs

- go to https://github.com/Stride-Labs/stridejs
- update the config in `scripts/clone_repos.ts` to point to the new `stride/cosmos-sdk/ibc-go` version
- update the config in `scripts/clone_repos.ts` to point to the new `stride`, `cosmos-sdk`, `ibc-go`, `wasmd` versions
- run `pnpm i`
- run `pnpm codegen`
- run `git commit...`
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"bech32": "2.0.0",
"jest": "29.7.0",
"prettier": "3.3.3",
"stridejs": "github:Stride-Labs/stridejs#f369bd62361a6879f182038c2648c33348863a7e",
"stridejs": "github:Stride-Labs/stridejs#f8ed078fba0b6cd818487d8fa7059b9b916ca355",
"typescript": "5.5.3",
"vitest": "2.0.3"
},
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/client/pnpm-lock.yaml

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

52 changes: 27 additions & 25 deletions integration-tests/client/test/core.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { Secp256k1HdWallet } from "@cosmjs/amino";
import { GasPrice } from "@cosmjs/stargate";
import {
StrideClient,
ibcDenom,
coinFromString,
convertBech32Prefix,
} from "stridejs";
import { StrideClient, ibcDenom } from "stridejs";
import { beforeAll, describe, test } from "vitest";
import { waitForChain, submitTxAndExpectSuccess } from "./utils";
import { submitTxAndExpectSuccess, waitForChain } from "./utils";

const RPC_ENDPOINT = "https://stride-rpc.internal.stridenet.co";

Expand Down Expand Up @@ -90,7 +85,10 @@ describe("x/stakeibc", () => {
creator: stridejs.address,
bech32prefix: "cosmos",
hostDenom: "uatom",
ibcDenom: ibcDenom([{incomingPortId: "transfer", incomingChannelId: "channel-0"}], "uatom"),
ibcDenom: ibcDenom(
[{ incomingPortId: "transfer", incomingChannelId: "channel-0" }],
"uatom",
),
connectionId: "connection-0",
transferChannelId: "channel-0",
unbondingPeriod: BigInt(1),
Expand All @@ -99,26 +97,30 @@ describe("x/stakeibc", () => {
lsmLiquidStakeEnabled: true,
communityPoolTreasuryAddress: "",
maxMessagesPerIcaTx: BigInt(2),
})

const msg = stridejs.types.stride.stakeibc.MessageComposer.withTypeUrl.registerHostZone({
creator: stridejs.address,
bech32prefix: "cosmos",
hostDenom: "uatom",
ibcDenom: ibcDenom([{incomingPortId: "transfer", incomingChannelId: "channel-0"}], "uatom"),
connectionId: "connection-0",
transferChannelId: "channel-0",
unbondingPeriod: BigInt(1),
minRedemptionRate: "0.9",
maxRedemptionRate: "1.5",
lsmLiquidStakeEnabled: true,
communityPoolTreasuryAddress: "",
maxMessagesPerIcaTx: BigInt(2),
});

const msg =
stridejs.types.stride.stakeibc.MessageComposer.withTypeUrl.registerHostZone(
{
creator: stridejs.address,
bech32prefix: "cosmos",
hostDenom: "uatom",
ibcDenom: ibcDenom(
[{ incomingPortId: "transfer", incomingChannelId: "channel-0" }],
"uatom",
),
connectionId: "connection-0",
transferChannelId: "channel-0",
unbondingPeriod: BigInt(1),
minRedemptionRate: "0.9",
maxRedemptionRate: "1.5",
lsmLiquidStakeEnabled: true,
communityPoolTreasuryAddress: "",
maxMessagesPerIcaTx: BigInt(2),
},
);

await submitTxAndExpectSuccess(stridejs, [msg]);
console.log(stridejs.query.stride.stakeibc.hostZoneAll());
});
});


13 changes: 7 additions & 6 deletions integration-tests/client/test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ describe("x/airdrop", () => {
}
expect(tx.code).toBe(0);

const { airdrop } = await stridejs.query.stride.airdrop.airdrop({
id: airdropId,
});
const { id, earlyClaimPenalty } =
await stridejs.query.stride.airdrop.airdrop({
id: airdropId,
});

expect(airdrop!.id).toBe(airdropId);
expect(airdrop!.earlyClaimPenalty).toBe("0.5");
expect(id).toBe(airdropId);
expect(earlyClaimPenalty).toBe("0.5");
});
});

Expand All @@ -145,7 +146,7 @@ describe("ibc", () => {
revisionHeight: 0n,
},
timeoutTimestamp: BigInt(
`${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes
`${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes
),
memo: "",
},
Expand Down
23 changes: 21 additions & 2 deletions integration-tests/client/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { coinsFromString, StrideClient } from "stridejs";
import { coinsFromString, EncodeObject, StrideClient } from "stridejs";
import { expect } from "vitest";

/**
* Waits for the chain to start by continuously sending transactions until .
Expand Down Expand Up @@ -30,4 +31,22 @@ export async function waitForChain(
// signAndBroadcast might throw if the RPC is not up yet
}
}
}
}

/**
* Submit a transaction and wait for it to be broadcasted and executed.
*
* @param {StrideClient} stridejs The Stride client instance.
* @param {any[]} msgs The messages array.
*/
export async function submitTxAndExpectSuccess(
stridejs: StrideClient,
msgs: EncodeObject[],
): Promise<void> {
const tx = await stridejs.signAndBroadcast(msgs, 2);

if (tx.code !== 0) {
console.error(tx.rawLog);
}
expect(tx.code).toBe(0);
}

0 comments on commit b05af9d

Please sign in to comment.