Merge pull request #1511 from hyperbolic-versor/ut

test: add unit test for isStdTx function
This commit is contained in:
Simon Warta 2023-11-22 10:00:58 +01:00 committed by GitHub
commit 6e6e47562f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();
});
});