import { describe, expect, it } from "vitest"; import { ProofStatus, ProofTypes, SignatureProof, } from "@notabene/javascript-sdk"; import { verifyCosmosSignature } from "../cosmos"; describe("verifyCosmosSignature", () => { it("returns verified proof when valid message and address", async () => { const proof: SignatureProof = { type: ProofTypes.COSMOS, did: "did:pkh:cosmos:cosmoshub-4:cosmos1tzxpcdsszyfuj852msx85c24u37jd7rly8skc8", status: ProofStatus.PENDING, attestation: "I certify that\n\ncosmos:cosmoshub-4 account cosmos1tzxpcdsszyfuj852msx85c24u37jd7rly8skc8\n\nbelonged to did:key:z6MksamQq4oVRktkeSDxs6pbixYFUaUca8xgCvnTVLQA5PC5\n\non Mon, 14 Jul 2025 15:09:56 GMT", address: "cosmos:cosmoshub-4:cosmos1tzxpcdsszyfuj852msx85c24u37jd7rly8skc8", proof: "r0L+4864I3p2jPRBt8IAnhhvYmemMkKGg9fcKM0GOBIScgIpmyX/+ObPT/09VMSCzxlzZkH6LQGLNiD2sudAZw==", wallet_provider: "Keplr (Wallet Connect)", chainSpecificData: { pub_key: { type: "tendermint/PubKeySecp256k1", value: "Ak8k3jYgH4srYi1ygG0GWLrdbF7VwQgjiLqjifuJSsmU", }, }, }; const result = await verifyCosmosSignature(proof); expect(result.status).toBe(ProofStatus.VERIFIED); }); it("returns failed proof when invalid message and address", async () => { const proof: SignatureProof = { type: ProofTypes.COSMOS, did: "did:pkh:cosmos:cosmoshub-4:cosmos1tzxpcdsszyfuj852msx85c24u37jd7rly8skc8", status: ProofStatus.PENDING, attestation: "I certify that\n\ncosmos:cosmoshub-4 account cosmos1tzxpcdsszyfuj852msx85c24u37jd7rly8skc8\n\nbelonged to did:key:z6MksamQq4oVRktkeSDxs6pbixYFUaUca8xgCvnTVLQA5PC5\n\non Mon, 14 Jul 2025 15:09:56 GMT", address: "cosmos:cosmoshub-4:cosmos1tzxpcdsszyfuj852msx85c24u37jd7rly8skc8", proof: '{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"Ak8k3jYgH4srYi1ygG0GWLrdbF7VwQgjiLqjifuJSsmU"},"signature":"invalid_signature_that_will_fail_verification"}', wallet_provider: "Keplr (Wallet Connect)", }; const result = await verifyCosmosSignature(proof); expect(result.status).toBe(ProofStatus.FAILED); }); });