Skip to content

Commit

Permalink
feat(timeout-height): expectAsync fail test
Browse files Browse the repository at this point in the history
  • Loading branch information
janfabian committed Oct 26, 2023
1 parent 5bdd121 commit af78d54
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
34 changes: 16 additions & 18 deletions packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

Expand Down Expand Up @@ -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();
});
});
});
Expand Down
34 changes: 16 additions & 18 deletions packages/stargate/src/signingstargateclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

Expand Down Expand Up @@ -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();
});
});
});
Expand Down

0 comments on commit af78d54

Please sign in to comment.