2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2017-01-24 16:18:23 +01:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import BigNumber from 'bignumber.js';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
|
2017-07-21 15:46:53 +02:00
|
|
|
import Api from '@parity/api/index';
|
2017-01-24 16:18:23 +01:00
|
|
|
import Store from './store';
|
|
|
|
|
|
|
|
const ADDRESS = '0x00000123456789abcdef123456789abcdef123456789abcdef';
|
|
|
|
const ACCOUNTS = { [ADDRESS]: {} };
|
|
|
|
const GETH_ADDRESSES = [
|
|
|
|
'0x123456789abcdef123456789abcdef123456789abcdef00000',
|
|
|
|
'0x00000123456789abcdef123456789abcdef123456789abcdef'
|
|
|
|
];
|
|
|
|
|
|
|
|
let counter = 1;
|
|
|
|
|
|
|
|
function createApi () {
|
|
|
|
return {
|
|
|
|
eth: {
|
|
|
|
getBalance: sinon.stub().resolves(new BigNumber(1))
|
|
|
|
},
|
|
|
|
parity: {
|
|
|
|
generateSecretPhrase: sinon.stub().resolves('some account phrase'),
|
2017-02-23 15:04:58 +01:00
|
|
|
importGethAccounts: sinon.stub().resolves(GETH_ADDRESSES),
|
2017-01-24 16:18:23 +01:00
|
|
|
listGethAccounts: sinon.stub().resolves(GETH_ADDRESSES),
|
|
|
|
newAccountFromPhrase: sinon.stub().resolves(ADDRESS),
|
|
|
|
newAccountFromSecret: sinon.stub().resolves(ADDRESS),
|
|
|
|
newAccountFromWallet: sinon.stub().resolves(ADDRESS),
|
|
|
|
phraseToAddress: () => Promise.resolve(`${++counter}`),
|
|
|
|
setAccountMeta: sinon.stub().resolves(),
|
2017-03-03 19:50:54 +01:00
|
|
|
setAccountName: sinon.stub().resolves(),
|
|
|
|
listVaults: sinon.stub().resolves([]),
|
|
|
|
listOpenedVaults: sinon.stub().resolves([])
|
2017-06-07 16:27:01 +02:00
|
|
|
},
|
|
|
|
util: Api.util
|
2017-01-24 16:18:23 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function createRedux () {
|
|
|
|
return {
|
|
|
|
dispatch: sinon.stub(),
|
|
|
|
subscribe: sinon.stub(),
|
|
|
|
getState: () => {
|
2017-05-18 11:50:16 +02:00
|
|
|
return {
|
|
|
|
nodeStatus: {
|
|
|
|
isTest: true
|
|
|
|
}
|
|
|
|
};
|
2017-01-24 16:18:23 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function createStore () {
|
|
|
|
return new Store(createApi(), ACCOUNTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
ACCOUNTS,
|
|
|
|
ADDRESS,
|
|
|
|
GETH_ADDRESSES,
|
|
|
|
createApi,
|
|
|
|
createRedux,
|
|
|
|
createStore
|
|
|
|
};
|