From c1a8adc5cfcd9f11f269411731ac64ea69a8aaa1 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Thu, 10 Nov 2022 04:05:14 -0500 Subject: [PATCH] tests: added wallet encryption --- src.ts/_tests/test-wallet.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src.ts/_tests/test-wallet.ts b/src.ts/_tests/test-wallet.ts index 8605aa765..b9e8f55a4 100644 --- a/src.ts/_tests/test-wallet.ts +++ b/src.ts/_tests/test-wallet.ts @@ -81,3 +81,21 @@ describe("Test Typed-Data Signing (EIP-712)", function() { }); } }); + +describe("Test Wallet Encryption", function() { + const password = "foobar"; + + it("encrypts a wallet: sync", function() { + const wallet = Wallet.createRandom(); + const json = wallet.encryptSync(password); + const decrypted = Wallet.fromEncryptedJsonSync(json, password); + assert.equal(decrypted.address, wallet.address, "address"); + }); + + it("encrypts a wallet: async", async function() { + const wallet = Wallet.createRandom(); + const json = await wallet.encrypt(password); + const decrypted = await Wallet.fromEncryptedJson(json, password); + assert.equal(decrypted.address, wallet.address, "address"); + }); +});