diff --git a/test/wallet-db.spec.ts b/test/wallet-db.spec.ts index 64c098d..b2b15d2 100644 --- a/test/wallet-db.spec.ts +++ b/test/wallet-db.spec.ts @@ -24,6 +24,16 @@ describe('Wallet DB', () => { expect(await walletDB.getVersion()).toBe(1); }); + it('should set and retrieve encryptedPrivateKey and encryptedChainCode', async () => { + const samplePrivateKey = 'samplePrivateKey'; + const sampleChainCode = 'sampleChainCode'; + await walletDB.setMasterKey(samplePrivateKey, sampleChainCode); + const { encryptedPrivateKey, encryptedChainCode } = + await walletDB.getMasterKey(); + expect(encryptedPrivateKey).toStrictEqual(samplePrivateKey); + expect(encryptedChainCode).toStrictEqual(sampleChainCode); + }); + afterAll(async () => { await walletDB.close(); fs.rmSync('./test/wallet-db', { recursive: true, force: true }); diff --git a/test/wallet.spec.ts b/test/wallet.spec.ts index 62f333a..8820718 100644 --- a/test/wallet.spec.ts +++ b/test/wallet.spec.ts @@ -32,9 +32,17 @@ describe('Wallet', () => { }); it('should initialise the wallet', async () => { - await wallet.init( - 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', - ); + await wallet.init({ + mnemonic: + 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', + }); + }); + + it('should set a new password, close and reopen the wallet with the same password', async () => { + const password = 'notSoSecretPassword'; + await wallet.setPassword(password); + await wallet.close(); + await wallet.init({ password }); }); it('should derive first receive address', async () => {