Skip to content

Commit

Permalink
Merge pull request #2592 from ethereum/issue/2591
Browse files Browse the repository at this point in the history
Breaking change of Wallet class fixed and test updated
  • Loading branch information
nivida authored Mar 27, 2019
2 parents c8828ed + 24c21f7 commit 9dfc93e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 9dfc93e

Please sign in to comment.