mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Polish some test code
This commit is contained in:
parent
b13f72a5f3
commit
5854d2b3b4
@ -1,10 +1,10 @@
|
||||
import { coins } from "@cosmjs/amino";
|
||||
import { coin, coins } from "@cosmjs/amino";
|
||||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
|
||||
import Long from "long";
|
||||
|
||||
import { SigningStargateClient } from "../../signingstargateclient";
|
||||
import { isDeliverTxSuccess } from "../../stargateclient";
|
||||
import { assertIsDeliverTxSuccess } from "../../stargateclient";
|
||||
import {
|
||||
defaultSigningClientOptions,
|
||||
faucet,
|
||||
@ -13,8 +13,8 @@ import {
|
||||
simapp,
|
||||
} from "../../testutils.spec";
|
||||
|
||||
describe("VestingExtension direct", () => {
|
||||
it("works with direct signing", async () => {
|
||||
describe("vestingTypes", () => {
|
||||
it("can sign MsgCreateVestingAccount with sign mode direct", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
|
||||
const client = await SigningStargateClient.connectWithSigner(
|
||||
@ -22,24 +22,25 @@ describe("VestingExtension direct", () => {
|
||||
wallet,
|
||||
defaultSigningClientOptions,
|
||||
);
|
||||
const memo = "Vesting is cool!";
|
||||
const fee = {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "180000", // 180k
|
||||
};
|
||||
|
||||
const memo = "Vesting is cool!";
|
||||
const recipient = makeRandomAddress();
|
||||
const vestingMsg = {
|
||||
typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
|
||||
value: MsgCreateVestingAccount.fromPartial({
|
||||
fromAddress: faucet.address0,
|
||||
toAddress: makeRandomAddress(),
|
||||
toAddress: recipient,
|
||||
amount: coins(1234, "ucosm"),
|
||||
endTime: Long.fromString("1838718434"),
|
||||
delayed: true,
|
||||
}),
|
||||
};
|
||||
|
||||
const result = await client.signAndBroadcast(faucet.address0, [vestingMsg], fee, memo);
|
||||
expect(isDeliverTxSuccess(result)).toEqual(true);
|
||||
const result = await client.signAndBroadcast(faucet.address0, [vestingMsg], "auto", memo);
|
||||
assertIsDeliverTxSuccess(result);
|
||||
const balance = await client.getBalance(recipient, "ucosm");
|
||||
expect(balance).toEqual(coin(1234, "ucosm"));
|
||||
|
||||
client.disconnect();
|
||||
});
|
||||
});
|
||||
|
@ -99,6 +99,7 @@ export const slowSimapp = {
|
||||
export const defaultSigningClientOptions: SigningStargateClientOptions = {
|
||||
broadcastPollIntervalMs: 300,
|
||||
broadcastTimeoutMs: 8_000,
|
||||
gasPrice: GasPrice.fromString("0.01ucosm"),
|
||||
};
|
||||
|
||||
export const faucet = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user