Skip to content

Commit

Permalink
console.log in Wallet removed and AccountsTest improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Furter committed Mar 26, 2019
1 parent 32aa002 commit 5dead91
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 0 additions & 2 deletions packages/web3-eth-accounts/src/models/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ export default class Wallet {

this.accountsIndex++;

console.log('ADD:', account);

return account;
}

Expand Down
33 changes: 28 additions & 5 deletions packages/web3-eth-accounts/tests/src/AccountsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ describe('AccountsTest', () => {
});

it('calls signTransaction and rejects with a promise', async () => {
const callback = jest.fn();

const transaction = {
from: 0,
gas: 1,
Expand All @@ -243,15 +241,40 @@ describe('AccountsTest', () => {
return Promise.reject(new Error('ERROR'));
});

await expect(accounts.signTransaction(transaction, 'pk', callback)).rejects.toThrow('ERROR');
await expect(accounts.signTransaction(transaction, 'pk')).rejects.toThrow('ERROR');

expect(Account.fromPrivateKey).toHaveBeenCalledWith('pk', accounts);

expect(callback).toHaveBeenCalledWith(new Error('ERROR'), null);

expect(transactionSignerMock.sign).toHaveBeenCalledWith(transaction, 'pk');
});

it('calls signTransaction and calls the callback with a error', (done) => {
const transaction = {
from: 0,
gas: 1,
gasPrice: 1,
nonce: 1,
chainId: 1
};

const account = {privateKey: 'pk', address: '0x0'};
Account.fromPrivateKey.mockReturnValueOnce(account);

transactionSignerMock.sign = jest.fn(() => {
return Promise.reject(new Error('ERROR'));
});

accounts.signTransaction(transaction, 'pk', (error, response) => {
expect(error).toEqual(new Error('ERROR'));

expect(Account.fromPrivateKey).toHaveBeenCalledWith('pk', accounts);

expect(transactionSignerMock.sign).toHaveBeenCalledWith(transaction, 'pk');

done();
});
});

it('calls recoverTransaction and returns the expected string', () => {
RLP.decode.mockReturnValueOnce([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);

Expand Down

0 comments on commit 5dead91

Please sign in to comment.