diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-04 22:52:16 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-04 22:52:16 +0800 |
commit | 86e26240a1995eac85178c277a227d75221077f6 (patch) | |
tree | 0a808692664bb1cfa7844235eb84753c56e3b6e4 /packages/subproviders/test | |
parent | 4445d1d5a0f5d5fa263d7a063519a9a9bca1ec94 (diff) | |
download | dexon-0x-contracts-86e26240a1995eac85178c277a227d75221077f6.tar.gz dexon-0x-contracts-86e26240a1995eac85178c277a227d75221077f6.tar.zst dexon-0x-contracts-86e26240a1995eac85178c277a227d75221077f6.zip |
Add `numberOfAccounts` param to `LedgerSubprovider` method `getAccountsAsync` and add tests
Diffstat (limited to 'packages/subproviders/test')
-rw-r--r-- | packages/subproviders/test/integration/ledger_subprovider_test.ts | 10 | ||||
-rw-r--r-- | packages/subproviders/test/unit/ledger_subprovider_test.ts | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts index 628b532d7..e17ededee 100644 --- a/packages/subproviders/test/integration/ledger_subprovider_test.ts +++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts @@ -26,11 +26,17 @@ describe('LedgerSubprovider', () => { }); }); describe('direct method calls', () => { - it('returns a list of accounts', async () => { + it('returns defaut number of accounts', async () => { const accounts = await ledgerSubprovider.getAccountsAsync(); expect(accounts[0]).to.not.be.an('undefined'); expect(accounts.length).to.be.equal(10); }); + it('returns requested number of accounts', async () => { + const numberOfAccounts = 20; + const accounts = await ledgerSubprovider.getAccountsAsync(numberOfAccounts); + expect(accounts[0]).to.not.be.an('undefined'); + expect(accounts.length).to.be.equal(numberOfAccounts); + }); it('signs a personal message', async () => { const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world')); const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data); @@ -172,7 +178,7 @@ describe('LedgerSubprovider', () => { }; const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { expect(err).to.be.a('null'); - const result = response.result.result; + const result = response.result; expect(result.length).to.be.equal(66); expect(result.substr(0, 2)).to.be.equal('0x'); done(); diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts index 1c70dd3a6..6c589dffe 100644 --- a/packages/subproviders/test/unit/ledger_subprovider_test.ts +++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts @@ -62,11 +62,17 @@ describe('LedgerSubprovider', () => { }); describe('direct method calls', () => { describe('success cases', () => { - it('returns a list of accounts', async () => { + it('returns defaut number of accounts', async () => { const accounts = await ledgerSubprovider.getAccountsAsync(); expect(accounts[0]).to.be.equal(FAKE_ADDRESS); expect(accounts.length).to.be.equal(10); }); + it('returns requested number of accounts', async () => { + const numberOfAccounts = 20; + const accounts = await ledgerSubprovider.getAccountsAsync(numberOfAccounts); + expect(accounts[0]).to.be.equal(FAKE_ADDRESS); + expect(accounts.length).to.be.equal(numberOfAccounts); + }); it('signs a personal message', async () => { const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world')); const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data); |