diff --git a/packages/amino/src/stdtx.spec.ts b/packages/amino/src/stdtx.spec.ts index 4f194e894b..8b038272fe 100644 --- a/packages/amino/src/stdtx.spec.ts +++ b/packages/amino/src/stdtx.spec.ts @@ -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", () => { @@ -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(); + }); +});