tests: added wallet encryption

This commit is contained in:
Richard Moore 2022-11-10 04:05:14 -05:00
parent b42107364d
commit c1a8adc5cf

@ -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");
});
});