Skip to content

Commit

Permalink
Merge pull request #1511 from hyperbolic-versor/ut
Browse files Browse the repository at this point in the history
test: add unit test for isStdTx function
  • Loading branch information
webmaster128 authored Nov 22, 2023
2 parents a8e151a + 000a865 commit 6e6e475
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion packages/amino/src/stdtx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { coins } from "./coins";
import { StdSignature } from "./signature";
import { makeSignDoc, StdFee } from "./signdoc";
import { makeStdTx } from "./stdtx";
import { isStdTx, makeStdTx, StdTx } from "./stdtx";

describe("makeStdTx", () => {
it("can make an StdTx from a SignDoc and one signature", () => {
Expand Down Expand Up @@ -50,3 +50,29 @@ describe("makeStdTx", () => {
});
});
});

describe("isStdTx", () => {
const validTx: StdTx = {
memo: "memoe",
msg: [{ type: "test", value: "Test Value" }],
fee: { amount: [{ denom: "ATOM", amount: "10" }], gas: "100000" },
signatures: [{ signature: "signature", pub_key: { type: "type", value: "value" } }],
};

it("should return true for a valid StdTx", () => {
expect(isStdTx(validTx)).toBeTruthy();
});

it("should return false for an invalid StdTx with missing properties", () => {
const { msg: _msg, ...invalidTx } = validTx;
expect(isStdTx(invalidTx)).toBeFalsy();
});

it("should return false for an invalid StdTx with incorrect types", () => {
const invalidTx = {
...validTx,
msg: "Invalid Message",
};
expect(isStdTx(invalidTx)).toBeFalsy();
});
});

0 comments on commit 6e6e475

Please sign in to comment.