Skip to content

Commit

Permalink
test: fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CalicoNino committed Oct 4, 2024
1 parent b948462 commit 46ea0ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/sdk/tx/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 46ea0ab

Please sign in to comment.