Skip to content

Commit

Permalink
test(cloudsync): improve cipher tests (#7344)
Browse files Browse the repository at this point in the history
  • Loading branch information
gre authored Jul 18, 2024
1 parent a72a99d commit 95fdef0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions libs/live-wallet/src/cloudsync/__tests__/cipher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ describe("makeCipher on static data set", () => {
walletSyncEncryptionKey: "test-encryption-key",
applicationPath: "0'/16'/0'",
};
const data = new Uint8Array([1, 2, 3, 4, 5]);
const data = {
foo: [
{
bar: "baz",
},
4,
],
emojis: "🚀🌕🦄",
number: 42,
};

it("encrypt/decrypt works together", async () => {
const encrypted = await cipher.encrypt(trustchain, data);
Expand All @@ -22,12 +31,15 @@ describe("makeCipher on static data set", () => {

it("encrypt is stable (non regression on encrypted data)", async () => {
const encrypted = await cipher.encrypt(trustchain, data);
expect(encrypted).toBe("h2NUqc2vTc0rrs2rTc0trs2tTc0prs2pTc0urs2uTc1S+v+f2Pnn");
expect(encrypted).toBe(
"h2NUqbU0MKhNdVGptbXTrU39baq1SsXZTsW1VkYGpmY6v17wDJjKg2cgzAo8A5rStcW1hlpGtla/Wtm5Sv9ZJOjg",
);
});

it("decrypt is stable (non regression on decrypted data)", async () => {
const encrypted = "h2NUqc2vTc0rrs2rTc0trs2tTc0prs2pTc0urs2uTc1S+v+f2Pnn";
const encrypted =
"h2NUqbU0MKhNdVGptbXTrU39baq1SsXZTsW1VkYGpmY6v17wDJjKg2cgzAo8A5rStcW1hlpGtla/Wtm5Sv9ZJOjg";
const decrypted = await cipher.decrypt(trustchain, encrypted);
expect(decrypted).toMatchObject(data);
expect(decrypted).toEqual(data);
});
});

0 comments on commit 95fdef0

Please sign in to comment.