Adding more tests
This commit is contained in:
parent
1899e212db
commit
4a4e54b1ce
@ -1,12 +1,21 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { AminoMsg, coins } from "@cosmjs/amino";
|
||||
import { coins, Secp256k1HdWallet } from "@cosmjs/amino";
|
||||
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
|
||||
import Long from "long";
|
||||
|
||||
import { AminoTypes } from "../../aminotypes";
|
||||
import { SigningStargateClient } from "../../signingstargateclient";
|
||||
import { isDeliverTxSuccess } from "../../stargateclient";
|
||||
import {
|
||||
defaultSigningClientOptions,
|
||||
faucet,
|
||||
pendingWithoutSimapp,
|
||||
simapp,
|
||||
unused,
|
||||
} from "../../testutils.spec";
|
||||
import { AminoMsgCreateVestingAccount, createVestingAminoConverters } from "./aminomessages";
|
||||
|
||||
describe("AminoTypes", () => {
|
||||
describe("VestingExtension Amino", () => {
|
||||
describe("toAmino", () => {
|
||||
it("works for MsgCreateVestingAccount", () => {
|
||||
const msg: MsgCreateVestingAccount = {
|
||||
@ -61,3 +70,34 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Signing and broadcasting", () => {
|
||||
it("works with Amino Signing", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic);
|
||||
const client = await SigningStargateClient.connectWithSigner(
|
||||
simapp.tendermintUrl,
|
||||
wallet,
|
||||
defaultSigningClientOptions,
|
||||
);
|
||||
const memo = "Vesting is cool!";
|
||||
const fee = {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "180000", // 180k
|
||||
};
|
||||
|
||||
const vestingMsg = {
|
||||
typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
|
||||
value: MsgCreateVestingAccount.fromPartial({
|
||||
fromAddress: faucet.address0,
|
||||
toAddress: unused.address,
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
45
packages/stargate/src/modules/vesting/messages.spec.ts
Normal file
45
packages/stargate/src/modules/vesting/messages.spec.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { 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 {
|
||||
defaultSigningClientOptions,
|
||||
faucet,
|
||||
makeRandomAddress,
|
||||
pendingWithoutSimapp,
|
||||
simapp,
|
||||
} from "../../testutils.spec";
|
||||
|
||||
describe("VestingExtension direct", () => {
|
||||
it("works with direct signing", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
|
||||
const client = await SigningStargateClient.connectWithSigner(
|
||||
simapp.tendermintUrl,
|
||||
wallet,
|
||||
defaultSigningClientOptions,
|
||||
);
|
||||
const memo = "Vesting is cool!";
|
||||
const fee = {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "180000", // 180k
|
||||
};
|
||||
|
||||
const vestingMsg = {
|
||||
typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
|
||||
value: MsgCreateVestingAccount.fromPartial({
|
||||
fromAddress: faucet.address0,
|
||||
toAddress: makeRandomAddress(),
|
||||
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);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user