From 46ea0ab3f885ea12edd6f23434a256a772229493 Mon Sep 17 00:00:00 2001 From: elshenak Date: Thu, 3 Oct 2024 22:28:55 -0400 Subject: [PATCH] test: fixing tests --- src/sdk/tx/account.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/sdk/tx/account.test.ts b/src/sdk/tx/account.test.ts index 76346f90..562bccc5 100644 --- a/src/sdk/tx/account.test.ts +++ b/src/sdk/tx/account.test.ts @@ -3,6 +3,14 @@ import { EthAccount } from "src/protojs/eth/types/v1/account" import { Any } from "src/protojs/google/protobuf/any" import Long from "long" import * as cosmjs from "@cosmjs/stargate" +import { decodeOptionalPubkey } from "@cosmjs/proto-signing" + +// Mock decodeOptionalPubkey +jest.mock("@cosmjs/proto-signing", () => ({ + decodeOptionalPubkey: jest.fn(), +})) + +const mockedDecodeOptionalPubkey = decodeOptionalPubkey as jest.Mock describe("accountFromEthAccount", () => { it("should throw an error when baseAccount is undefined", () => { @@ -30,6 +38,11 @@ describe("accountFromEthAccount", () => { codeHash: "", } + mockedDecodeOptionalPubkey.mockReturnValue({ + typeUrl: "/cosmos.crypto.secp256k1.PubKey", + value: new Uint8Array([1, 2, 3]), + }) + const account = accountFromEthAccount(ethAccount) expect(account.address).toBe("nibi1testaddress") @@ -60,6 +73,11 @@ describe("accountFromNibiru", () => { }).finish(), } + mockedDecodeOptionalPubkey.mockReturnValue({ + typeUrl: "/cosmos.crypto.secp256k1.PubKey", + value: new Uint8Array([4, 5, 6]), + }) + const account = accountFromNibiru(input) expect(account.address).toBe("nibi1testaddress")