From cad43527759225d04e5d8758dfaffd7fe2eb7a12 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 3 Aug 2022 15:35:28 +0200 Subject: [PATCH] Fix some more tests for 0.46 --- .../src/signingcosmwasmclient.spec.ts | 2 +- packages/ledger-amino/src/ledgersigner.spec.ts | 2 +- packages/stargate/src/modules/authz/queries.spec.ts | 3 ++- packages/stargate/src/modules/gov/queries.spec.ts | 2 +- packages/stargate/src/modules/tx/queries.spec.ts | 11 ++++++++--- packages/stargate/src/signingstargateclient.spec.ts | 2 +- packages/stargate/src/stargateclient.spec.ts | 8 +++++++- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts index 9e66a9f5..fe71f68e 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts @@ -92,7 +92,7 @@ describe("SigningCosmWasmClient", () => { const memo = "Go go go"; const gasUsed = await client.simulate(alice.address0, [executeContractMsg], memo); expect(gasUsed).toBeGreaterThanOrEqual(101_000); - expect(gasUsed).toBeLessThanOrEqual(150_000); + expect(gasUsed).toBeLessThanOrEqual(200_000); client.disconnect(); }); }); diff --git a/packages/ledger-amino/src/ledgersigner.spec.ts b/packages/ledger-amino/src/ledgersigner.spec.ts index d9bf56a8..65c1c2ed 100644 --- a/packages/ledger-amino/src/ledgersigner.spec.ts +++ b/packages/ledger-amino/src/ledgersigner.spec.ts @@ -47,7 +47,7 @@ async function createTransport(): Promise { describe("LedgerSigner", () => { const defaultChainId = "testing"; - const defaultFee = calculateFee(80_000, "0.025ucosm"); + const defaultFee = calculateFee(100_000, "0.025ucosm"); const defaultMemo = "Some memo"; const defaultSequence = "0"; const defaultAccountNumber = "42"; diff --git a/packages/stargate/src/modules/authz/queries.spec.ts b/packages/stargate/src/modules/authz/queries.spec.ts index f79e2e59..db516ef1 100644 --- a/packages/stargate/src/modules/authz/queries.spec.ts +++ b/packages/stargate/src/modules/authz/queries.spec.ts @@ -14,6 +14,7 @@ import { pendingWithoutSimapp44Or46, simapp, simapp44Enabled, + simapp46Enabled, } from "../../testutils.spec"; import { AuthzExtension, setupAuthzExtension } from "./queries"; @@ -35,7 +36,7 @@ describe("AuthzExtension", () => { const grantedMsg = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward"; beforeAll(async () => { - if (simapp44Enabled()) { + if (simapp44Enabled() || simapp46Enabled()) { 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/gov/queries.spec.ts b/packages/stargate/src/modules/gov/queries.spec.ts index dc61ee27..93ff788b 100644 --- a/packages/stargate/src/modules/gov/queries.spec.ts +++ b/packages/stargate/src/modules/gov/queries.spec.ts @@ -397,7 +397,7 @@ describe("GovExtension", () => { Vote.fromPartial({ voter: voter1Address, proposalId: longify(proposalId), - option: VoteOption.VOTE_OPTION_YES, + option: simapp44Enabled() ? VoteOption.VOTE_OPTION_YES : VoteOption.VOTE_OPTION_UNSPECIFIED, options: [ WeightedVoteOption.fromPartial({ option: VoteOption.VOTE_OPTION_YES, diff --git a/packages/stargate/src/modules/tx/queries.spec.ts b/packages/stargate/src/modules/tx/queries.spec.ts index ad16e077..a14a5c74 100644 --- a/packages/stargate/src/modules/tx/queries.spec.ts +++ b/packages/stargate/src/modules/tx/queries.spec.ts @@ -4,7 +4,7 @@ import { assertDefined, sleep } from "@cosmjs/utils"; import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx"; import Long from "long"; -import { longify, QueryClient } from "../../queryclient"; +import { QueryClient } from "../../queryclient"; import { defaultRegistryTypes, SigningStargateClient } from "../../signingstargateclient"; import { assertIsDeliverTxSuccess, StargateClient } from "../../stargateclient"; import { @@ -13,6 +13,8 @@ import { makeRandomAddress, pendingWithoutSimapp, simapp, + simapp42Enabled, + simapp44Enabled, simappEnabled, validator, } from "../../testutils.spec"; @@ -94,8 +96,11 @@ describe("TxExtension", () => { const { sequence } = await sequenceClient.getSequence(faucet.address0); const response = await client.tx.simulate([msgAny], "foo", faucet.pubkey0, sequence); expect(response.gasInfo?.gasUsed.toNumber()).toBeGreaterThanOrEqual(101_000); - expect(response.gasInfo?.gasUsed.toNumber()).toBeLessThanOrEqual(150_000); - expect(response.gasInfo?.gasWanted).toEqual(longify(Long.UZERO)); + expect(response.gasInfo?.gasUsed.toNumber()).toBeLessThanOrEqual(200_000); + expect(response.gasInfo?.gasWanted).toEqual( + // Some dummy value. Value does not matter for regular users. + simapp42Enabled() || simapp44Enabled() ? Long.UZERO : Long.MAX_UNSIGNED_VALUE, + ); tmClient.disconnect(); }); diff --git a/packages/stargate/src/signingstargateclient.spec.ts b/packages/stargate/src/signingstargateclient.spec.ts index 28f84249..352bf6b6 100644 --- a/packages/stargate/src/signingstargateclient.spec.ts +++ b/packages/stargate/src/signingstargateclient.spec.ts @@ -63,7 +63,7 @@ describe("SigningStargateClient", () => { const memo = "Use your power wisely"; const gasUsed = await client.simulate(faucet.address0, [msgAny], memo); expect(gasUsed).toBeGreaterThanOrEqual(101_000); - expect(gasUsed).toBeLessThanOrEqual(150_000); + expect(gasUsed).toBeLessThanOrEqual(200_000); client.disconnect(); }); diff --git a/packages/stargate/src/stargateclient.spec.ts b/packages/stargate/src/stargateclient.spec.ts index 1d50a57d..c0306d21 100644 --- a/packages/stargate/src/stargateclient.spec.ts +++ b/packages/stargate/src/stargateclient.spec.ts @@ -28,6 +28,8 @@ import { pendingWithoutSimapp, pendingWithoutSlowSimapp, simapp, + simapp42Enabled, + simapp44Enabled, slowSimapp, tendermintIdMatcher, unused, @@ -431,7 +433,11 @@ describe("StargateClient", () => { }); const txRawBytes = Uint8Array.from(TxRaw.encode(txRaw).finish()); - await expectAsync(client.broadcastTx(txRawBytes)).toBeRejectedWithError(/invalid recipient address/i); + await expectAsync(client.broadcastTx(txRawBytes)).toBeRejectedWithError( + simapp42Enabled() || simapp44Enabled() + ? /invalid recipient address/i + : /Broadcasting transaction failed with code 7/i, + ); client.disconnect(); });