Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Breaking change of Wallet class fixed and test updated #2592

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/web3-eth-accounts/src/models/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default class Wallet {
return target.accounts[name];
}

if (name === 'length') {
return target.accountsIndex;
}

return target[name];
}
});
Expand Down
10 changes: 8 additions & 2 deletions packages/web3-eth-accounts/tests/src/models/WalletTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ describe('WalletTest', () => {
expect(wallet.defaultKeyName).toEqual('web3js_wallet');
});

it('calls wallet.create and returns the expected value', () => {
it('calls the length property and returns the accountsIndex', () => {
wallet.accountsIndex = 99;

expect(wallet.length).toEqual(99);
});

it('calls create and returns the expected value', () => {
Utils.randomHex.mockReturnValueOnce('asdf');

Account.from.mockReturnValueOnce({address: '0x0', privateKey: '0x0'});
Expand Down Expand Up @@ -164,7 +170,7 @@ describe('WalletTest', () => {

expect(() => {
wallet.decrypt([true], 'pw');
}).toThrow("Couldn't decrypt accounts. Password wrong?");
}).toThrow('Couldn\'t decrypt accounts. Password wrong?');

expect(Account.fromV3Keystore).toHaveBeenCalledWith(true, 'pw', false, accountsMock);
});
Expand Down