aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/test
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-23 00:25:02 +0800
committerFabio Berger <me@fabioberger.com>2018-05-23 00:25:02 +0800
commit4a0c8d72b05152ee2fd71245873d5a70f7281058 (patch)
tree2c28ad8214aaaa10913a621509d0ae4020ee4d3d /packages/subproviders/test
parentd460c0e8b9c6f4081803fff4e2d2347be8cd5ce3 (diff)
parentab9cfd293b3ccc2aacb4238aebe2b033e55b7935 (diff)
downloaddexon-sol-tools-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar
dexon-sol-tools-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar.gz
dexon-sol-tools-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar.bz2
dexon-sol-tools-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar.lz
dexon-sol-tools-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar.xz
dexon-sol-tools-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar.zst
dexon-sol-tools-4a0c8d72b05152ee2fd71245873d5a70f7281058.zip
merge development
Diffstat (limited to 'packages/subproviders/test')
-rw-r--r--packages/subproviders/test/integration/ledger_subprovider_test.ts13
-rw-r--r--packages/subproviders/test/unit/ledger_subprovider_test.ts8
-rw-r--r--packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts5
-rw-r--r--packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts5
4 files changed, 19 insertions, 12 deletions
diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts
index 70fd2cfce..d3e9d0fde 100644
--- a/packages/subproviders/test/integration/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts
@@ -20,6 +20,8 @@ import { reportCallbackErrors } from '../utils/report_callback_errors';
chaiSetup.configure();
const expect = chai.expect;
+const DEFAULT_NUM_ACCOUNTS = 10;
+const EXPECTED_SIGNATURE_LENGTH = 132;
async function ledgerEthereumNodeJsClientFactoryAsync(): Promise<LedgerEthereumClient> {
const ledgerConnection = await TransportNodeHid.create();
@@ -41,7 +43,7 @@ describe('LedgerSubprovider', () => {
it('returns default number of accounts', async () => {
const accounts = await ledgerSubprovider.getAccountsAsync();
expect(accounts[0]).to.not.be.an('undefined');
- expect(accounts.length).to.be.equal(10);
+ expect(accounts.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
});
it('returns the expected accounts from a ledger set up with the test mnemonic', async () => {
const accounts = await ledgerSubprovider.getAccountsAsync();
@@ -105,7 +107,7 @@ describe('LedgerSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- expect(response.result.length).to.be.equal(10);
+ expect(response.result.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
done();
});
ledgerProvider.sendAsync(payload, callback);
@@ -123,7 +125,7 @@ describe('LedgerSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- expect(response.result.length).to.be.equal(132);
+ expect(response.result.length).to.be.equal(EXPECTED_SIGNATURE_LENGTH);
expect(response.result.substr(0, 2)).to.be.equal('0x');
done();
});
@@ -143,7 +145,7 @@ describe('LedgerSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- expect(response.result.length).to.be.equal(132);
+ expect(response.result.length).to.be.equal(EXPECTED_SIGNATURE_LENGTH);
expect(response.result.substr(0, 2)).to.be.equal('0x');
done();
});
@@ -197,7 +199,8 @@ describe('LedgerSubprovider', () => {
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
const result = response.result;
- expect(result.length).to.be.equal(66);
+ const signedTxLength = 66;
+ expect(result.length).to.be.equal(signedTxLength);
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 6455454cb..8571f7d11 100644
--- a/packages/subproviders/test/unit/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts
@@ -21,6 +21,7 @@ import { reportCallbackErrors } from '../utils/report_callback_errors';
chaiSetup.configure();
const expect = chai.expect;
const FAKE_ADDRESS = '0xb088a3bc93f71b4de97b9de773e9647645983688';
+const DEFAULT_NUM_ACCOUNTS = 10;
describe('LedgerSubprovider', () => {
const networkId: number = 42;
@@ -73,7 +74,7 @@ describe('LedgerSubprovider', () => {
it('returns default number of accounts', async () => {
const accounts = await ledgerSubprovider.getAccountsAsync();
expect(accounts[0]).to.be.equal(FAKE_ADDRESS);
- expect(accounts.length).to.be.equal(10);
+ expect(accounts.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
});
it('returns requested number of accounts', async () => {
const numberOfAccounts = 20;
@@ -119,7 +120,7 @@ describe('LedgerSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- expect(response.result.length).to.be.equal(10);
+ expect(response.result.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
expect(response.result[0]).to.be.equal(FAKE_ADDRESS);
done();
});
@@ -176,7 +177,8 @@ describe('LedgerSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- expect(response.result.raw.length).to.be.equal(192);
+ const rawTxLength = 192;
+ expect(response.result.raw.length).to.be.equal(rawTxLength);
expect(response.result.raw.substr(0, 2)).to.be.equal('0x');
done();
});
diff --git a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
index 52b636ac2..90565181e 100644
--- a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
+++ b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
@@ -18,6 +18,7 @@ import { reportCallbackErrors } from '../utils/report_callback_errors';
chaiSetup.configure();
const expect = chai.expect;
+const DEFAULT_NUM_ACCOUNTS = 10;
describe('MnemonicWalletSubprovider', () => {
let subprovider: MnemonicWalletSubprovider;
@@ -33,7 +34,7 @@ describe('MnemonicWalletSubprovider', () => {
const accounts = await subprovider.getAccountsAsync();
expect(accounts[0]).to.be.equal(fixtureData.TEST_RPC_ACCOUNT_0);
expect(accounts[1]).to.be.equal(fixtureData.TEST_RPC_ACCOUNT_1);
- expect(accounts.length).to.be.equal(10);
+ expect(accounts.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
});
it('signs a personal message', async () => {
const data = ethUtils.bufferToHex(ethUtils.toBuffer(fixtureData.PERSONAL_MESSAGE_STRING));
@@ -90,7 +91,7 @@ describe('MnemonicWalletSubprovider', () => {
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result[0]).to.be.equal(fixtureData.TEST_RPC_ACCOUNT_0);
- expect(response.result.length).to.be.equal(10);
+ expect(response.result.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
done();
});
provider.sendAsync(payload, callback);
diff --git a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
index f9c47f141..fdbbb332c 100644
--- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
+++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
@@ -14,6 +14,7 @@ import { reportCallbackErrors } from '../utils/report_callback_errors';
const expect = chai.expect;
chaiSetup.configure();
+const DEFAULT_NUM_ACCOUNTS = 10;
describe('RedundantSubprovider', () => {
let provider: Web3ProviderEngine;
@@ -32,7 +33,7 @@ describe('RedundantSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- expect(response.result.length).to.be.equal(10);
+ expect(response.result.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
done();
});
provider.sendAsync(payload, callback);
@@ -55,7 +56,7 @@ describe('RedundantSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- expect(response.result.length).to.be.equal(10);
+ expect(response.result.length).to.be.equal(DEFAULT_NUM_ACCOUNTS);
done();
});
provider.sendAsync(payload, callback);