Skip to content

Commit

Permalink
test: add tests for new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
emjshrx committed Feb 10, 2024
1 parent 85b18ef commit 5489985
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions test/wallet-db.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
14 changes: 11 additions & 3 deletions test/wallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 5489985

Please sign in to comment.