Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct data format in vesting aminomessage #1114

Merged
merged 5 commits into from
Apr 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding tests
msteiner96 committed Apr 7, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1899e212dba3deedd415b875e9c4d23dad64a116
63 changes: 63 additions & 0 deletions packages/stargate/src/modules/vesting/aminomessages.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { AminoMsg, coins } from "@cosmjs/amino";
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
import Long from "long";

import { AminoTypes } from "../../aminotypes";
import { AminoMsgCreateVestingAccount, createVestingAminoConverters } from "./aminomessages";

describe("AminoTypes", () => {
describe("toAmino", () => {
it("works for MsgCreateVestingAccount", () => {
const msg: MsgCreateVestingAccount = {
fromAddress: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
toAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
amount: coins(1234, "utest"),
endTime: Long.fromString("1838718434"),
delayed: true,
};
const aminoTypes = new AminoTypes(createVestingAminoConverters());
const aminoMsg = aminoTypes.toAmino({
typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
value: msg,
});
const expected: AminoMsgCreateVestingAccount = {
type: "cosmos-sdk/MsgCreateVestingAccount",
value: {
from_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
to_address: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
amount: coins(1234, "utest"),
end_time: "1838718434",
delayed: true,
},
};
expect(aminoMsg).toEqual(expected);
});
});
describe("fromAmino", () => {
it("works for MsgCreateVestingAccount", () => {
const aminoMsg: AminoMsgCreateVestingAccount = {
type: "cosmos-sdk/MsgCreateVestingAccount",
value: {
from_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
to_address: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
amount: coins(1234, "utest"),
end_time: "1838718434",
delayed: true,
},
};
const msg = new AminoTypes(createVestingAminoConverters()).fromAmino(aminoMsg);
const expectedValue: MsgCreateVestingAccount = {
fromAddress: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
toAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
amount: coins(1234, "utest"),
endTime: Long.fromString("1838718434"),
delayed: true,
};
expect(msg).toEqual({
typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
value: expectedValue,
});
});
});
});