aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/test/integration/ledger_subprovider_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/subproviders/test/integration/ledger_subprovider_test.ts')
-rw-r--r--packages/subproviders/test/integration/ledger_subprovider_test.ts44
1 files changed, 28 insertions, 16 deletions
diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts
index 75f6d47fe..628b532d7 100644
--- a/packages/subproviders/test/integration/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts
@@ -2,23 +2,14 @@ import * as chai from 'chai';
import promisify = require('es6-promisify');
import * as ethUtils from 'ethereumjs-util';
import * as _ from 'lodash';
-import * as mocha from 'mocha';
import Web3 = require('web3');
import Web3ProviderEngine = require('web3-provider-engine');
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
-import {
- ECSignature,
- ledgerEthereumNodeJsClientFactoryAsync,
- LedgerSubprovider,
-} from '../../src';
-import {
- DoneCallback,
- LedgerGetAddressResult,
- PartialTxParams,
-} from '../../src/types';
-import {chaiSetup} from '../chai_setup';
-import {reportCallbackErrors} from '../utils/report_callback_errors';
+import { ledgerEthereumNodeJsClientFactoryAsync, LedgerSubprovider } from '../../src';
+import { DoneCallback } from '../../src/types';
+import { chaiSetup } from '../chai_setup';
+import { reportCallbackErrors } from '../utils/report_callback_errors';
chaiSetup.configure();
const expect = chai.expect;
@@ -55,8 +46,9 @@ describe('LedgerSubprovider', () => {
chainId: 3,
};
const txHex = await ledgerSubprovider.signTransactionAsync(tx);
- // tslint:disable-next-line:max-line-length
- expect(txHex).to.be.equal('0xf85f8080822710940000000000000000000000000000000000000000808077a088a95ef1378487bc82be558e82c8478baf840c545d5b887536bb1da63673a98ba0019f4a4b9a107d1e6752bf7f701e275f28c13791d6e76af895b07373462cefaa');
+ expect(txHex).to.be.equal(
+ '0xf85f8080822710940000000000000000000000000000000000000000808077a088a95ef1378487bc82be558e82c8478baf840c545d5b887536bb1da63673a98ba0019f4a4b9a107d1e6752bf7f701e275f28c13791d6e76af895b07373462cefaa',
+ );
});
});
describe('calls through a provider', () => {
@@ -89,7 +81,27 @@ describe('LedgerSubprovider', () => {
});
ledgerProvider.sendAsync(payload, callback);
});
- it('signs a personal message', (done: DoneCallback) => {
+ it('signs a personal message with eth_sign', (done: DoneCallback) => {
+ (async () => {
+ const messageHex = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
+ const accounts = await ledgerSubprovider.getAccountsAsync();
+ const signer = accounts[0];
+ const payload = {
+ jsonrpc: '2.0',
+ method: 'eth_sign',
+ params: [signer, messageHex],
+ id: 1,
+ };
+ const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ expect(err).to.be.a('null');
+ expect(response.result.length).to.be.equal(132);
+ expect(response.result.substr(0, 2)).to.be.equal('0x');
+ done();
+ });
+ ledgerProvider.sendAsync(payload, callback);
+ })().catch(done);
+ });
+ it('signs a personal message with personal_sign', (done: DoneCallback) => {
(async () => {
const messageHex = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
const accounts = await ledgerSubprovider.getAccountsAsync();