aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/test/unit
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-04-10 09:58:12 +0800
committerJacob Evans <jacob@dekz.net>2018-04-10 09:58:12 +0800
commit5b69cd4a22ce1720f4441aaa74c86f895015c0fd (patch)
tree2a38d521a8b4a944d3e7c3634a56583b3960b354 /packages/subproviders/test/unit
parent0e8f5004d6a53929a4cc1de9231c43899c8b6eeb (diff)
downloaddexon-sol-tools-5b69cd4a22ce1720f4441aaa74c86f895015c0fd.tar
dexon-sol-tools-5b69cd4a22ce1720f4441aaa74c86f895015c0fd.tar.gz
dexon-sol-tools-5b69cd4a22ce1720f4441aaa74c86f895015c0fd.tar.bz2
dexon-sol-tools-5b69cd4a22ce1720f4441aaa74c86f895015c0fd.tar.lz
dexon-sol-tools-5b69cd4a22ce1720f4441aaa74c86f895015c0fd.tar.xz
dexon-sol-tools-5b69cd4a22ce1720f4441aaa74c86f895015c0fd.tar.zst
dexon-sol-tools-5b69cd4a22ce1720f4441aaa74c86f895015c0fd.zip
Added walletUtils and address in signMessage
Diffstat (limited to 'packages/subproviders/test/unit')
-rw-r--r--packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts26
-rw-r--r--packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts23
2 files changed, 39 insertions, 10 deletions
diff --git a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
index e58461005..7aaef4944 100644
--- a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
+++ b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts
@@ -9,7 +9,6 @@ import {
DoneCallback,
LedgerCommunicationClient,
LedgerSubproviderErrors,
- MnemonicSubproviderErrors,
WalletSubproviderErrors,
} from '../../src/types';
import { chaiSetup } from '../chai_setup';
@@ -48,7 +47,7 @@ describe('MnemonicWalletSubprovider', () => {
it('throws an error if account cannot be found', async () => {
const txData = { ...fixtureData.TX_DATA, from: '0x0' };
return expect(subprovider.signTransactionAsync(txData)).to.be.rejectedWith(
- MnemonicSubproviderErrors.AddressSearchExhausted,
+ WalletSubproviderErrors.AddressNotFound,
);
});
});
@@ -83,7 +82,7 @@ describe('MnemonicWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'eth_sign',
- params: ['0x0000000000000000000000000000000000000000', messageHex],
+ params: [fixtureData.TEST_RPC_ACCOUNT_0, messageHex],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -98,7 +97,7 @@ describe('MnemonicWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'personal_sign',
- params: [messageHex, '0x0000000000000000000000000000000000000000'],
+ params: [messageHex, fixtureData.TEST_RPC_ACCOUNT_0],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -115,7 +114,7 @@ describe('MnemonicWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'eth_sign',
- params: ['0x0000000000000000000000000000000000000000', nonHexMessage],
+ params: [fixtureData.TEST_RPC_ACCOUNT_0, nonHexMessage],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -130,7 +129,7 @@ describe('MnemonicWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'personal_sign',
- params: [nonHexMessage, '0x0000000000000000000000000000000000000000'],
+ params: [nonHexMessage, fixtureData.TEST_RPC_ACCOUNT_0],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -140,6 +139,21 @@ describe('MnemonicWalletSubprovider', () => {
});
provider.sendAsync(payload, callback);
});
+ it('should throw if `address` param not found when calling personal_sign', (done: DoneCallback) => {
+ const nonHexMessage = 'hello world';
+ const payload = {
+ jsonrpc: '2.0',
+ method: 'personal_sign',
+ params: [nonHexMessage, '0x0'],
+ id: 1,
+ };
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
+ expect(err).to.not.be.a('null');
+ expect(err.message).to.be.equal(`${WalletSubproviderErrors.AddressNotFound}: 0x0`);
+ done();
+ });
+ provider.sendAsync(payload, callback);
+ });
it('should throw if `from` param missing when calling eth_sendTransaction', (done: DoneCallback) => {
const tx = {
to: '0xafa3f8684e54059998bc3a7b0d2b0da075154d66',
diff --git a/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts b/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts
index ca0665871..8aaddeaf4 100644
--- a/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts
+++ b/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts
@@ -71,7 +71,7 @@ describe('PrivateKeyWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'eth_sign',
- params: ['0x0000000000000000000000000000000000000000', messageHex],
+ params: [fixtureData.TEST_RPC_ACCOUNT_0, messageHex],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -86,7 +86,7 @@ describe('PrivateKeyWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'personal_sign',
- params: [messageHex, '0x0000000000000000000000000000000000000000'],
+ params: [messageHex, fixtureData.TEST_RPC_ACCOUNT_0],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -103,7 +103,7 @@ describe('PrivateKeyWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'eth_sign',
- params: ['0x0000000000000000000000000000000000000000', nonHexMessage],
+ params: [fixtureData.TEST_RPC_ACCOUNT_0, nonHexMessage],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -118,7 +118,7 @@ describe('PrivateKeyWalletSubprovider', () => {
const payload = {
jsonrpc: '2.0',
method: 'personal_sign',
- params: [nonHexMessage, '0x0000000000000000000000000000000000000000'],
+ params: [nonHexMessage, fixtureData.TEST_RPC_ACCOUNT_0],
id: 1,
};
const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
@@ -165,6 +165,21 @@ describe('PrivateKeyWalletSubprovider', () => {
});
provider.sendAsync(payload, callback);
});
+ it('should throw if `address` param not found when calling personal_sign', (done: DoneCallback) => {
+ const nonHexMessage = 'hello world';
+ const payload = {
+ jsonrpc: '2.0',
+ method: 'personal_sign',
+ params: [nonHexMessage, '0x0'],
+ id: 1,
+ };
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
+ expect(err).to.not.be.a('null');
+ expect(err.message).to.be.equal(`${WalletSubproviderErrors.AddressNotFound}: 0x0`);
+ done();
+ });
+ provider.sendAsync(payload, callback);
+ });
});
});
});