diff --git a/spec/unit/rust-crypto/recovery-key.spec.ts b/spec/unit/rust-crypto/recovery-key.spec.ts index 8e45952d7fd..ab48a78f99a 100644 --- a/spec/unit/rust-crypto/recovery-key.spec.ts +++ b/spec/unit/rust-crypto/recovery-key.spec.ts @@ -18,22 +18,26 @@ import { decodeRecoveryKey, encodeRecoveryKey } from "../../../src/crypto-api"; describe("recovery key", () => { describe("decodeRecoveryKey", () => { - it("should thrown an incorrect parity", () => { - expect(() => decodeRecoveryKey("alice")).toThrow("Incorrect parity"); - }); - it("should thrown an incorrect length error", () => { const key = [0, 1]; - const encodedKey = encodeRecoveryKey(key); + const encodedKey = encodeRecoveryKey(key)!; + + expect(() => decodeRecoveryKey(encodedKey)).toThrow("Incorrect length"); + }); + + it("should thrown an incorrect parity", () => { + const key = Array.from({ length: 32 }, (_, i) => i); + let encodedKey = encodeRecoveryKey(key)!; + encodedKey = encodedKey.replace("EsSz", "EsSZ"); - expect(() => decodeRecoveryKey(encodedKey!)).toThrow("Incorrect length"); + expect(() => decodeRecoveryKey(encodedKey!)).toThrow("Incorrect parity"); }); it("should decode a valid encoded key", () => { const key = Array.from({ length: 32 }, (_, i) => i); - const encodedKey = encodeRecoveryKey(key); + const encodedKey = encodeRecoveryKey(key)!; - expect(decodeRecoveryKey(encodedKey!)).toEqual(new Uint8Array(key)); + expect(decodeRecoveryKey(encodedKey)).toEqual(new Uint8Array(key)); }); }); });