From 39091439d9994aa6ecdb7fa3dcae142ee5747dd2 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 8 Oct 2025 09:18:51 +0200 Subject: [PATCH 1/3] Fix test skipping of "connectionStatus" This was missed in https://github.com/cosmos/cosmjs/pull/1809 --- packages/socket/src/queueingstreamingsocket.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/socket/src/queueingstreamingsocket.spec.ts b/packages/socket/src/queueingstreamingsocket.spec.ts index 772ede0d16..a17c21e5ab 100644 --- a/packages/socket/src/queueingstreamingsocket.spec.ts +++ b/packages/socket/src/queueingstreamingsocket.spec.ts @@ -146,7 +146,7 @@ describe("QueueingStreamingSocket", () => { }); }); - describe("connectionStatus", () => { + (enabled ? describe : xdescribe)("connectionStatus", () => { it("exposes connection status", async () => { let done!: (() => void) & { fail: (e?: any) => void }; const ret = new Promise((resolve, reject) => { From e96fefa13cf9a2bc2456b562789fcb7c830332bd Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 8 Oct 2025 09:13:05 +0200 Subject: [PATCH 2/3] Improve consistency for skipping tests Follow-up of https://github.com/cosmos/cosmjs/pull/1809 --- .../src/cosmwasmclient.searchtx.spec.ts | 2 +- .../src/cosmwasmclient.spec.ts | 4 +- .../src/modules/wasm/queries.spec.ts | 2 +- .../cosmwasm-stargate/src/testutils.spec.ts | 6 +- packages/faucet/src/api/webserver.spec.ts | 11 +-- packages/faucet/src/faucet.spec.ts | 5 +- packages/faucet/src/testutils.spec.ts | 3 + .../ledger-amino/src/ledgersigner.spec.ts | 6 +- packages/ledger-amino/src/testutils.spec.ts | 10 ++- .../src/modules/authz/queries.spec.ts | 2 +- .../src/modules/distribution/queries.spec.ts | 2 +- .../stargate/src/modules/gov/messages.spec.ts | 4 +- .../stargate/src/modules/gov/queries.spec.ts | 2 +- .../src/modules/staking/messages.spec.ts | 4 +- .../src/modules/staking/queries.spec.ts | 2 +- .../stargate/src/modules/tx/queries.spec.ts | 2 +- .../src/signingstargateclient.spec.ts | 4 +- .../src/stargateclient.searchtx.spec.ts | 2 +- packages/stargate/src/stargateclient.spec.ts | 6 +- packages/stargate/src/testutils.spec.ts | 23 ++----- .../src/comet38/comet38client.spec.ts | 69 +++++-------------- .../src/rpcclients/http.spec.ts | 5 +- .../src/rpcclients/httpbatchclient.spec.ts | 12 +--- .../src/rpcclients/httpclient.spec.ts | 11 +-- .../src/rpcclients/rpcclient.spec.ts | 14 +--- .../src/rpcclients/websocketclient.spec.ts | 23 +------ .../tendermint34/tendermint34client.spec.ts | 61 ++++------------ .../tendermint37/tendermint37client.spec.ts | 61 ++++------------ packages/tendermint-rpc/src/testutil.spec.ts | 10 +-- 29 files changed, 95 insertions(+), 273 deletions(-) create mode 100644 packages/faucet/src/testutils.spec.ts diff --git a/packages/cosmwasm-stargate/src/cosmwasmclient.searchtx.spec.ts b/packages/cosmwasm-stargate/src/cosmwasmclient.searchtx.spec.ts index 9e2db7fac9..aa60aedee9 100644 --- a/packages/cosmwasm-stargate/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/cosmwasm-stargate/src/cosmwasmclient.searchtx.spec.ts @@ -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(); diff --git a/packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts b/packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts index 35e457ffdf..072fecebb4 100644 --- a/packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts +++ b/packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts @@ -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); @@ -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); diff --git a/packages/cosmwasm-stargate/src/modules/wasm/queries.spec.ts b/packages/cosmwasm-stargate/src/modules/wasm/queries.spec.ts index 61087cac56..ed75d05cfb 100644 --- a/packages/cosmwasm-stargate/src/modules/wasm/queries.spec.ts +++ b/packages/cosmwasm-stargate/src/modules/wasm/queries.spec.ts @@ -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); diff --git a/packages/cosmwasm-stargate/src/testutils.spec.ts b/packages/cosmwasm-stargate/src/testutils.spec.ts index c18a2a8329..25d99dcf4f 100644 --- a/packages/cosmwasm-stargate/src/testutils.spec.ts +++ b/packages/cosmwasm-stargate/src/testutils.spec.ts @@ -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; } diff --git a/packages/faucet/src/api/webserver.spec.ts b/packages/faucet/src/api/webserver.spec.ts index 1e68c9da84..b665f354d9 100644 --- a/packages/faucet/src/api/webserver.spec.ts +++ b/packages/faucet/src/api/webserver.spec.ts @@ -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"], }; @@ -22,7 +16,7 @@ const faucetMnemonic = const testingPort = 62222; -describe("Webserver", () => { +(simappEnabled ? describe : xdescribe)("Webserver", () => { const pathBuilder = makeCosmoshubPath; const rpcUrl = "http://localhost:26658"; @@ -38,7 +32,6 @@ describe("Webserver", () => { }); it("can be constructed and started", async () => { - pendingWithoutSimapp(); const faucet = await Faucet.make( rpcUrl, defaultAddressPrefix, diff --git a/packages/faucet/src/faucet.spec.ts b/packages/faucet/src/faucet.spec.ts index f0642f61e6..5409000dfc 100644 --- a/packages/faucet/src/faucet.spec.ts +++ b/packages/faucet/src/faucet.spec.ts @@ -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"], }; @@ -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"; diff --git a/packages/faucet/src/testutils.spec.ts b/packages/faucet/src/testutils.spec.ts new file mode 100644 index 0000000000..ee9d17768a --- /dev/null +++ b/packages/faucet/src/testutils.spec.ts @@ -0,0 +1,3 @@ +export const simappEnabled = !!( + globalThis.process?.env.SIMAPP47_ENABLED || globalThis.process?.env.SIMAPP50_ENABLED +); diff --git a/packages/ledger-amino/src/ledgersigner.spec.ts b/packages/ledger-amino/src/ledgersigner.spec.ts index 6b65a39255..2ce001b343 100644 --- a/packages/ledger-amino/src/ledgersigner.spec.ts +++ b/packages/ledger-amino/src/ledgersigner.spec.ts @@ -38,7 +38,7 @@ async function createTransport(): Promise { 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"; @@ -48,7 +48,7 @@ async function createTransport(): Promise { 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"); @@ -147,7 +147,7 @@ async function createTransport(): Promise { interactiveTimeout, ); - (simappEnabled() ? it : xit)( + (simappEnabled ? it : xit)( "creates signature accepted by Stargate backend", async () => { const signer = new LedgerSigner(transport, { diff --git a/packages/ledger-amino/src/testutils.spec.ts b/packages/ledger-amino/src/testutils.spec.ts index 0c9409e544..04f12e079a 100644 --- a/packages/ledger-amino/src/testutils.spec.ts +++ b/packages/ledger-amino/src/testutils.spec.ts @@ -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", diff --git a/packages/stargate/src/modules/authz/queries.spec.ts b/packages/stargate/src/modules/authz/queries.spec.ts index 3c65ea251a..bdb3809322 100644 --- a/packages/stargate/src/modules/authz/queries.spec.ts +++ b/packages/stargate/src/modules/authz/queries.spec.ts @@ -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. diff --git a/packages/stargate/src/modules/distribution/queries.spec.ts b/packages/stargate/src/modules/distribution/queries.spec.ts index 59e0e7d99a..755ef5f928 100644 --- a/packages/stargate/src/modules/distribution/queries.spec.ts +++ b/packages/stargate/src/modules/distribution/queries.spec.ts @@ -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, diff --git a/packages/stargate/src/modules/gov/messages.spec.ts b/packages/stargate/src/modules/gov/messages.spec.ts index dbd8becf3c..7f47b08a9c 100644 --- a/packages/stargate/src/modules/gov/messages.spec.ts +++ b/packages/stargate/src/modules/gov/messages.spec.ts @@ -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( @@ -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( diff --git a/packages/stargate/src/modules/gov/queries.spec.ts b/packages/stargate/src/modules/gov/queries.spec.ts index 1cb9dbc85e..e9d7cb0abc 100644 --- a/packages/stargate/src/modules/gov/queries.spec.ts +++ b/packages/stargate/src/modules/gov/queries.spec.ts @@ -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. diff --git a/packages/stargate/src/modules/staking/messages.spec.ts b/packages/stargate/src/modules/staking/messages.spec.ts index 36c4b5093b..06c4c009fd 100644 --- a/packages/stargate/src/modules/staking/messages.spec.ts +++ b/packages/stargate/src/modules/staking/messages.spec.ts @@ -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(); @@ -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(); diff --git a/packages/stargate/src/modules/staking/queries.spec.ts b/packages/stargate/src/modules/staking/queries.spec.ts index 9801a334fb..ad051f0143 100644 --- a/packages/stargate/src/modules/staking/queries.spec.ts +++ b/packages/stargate/src/modules/staking/queries.spec.ts @@ -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, diff --git a/packages/stargate/src/modules/tx/queries.spec.ts b/packages/stargate/src/modules/tx/queries.spec.ts index c3ba17853e..ad395de4fe 100644 --- a/packages/stargate/src/modules/tx/queries.spec.ts +++ b/packages/stargate/src/modules/tx/queries.spec.ts @@ -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, diff --git a/packages/stargate/src/signingstargateclient.spec.ts b/packages/stargate/src/signingstargateclient.spec.ts index 8111c03a9e..f905ea1f7a 100644 --- a/packages/stargate/src/signingstargateclient.spec.ts +++ b/packages/stargate/src/signingstargateclient.spec.ts @@ -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(); @@ -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(); diff --git a/packages/stargate/src/stargateclient.searchtx.spec.ts b/packages/stargate/src/stargateclient.searchtx.spec.ts index f378ebdadb..c33dfbc426 100644 --- a/packages/stargate/src/stargateclient.searchtx.spec.ts +++ b/packages/stargate/src/stargateclient.searchtx.spec.ts @@ -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(); diff --git a/packages/stargate/src/stargateclient.spec.ts b/packages/stargate/src/stargateclient.spec.ts index 1ad5f9d73b..9984cd2f27 100644 --- a/packages/stargate/src/stargateclient.spec.ts +++ b/packages/stargate/src/stargateclient.spec.ts @@ -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"}/); @@ -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 { diff --git a/packages/stargate/src/testutils.spec.ts b/packages/stargate/src/testutils.spec.ts index 9eb17f9f9d..9122be90ce 100644 --- a/packages/stargate/src/testutils.spec.ts +++ b/packages/stargate/src/testutils.spec.ts @@ -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; } diff --git a/packages/tendermint-rpc/src/comet38/comet38client.spec.ts b/packages/tendermint-rpc/src/comet38/comet38client.spec.ts index 64c5889d52..5c2fe96617 100644 --- a/packages/tendermint-rpc/src/comet38/comet38client.spec.ts +++ b/packages/tendermint-rpc/src/comet38/comet38client.spec.ts @@ -9,7 +9,6 @@ import { buildKvTx, ExpectedValues, nonNegativeIntegerMatcher, - pendingWithoutTendermint, randomString, tendermintEnabled, tendermintInstances, @@ -20,10 +19,13 @@ import { hashTx } from "./hasher"; import { buildQuery } from "./requests"; import * as responses from "./responses"; +/** + * Runs tests using given client. A compatible backend must be running for this suite. + * Code that does not require a functional backend should be extracted and tested low-level. + */ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { describe("create", () => { it("can auto-discover Tendermint version and communicate", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const info = await client.abciInfo(); expect(info).toBeTruthy(); @@ -31,7 +33,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can connect to Tendermint with known version", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); expect(await client.abciInfo()).toBeTruthy(); client.disconnect(); @@ -39,7 +40,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get genesis", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const genesis = await client.genesis(); expect(genesis).toBeTruthy(); @@ -48,7 +48,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxCommit", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -68,7 +67,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxSync", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -84,7 +82,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxAsync", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -96,7 +93,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("gets the same tx hash from backend as calculated locally", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); const calculatedTxHash = hashTx(tx); @@ -109,7 +105,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("abciQuery", () => { it("can query the state", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const key = randomString(); @@ -135,7 +130,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get a commit", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const response = await client.commit(4); @@ -150,7 +144,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get validators", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const response = await client.validators({}); @@ -168,7 +161,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all validators", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const response = await client.validatorsAll(); @@ -186,7 +178,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can call a bunch of methods", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); expect(await client.block()).toBeTruthy(); @@ -198,7 +189,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("status", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const status = await client.status(); @@ -239,7 +229,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("numUnconfirmedTxs", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const response = await client.numUnconfirmedTxs(); @@ -253,7 +242,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockResults", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const height = 3; @@ -268,7 +256,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockSearch", () => { beforeAll(async () => { - if (tendermintEnabled()) { + if (tendermintEnabled) { const client = Comet38Client.create(rpcFactory()); async function sendTx(): Promise { @@ -292,7 +280,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can paginate over blockSearch results", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" }); @@ -311,7 +298,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all search results in one call", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" }); @@ -330,7 +316,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockchain", () => { it("returns latest in descending order by default", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); // Run in parallel to increase chance there is no block between the calls @@ -347,7 +332,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can limit by maxHeight", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -361,7 +345,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("works with maxHeight in the future", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -376,7 +359,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can limit by minHeight and maxHeight", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -390,7 +372,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("contains all the info", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -419,7 +400,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("tx", () => { it("can query a tx properly", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const find = randomString(); @@ -459,7 +439,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) let broadcast1: responses.BroadcastTxCommitResponse | undefined; beforeAll(async () => { - if (tendermintEnabled()) { + if (tendermintEnabled) { const client = Comet38Client.create(rpcFactory()); async function sendTx(): Promise<[Uint8Array, responses.BroadcastTxCommitResponse]> { @@ -485,7 +465,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("finds a single tx by hash", async () => { - pendingWithoutTendermint(); assert(tx1 && broadcast1); const client = Comet38Client.create(rpcFactory()); @@ -508,7 +487,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("finds a single tx by tags", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const txKey2 = randomString(); @@ -558,7 +536,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) // Code 0.34: https://github.com/tendermint/tendermint/blob/v0.34.10/rpc/core/tx.go#L89 // Code 0.35: https://github.com/tendermint/tendermint/blob/v0.35.6/internal/rpc/core/tx.go#L93 // Code 0.37: https://github.com/cometbft/cometbft/blob/v0.37.0-rc3/rpc/core/tx.go#L87 - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -575,7 +552,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can set the order", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -590,7 +566,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can paginate over txSearch results", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -609,7 +584,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all search results in one call", async () => { - pendingWithoutTendermint(); const client = Comet38Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -626,6 +600,10 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); } +/** + * Runs tests using given client. A compatible backend must be running for this suite. + * Code that does not require a functional backend should be extracted and tested low-level. + */ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { it("can subscribe to block header events", async () => { let done!: (() => void) & { fail: (e?: any) => void }; @@ -633,7 +611,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue done = resolve as typeof done; done.fail = reject; }); - pendingWithoutTendermint(); const testStart = ReadonlyDate.now(); @@ -694,8 +671,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to block events", async () => { - pendingWithoutTendermint(); - const testStart = ReadonlyDate.now(); const transactionData1 = buildKvTx(randomString(), randomString()); @@ -758,8 +733,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to transaction events", async () => { - pendingWithoutTendermint(); - const events: responses.TxEvent[] = []; const client = Comet38Client.create(rpcFactory()); const stream = client.subscribeTx(); @@ -799,8 +772,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to transaction events filtered by creator", async () => { - pendingWithoutTendermint(); - const transactionData1 = buildKvTx(randomString(), randomString()); const transactionData2 = buildKvTx(randomString(), randomString()); @@ -841,8 +812,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can unsubscribe and re-subscribe to the same stream", async () => { - pendingWithoutTendermint(); - const client = Comet38Client.create(rpcFactory()); const stream = client.subscribeNewBlockHeader(); @@ -874,8 +843,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe twice", async () => { - pendingWithoutTendermint(); - const client = Comet38Client.create(rpcFactory()); const stream1 = client.subscribeNewBlockHeader(); const stream2 = client.subscribeNewBlockHeader(); @@ -891,9 +858,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue describe("Comet38Client with CometBFT 0.38 backend", () => { const { url, expected } = tendermintInstances[38]; - it("can connect to a given url", async () => { - pendingWithoutTendermint(); - + (tendermintEnabled ? it : xit)("can connect to a given url", async () => { // http connection { const client = await Comet38Client.connect("http://" + url); @@ -911,11 +876,11 @@ describe("Comet38Client with CometBFT 0.38 backend", () => { } }); - describe("With HttpClient", () => { + (tendermintEnabled ? describe : xdescribe)("With HttpClient", () => { defaultTestSuite(() => new HttpClient("http://" + url), expected); }); - describe("With WebsocketClient", () => { + (tendermintEnabled ? describe : xdescribe)("With WebsocketClient", () => { // don't print out WebSocket errors if marked pending const onError = globalThis.process?.env.TENDERMINT_ENABLED ? console.error : () => 0; const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError); @@ -927,9 +892,7 @@ describe("Comet38Client with CometBFT 0.38 backend", () => { describe("Comet38Client with CometBFT 1 backend", () => { const { url, expected } = tendermintInstances[1]; - it("can connect to a given url", async () => { - pendingWithoutTendermint(); - + (tendermintEnabled ? it : xit)("can connect to a given url", async () => { // http connection { const client = await Comet38Client.connect("http://" + url); @@ -947,11 +910,11 @@ describe("Comet38Client with CometBFT 1 backend", () => { } }); - describe("With HttpClient", () => { + (tendermintEnabled ? describe : xdescribe)("With HttpClient", () => { defaultTestSuite(() => new HttpClient("http://" + url), expected); }); - describe("With WebsocketClient", () => { + (tendermintEnabled ? describe : xdescribe)("With WebsocketClient", () => { // don't print out WebSocket errors if marked pending const onError = globalThis.process?.env.TENDERMINT_ENABLED ? console.error : () => 0; const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError); diff --git a/packages/tendermint-rpc/src/rpcclients/http.spec.ts b/packages/tendermint-rpc/src/rpcclients/http.spec.ts index 3eb16f324b..1b33e40571 100644 --- a/packages/tendermint-rpc/src/rpcclients/http.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/http.spec.ts @@ -1,5 +1,5 @@ import { createJsonRpcRequest } from "../jsonrpc"; -import { defaultInstance, pendingWithoutTendermint } from "../testutil.spec"; +import { defaultInstance, tendermintEnabled } from "../testutil.spec"; import { http } from "./http"; function pendingWithoutHttpServer(): void { @@ -13,8 +13,7 @@ const tendermintUrl = defaultInstance.url; const echoUrl = "http://localhost:5555/echo_headers"; describe("http", () => { - it("can send a health request", async () => { - pendingWithoutTendermint(); + (tendermintEnabled ? it : xit)("can send a health request", async () => { const response = await http("POST", `http://${tendermintUrl}`, undefined, createJsonRpcRequest("health")); expect(response).toEqual(jasmine.objectContaining({ jsonrpc: "2.0" })); }); diff --git a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts index 831c0ed52a..a3ac6f35f0 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts @@ -1,18 +1,11 @@ import { createJsonRpcRequest } from "../jsonrpc"; -import { defaultInstance } from "../testutil.spec"; +import { defaultInstance, tendermintEnabled } from "../testutil.spec"; import { HttpBatchClient } from "./httpbatchclient"; -function pendingWithoutTendermint(): void { - if (!process.env.TENDERMINT_ENABLED) { - pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests"); - } -} - -describe("HttpBatchClient", () => { +(tendermintEnabled ? describe : xdescribe)("HttpBatchClient", () => { const tendermintUrl = "http://" + defaultInstance.url; it("can make a simple call", async () => { - pendingWithoutTendermint(); const client = new HttpBatchClient(tendermintUrl); const healthResponse = await client.execute(createJsonRpcRequest("health")); @@ -35,7 +28,6 @@ describe("HttpBatchClient", () => { }); it("dispatches requests as soon as batch size limit is reached", async () => { - pendingWithoutTendermint(); const client = new HttpBatchClient(tendermintUrl, { dispatchInterval: 3600_000 /* 1h to make test time out if this is not working */, batchSizeLimit: 3, diff --git a/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts b/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts index 15486bc15f..0668d8a8da 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts @@ -1,18 +1,11 @@ import { createJsonRpcRequest } from "../jsonrpc"; -import { defaultInstance } from "../testutil.spec"; +import { defaultInstance, tendermintEnabled } from "../testutil.spec"; import { HttpClient } from "./httpclient"; -function pendingWithoutTendermint(): void { - if (!process.env.TENDERMINT_ENABLED) { - pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests"); - } -} - -describe("HttpClient", () => { +(tendermintEnabled ? describe : xdescribe)("HttpClient", () => { const tendermintUrl = "http://" + defaultInstance.url; it("can make a simple call", async () => { - pendingWithoutTendermint(); const client = new HttpClient(tendermintUrl); const healthResponse = await client.execute(createJsonRpcRequest("health")); diff --git a/packages/tendermint-rpc/src/rpcclients/rpcclient.spec.ts b/packages/tendermint-rpc/src/rpcclients/rpcclient.spec.ts index 8720ffd256..37262534cb 100644 --- a/packages/tendermint-rpc/src/rpcclients/rpcclient.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/rpcclient.spec.ts @@ -1,22 +1,14 @@ import { createJsonRpcRequest } from "../jsonrpc"; -import { defaultInstance } from "../testutil.spec"; +import { defaultInstance, tendermintEnabled } from "../testutil.spec"; import { HttpClient } from "./httpclient"; import { hasProtocol, instanceOfRpcStreamingClient } from "./rpcclient"; import { WebsocketClient } from "./websocketclient"; -function pendingWithoutTendermint(): void { - if (!process.env.TENDERMINT_ENABLED) { - pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests"); - } -} - -describe("RpcClient", () => { +(tendermintEnabled ? describe : xdescribe)("RpcClient", () => { const httpUrl = "http://" + defaultInstance.url; const wsUrl = "ws://" + defaultInstance.url; it("has working instanceOfRpcStreamingClient()", async () => { - pendingWithoutTendermint(); - const httpClient = new HttpClient(httpUrl); const wsClient = new WebsocketClient(wsUrl); @@ -29,8 +21,6 @@ describe("RpcClient", () => { }); it("should also work with trailing slashes", async () => { - pendingWithoutTendermint(); - const statusRequest = createJsonRpcRequest("status"); const httpClient = new HttpClient(httpUrl + "/"); diff --git a/packages/tendermint-rpc/src/rpcclients/websocketclient.spec.ts b/packages/tendermint-rpc/src/rpcclients/websocketclient.spec.ts index bef1529bfa..908b25c7c7 100644 --- a/packages/tendermint-rpc/src/rpcclients/websocketclient.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/websocketclient.spec.ts @@ -3,24 +3,15 @@ import { toListPromise } from "@cosmjs/stream"; import { Stream } from "xstream"; import { createJsonRpcRequest } from "../jsonrpc"; -import { defaultInstance } from "../testutil.spec"; +import { defaultInstance, tendermintEnabled } from "../testutil.spec"; import { SubscriptionEvent } from "./rpcclient"; import { WebsocketClient } from "./websocketclient"; -function pendingWithoutTendermint(): void { - if (globalThis.process?.env.TENDERMINT_ENABLED) { - return; - } - pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests"); -} - -describe("WebsocketClient", () => { +(tendermintEnabled ? describe : xdescribe)("WebsocketClient", () => { const { blockTime, url } = defaultInstance; const tendermintUrl = "ws://" + url; it("can make a simple call", async () => { - pendingWithoutTendermint(); - const client = new WebsocketClient(tendermintUrl); const healthResponse = await client.execute(createJsonRpcRequest("health")); @@ -48,7 +39,6 @@ describe("WebsocketClient", () => { done = resolve as typeof done; done.fail = reject; }); - pendingWithoutTendermint(); const client = new WebsocketClient(tendermintUrl); @@ -90,8 +80,6 @@ describe("WebsocketClient", () => { }); it("can listen to the same query twice", async () => { - pendingWithoutTendermint(); - const client = new WebsocketClient(tendermintUrl); const newBlockHeaderQuery = "tm.event='NewBlockHeader'"; @@ -120,7 +108,6 @@ describe("WebsocketClient", () => { done = resolve as typeof done; done.fail = reject; }); - pendingWithoutTendermint(); const client = new WebsocketClient(tendermintUrl); @@ -169,7 +156,6 @@ describe("WebsocketClient", () => { done = resolve as typeof done; done.fail = reject; }); - pendingWithoutTendermint(); const client = new WebsocketClient(tendermintUrl); @@ -196,8 +182,6 @@ describe("WebsocketClient", () => { }); it("fails when executing on a disconnected client", async () => { - pendingWithoutTendermint(); - const client = new WebsocketClient(tendermintUrl); // dummy command to ensure client is connected await client.execute(createJsonRpcRequest("health")); @@ -220,7 +204,6 @@ describe("WebsocketClient", () => { done = resolve as typeof done; done.fail = reject; }); - pendingWithoutTendermint(); // async and done does not work together with pending() in Jasmine 2.8 (async () => { @@ -240,8 +223,6 @@ describe("WebsocketClient", () => { }); it("cannot listen to simple requests", async () => { - pendingWithoutTendermint(); - const client = new WebsocketClient(tendermintUrl); const req = createJsonRpcRequest("health"); diff --git a/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts b/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts index bf0af928ee..08292ebc3e 100644 --- a/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts +++ b/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts @@ -9,7 +9,6 @@ import { buildKvTx, ExpectedValues, nonNegativeIntegerMatcher, - pendingWithoutTendermint, randomString, tendermintEnabled, tendermintInstances, @@ -20,10 +19,13 @@ import { buildQuery } from "./requests"; import * as responses from "./responses"; import { Tendermint34Client } from "./tendermint34client"; +/** + * Runs tests using given client. A compatible backend must be running for this suite. + * Code that does not require a functional backend should be extracted and tested low-level. + */ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { describe("create", () => { it("can auto-discover Tendermint version and communicate", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const info = await client.abciInfo(); expect(info).toBeTruthy(); @@ -31,7 +33,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can connect to Tendermint with known version", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); expect(await client.abciInfo()).toBeTruthy(); client.disconnect(); @@ -39,7 +40,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get genesis", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const genesis = await client.genesis(); expect(genesis).toBeTruthy(); @@ -48,7 +48,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxCommit", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -68,7 +67,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxSync", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -84,7 +82,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxAsync", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -96,7 +93,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("gets the same tx hash from backend as calculated locally", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); const calculatedTxHash = hashTx(tx); @@ -109,7 +105,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("abciQuery", () => { it("can query the state", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const key = randomString(); @@ -135,7 +130,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get a commit", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const response = await client.commit(4); @@ -150,7 +144,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get validators", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const response = await client.validators({}); @@ -168,7 +161,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all validators", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const response = await client.validatorsAll(); @@ -186,7 +178,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can call a bunch of methods", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); expect(await client.block()).toBeTruthy(); @@ -198,7 +189,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("status", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const status = await client.status(); @@ -239,7 +229,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("numUnconfirmedTxs", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const response = await client.numUnconfirmedTxs(); @@ -253,7 +242,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockResults", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const height = 3; @@ -269,7 +257,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockSearch", () => { beforeAll(async () => { - if (tendermintEnabled()) { + if (tendermintEnabled) { const client = Tendermint34Client.create(rpcFactory()); async function sendTx(): Promise { @@ -293,7 +281,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can paginate over blockSearch results", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" }); @@ -312,7 +299,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all search results in one call", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" }); @@ -331,7 +317,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockchain", () => { it("returns latest in descending order by default", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); // Run in parallel to increase chance there is no block between the calls @@ -348,7 +333,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can limit by maxHeight", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -362,7 +346,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("works with maxHeight in the future", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -376,7 +359,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can limit by minHeight and maxHeight", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -390,7 +372,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("contains all the info", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -419,7 +400,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("tx", () => { it("can query a tx properly", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const find = randomString(); @@ -459,7 +439,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) let broadcast1: responses.BroadcastTxCommitResponse | undefined; beforeAll(async () => { - if (tendermintEnabled()) { + if (tendermintEnabled) { const client = Tendermint34Client.create(rpcFactory()); async function sendTx(): Promise<[Uint8Array, responses.BroadcastTxCommitResponse]> { @@ -485,7 +465,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("finds a single tx by hash", async () => { - pendingWithoutTendermint(); assert(tx1 && broadcast1); const client = Tendermint34Client.create(rpcFactory()); @@ -504,7 +483,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("finds a single tx by tags", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const txKey2 = randomString(); @@ -550,7 +528,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) // NOTE: The Tendermint docs claim the default ordering is "desc" but it is actually "asc" // Docs: https://docs.tendermint.com/master/rpc/#/Info/tx_search // Code: https://github.com/tendermint/tendermint/blob/v0.34.10/rpc/core/tx.go#L89 - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -567,7 +544,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can set the order", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -582,7 +558,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can paginate over txSearch results", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -601,7 +576,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all search results in one call", async () => { - pendingWithoutTendermint(); const client = Tendermint34Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -618,6 +592,10 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); } +/** + * Runs tests using given client. A compatible backend must be running for this suite. + * Code that does not require a functional backend should be extracted and tested low-level. + */ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { it("can subscribe to block header events", async () => { let done!: (() => void) & { fail: (e?: any) => void }; @@ -625,7 +603,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue done = resolve as typeof done; done.fail = reject; }); - pendingWithoutTendermint(); const testStart = ReadonlyDate.now(); @@ -685,8 +662,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to block events", async () => { - pendingWithoutTendermint(); - const testStart = ReadonlyDate.now(); const transactionData1 = buildKvTx(randomString(), randomString()); @@ -746,8 +721,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to transaction events", async () => { - pendingWithoutTendermint(); - const events: responses.TxEvent[] = []; const client = Tendermint34Client.create(rpcFactory()); const stream = client.subscribeTx(); @@ -787,8 +760,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to transaction events filtered by creator", async () => { - pendingWithoutTendermint(); - const transactionData1 = buildKvTx(randomString(), randomString()); const transactionData2 = buildKvTx(randomString(), randomString()); @@ -829,8 +800,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can unsubscribe and re-subscribe to the same stream", async () => { - pendingWithoutTendermint(); - const client = Tendermint34Client.create(rpcFactory()); const stream = client.subscribeNewBlockHeader(); @@ -862,8 +831,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe twice", async () => { - pendingWithoutTendermint(); - const client = Tendermint34Client.create(rpcFactory()); const stream1 = client.subscribeNewBlockHeader(); const stream2 = client.subscribeNewBlockHeader(); @@ -879,9 +846,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue describe("Tendermint34Client", () => { const { url, expected } = tendermintInstances[34]; - it("can connect to a given url", async () => { - pendingWithoutTendermint(); - + (tendermintEnabled ? it : xit)("can connect to a given url", async () => { // http connection { const client = await Tendermint34Client.connect("http://" + url); @@ -899,11 +864,11 @@ describe("Tendermint34Client", () => { } }); - describe("With HttpClient", () => { + (tendermintEnabled ? describe : xdescribe)("With HttpClient", () => { defaultTestSuite(() => new HttpClient("http://" + url), expected); }); - describe("With WebsocketClient", () => { + (tendermintEnabled ? describe : xdescribe)("With WebsocketClient", () => { // don't print out WebSocket errors if marked pending const onError = globalThis.process?.env.TENDERMINT_ENABLED ? console.error : () => 0; const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError); diff --git a/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts b/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts index 1280ef9bf2..9a1df420b4 100644 --- a/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts +++ b/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts @@ -9,7 +9,6 @@ import { buildKvTx, ExpectedValues, nonNegativeIntegerMatcher, - pendingWithoutTendermint, randomString, tendermintEnabled, tendermintInstances, @@ -20,10 +19,13 @@ import { buildQuery } from "./requests"; import * as responses from "./responses"; import { Tendermint37Client } from "./tendermint37client"; +/** + * Runs tests using given client. A compatible backend must be running for this suite. + * Code that does not require a functional backend should be extracted and tested low-level. + */ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { describe("create", () => { it("can auto-discover Tendermint version and communicate", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const info = await client.abciInfo(); expect(info).toBeTruthy(); @@ -31,7 +33,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can connect to Tendermint with known version", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); expect(await client.abciInfo()).toBeTruthy(); client.disconnect(); @@ -39,7 +40,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get genesis", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const genesis = await client.genesis(); expect(genesis).toBeTruthy(); @@ -48,7 +48,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxCommit", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -68,7 +67,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxSync", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -84,7 +82,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("broadcastTxAsync", () => { it("can broadcast a transaction", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); @@ -96,7 +93,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("gets the same tx hash from backend as calculated locally", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const tx = buildKvTx(randomString(), randomString()); const calculatedTxHash = hashTx(tx); @@ -109,7 +105,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("abciQuery", () => { it("can query the state", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const key = randomString(); @@ -135,7 +130,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get a commit", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const response = await client.commit(4); @@ -150,7 +144,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get validators", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const response = await client.validators({}); @@ -168,7 +161,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all validators", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const response = await client.validatorsAll(); @@ -186,7 +178,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can call a bunch of methods", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); expect(await client.block()).toBeTruthy(); @@ -198,7 +189,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("status", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const status = await client.status(); @@ -239,7 +229,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("numUnconfirmedTxs", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const response = await client.numUnconfirmedTxs(); @@ -253,7 +242,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockResults", () => { it("works", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const height = 3; @@ -269,7 +257,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockSearch", () => { beforeAll(async () => { - if (tendermintEnabled()) { + if (tendermintEnabled) { const client = Tendermint37Client.create(rpcFactory()); async function sendTx(): Promise { @@ -293,7 +281,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can paginate over blockSearch results", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" }); @@ -312,7 +299,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all search results in one call", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" }); @@ -331,7 +317,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("blockchain", () => { it("returns latest in descending order by default", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); // Run in parallel to increase chance there is no block between the calls @@ -348,7 +333,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can limit by maxHeight", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -362,7 +346,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("works with maxHeight in the future", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -377,7 +360,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can limit by minHeight and maxHeight", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -391,7 +373,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("contains all the info", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const height = (await client.status()).syncInfo.latestBlockHeight; @@ -420,7 +401,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) describe("tx", () => { it("can query a tx properly", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const find = randomString(); @@ -460,7 +440,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) let broadcast1: responses.BroadcastTxCommitResponse | undefined; beforeAll(async () => { - if (tendermintEnabled()) { + if (tendermintEnabled) { const client = Tendermint37Client.create(rpcFactory()); async function sendTx(): Promise<[Uint8Array, responses.BroadcastTxCommitResponse]> { @@ -486,7 +466,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("finds a single tx by hash", async () => { - pendingWithoutTendermint(); assert(tx1 && broadcast1); const client = Tendermint37Client.create(rpcFactory()); @@ -505,7 +484,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("finds a single tx by tags", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const txKey2 = randomString(); @@ -555,7 +533,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) // Code 0.34: https://github.com/tendermint/tendermint/blob/v0.34.10/rpc/core/tx.go#L89 // Code 0.35: https://github.com/tendermint/tendermint/blob/v0.35.6/internal/rpc/core/tx.go#L93 // Code 0.37: https://github.com/cometbft/cometbft/blob/v0.37.0-rc3/rpc/core/tx.go#L87 - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -572,7 +549,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can set the order", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -587,7 +563,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can paginate over txSearch results", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -606,7 +581,6 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); it("can get all search results in one call", async () => { - pendingWithoutTendermint(); const client = Tendermint37Client.create(rpcFactory()); const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] }); @@ -623,6 +597,10 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues) }); } +/** + * Runs tests using given client. A compatible backend must be running for this suite. + * Code that does not require a functional backend should be extracted and tested low-level. + */ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { it("can subscribe to block header events", async () => { let done!: (() => void) & { fail: (e?: any) => void }; @@ -630,7 +608,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue done = resolve as typeof done; done.fail = reject; }); - pendingWithoutTendermint(); const testStart = ReadonlyDate.now(); @@ -691,8 +668,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to block events", async () => { - pendingWithoutTendermint(); - const testStart = ReadonlyDate.now(); const transactionData1 = buildKvTx(randomString(), randomString()); @@ -755,8 +730,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to transaction events", async () => { - pendingWithoutTendermint(); - const events: responses.TxEvent[] = []; const client = Tendermint37Client.create(rpcFactory()); const stream = client.subscribeTx(); @@ -796,8 +769,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe to transaction events filtered by creator", async () => { - pendingWithoutTendermint(); - const transactionData1 = buildKvTx(randomString(), randomString()); const transactionData2 = buildKvTx(randomString(), randomString()); @@ -838,8 +809,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can unsubscribe and re-subscribe to the same stream", async () => { - pendingWithoutTendermint(); - const client = Tendermint37Client.create(rpcFactory()); const stream = client.subscribeNewBlockHeader(); @@ -871,8 +840,6 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue }); it("can subscribe twice", async () => { - pendingWithoutTendermint(); - const client = Tendermint37Client.create(rpcFactory()); const stream1 = client.subscribeNewBlockHeader(); const stream2 = client.subscribeNewBlockHeader(); @@ -888,9 +855,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue describe("Tendermint37Client", () => { const { url, expected } = tendermintInstances[37]; - it("can connect to a given url", async () => { - pendingWithoutTendermint(); - + (tendermintEnabled ? it : xit)("can connect to a given url", async () => { // http connection { const client = await Tendermint37Client.connect("http://" + url); @@ -908,11 +873,11 @@ describe("Tendermint37Client", () => { } }); - describe("With HttpClient", () => { + (tendermintEnabled ? describe : xdescribe)("With HttpClient", () => { defaultTestSuite(() => new HttpClient("http://" + url), expected); }); - describe("With WebsocketClient", () => { + (tendermintEnabled ? describe : xdescribe)("With WebsocketClient", () => { // don't print out WebSocket errors if marked pending const onError = globalThis.process?.env.TENDERMINT_ENABLED ? console.error : () => 0; const factory = (): WebsocketClient => new WebsocketClient("ws://" + url, onError); diff --git a/packages/tendermint-rpc/src/testutil.spec.ts b/packages/tendermint-rpc/src/testutil.spec.ts index 4fd9c9488d..70ef071444 100644 --- a/packages/tendermint-rpc/src/testutil.spec.ts +++ b/packages/tendermint-rpc/src/testutil.spec.ts @@ -99,15 +99,7 @@ export const tendermintInstances: Record = { export const defaultInstance: TendermintInstance = tendermintInstances[34]; -export function tendermintEnabled(): boolean { - return !!globalThis.process?.env.TENDERMINT_ENABLED; -} - -export function pendingWithoutTendermint(): void { - if (!tendermintEnabled()) { - pending("Set TENDERMINT_ENABLED to enable tendermint-based tests"); - } -} +export const tendermintEnabled: boolean = !!globalThis.process?.env.TENDERMINT_ENABLED; export async function tendermintSearchIndexUpdated(): Promise { // Tendermint needs some time before a committed transaction is found in search From 8ad65066a284ae12c28ed4eebaa4defe140b99ad Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 8 Oct 2025 10:27:19 +0200 Subject: [PATCH 3/3] Remove outdated "auto-discover Tendermint version" tests Nothing is auto-detected here anymore --- .../src/comet38/comet38client.spec.ts | 18 +++++++----------- .../tendermint34/tendermint34client.spec.ts | 11 +++++++---- .../tendermint37/tendermint37client.spec.ts | 18 +++++++----------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/packages/tendermint-rpc/src/comet38/comet38client.spec.ts b/packages/tendermint-rpc/src/comet38/comet38client.spec.ts index 5c2fe96617..b932e66161 100644 --- a/packages/tendermint-rpc/src/comet38/comet38client.spec.ts +++ b/packages/tendermint-rpc/src/comet38/comet38client.spec.ts @@ -24,28 +24,24 @@ import * as responses from "./responses"; * Code that does not require a functional backend should be extracted and tested low-level. */ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { - describe("create", () => { - it("can auto-discover Tendermint version and communicate", async () => { + describe("abciInfo", () => { + it("works", async () => { const client = Comet38Client.create(rpcFactory()); const info = await client.abciInfo(); expect(info).toBeTruthy(); client.disconnect(); }); + }); - it("can connect to Tendermint with known version", async () => { + describe("genesis", () => { + it("works", async () => { const client = Comet38Client.create(rpcFactory()); - expect(await client.abciInfo()).toBeTruthy(); + const genesis = await client.genesis(); + expect(genesis).toBeTruthy(); client.disconnect(); }); }); - it("can get genesis", async () => { - const client = Comet38Client.create(rpcFactory()); - const genesis = await client.genesis(); - expect(genesis).toBeTruthy(); - client.disconnect(); - }); - describe("broadcastTxCommit", () => { it("can broadcast a transaction", async () => { const client = Comet38Client.create(rpcFactory()); diff --git a/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts b/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts index 08292ebc3e..b150d19db8 100644 --- a/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts +++ b/packages/tendermint-rpc/src/tendermint34/tendermint34client.spec.ts @@ -24,17 +24,20 @@ import { Tendermint34Client } from "./tendermint34client"; * Code that does not require a functional backend should be extracted and tested low-level. */ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { - describe("create", () => { - it("can auto-discover Tendermint version and communicate", async () => { + describe("abciInfo", () => { + it("works", async () => { const client = Tendermint34Client.create(rpcFactory()); const info = await client.abciInfo(); expect(info).toBeTruthy(); client.disconnect(); }); + }); - it("can connect to Tendermint with known version", async () => { + describe("genesis", () => { + it("works", async () => { const client = Tendermint34Client.create(rpcFactory()); - expect(await client.abciInfo()).toBeTruthy(); + const genesis = await client.genesis(); + expect(genesis).toBeTruthy(); client.disconnect(); }); }); diff --git a/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts b/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts index 9a1df420b4..dae96ceb10 100644 --- a/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts +++ b/packages/tendermint-rpc/src/tendermint37/tendermint37client.spec.ts @@ -24,28 +24,24 @@ import { Tendermint37Client } from "./tendermint37client"; * Code that does not require a functional backend should be extracted and tested low-level. */ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues): void { - describe("create", () => { - it("can auto-discover Tendermint version and communicate", async () => { + describe("abciInfo", () => { + it("works", async () => { const client = Tendermint37Client.create(rpcFactory()); const info = await client.abciInfo(); expect(info).toBeTruthy(); client.disconnect(); }); + }); - it("can connect to Tendermint with known version", async () => { + describe("genesis", () => { + it("works", async () => { const client = Tendermint37Client.create(rpcFactory()); - expect(await client.abciInfo()).toBeTruthy(); + const genesis = await client.genesis(); + expect(genesis).toBeTruthy(); client.disconnect(); }); }); - it("can get genesis", async () => { - const client = Tendermint37Client.create(rpcFactory()); - const genesis = await client.genesis(); - expect(genesis).toBeTruthy(); - client.disconnect(); - }); - describe("broadcastTxCommit", () => { it("can broadcast a transaction", async () => { const client = Tendermint37Client.create(rpcFactory());