Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("CosmWasmClient.getTx and .searchTx", () => {
let sendSuccessful: TestTxSend | undefined;

beforeAll(async () => {
if (wasmdEnabled()) {
if (wasmdEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: wasmd.prefix });
const client = await CosmWasmClient.connect(wasmd.endpoint);
const unsuccessfulRecipient = makeRandomAddress();
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ describe("CosmWasmClient", () => {
let contract: HackatomInstance | undefined;

beforeAll(async () => {
if (wasmdEnabled()) {
if (wasmdEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: wasmd.prefix });
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet);
const { codeId } = await client.upload(alice.address0, getHackatom().data, defaultUploadFee);
Expand Down Expand Up @@ -410,7 +410,7 @@ describe("CosmWasmClient", () => {
let contract: HackatomInstance | undefined;

beforeAll(async () => {
if (wasmdEnabled()) {
if (wasmdEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: wasmd.prefix });
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet);
const { codeId } = await client.upload(alice.address0, getHackatom().data, defaultUploadFee);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe("WasmExtension", () => {
let hackatomContractAddress: string | undefined;

beforeAll(async () => {
if (wasmdEnabled()) {
if (wasmdEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: wasmd.prefix });
const result = await uploadContract(wallet, hackatom);
assertIsDeliverTxSuccess(result);
Expand Down
6 changes: 2 additions & 4 deletions packages/cosmwasm-stargate/src/testutils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,10 @@ export const deployedIbcReflect = {
],
};

export function wasmdEnabled(): boolean {
return !!process.env.WASMD_ENABLED;
}
export const wasmdEnabled: boolean = !!globalThis.process?.env.WASMD_ENABLED;

export function pendingWithoutWasmd(): void {
if (!wasmdEnabled()) {
if (!wasmdEnabled) {
pending("Set WASMD_ENABLED to enable Wasmd-based tests");
return;
}
Expand Down
11 changes: 2 additions & 9 deletions packages/faucet/src/api/webserver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import { makeCosmoshubPath } from "@cosmjs/stargate";
import { sleep } from "@cosmjs/utils";

import { Faucet } from "../faucet";
import { simappEnabled } from "../testutils.spec";
import { TokenConfiguration } from "../tokenmanager";
import { ChainConstants, Webserver } from "./webserver";

function pendingWithoutSimapp(): void {
if (!process.env.SIMAPP47_ENABLED && !process.env.SIMAPP50_ENABLED) {
pending("Set SIMAPP{47,50}_ENABLED to enable Stargate node-based tests");
return;
}
}

const defaultTokenConfig: TokenConfiguration = {
bankTokens: ["ucosm", "ustake"],
};
Expand All @@ -22,7 +16,7 @@ const faucetMnemonic =

const testingPort = 62222;

describe("Webserver", () => {
(simappEnabled ? describe : xdescribe)("Webserver", () => {
const pathBuilder = makeCosmoshubPath;

const rpcUrl = "http://localhost:26658";
Expand All @@ -38,7 +32,6 @@ describe("Webserver", () => {
});

it("can be constructed and started", async () => {
pendingWithoutSimapp();
const faucet = await Faucet.make(
rpcUrl,
defaultAddressPrefix,
Expand Down
5 changes: 2 additions & 3 deletions packages/faucet/src/faucet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { makeCosmoshubPath, StargateClient } from "@cosmjs/stargate";
import { assert } from "@cosmjs/utils";

import { Faucet } from "./faucet";
import { simappEnabled } from "./testutils.spec";
import { TokenConfiguration } from "./tokenmanager";

const enabled = !!(globalThis.process?.env.SIMAPP47_ENABLED || globalThis.process?.env.SIMAPP50_ENABLED);

const defaultTokenConfig: TokenConfiguration = {
bankTokens: ["ucosm", "ustake"],
};
Expand All @@ -20,7 +19,7 @@ function makeRandomAddress(): string {
const faucetMnemonic =
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone";

(enabled ? describe : xdescribe)("Faucet", () => {
(simappEnabled ? describe : xdescribe)("Faucet", () => {
const pathBuilder = makeCosmoshubPath;

const apiUrl = "http://localhost:26658";
Expand Down
3 changes: 3 additions & 0 deletions packages/faucet/src/testutils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const simappEnabled = !!(
globalThis.process?.env.SIMAPP47_ENABLED || globalThis.process?.env.SIMAPP50_ENABLED
);
6 changes: 3 additions & 3 deletions packages/ledger-amino/src/ledgersigner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function createTransport(): Promise<Transport> {
return TransportClass.create(interactiveTimeout, interactiveTimeout);
}

(ledgerEnabled() ? describe : xdescribe)("LedgerSigner", () => {
(ledgerEnabled ? describe : xdescribe)("LedgerSigner", () => {
const defaultChainId = "testing";
const defaultFee = calculateFee(100_000, "0.025ucosm");
const defaultMemo = "Some memo";
Expand All @@ -48,7 +48,7 @@ async function createTransport(): Promise<Transport> {
let transport: Transport;

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
const wallet = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(simapp.endpoint, wallet);
const amount = coins(226644, "ucosm");
Expand Down Expand Up @@ -147,7 +147,7 @@ async function createTransport(): Promise<Transport> {
interactiveTimeout,
);

(simappEnabled() ? it : xit)(
(simappEnabled ? it : xit)(
"creates signature accepted by Stargate backend",
async () => {
const signer = new LedgerSigner(transport, {
Expand Down
10 changes: 4 additions & 6 deletions packages/ledger-amino/src/testutils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ export const faucet = {
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
};

export function ledgerEnabled(): boolean {
return !!globalThis.process?.env.LEDGER_ENABLED;
}
export const ledgerEnabled: boolean = !!globalThis.process?.env.LEDGER_ENABLED;

export function simappEnabled(): boolean {
return !!(globalThis.process?.env.SIMAPP47_ENABLED || globalThis.process?.env.SIMAPP50_ENABLED);
}
export const simappEnabled: boolean = !!(
globalThis.process?.env.SIMAPP47_ENABLED || globalThis.process?.env.SIMAPP50_ENABLED
);

export const simapp = {
endpoint: "ws://localhost:26658",
Expand Down
2 changes: 1 addition & 1 deletion packages/socket/src/queueingstreamingsocket.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe("QueueingStreamingSocket", () => {
});
});

describe("connectionStatus", () => {
(enabled ? describe : xdescribe)("connectionStatus", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. Not sure why the tests were even passing on #1809 if this test wasn't being skipped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They did not pass if no Tendermint backend is running. I got the failure locally. But in CI we always have Tendermint running.

it("exposes connection status", async () => {
let done!: (() => void) & { fail: (e?: any) => void };
const ret = new Promise<void>((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/stargate/src/modules/authz/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("AuthzExtension", () => {
const grantedMsg = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic, {
// Use address 1 and 2 instead of 0 to avoid conflicts with other delegation tests
// This must match `voterAddress` above.
Expand Down
2 changes: 1 addition & 1 deletion packages/stargate/src/modules/distribution/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("DistributionExtension", () => {
};

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrlHttp,
Expand Down
4 changes: 2 additions & 2 deletions packages/stargate/src/modules/gov/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("gov messages", () => {
let proposalId: string | undefined;

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
voterWallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic, { hdPaths: voterPaths });
voterWalletAmino = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic, { hdPaths: voterPaths });
const client = await SigningStargateClient.connectWithSigner(
Expand Down Expand Up @@ -208,7 +208,7 @@ describe("gov messages", () => {

it("works with Amino JSON signer", async () => {
pendingWithoutSimapp();
if (simapp50Enabled()) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");
if (simapp50Enabled) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");
assert(voterWalletAmino);
assert(proposalId, "Missing proposal ID");
const client = await SigningStargateClient.connectWithSigner(
Expand Down
2 changes: 1 addition & 1 deletion packages/stargate/src/modules/gov/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("GovExtension", () => {
let proposalId: string | undefined;

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic, {
// Use address 1 and 2 instead of 0 to avoid conflicts with other delegation tests
// This must match `voterAddress` above.
Expand Down
4 changes: 2 additions & 2 deletions packages/stargate/src/modules/staking/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe("staking messages", () => {

it("works with Amino JSON signer", async () => {
pendingWithoutSimapp();
if (simapp50Enabled()) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");
if (simapp50Enabled) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");

const valWallet = await Secp256k1HdWallet.generate();
const [valAccount] = await valWallet.getAccounts();
Expand Down Expand Up @@ -237,7 +237,7 @@ describe("staking messages", () => {

it("works with Amino JSON signer", async () => {
pendingWithoutSimapp();
if (simapp50Enabled()) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");
if (simapp50Enabled) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");

const valWallet = await Secp256k1HdWallet.generate();
const [valAccount] = await valWallet.getAccounts();
Expand Down
2 changes: 1 addition & 1 deletion packages/stargate/src/modules/staking/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("StakingExtension", () => {
};

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrlHttp,
Expand Down
2 changes: 1 addition & 1 deletion packages/stargate/src/modules/tx/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("TxExtension", () => {
let memo: string | undefined;

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrlHttp,
Expand Down
4 changes: 2 additions & 2 deletions packages/stargate/src/signingstargateclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("SigningStargateClient", () => {
);
assertIsDeliverTxSuccess(result);

if (simapp50Enabled()) {
if (simapp50Enabled) {
expect(result.rawLog).toEqual(""); // empty now (https://github.com/cosmos/cosmos-sdk/pull/15845)
} else {
expect(result.rawLog).toBeTruthy();
Expand Down Expand Up @@ -163,7 +163,7 @@ describe("SigningStargateClient", () => {
);
assertIsDeliverTxSuccess(result);

if (simapp50Enabled()) {
if (simapp50Enabled) {
expect(result.rawLog).toEqual(""); // empty now (https://github.com/cosmos/cosmos-sdk/pull/15845)
} else {
expect(result.rawLog).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion packages/stargate/src/stargateclient.searchtx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("StargateClient.getTx and .searchTx", () => {
let sendSuccessful: TestTxSend | undefined;

beforeAll(async () => {
if (simappEnabled()) {
if (simappEnabled) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await StargateClient.connect(simapp.tendermintUrlHttp);
const unsuccessfulRecipient = makeRandomAddress();
Expand Down
6 changes: 3 additions & 3 deletions packages/stargate/src/stargateclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ describe("StargateClient", () => {

const { gasUsed, rawLog, transactionHash } = txResult;
expect(gasUsed).toBeGreaterThan(0);
if (simapp50Enabled()) {
if (simapp50Enabled) {
expect(rawLog).toEqual(""); // empty now (https://github.com/cosmos/cosmos-sdk/pull/15845)
} else {
expect(rawLog).toMatch(/{"key":"amount","value":"1234567ucosm"}/);
Expand Down Expand Up @@ -466,13 +466,13 @@ describe("StargateClient", () => {
assert(false, "Expected broadcastTx to throw");
} catch (error: any) {
expect(error).toMatch(
simapp47Enabled()
simapp47Enabled
? /Broadcasting transaction failed with code 7/i
: // New error code for SDK 0.50+
/Broadcasting transaction failed with code 4/i,
);
assert(error instanceof BroadcastTxError);
if (simapp50Enabled()) {
if (simapp50Enabled) {
// New error code for SDK 0.50+
expect(error.code).toEqual(4);
} else {
Expand Down
23 changes: 7 additions & 16 deletions packages/stargate/src/testutils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,22 @@ import { AuthInfo, SignDoc, TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { calculateFee, GasPrice } from "./fee";
import { SigningStargateClientOptions } from "./signingstargateclient";

export function simapp47Enabled(): boolean {
return !!process.env.SIMAPP47_ENABLED;
}

export function simapp50Enabled(): boolean {
return !!process.env.SIMAPP50_ENABLED;
}

export function simappEnabled(): boolean {
return simapp47Enabled() || simapp50Enabled();
}
export const simapp47Enabled: boolean = !!globalThis.process?.env.SIMAPP47_ENABLED;
export const simapp50Enabled: boolean = !!globalThis.process?.env.SIMAPP50_ENABLED;
export const simappEnabled: boolean = simapp47Enabled || simapp50Enabled;

export function pendingWithoutSimapp(): void {
if (!simappEnabled()) {
if (!simappEnabled) {
pending("Set SIMAPP{47,50}_ENABLED to enable Simapp based tests");
return;
}
}

export function slowSimappEnabled(): boolean {
return !!process.env.SLOW_SIMAPP47_ENABLED || !!process.env.SLOW_SIMAPP50_ENABLED;
}
export const slowSimappEnabled: boolean =
!!globalThis.process?.env.SLOW_SIMAPP47_ENABLED || !!globalThis.process?.env.SLOW_SIMAPP50_ENABLED;

export function pendingWithoutSlowSimapp(): void {
if (!slowSimappEnabled()) {
if (!slowSimappEnabled) {
pending("Set SLOW_SIMAPP{47,50}_ENABLED to enable slow Simapp based tests");
return;
}
Expand Down
Loading
Loading