feat(timeout-height): add past timeout height test
This commit is contained in:
parent
efeb501b69
commit
5bdd1215f5
@ -1192,7 +1192,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
client.disconnect();
|
||||
});
|
||||
|
||||
it("works with a custom timeout height", async () => {
|
||||
it("works with a custom timeoutHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: wasmd.prefix });
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, {
|
||||
@ -1222,6 +1222,42 @@ describe("SigningCosmWasmClient", () => {
|
||||
|
||||
client.disconnect();
|
||||
});
|
||||
|
||||
it("fails with past timeoutHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: wasmd.prefix });
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, {
|
||||
...defaultSigningClientOptions,
|
||||
});
|
||||
|
||||
const msg = MsgSend.fromPartial({
|
||||
fromAddress: alice.address0,
|
||||
toAddress: alice.address0,
|
||||
amount: [coin(1, "ucosm")],
|
||||
});
|
||||
const msgAny: MsgSendEncodeObject = {
|
||||
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
|
||||
value: msg,
|
||||
};
|
||||
const fee = {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "222000", // 222k
|
||||
};
|
||||
const memo = "Use your power wisely";
|
||||
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();
|
||||
}
|
||||
|
||||
throw new Error("tx should have failed because of past timeoutHeight");
|
||||
});
|
||||
});
|
||||
|
||||
describe("legacy Amino mode", () => {
|
||||
@ -1469,6 +1505,42 @@ describe("SigningCosmWasmClient", () => {
|
||||
|
||||
client.disconnect();
|
||||
});
|
||||
|
||||
it("fails with past timeoutHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic, { prefix: wasmd.prefix });
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, {
|
||||
...defaultSigningClientOptions,
|
||||
});
|
||||
|
||||
const msg = MsgSend.fromPartial({
|
||||
fromAddress: alice.address0,
|
||||
toAddress: alice.address0,
|
||||
amount: [coin(1, "ucosm")],
|
||||
});
|
||||
const msgAny: MsgSendEncodeObject = {
|
||||
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
|
||||
value: msg,
|
||||
};
|
||||
const fee = {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "200000",
|
||||
};
|
||||
const memo = "Use your tokens wisely";
|
||||
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();
|
||||
}
|
||||
|
||||
throw new Error("tx should have failed because of past timeoutHeight");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -942,6 +942,44 @@ describe("SigningStargateClient", () => {
|
||||
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));
|
||||
assertIsDeliverTxSuccess(result);
|
||||
});
|
||||
|
||||
it("fails with past timeoutHeight", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
|
||||
const client = await SigningStargateClient.connectWithSigner(
|
||||
simapp.tendermintUrl,
|
||||
wallet,
|
||||
defaultSigningClientOptions,
|
||||
);
|
||||
|
||||
const msg = MsgSend.fromPartial({
|
||||
fromAddress: faucet.address0,
|
||||
toAddress: faucet.address0,
|
||||
amount: [coin(1, "ucosm")],
|
||||
});
|
||||
const msgAny: MsgSendEncodeObject = {
|
||||
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
|
||||
value: msg,
|
||||
};
|
||||
const fee = {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "222000", // 222k
|
||||
};
|
||||
const memo = "Use your power wisely";
|
||||
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();
|
||||
}
|
||||
|
||||
throw new Error("tx should have failed because of past timeoutHeight");
|
||||
});
|
||||
});
|
||||
|
||||
describe("legacy Amino mode", () => {
|
||||
@ -1183,6 +1221,44 @@ describe("SigningStargateClient", () => {
|
||||
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));
|
||||
assertIsDeliverTxSuccess(result);
|
||||
});
|
||||
|
||||
it("fails with past timeoutHeight", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic);
|
||||
const client = await SigningStargateClient.connectWithSigner(
|
||||
simapp.tendermintUrl,
|
||||
wallet,
|
||||
defaultSigningClientOptions,
|
||||
);
|
||||
|
||||
const msg = MsgSend.fromPartial({
|
||||
fromAddress: faucet.address0,
|
||||
toAddress: faucet.address0,
|
||||
amount: [coin(1, "ucosm")],
|
||||
});
|
||||
const msgAny: MsgSendEncodeObject = {
|
||||
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
|
||||
value: msg,
|
||||
};
|
||||
const fee = {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "200000",
|
||||
};
|
||||
const memo = "Use your tokens wisely";
|
||||
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();
|
||||
}
|
||||
|
||||
throw new Error("tx should have failed because of past timeoutHeight");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user