diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts index 9693e35046..307fc626a4 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts @@ -1247,16 +1247,15 @@ describe("SigningCosmWasmClient", () => { const height = await client.getHeight(); const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height - 1)); - try { - await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); - } catch (e: any) { - assert(e.code === 30); - return; - } finally { - client.disconnect(); - } + await expectAsync( + client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())), + ).toBeRejectedWith( + jasmine.objectContaining({ + code: 30, + }), + ); - throw new Error("tx should have failed because of past timeoutHeight"); + client.disconnect(); }); }); @@ -1530,16 +1529,15 @@ describe("SigningCosmWasmClient", () => { const height = await client.getHeight(); const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height - 1)); - try { - await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); - } catch (e: any) { - assert(e.code === 30); - return; - } finally { - client.disconnect(); - } + await expectAsync( + client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())), + ).toBeRejectedWith( + jasmine.objectContaining({ + code: 30, + }), + ); - throw new Error("tx should have failed because of past timeoutHeight"); + client.disconnect(); }); }); }); diff --git a/packages/stargate/src/signingstargateclient.spec.ts b/packages/stargate/src/signingstargateclient.spec.ts index ef26449e44..a676631e46 100644 --- a/packages/stargate/src/signingstargateclient.spec.ts +++ b/packages/stargate/src/signingstargateclient.spec.ts @@ -969,16 +969,15 @@ describe("SigningStargateClient", () => { const height = await client.getHeight(); const signed = await client.sign(faucet.address0, [msgAny], fee, memo, undefined, BigInt(height - 1)); - try { - await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); - } catch (e: any) { - assert(e.code === 30); - return; - } finally { - client.disconnect(); - } + await expectAsync( + client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())), + ).toBeRejectedWith( + jasmine.objectContaining({ + code: 30, + }), + ); - throw new Error("tx should have failed because of past timeoutHeight"); + client.disconnect(); }); }); @@ -1248,16 +1247,15 @@ describe("SigningStargateClient", () => { const height = await client.getHeight(); const signed = await client.sign(faucet.address0, [msgAny], fee, memo, undefined, BigInt(height - 1)); - try { - await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); - } catch (e: any) { - assert(e.code === 30); - return; - } finally { - client.disconnect(); - } + await expectAsync( + client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())), + ).toBeRejectedWith( + jasmine.objectContaining({ + code: 30, + }), + ); - throw new Error("tx should have failed because of past timeoutHeight"); + client.disconnect(); }); }); });