Skip to content

Commit

Permalink
test: add unit test for isStdTx function
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperbolic-versor committed Nov 16, 2023
1 parent a8e151a commit bd46b88
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, ...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 bd46b88

Please sign in to comment.